id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
16,300 | chemlab/chemlab | chemlab/core/system.py | System.where | def where(self, within_of=None, inplace=False, **kwargs):
"""Return indices that met the conditions"""
masks = super(System, self).where(inplace=inplace, **kwargs)
def index_to_mask(index, n):
val = np.zeros(n, dtype='bool')
val[index] = True
return v... | python | def where(self, within_of=None, inplace=False, **kwargs):
"""Return indices that met the conditions"""
masks = super(System, self).where(inplace=inplace, **kwargs)
def index_to_mask(index, n):
val = np.zeros(n, dtype='bool')
val[index] = True
return v... | [
"def",
"where",
"(",
"self",
",",
"within_of",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"masks",
"=",
"super",
"(",
"System",
",",
"self",
")",
".",
"where",
"(",
"inplace",
"=",
"inplace",
",",
"*",
"*",
"kwa... | Return indices that met the conditions | [
"Return",
"indices",
"that",
"met",
"the",
"conditions"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/system.py#L252-L284 |
16,301 | chemlab/chemlab | chemlab/qc/utils.py | _gser | def _gser(a,x):
"Series representation of Gamma. NumRec sect 6.1."
ITMAX=100
EPS=3.e-7
gln=lgamma(a)
assert(x>=0),'x < 0 in gser'
if x == 0 : return 0,gln
ap = a
delt = sum = 1./a
for i in range(ITMAX):
ap=ap+1.
delt=delt*x/ap
sum=sum+delt
if abs(del... | python | def _gser(a,x):
"Series representation of Gamma. NumRec sect 6.1."
ITMAX=100
EPS=3.e-7
gln=lgamma(a)
assert(x>=0),'x < 0 in gser'
if x == 0 : return 0,gln
ap = a
delt = sum = 1./a
for i in range(ITMAX):
ap=ap+1.
delt=delt*x/ap
sum=sum+delt
if abs(del... | [
"def",
"_gser",
"(",
"a",
",",
"x",
")",
":",
"ITMAX",
"=",
"100",
"EPS",
"=",
"3.e-7",
"gln",
"=",
"lgamma",
"(",
"a",
")",
"assert",
"(",
"x",
">=",
"0",
")",
",",
"'x < 0 in gser'",
"if",
"x",
"==",
"0",
":",
"return",
"0",
",",
"gln",
"ap... | Series representation of Gamma. NumRec sect 6.1. | [
"Series",
"representation",
"of",
"Gamma",
".",
"NumRec",
"sect",
"6",
".",
"1",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/qc/utils.py#L86-L105 |
16,302 | chemlab/chemlab | chemlab/qc/utils.py | _gcf | def _gcf(a,x):
"Continued fraction representation of Gamma. NumRec sect 6.1"
ITMAX=100
EPS=3.e-7
FPMIN=1.e-30
gln=lgamma(a)
b=x+1.-a
c=1./FPMIN
d=1./b
h=d
for i in range(1,ITMAX+1):
an=-i*(i-a)
b=b+2.
d=an*d+b
if abs(d) < FPMIN: d=FPMIN
c=... | python | def _gcf(a,x):
"Continued fraction representation of Gamma. NumRec sect 6.1"
ITMAX=100
EPS=3.e-7
FPMIN=1.e-30
gln=lgamma(a)
b=x+1.-a
c=1./FPMIN
d=1./b
h=d
for i in range(1,ITMAX+1):
an=-i*(i-a)
b=b+2.
d=an*d+b
if abs(d) < FPMIN: d=FPMIN
c=... | [
"def",
"_gcf",
"(",
"a",
",",
"x",
")",
":",
"ITMAX",
"=",
"100",
"EPS",
"=",
"3.e-7",
"FPMIN",
"=",
"1.e-30",
"gln",
"=",
"lgamma",
"(",
"a",
")",
"b",
"=",
"x",
"+",
"1.",
"-",
"a",
"c",
"=",
"1.",
"/",
"FPMIN",
"d",
"=",
"1.",
"/",
"b"... | Continued fraction representation of Gamma. NumRec sect 6.1 | [
"Continued",
"fraction",
"representation",
"of",
"Gamma",
".",
"NumRec",
"sect",
"6",
".",
"1"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/qc/utils.py#L107-L132 |
16,303 | chemlab/chemlab | chemlab/qc/utils.py | dmat | def dmat(c,nocc):
"Form the density matrix from the first nocc orbitals of c"
return np.dot(c[:,:nocc],c[:,:nocc].T) | python | def dmat(c,nocc):
"Form the density matrix from the first nocc orbitals of c"
return np.dot(c[:,:nocc],c[:,:nocc].T) | [
"def",
"dmat",
"(",
"c",
",",
"nocc",
")",
":",
"return",
"np",
".",
"dot",
"(",
"c",
"[",
":",
",",
":",
"nocc",
"]",
",",
"c",
"[",
":",
",",
":",
"nocc",
"]",
".",
"T",
")"
] | Form the density matrix from the first nocc orbitals of c | [
"Form",
"the",
"density",
"matrix",
"from",
"the",
"first",
"nocc",
"orbitals",
"of",
"c"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/qc/utils.py#L138-L140 |
16,304 | chemlab/chemlab | chemlab/qc/utils.py | geigh | def geigh(H,S):
"Solve the generalized eigensystem Hc = ESc"
A = cholorth(S)
E,U = np.linalg.eigh(simx(H,A))
return E,np.dot(A,U) | python | def geigh(H,S):
"Solve the generalized eigensystem Hc = ESc"
A = cholorth(S)
E,U = np.linalg.eigh(simx(H,A))
return E,np.dot(A,U) | [
"def",
"geigh",
"(",
"H",
",",
"S",
")",
":",
"A",
"=",
"cholorth",
"(",
"S",
")",
"E",
",",
"U",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"simx",
"(",
"H",
",",
"A",
")",
")",
"return",
"E",
",",
"np",
".",
"dot",
"(",
"A",
",",
"U"... | Solve the generalized eigensystem Hc = ESc | [
"Solve",
"the",
"generalized",
"eigensystem",
"Hc",
"=",
"ESc"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/qc/utils.py#L168-L172 |
16,305 | chemlab/chemlab | chemlab/utils/neighbors.py | _check_periodic | def _check_periodic(periodic):
'''Validate periodic input'''
periodic = np.array(periodic)
# If it is a matrix
if len(periodic.shape) == 2:
assert periodic.shape[0] == periodic.shape[1], 'periodic shoud be a square matrix or a flat array'
return np.diag(periodic)
elif len(periodic.s... | python | def _check_periodic(periodic):
'''Validate periodic input'''
periodic = np.array(periodic)
# If it is a matrix
if len(periodic.shape) == 2:
assert periodic.shape[0] == periodic.shape[1], 'periodic shoud be a square matrix or a flat array'
return np.diag(periodic)
elif len(periodic.s... | [
"def",
"_check_periodic",
"(",
"periodic",
")",
":",
"periodic",
"=",
"np",
".",
"array",
"(",
"periodic",
")",
"# If it is a matrix",
"if",
"len",
"(",
"periodic",
".",
"shape",
")",
"==",
"2",
":",
"assert",
"periodic",
".",
"shape",
"[",
"0",
"]",
"... | Validate periodic input | [
"Validate",
"periodic",
"input"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/neighbors.py#L19-L30 |
16,306 | chemlab/chemlab | chemlab/utils/neighbors.py | count_neighbors | def count_neighbors(coordinates_a, coordinates_b, periodic, r):
'''Count the neighbours number of neighbors.
:param np.ndarray coordinates_a: Either an array of coordinates of shape (N,3)
or a single point of shape (3,)
:param np.ndarray coordinates_b: Same as coordinat... | python | def count_neighbors(coordinates_a, coordinates_b, periodic, r):
'''Count the neighbours number of neighbors.
:param np.ndarray coordinates_a: Either an array of coordinates of shape (N,3)
or a single point of shape (3,)
:param np.ndarray coordinates_b: Same as coordinat... | [
"def",
"count_neighbors",
"(",
"coordinates_a",
",",
"coordinates_b",
",",
"periodic",
",",
"r",
")",
":",
"indices",
"=",
"nearest_neighbors",
"(",
"coordinates_a",
",",
"coordinates_b",
",",
"periodic",
",",
"r",
"=",
"r",
")",
"[",
"0",
"]",
"if",
"len"... | Count the neighbours number of neighbors.
:param np.ndarray coordinates_a: Either an array of coordinates of shape (N,3)
or a single point of shape (3,)
:param np.ndarray coordinates_b: Same as coordinates_a
:param np.ndarray periodic: Either a matrix of box vectors (3,... | [
"Count",
"the",
"neighbours",
"number",
"of",
"neighbors",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/neighbors.py#L77-L97 |
16,307 | chemlab/chemlab | chemlab/mviewer/api/appeareance.py | change_default_radii | def change_default_radii(def_map):
"""Change the default radii
"""
s = current_system()
rep = current_representation()
rep.radii_state.default = [def_map[t] for t in s.type_array]
rep.radii_state.reset() | python | def change_default_radii(def_map):
"""Change the default radii
"""
s = current_system()
rep = current_representation()
rep.radii_state.default = [def_map[t] for t in s.type_array]
rep.radii_state.reset() | [
"def",
"change_default_radii",
"(",
"def_map",
")",
":",
"s",
"=",
"current_system",
"(",
")",
"rep",
"=",
"current_representation",
"(",
")",
"rep",
".",
"radii_state",
".",
"default",
"=",
"[",
"def_map",
"[",
"t",
"]",
"for",
"t",
"in",
"s",
".",
"t... | Change the default radii | [
"Change",
"the",
"default",
"radii"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/appeareance.py#L128-L134 |
16,308 | chemlab/chemlab | chemlab/mviewer/api/appeareance.py | add_post_processing | def add_post_processing(effect, **options):
"""Apply a post processing effect.
**Parameters**
effect: string
The effect to be applied, choose between ``ssao``,
``outline``, ``fxaa``, ``gamma``.
**options:
Options used to initialize the effect, check the
:doc:`... | python | def add_post_processing(effect, **options):
"""Apply a post processing effect.
**Parameters**
effect: string
The effect to be applied, choose between ``ssao``,
``outline``, ``fxaa``, ``gamma``.
**options:
Options used to initialize the effect, check the
:doc:`... | [
"def",
"add_post_processing",
"(",
"effect",
",",
"*",
"*",
"options",
")",
":",
"from",
"chemlab",
".",
"graphics",
".",
"postprocessing",
"import",
"SSAOEffect",
",",
"OutlineEffect",
",",
"FXAAEffect",
",",
"GammaCorrectionEffect",
"pp_map",
"=",
"{",
"'ssao'... | Apply a post processing effect.
**Parameters**
effect: string
The effect to be applied, choose between ``ssao``,
``outline``, ``fxaa``, ``gamma``.
**options:
Options used to initialize the effect, check the
:doc:`chemlab.graphics.postprocessing` for a complete
... | [
"Apply",
"a",
"post",
"processing",
"effect",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/appeareance.py#L192-L229 |
16,309 | chemlab/chemlab | chemlab/core/spacegroup/cell.py | unit_vector | def unit_vector(x):
"""Return a unit vector in the same direction as x."""
y = np.array(x, dtype='float')
return y/norm(y) | python | def unit_vector(x):
"""Return a unit vector in the same direction as x."""
y = np.array(x, dtype='float')
return y/norm(y) | [
"def",
"unit_vector",
"(",
"x",
")",
":",
"y",
"=",
"np",
".",
"array",
"(",
"x",
",",
"dtype",
"=",
"'float'",
")",
"return",
"y",
"/",
"norm",
"(",
"y",
")"
] | Return a unit vector in the same direction as x. | [
"Return",
"a",
"unit",
"vector",
"in",
"the",
"same",
"direction",
"as",
"x",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/cell.py#L13-L16 |
16,310 | chemlab/chemlab | chemlab/core/spacegroup/cell.py | angle | def angle(x, y):
"""Return the angle between vectors a and b in degrees."""
return arccos(dot(x, y)/(norm(x)*norm(y)))*180./pi | python | def angle(x, y):
"""Return the angle between vectors a and b in degrees."""
return arccos(dot(x, y)/(norm(x)*norm(y)))*180./pi | [
"def",
"angle",
"(",
"x",
",",
"y",
")",
":",
"return",
"arccos",
"(",
"dot",
"(",
"x",
",",
"y",
")",
"/",
"(",
"norm",
"(",
"x",
")",
"*",
"norm",
"(",
"y",
")",
")",
")",
"*",
"180.",
"/",
"pi"
] | Return the angle between vectors a and b in degrees. | [
"Return",
"the",
"angle",
"between",
"vectors",
"a",
"and",
"b",
"in",
"degrees",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/cell.py#L19-L21 |
16,311 | chemlab/chemlab | chemlab/core/spacegroup/cell.py | metric_from_cell | def metric_from_cell(cell):
"""Calculates the metric matrix from cell, which is given in the
Cartesian system."""
cell = np.asarray(cell, dtype=float)
return np.dot(cell, cell.T) | python | def metric_from_cell(cell):
"""Calculates the metric matrix from cell, which is given in the
Cartesian system."""
cell = np.asarray(cell, dtype=float)
return np.dot(cell, cell.T) | [
"def",
"metric_from_cell",
"(",
"cell",
")",
":",
"cell",
"=",
"np",
".",
"asarray",
"(",
"cell",
",",
"dtype",
"=",
"float",
")",
"return",
"np",
".",
"dot",
"(",
"cell",
",",
"cell",
".",
"T",
")"
] | Calculates the metric matrix from cell, which is given in the
Cartesian system. | [
"Calculates",
"the",
"metric",
"matrix",
"from",
"cell",
"which",
"is",
"given",
"in",
"the",
"Cartesian",
"system",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/cell.py#L101-L105 |
16,312 | chemlab/chemlab | chemlab/io/datafile.py | add_default_handler | def add_default_handler(ioclass, format, extension=None):
"""Register a new data handler for a given format in
the default handler list.
This is a convenience function used internally to setup the
default handlers. It can be used to add other handlers at
runtime even if this isn't a sug... | python | def add_default_handler(ioclass, format, extension=None):
"""Register a new data handler for a given format in
the default handler list.
This is a convenience function used internally to setup the
default handlers. It can be used to add other handlers at
runtime even if this isn't a sug... | [
"def",
"add_default_handler",
"(",
"ioclass",
",",
"format",
",",
"extension",
"=",
"None",
")",
":",
"if",
"format",
"in",
"_handler_map",
":",
"print",
"(",
"\"Warning: format {} already present.\"",
".",
"format",
"(",
"format",
")",
")",
"_handler_map",
"[",... | Register a new data handler for a given format in
the default handler list.
This is a convenience function used internally to setup the
default handlers. It can be used to add other handlers at
runtime even if this isn't a suggested practice.
**Parameters**
ioclass: IOHandle... | [
"Register",
"a",
"new",
"data",
"handler",
"for",
"a",
"given",
"format",
"in",
"the",
"default",
"handler",
"list",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/datafile.py#L39-L66 |
16,313 | chemlab/chemlab | chemlab/utils/pbc.py | minimum_image | def minimum_image(coords, pbc):
"""
Wraps a vector collection of atom positions into the central periodic
image or primary simulation cell.
Parameters
----------
pos : :class:`numpy.ndarray`, (Nx3)
Vector collection of atom positions.
Returns
-------
wrap : :class:`numpy.ndarra... | python | def minimum_image(coords, pbc):
"""
Wraps a vector collection of atom positions into the central periodic
image or primary simulation cell.
Parameters
----------
pos : :class:`numpy.ndarray`, (Nx3)
Vector collection of atom positions.
Returns
-------
wrap : :class:`numpy.ndarra... | [
"def",
"minimum_image",
"(",
"coords",
",",
"pbc",
")",
":",
"# This will do the broadcasting",
"coords",
"=",
"np",
".",
"array",
"(",
"coords",
")",
"pbc",
"=",
"np",
".",
"array",
"(",
"pbc",
")",
"# For each coordinate this number represents which box we are in"... | Wraps a vector collection of atom positions into the central periodic
image or primary simulation cell.
Parameters
----------
pos : :class:`numpy.ndarray`, (Nx3)
Vector collection of atom positions.
Returns
-------
wrap : :class:`numpy.ndarray`, (Nx3)
Returns atomic positions wrapp... | [
"Wraps",
"a",
"vector",
"collection",
"of",
"atom",
"positions",
"into",
"the",
"central",
"periodic",
"image",
"or",
"primary",
"simulation",
"cell",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L6-L31 |
16,314 | chemlab/chemlab | chemlab/utils/pbc.py | subtract_vectors | def subtract_vectors(a, b, periodic):
'''Returns the difference of the points vec_a - vec_b subject
to the periodic boundary conditions.
'''
r = a - b
delta = np.abs(r)
sign = np.sign(r)
return np.where(delta > 0.5 * periodic, sign * (periodic - delta), r) | python | def subtract_vectors(a, b, periodic):
'''Returns the difference of the points vec_a - vec_b subject
to the periodic boundary conditions.
'''
r = a - b
delta = np.abs(r)
sign = np.sign(r)
return np.where(delta > 0.5 * periodic, sign * (periodic - delta), r) | [
"def",
"subtract_vectors",
"(",
"a",
",",
"b",
",",
"periodic",
")",
":",
"r",
"=",
"a",
"-",
"b",
"delta",
"=",
"np",
".",
"abs",
"(",
"r",
")",
"sign",
"=",
"np",
".",
"sign",
"(",
"r",
")",
"return",
"np",
".",
"where",
"(",
"delta",
">",
... | Returns the difference of the points vec_a - vec_b subject
to the periodic boundary conditions. | [
"Returns",
"the",
"difference",
"of",
"the",
"points",
"vec_a",
"-",
"vec_b",
"subject",
"to",
"the",
"periodic",
"boundary",
"conditions",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L80-L88 |
16,315 | chemlab/chemlab | chemlab/utils/pbc.py | add_vectors | def add_vectors(vec_a, vec_b, periodic):
'''Returns the sum of the points vec_a - vec_b subject
to the periodic boundary conditions.
'''
moved = noperiodic(np.array([vec_a, vec_b]), periodic)
return vec_a + vec_b | python | def add_vectors(vec_a, vec_b, periodic):
'''Returns the sum of the points vec_a - vec_b subject
to the periodic boundary conditions.
'''
moved = noperiodic(np.array([vec_a, vec_b]), periodic)
return vec_a + vec_b | [
"def",
"add_vectors",
"(",
"vec_a",
",",
"vec_b",
",",
"periodic",
")",
":",
"moved",
"=",
"noperiodic",
"(",
"np",
".",
"array",
"(",
"[",
"vec_a",
",",
"vec_b",
"]",
")",
",",
"periodic",
")",
"return",
"vec_a",
"+",
"vec_b"
] | Returns the sum of the points vec_a - vec_b subject
to the periodic boundary conditions. | [
"Returns",
"the",
"sum",
"of",
"the",
"points",
"vec_a",
"-",
"vec_b",
"subject",
"to",
"the",
"periodic",
"boundary",
"conditions",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L91-L97 |
16,316 | chemlab/chemlab | chemlab/utils/pbc.py | distance_matrix | def distance_matrix(a, b, periodic):
'''Calculate a distrance matrix between coordinates sets a and b
'''
a = a
b = b[:, np.newaxis]
return periodic_distance(a, b, periodic) | python | def distance_matrix(a, b, periodic):
'''Calculate a distrance matrix between coordinates sets a and b
'''
a = a
b = b[:, np.newaxis]
return periodic_distance(a, b, periodic) | [
"def",
"distance_matrix",
"(",
"a",
",",
"b",
",",
"periodic",
")",
":",
"a",
"=",
"a",
"b",
"=",
"b",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"return",
"periodic_distance",
"(",
"a",
",",
"b",
",",
"periodic",
")"
] | Calculate a distrance matrix between coordinates sets a and b | [
"Calculate",
"a",
"distrance",
"matrix",
"between",
"coordinates",
"sets",
"a",
"and",
"b"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L100-L105 |
16,317 | chemlab/chemlab | chemlab/utils/pbc.py | geometric_center | def geometric_center(coords, periodic):
'''Geometric center taking into account periodic boundaries'''
max_vals = periodic
theta = 2 * np.pi * (coords / max_vals)
eps = np.cos(theta) * max_vals / (2 * np.pi)
zeta = np.sin(theta) * max_vals / (2 * np.pi)
eps_avg = eps.sum(axis=0)
zeta_avg = ... | python | def geometric_center(coords, periodic):
'''Geometric center taking into account periodic boundaries'''
max_vals = periodic
theta = 2 * np.pi * (coords / max_vals)
eps = np.cos(theta) * max_vals / (2 * np.pi)
zeta = np.sin(theta) * max_vals / (2 * np.pi)
eps_avg = eps.sum(axis=0)
zeta_avg = ... | [
"def",
"geometric_center",
"(",
"coords",
",",
"periodic",
")",
":",
"max_vals",
"=",
"periodic",
"theta",
"=",
"2",
"*",
"np",
".",
"pi",
"*",
"(",
"coords",
"/",
"max_vals",
")",
"eps",
"=",
"np",
".",
"cos",
"(",
"theta",
")",
"*",
"max_vals",
"... | Geometric center taking into account periodic boundaries | [
"Geometric",
"center",
"taking",
"into",
"account",
"periodic",
"boundaries"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L123-L134 |
16,318 | chemlab/chemlab | chemlab/utils/pbc.py | radius_of_gyration | def radius_of_gyration(coords, periodic):
'''Calculate the square root of the mean distance squared from the center of gravity.
'''
gc = geometric_center(coords, periodic)
return (periodic_distance(coords, gc, periodic) ** 2).sum() / len(coords) | python | def radius_of_gyration(coords, periodic):
'''Calculate the square root of the mean distance squared from the center of gravity.
'''
gc = geometric_center(coords, periodic)
return (periodic_distance(coords, gc, periodic) ** 2).sum() / len(coords) | [
"def",
"radius_of_gyration",
"(",
"coords",
",",
"periodic",
")",
":",
"gc",
"=",
"geometric_center",
"(",
"coords",
",",
"periodic",
")",
"return",
"(",
"periodic_distance",
"(",
"coords",
",",
"gc",
",",
"periodic",
")",
"**",
"2",
")",
".",
"sum",
"("... | Calculate the square root of the mean distance squared from the center of gravity. | [
"Calculate",
"the",
"square",
"root",
"of",
"the",
"mean",
"distance",
"squared",
"from",
"the",
"center",
"of",
"gravity",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/pbc.py#L137-L142 |
16,319 | chemlab/chemlab | chemlab/libs/chemspipy.py | find | def find(query):
""" Search by Name, SMILES, InChI, InChIKey, etc. Returns first 100 Compounds """
assert type(query) == str or type(query) == str, 'query not a string object'
searchurl = 'http://www.chemspider.com/Search.asmx/SimpleSearch?query=%s&token=%s' % (urlquote(query), TOKEN)
response = urlopen... | python | def find(query):
""" Search by Name, SMILES, InChI, InChIKey, etc. Returns first 100 Compounds """
assert type(query) == str or type(query) == str, 'query not a string object'
searchurl = 'http://www.chemspider.com/Search.asmx/SimpleSearch?query=%s&token=%s' % (urlquote(query), TOKEN)
response = urlopen... | [
"def",
"find",
"(",
"query",
")",
":",
"assert",
"type",
"(",
"query",
")",
"==",
"str",
"or",
"type",
"(",
"query",
")",
"==",
"str",
",",
"'query not a string object'",
"searchurl",
"=",
"'http://www.chemspider.com/Search.asmx/SimpleSearch?query=%s&token=%s'",
"%"... | Search by Name, SMILES, InChI, InChIKey, etc. Returns first 100 Compounds | [
"Search",
"by",
"Name",
"SMILES",
"InChI",
"InChIKey",
"etc",
".",
"Returns",
"first",
"100",
"Compounds"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L213-L224 |
16,320 | chemlab/chemlab | chemlab/libs/chemspipy.py | Compound.imageurl | def imageurl(self):
""" Return the URL of a png image of the 2D structure """
if self._imageurl is None:
self._imageurl = 'http://www.chemspider.com/ImagesHandler.ashx?id=%s' % self.csid
return self._imageurl | python | def imageurl(self):
""" Return the URL of a png image of the 2D structure """
if self._imageurl is None:
self._imageurl = 'http://www.chemspider.com/ImagesHandler.ashx?id=%s' % self.csid
return self._imageurl | [
"def",
"imageurl",
"(",
"self",
")",
":",
"if",
"self",
".",
"_imageurl",
"is",
"None",
":",
"self",
".",
"_imageurl",
"=",
"'http://www.chemspider.com/ImagesHandler.ashx?id=%s'",
"%",
"self",
".",
"csid",
"return",
"self",
".",
"_imageurl"
] | Return the URL of a png image of the 2D structure | [
"Return",
"the",
"URL",
"of",
"a",
"png",
"image",
"of",
"the",
"2D",
"structure"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L71-L75 |
16,321 | chemlab/chemlab | chemlab/libs/chemspipy.py | Compound.loadextendedcompoundinfo | def loadextendedcompoundinfo(self):
""" Load extended compound info from the Mass Spec API """
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetExtendedCompoundInfo?CSID=%s&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(response)
mf = tree.find('{... | python | def loadextendedcompoundinfo(self):
""" Load extended compound info from the Mass Spec API """
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetExtendedCompoundInfo?CSID=%s&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(response)
mf = tree.find('{... | [
"def",
"loadextendedcompoundinfo",
"(",
"self",
")",
":",
"apiurl",
"=",
"'http://www.chemspider.com/MassSpecAPI.asmx/GetExtendedCompoundInfo?CSID=%s&token=%s'",
"%",
"(",
"self",
".",
"csid",
",",
"TOKEN",
")",
"response",
"=",
"urlopen",
"(",
"apiurl",
")",
"tree",
... | Load extended compound info from the Mass Spec API | [
"Load",
"extended",
"compound",
"info",
"from",
"the",
"Mass",
"Spec",
"API"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L154-L180 |
16,322 | chemlab/chemlab | chemlab/libs/chemspipy.py | Compound.image | def image(self):
""" Return string containing PNG binary image data of 2D structure image """
if self._image is None:
apiurl = 'http://www.chemspider.com/Search.asmx/GetCompoundThumbnail?id=%s&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(re... | python | def image(self):
""" Return string containing PNG binary image data of 2D structure image """
if self._image is None:
apiurl = 'http://www.chemspider.com/Search.asmx/GetCompoundThumbnail?id=%s&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(re... | [
"def",
"image",
"(",
"self",
")",
":",
"if",
"self",
".",
"_image",
"is",
"None",
":",
"apiurl",
"=",
"'http://www.chemspider.com/Search.asmx/GetCompoundThumbnail?id=%s&token=%s'",
"%",
"(",
"self",
".",
"csid",
",",
"TOKEN",
")",
"response",
"=",
"urlopen",
"("... | Return string containing PNG binary image data of 2D structure image | [
"Return",
"string",
"containing",
"PNG",
"binary",
"image",
"data",
"of",
"2D",
"structure",
"image"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L183-L190 |
16,323 | chemlab/chemlab | chemlab/libs/chemspipy.py | Compound.mol | def mol(self):
""" Return record in MOL format """
if self._mol is None:
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=false&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(response)
self._mol = t... | python | def mol(self):
""" Return record in MOL format """
if self._mol is None:
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=false&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(response)
self._mol = t... | [
"def",
"mol",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mol",
"is",
"None",
":",
"apiurl",
"=",
"'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=false&token=%s'",
"%",
"(",
"self",
".",
"csid",
",",
"TOKEN",
")",
"response",
"=",
"urlopen... | Return record in MOL format | [
"Return",
"record",
"in",
"MOL",
"format"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L193-L200 |
16,324 | chemlab/chemlab | chemlab/libs/chemspipy.py | Compound.mol3d | def mol3d(self):
""" Return record in MOL format with 3D coordinates calculated """
if self._mol3d is None:
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=true&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(r... | python | def mol3d(self):
""" Return record in MOL format with 3D coordinates calculated """
if self._mol3d is None:
apiurl = 'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=true&token=%s' % (self.csid,TOKEN)
response = urlopen(apiurl)
tree = ET.parse(r... | [
"def",
"mol3d",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mol3d",
"is",
"None",
":",
"apiurl",
"=",
"'http://www.chemspider.com/MassSpecAPI.asmx/GetRecordMol?csid=%s&calc3d=true&token=%s'",
"%",
"(",
"self",
".",
"csid",
",",
"TOKEN",
")",
"response",
"=",
"urlo... | Return record in MOL format with 3D coordinates calculated | [
"Return",
"record",
"in",
"MOL",
"format",
"with",
"3D",
"coordinates",
"calculated"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/chemspipy.py#L203-L210 |
16,325 | chemlab/chemlab | chemlab/graphics/renderers/ballandstick.py | BallAndStickRenderer.update_positions | def update_positions(self, r_array):
'''Update the coordinate array r_array'''
self.ar.update_positions(r_array)
if self.has_bonds:
self.br.update_positions(r_array) | python | def update_positions(self, r_array):
'''Update the coordinate array r_array'''
self.ar.update_positions(r_array)
if self.has_bonds:
self.br.update_positions(r_array) | [
"def",
"update_positions",
"(",
"self",
",",
"r_array",
")",
":",
"self",
".",
"ar",
".",
"update_positions",
"(",
"r_array",
")",
"if",
"self",
".",
"has_bonds",
":",
"self",
".",
"br",
".",
"update_positions",
"(",
"r_array",
")"
] | Update the coordinate array r_array | [
"Update",
"the",
"coordinate",
"array",
"r_array"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/ballandstick.py#L52-L57 |
16,326 | chemlab/chemlab | chemlab/core/base.py | concatenate_attributes | def concatenate_attributes(attributes):
'''Concatenate InstanceAttribute to return a bigger one.'''
# We get a template/
tpl = attributes[0]
attr = InstanceAttribute(tpl.name, tpl.shape,
tpl.dtype, tpl.dim, alias=None)
# Special case, not a single array has size bi... | python | def concatenate_attributes(attributes):
'''Concatenate InstanceAttribute to return a bigger one.'''
# We get a template/
tpl = attributes[0]
attr = InstanceAttribute(tpl.name, tpl.shape,
tpl.dtype, tpl.dim, alias=None)
# Special case, not a single array has size bi... | [
"def",
"concatenate_attributes",
"(",
"attributes",
")",
":",
"# We get a template/",
"tpl",
"=",
"attributes",
"[",
"0",
"]",
"attr",
"=",
"InstanceAttribute",
"(",
"tpl",
".",
"name",
",",
"tpl",
".",
"shape",
",",
"tpl",
".",
"dtype",
",",
"tpl",
".",
... | Concatenate InstanceAttribute to return a bigger one. | [
"Concatenate",
"InstanceAttribute",
"to",
"return",
"a",
"bigger",
"one",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L700-L712 |
16,327 | chemlab/chemlab | chemlab/core/base.py | concatenate_fields | def concatenate_fields(fields, dim):
'Create an INstanceAttribute from a list of InstnaceFields'
if len(fields) == 0:
raise ValueError('fields cannot be an empty list')
if len(set((f.name, f.shape, f.dtype) for f in fields)) != 1:
raise ValueError('fields should have homogeneous name, s... | python | def concatenate_fields(fields, dim):
'Create an INstanceAttribute from a list of InstnaceFields'
if len(fields) == 0:
raise ValueError('fields cannot be an empty list')
if len(set((f.name, f.shape, f.dtype) for f in fields)) != 1:
raise ValueError('fields should have homogeneous name, s... | [
"def",
"concatenate_fields",
"(",
"fields",
",",
"dim",
")",
":",
"if",
"len",
"(",
"fields",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'fields cannot be an empty list'",
")",
"if",
"len",
"(",
"set",
"(",
"(",
"f",
".",
"name",
",",
"f",
".",
... | Create an INstanceAttribute from a list of InstnaceFields | [
"Create",
"an",
"INstanceAttribute",
"from",
"a",
"list",
"of",
"InstnaceFields"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L714-L726 |
16,328 | chemlab/chemlab | chemlab/core/base.py | normalize_index | def normalize_index(index):
"""normalize numpy index"""
index = np.asarray(index)
if len(index) == 0:
return index.astype('int')
if index.dtype == 'bool':
index = index.nonzero()[0]
elif index.dtype == 'int':
pass
else:
raise ValueError('Index should be ... | python | def normalize_index(index):
"""normalize numpy index"""
index = np.asarray(index)
if len(index) == 0:
return index.astype('int')
if index.dtype == 'bool':
index = index.nonzero()[0]
elif index.dtype == 'int':
pass
else:
raise ValueError('Index should be ... | [
"def",
"normalize_index",
"(",
"index",
")",
":",
"index",
"=",
"np",
".",
"asarray",
"(",
"index",
")",
"if",
"len",
"(",
"index",
")",
"==",
"0",
":",
"return",
"index",
".",
"astype",
"(",
"'int'",
")",
"if",
"index",
".",
"dtype",
"==",
"'bool'... | normalize numpy index | [
"normalize",
"numpy",
"index"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L745-L758 |
16,329 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.to_dict | def to_dict(self):
"""Return a dict representing the ChemicalEntity that can be read back
using from_dict.
"""
ret = merge_dicts(self.__attributes__, self.__relations__, self.__fields__)
ret = {k : v.value for k,v in ret.items()}
ret['maps'] = {k : v.val... | python | def to_dict(self):
"""Return a dict representing the ChemicalEntity that can be read back
using from_dict.
"""
ret = merge_dicts(self.__attributes__, self.__relations__, self.__fields__)
ret = {k : v.value for k,v in ret.items()}
ret['maps'] = {k : v.val... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"ret",
"=",
"merge_dicts",
"(",
"self",
".",
"__attributes__",
",",
"self",
".",
"__relations__",
",",
"self",
".",
"__fields__",
")",
"ret",
"=",
"{",
"k",
":",
"v",
".",
"value",
"for",
"k",
",",
"v",
"in"... | Return a dict representing the ChemicalEntity that can be read back
using from_dict. | [
"Return",
"a",
"dict",
"representing",
"the",
"ChemicalEntity",
"that",
"can",
"be",
"read",
"back",
"using",
"from_dict",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L105-L114 |
16,330 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.from_json | def from_json(cls, string):
"""Create a ChemicalEntity from a json string
"""
exp_dict = json_to_data(string)
version = exp_dict.get('version', 0)
if version == 0:
return cls.from_dict(exp_dict)
elif version == 1:
return cls.from_dict(exp_dict)
... | python | def from_json(cls, string):
"""Create a ChemicalEntity from a json string
"""
exp_dict = json_to_data(string)
version = exp_dict.get('version', 0)
if version == 0:
return cls.from_dict(exp_dict)
elif version == 1:
return cls.from_dict(exp_dict)
... | [
"def",
"from_json",
"(",
"cls",
",",
"string",
")",
":",
"exp_dict",
"=",
"json_to_data",
"(",
"string",
")",
"version",
"=",
"exp_dict",
".",
"get",
"(",
"'version'",
",",
"0",
")",
"if",
"version",
"==",
"0",
":",
"return",
"cls",
".",
"from_dict",
... | Create a ChemicalEntity from a json string | [
"Create",
"a",
"ChemicalEntity",
"from",
"a",
"json",
"string"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L117-L127 |
16,331 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.copy | def copy(self):
"""Create a copy of this ChemicalEntity
"""
inst = super(type(self), type(self)).empty(**self.dimensions)
# Need to copy all attributes, fields, relations
inst.__attributes__ = {k: v.copy() for k, v in self.__attributes__.items()}
inst.__... | python | def copy(self):
"""Create a copy of this ChemicalEntity
"""
inst = super(type(self), type(self)).empty(**self.dimensions)
# Need to copy all attributes, fields, relations
inst.__attributes__ = {k: v.copy() for k, v in self.__attributes__.items()}
inst.__... | [
"def",
"copy",
"(",
"self",
")",
":",
"inst",
"=",
"super",
"(",
"type",
"(",
"self",
")",
",",
"type",
"(",
"self",
")",
")",
".",
"empty",
"(",
"*",
"*",
"self",
".",
"dimensions",
")",
"# Need to copy all attributes, fields, relations",
"inst",
".",
... | Create a copy of this ChemicalEntity | [
"Create",
"a",
"copy",
"of",
"this",
"ChemicalEntity"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L138-L151 |
16,332 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.copy_from | def copy_from(self, other):
"""Copy properties from another ChemicalEntity
"""
# Need to copy all attributes, fields, relations
self.__attributes__ = {k: v.copy() for k, v in other.__attributes__.items()}
self.__fields__ = {k: v.copy() for k, v in other.__fields__.items(... | python | def copy_from(self, other):
"""Copy properties from another ChemicalEntity
"""
# Need to copy all attributes, fields, relations
self.__attributes__ = {k: v.copy() for k, v in other.__attributes__.items()}
self.__fields__ = {k: v.copy() for k, v in other.__fields__.items(... | [
"def",
"copy_from",
"(",
"self",
",",
"other",
")",
":",
"# Need to copy all attributes, fields, relations",
"self",
".",
"__attributes__",
"=",
"{",
"k",
":",
"v",
".",
"copy",
"(",
")",
"for",
"k",
",",
"v",
"in",
"other",
".",
"__attributes__",
".",
"it... | Copy properties from another ChemicalEntity | [
"Copy",
"properties",
"from",
"another",
"ChemicalEntity"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L153-L162 |
16,333 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.update | def update(self, dictionary):
"""Update the current chemical entity from a dictionary of attributes"""
allowed_attrs = list(self.__attributes__.keys())
allowed_attrs += [a.alias for a in self.__attributes__.values()]
for k in dictionary:
# We only update existing attributes
... | python | def update(self, dictionary):
"""Update the current chemical entity from a dictionary of attributes"""
allowed_attrs = list(self.__attributes__.keys())
allowed_attrs += [a.alias for a in self.__attributes__.values()]
for k in dictionary:
# We only update existing attributes
... | [
"def",
"update",
"(",
"self",
",",
"dictionary",
")",
":",
"allowed_attrs",
"=",
"list",
"(",
"self",
".",
"__attributes__",
".",
"keys",
"(",
")",
")",
"allowed_attrs",
"+=",
"[",
"a",
".",
"alias",
"for",
"a",
"in",
"self",
".",
"__attributes__",
"."... | Update the current chemical entity from a dictionary of attributes | [
"Update",
"the",
"current",
"chemical",
"entity",
"from",
"a",
"dictionary",
"of",
"attributes"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L164-L172 |
16,334 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.subentity | def subentity(self, Entity, index):
"""Return child entity"""
dim = Entity.__dimension__
entity = Entity.empty()
if index >= self.dimensions[dim]:
raise ValueError('index {} out of bounds for dimension {} (size {})'
.format(index, dim, se... | python | def subentity(self, Entity, index):
"""Return child entity"""
dim = Entity.__dimension__
entity = Entity.empty()
if index >= self.dimensions[dim]:
raise ValueError('index {} out of bounds for dimension {} (size {})'
.format(index, dim, se... | [
"def",
"subentity",
"(",
"self",
",",
"Entity",
",",
"index",
")",
":",
"dim",
"=",
"Entity",
".",
"__dimension__",
"entity",
"=",
"Entity",
".",
"empty",
"(",
")",
"if",
"index",
">=",
"self",
".",
"dimensions",
"[",
"dim",
"]",
":",
"raise",
"Value... | Return child entity | [
"Return",
"child",
"entity"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L343-L386 |
16,335 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.sub_dimension | def sub_dimension(self, index, dimension, propagate=True, inplace=False):
"""Return a ChemicalEntity sliced through a dimension.
If other dimensions depend on this one those are updated accordingly.
"""
filter_ = self._propagate_dim(index, dimension, propagate)
return se... | python | def sub_dimension(self, index, dimension, propagate=True, inplace=False):
"""Return a ChemicalEntity sliced through a dimension.
If other dimensions depend on this one those are updated accordingly.
"""
filter_ = self._propagate_dim(index, dimension, propagate)
return se... | [
"def",
"sub_dimension",
"(",
"self",
",",
"index",
",",
"dimension",
",",
"propagate",
"=",
"True",
",",
"inplace",
"=",
"False",
")",
":",
"filter_",
"=",
"self",
".",
"_propagate_dim",
"(",
"index",
",",
"dimension",
",",
"propagate",
")",
"return",
"s... | Return a ChemicalEntity sliced through a dimension.
If other dimensions depend on this one those are updated accordingly. | [
"Return",
"a",
"ChemicalEntity",
"sliced",
"through",
"a",
"dimension",
".",
"If",
"other",
"dimensions",
"depend",
"on",
"this",
"one",
"those",
"are",
"updated",
"accordingly",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L446-L452 |
16,336 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.expand_dimension | def expand_dimension(self, newdim, dimension, maps={}, relations={}):
''' When we expand we need to provide new maps and relations as those
can't be inferred '''
for name, attr in self.__attributes__.items():
if attr.dim == dimension:
newattr = attr.copy()
... | python | def expand_dimension(self, newdim, dimension, maps={}, relations={}):
''' When we expand we need to provide new maps and relations as those
can't be inferred '''
for name, attr in self.__attributes__.items():
if attr.dim == dimension:
newattr = attr.copy()
... | [
"def",
"expand_dimension",
"(",
"self",
",",
"newdim",
",",
"dimension",
",",
"maps",
"=",
"{",
"}",
",",
"relations",
"=",
"{",
"}",
")",
":",
"for",
"name",
",",
"attr",
"in",
"self",
".",
"__attributes__",
".",
"items",
"(",
")",
":",
"if",
"att... | When we expand we need to provide new maps and relations as those
can't be inferred | [
"When",
"we",
"expand",
"we",
"need",
"to",
"provide",
"new",
"maps",
"and",
"relations",
"as",
"those",
"can",
"t",
"be",
"inferred"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L461-L504 |
16,337 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.concat | def concat(self, other, inplace=False):
'''Concatenate two ChemicalEntity of the same kind'''
# Create new entity
if inplace:
obj = self
else:
obj = self.copy()
# Stitch every attribute
for name, attr in obj.__attributes__.items()... | python | def concat(self, other, inplace=False):
'''Concatenate two ChemicalEntity of the same kind'''
# Create new entity
if inplace:
obj = self
else:
obj = self.copy()
# Stitch every attribute
for name, attr in obj.__attributes__.items()... | [
"def",
"concat",
"(",
"self",
",",
"other",
",",
"inplace",
"=",
"False",
")",
":",
"# Create new entity",
"if",
"inplace",
":",
"obj",
"=",
"self",
"else",
":",
"obj",
"=",
"self",
".",
"copy",
"(",
")",
"# Stitch every attribute",
"for",
"name",
",",
... | Concatenate two ChemicalEntity of the same kind | [
"Concatenate",
"two",
"ChemicalEntity",
"of",
"the",
"same",
"kind"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L544-L573 |
16,338 | chemlab/chemlab | chemlab/core/base.py | ChemicalEntity.sub | def sub(self, inplace=False, **kwargs):
"""Return a entity where the conditions are met"""
filter_ = self.where(**kwargs)
return self.subindex(filter_, inplace) | python | def sub(self, inplace=False, **kwargs):
"""Return a entity where the conditions are met"""
filter_ = self.where(**kwargs)
return self.subindex(filter_, inplace) | [
"def",
"sub",
"(",
"self",
",",
"inplace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"filter_",
"=",
"self",
".",
"where",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"subindex",
"(",
"filter_",
",",
"inplace",
")"
] | Return a entity where the conditions are met | [
"Return",
"a",
"entity",
"where",
"the",
"conditions",
"are",
"met"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/base.py#L636-L639 |
16,339 | chemlab/chemlab | chemlab/core/attributes.py | InstanceArray.sub | def sub(self, index):
"""Return a sub-attribute"""
index = np.asarray(index)
if index.dtype == 'bool':
index = index.nonzero()[0]
if self.size < len(index):
raise ValueError('Can\'t subset "{}": index ({}) is bigger than the number of elements ({})'.forma... | python | def sub(self, index):
"""Return a sub-attribute"""
index = np.asarray(index)
if index.dtype == 'bool':
index = index.nonzero()[0]
if self.size < len(index):
raise ValueError('Can\'t subset "{}": index ({}) is bigger than the number of elements ({})'.forma... | [
"def",
"sub",
"(",
"self",
",",
"index",
")",
":",
"index",
"=",
"np",
".",
"asarray",
"(",
"index",
")",
"if",
"index",
".",
"dtype",
"==",
"'bool'",
":",
"index",
"=",
"index",
".",
"nonzero",
"(",
")",
"[",
"0",
"]",
"if",
"self",
".",
"size... | Return a sub-attribute | [
"Return",
"a",
"sub",
"-",
"attribute"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/attributes.py#L119-L135 |
16,340 | chemlab/chemlab | chemlab/libs/cirpy.py | resolve | def resolve(input, representation, resolvers=None, **kwargs):
""" Resolve input to the specified output representation """
resultdict = query(input, representation, resolvers, **kwargs)
result = resultdict[0]['value'] if resultdict else None
if result and len(result) == 1:
result = result[0]
... | python | def resolve(input, representation, resolvers=None, **kwargs):
""" Resolve input to the specified output representation """
resultdict = query(input, representation, resolvers, **kwargs)
result = resultdict[0]['value'] if resultdict else None
if result and len(result) == 1:
result = result[0]
... | [
"def",
"resolve",
"(",
"input",
",",
"representation",
",",
"resolvers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"resultdict",
"=",
"query",
"(",
"input",
",",
"representation",
",",
"resolvers",
",",
"*",
"*",
"kwargs",
")",
"result",
"=",
"re... | Resolve input to the specified output representation | [
"Resolve",
"input",
"to",
"the",
"specified",
"output",
"representation"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/cirpy.py#L33-L39 |
16,341 | chemlab/chemlab | chemlab/libs/cirpy.py | query | def query(input, representation, resolvers=None, **kwargs):
""" Get all results for resolving input to the specified output representation """
apiurl = API_BASE+'/%s/%s/xml' % (urlquote(input), representation)
if resolvers:
kwargs['resolver'] = ",".join(resolvers)
if kwargs:
apiurl+= '?%... | python | def query(input, representation, resolvers=None, **kwargs):
""" Get all results for resolving input to the specified output representation """
apiurl = API_BASE+'/%s/%s/xml' % (urlquote(input), representation)
if resolvers:
kwargs['resolver'] = ",".join(resolvers)
if kwargs:
apiurl+= '?%... | [
"def",
"query",
"(",
"input",
",",
"representation",
",",
"resolvers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"apiurl",
"=",
"API_BASE",
"+",
"'/%s/%s/xml'",
"%",
"(",
"urlquote",
"(",
"input",
")",
",",
"representation",
")",
"if",
"resolvers",... | Get all results for resolving input to the specified output representation | [
"Get",
"all",
"results",
"for",
"resolving",
"input",
"to",
"the",
"specified",
"output",
"representation"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/cirpy.py#L42-L64 |
16,342 | chemlab/chemlab | chemlab/libs/cirpy.py | download | def download(input, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
""" Resolve and download structure as a file """
kwargs['format'] = format
if resolvers:
kwargs['resolver'] = ",".join(resolvers)
url = API_BASE+'/%s/file?%s' % (urlquote(input), urlencode(kwargs))
try:
... | python | def download(input, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
""" Resolve and download structure as a file """
kwargs['format'] = format
if resolvers:
kwargs['resolver'] = ",".join(resolvers)
url = API_BASE+'/%s/file?%s' % (urlquote(input), urlencode(kwargs))
try:
... | [
"def",
"download",
"(",
"input",
",",
"filename",
",",
"format",
"=",
"'sdf'",
",",
"overwrite",
"=",
"False",
",",
"resolvers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'format'",
"]",
"=",
"format",
"if",
"resolvers",
":",
"k... | Resolve and download structure as a file | [
"Resolve",
"and",
"download",
"structure",
"as",
"a",
"file"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/cirpy.py#L66-L81 |
16,343 | chemlab/chemlab | chemlab/libs/cirpy.py | Molecule.download | def download(self, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
""" Download the resolved structure as a file """
download(self.input, filename, format, overwrite, resolvers, **kwargs) | python | def download(self, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
""" Download the resolved structure as a file """
download(self.input, filename, format, overwrite, resolvers, **kwargs) | [
"def",
"download",
"(",
"self",
",",
"filename",
",",
"format",
"=",
"'sdf'",
",",
"overwrite",
"=",
"False",
",",
"resolvers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"download",
"(",
"self",
".",
"input",
",",
"filename",
",",
"format",
","... | Download the resolved structure as a file | [
"Download",
"the",
"resolved",
"structure",
"as",
"a",
"file"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/cirpy.py#L196-L198 |
16,344 | chemlab/chemlab | chemlab/utils/__init__.py | dipole_moment | def dipole_moment(r_array, charge_array):
'''Return the dipole moment of a neutral system.
'''
return np.sum(r_array * charge_array[:, np.newaxis], axis=0) | python | def dipole_moment(r_array, charge_array):
'''Return the dipole moment of a neutral system.
'''
return np.sum(r_array * charge_array[:, np.newaxis], axis=0) | [
"def",
"dipole_moment",
"(",
"r_array",
",",
"charge_array",
")",
":",
"return",
"np",
".",
"sum",
"(",
"r_array",
"*",
"charge_array",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
",",
"axis",
"=",
"0",
")"
] | Return the dipole moment of a neutral system. | [
"Return",
"the",
"dipole",
"moment",
"of",
"a",
"neutral",
"system",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/utils/__init__.py#L90-L93 |
16,345 | chemlab/chemlab | chemlab/graphics/qt/qtviewer.py | QtViewer.schedule | def schedule(self, callback, timeout=100):
'''Schedule a function to be called repeated time.
This method can be used to perform animations.
**Example**
This is a typical way to perform an animation, just::
from chemlab.graphics.qt import QtViewer
... | python | def schedule(self, callback, timeout=100):
'''Schedule a function to be called repeated time.
This method can be used to perform animations.
**Example**
This is a typical way to perform an animation, just::
from chemlab.graphics.qt import QtViewer
... | [
"def",
"schedule",
"(",
"self",
",",
"callback",
",",
"timeout",
"=",
"100",
")",
":",
"timer",
"=",
"QTimer",
"(",
"self",
")",
"timer",
".",
"timeout",
".",
"connect",
"(",
"callback",
")",
"timer",
".",
"start",
"(",
"timeout",
")",
"return",
"tim... | Schedule a function to be called repeated time.
This method can be used to perform animations.
**Example**
This is a typical way to perform an animation, just::
from chemlab.graphics.qt import QtViewer
from chemlab.graphics.renderers import Sph... | [
"Schedule",
"a",
"function",
"to",
"be",
"called",
"repeated",
"time",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/qt/qtviewer.py#L87-L129 |
16,346 | chemlab/chemlab | chemlab/graphics/qt/qtviewer.py | QtViewer.add_ui | def add_ui(self, klass, *args, **kwargs):
'''Add an UI element for the current scene. The approach is
the same as renderers.
.. warning:: The UI api is not yet finalized
'''
ui = klass(self.widget, *args, **kwargs)
self.widget.uis.append(ui)
return ui | python | def add_ui(self, klass, *args, **kwargs):
'''Add an UI element for the current scene. The approach is
the same as renderers.
.. warning:: The UI api is not yet finalized
'''
ui = klass(self.widget, *args, **kwargs)
self.widget.uis.append(ui)
return ui | [
"def",
"add_ui",
"(",
"self",
",",
"klass",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ui",
"=",
"klass",
"(",
"self",
".",
"widget",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"widget",
".",
"uis",
".",
"append",
... | Add an UI element for the current scene. The approach is
the same as renderers.
.. warning:: The UI api is not yet finalized | [
"Add",
"an",
"UI",
"element",
"for",
"the",
"current",
"scene",
".",
"The",
"approach",
"is",
"the",
"same",
"as",
"renderers",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/qt/qtviewer.py#L182-L191 |
16,347 | chemlab/chemlab | chemlab/io/handlers/gamess.py | parse_card | def parse_card(card, text, default=None):
"""Parse a card from an input string
"""
match = re.search(card.lower() + r"\s*=\s*(\w+)", text.lower())
return match.group(1) if match else default | python | def parse_card(card, text, default=None):
"""Parse a card from an input string
"""
match = re.search(card.lower() + r"\s*=\s*(\w+)", text.lower())
return match.group(1) if match else default | [
"def",
"parse_card",
"(",
"card",
",",
"text",
",",
"default",
"=",
"None",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"card",
".",
"lower",
"(",
")",
"+",
"r\"\\s*=\\s*(\\w+)\"",
",",
"text",
".",
"lower",
"(",
")",
")",
"return",
"match",
... | Parse a card from an input string | [
"Parse",
"a",
"card",
"from",
"an",
"input",
"string"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/handlers/gamess.py#L143-L148 |
16,348 | chemlab/chemlab | chemlab/io/handlers/gamess.py | GamessDataParser._parse_geometry | def _parse_geometry(self, geom):
"""Parse a geometry string and return Molecule object from
it.
"""
atoms = []
for i, line in enumerate(geom.splitlines()):
sym, atno, x, y, z = line.split()
atoms.append(Atom(sym, [float(x), float(y), float(z)], id=i))
... | python | def _parse_geometry(self, geom):
"""Parse a geometry string and return Molecule object from
it.
"""
atoms = []
for i, line in enumerate(geom.splitlines()):
sym, atno, x, y, z = line.split()
atoms.append(Atom(sym, [float(x), float(y), float(z)], id=i))
... | [
"def",
"_parse_geometry",
"(",
"self",
",",
"geom",
")",
":",
"atoms",
"=",
"[",
"]",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"geom",
".",
"splitlines",
"(",
")",
")",
":",
"sym",
",",
"atno",
",",
"x",
",",
"y",
",",
"z",
"=",
"line",... | Parse a geometry string and return Molecule object from
it. | [
"Parse",
"a",
"geometry",
"string",
"and",
"return",
"Molecule",
"object",
"from",
"it",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/handlers/gamess.py#L67-L77 |
16,349 | chemlab/chemlab | chemlab/io/handlers/gamess.py | GamessDataParser.parse_optimize | def parse_optimize(self):
"""Parse the ouput resulted of a geometry optimization. Or a
saddle point.
"""
match = re.search("EQUILIBRIUM GEOMETRY LOCATED", self.text)
spmatch = "SADDLE POINT LOCATED" in self.text
located = True if match or spmatch else False
poin... | python | def parse_optimize(self):
"""Parse the ouput resulted of a geometry optimization. Or a
saddle point.
"""
match = re.search("EQUILIBRIUM GEOMETRY LOCATED", self.text)
spmatch = "SADDLE POINT LOCATED" in self.text
located = True if match or spmatch else False
poin... | [
"def",
"parse_optimize",
"(",
"self",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"\"EQUILIBRIUM GEOMETRY LOCATED\"",
",",
"self",
".",
"text",
")",
"spmatch",
"=",
"\"SADDLE POINT LOCATED\"",
"in",
"self",
".",
"text",
"located",
"=",
"True",
"if",
"m... | Parse the ouput resulted of a geometry optimization. Or a
saddle point. | [
"Parse",
"the",
"ouput",
"resulted",
"of",
"a",
"geometry",
"optimization",
".",
"Or",
"a",
"saddle",
"point",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/handlers/gamess.py#L79-L104 |
16,350 | chemlab/chemlab | chemlab/graphics/renderers/cylinder_imp.py | CylinderImpostorRenderer.change_attributes | def change_attributes(self, bounds, radii, colors):
"""Reinitialize the buffers, to accomodate the new
attributes. This is used to change the number of cylinders to
be displayed.
"""
self.n_cylinders = len(bounds)
self.is_empty = True if self.n_cylinders == 0 el... | python | def change_attributes(self, bounds, radii, colors):
"""Reinitialize the buffers, to accomodate the new
attributes. This is used to change the number of cylinders to
be displayed.
"""
self.n_cylinders = len(bounds)
self.is_empty = True if self.n_cylinders == 0 el... | [
"def",
"change_attributes",
"(",
"self",
",",
"bounds",
",",
"radii",
",",
"colors",
")",
":",
"self",
".",
"n_cylinders",
"=",
"len",
"(",
"bounds",
")",
"self",
".",
"is_empty",
"=",
"True",
"if",
"self",
".",
"n_cylinders",
"==",
"0",
"else",
"False... | Reinitialize the buffers, to accomodate the new
attributes. This is used to change the number of cylinders to
be displayed. | [
"Reinitialize",
"the",
"buffers",
"to",
"accomodate",
"the",
"new",
"attributes",
".",
"This",
"is",
"used",
"to",
"change",
"the",
"number",
"of",
"cylinders",
"to",
"be",
"displayed",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/cylinder_imp.py#L32-L123 |
16,351 | chemlab/chemlab | chemlab/graphics/renderers/cylinder_imp.py | CylinderImpostorRenderer.update_bounds | def update_bounds(self, bounds):
'''Update the bounds inplace'''
self.bounds = np.array(bounds, dtype='float32')
vertices, directions = self._gen_bounds(self.bounds)
self._verts_vbo.set_data(vertices)
self._directions_vbo.set_data(directions)
self.widget.update(... | python | def update_bounds(self, bounds):
'''Update the bounds inplace'''
self.bounds = np.array(bounds, dtype='float32')
vertices, directions = self._gen_bounds(self.bounds)
self._verts_vbo.set_data(vertices)
self._directions_vbo.set_data(directions)
self.widget.update(... | [
"def",
"update_bounds",
"(",
"self",
",",
"bounds",
")",
":",
"self",
".",
"bounds",
"=",
"np",
".",
"array",
"(",
"bounds",
",",
"dtype",
"=",
"'float32'",
")",
"vertices",
",",
"directions",
"=",
"self",
".",
"_gen_bounds",
"(",
"self",
".",
"bounds"... | Update the bounds inplace | [
"Update",
"the",
"bounds",
"inplace"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/cylinder_imp.py#L209-L216 |
16,352 | chemlab/chemlab | chemlab/graphics/renderers/cylinder_imp.py | CylinderImpostorRenderer.update_radii | def update_radii(self, radii):
'''Update the radii inplace'''
self.radii = np.array(radii, dtype='float32')
prim_radii = self._gen_radii(self.radii)
self._radii_vbo.set_data(prim_radii)
self.widget.update() | python | def update_radii(self, radii):
'''Update the radii inplace'''
self.radii = np.array(radii, dtype='float32')
prim_radii = self._gen_radii(self.radii)
self._radii_vbo.set_data(prim_radii)
self.widget.update() | [
"def",
"update_radii",
"(",
"self",
",",
"radii",
")",
":",
"self",
".",
"radii",
"=",
"np",
".",
"array",
"(",
"radii",
",",
"dtype",
"=",
"'float32'",
")",
"prim_radii",
"=",
"self",
".",
"_gen_radii",
"(",
"self",
".",
"radii",
")",
"self",
".",
... | Update the radii inplace | [
"Update",
"the",
"radii",
"inplace"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/cylinder_imp.py#L218-L224 |
16,353 | chemlab/chemlab | chemlab/graphics/renderers/cylinder_imp.py | CylinderImpostorRenderer.update_colors | def update_colors(self, colors):
'''Update the colors inplace'''
self.colors = np.array(colors, dtype='uint8')
prim_colors = self._gen_colors(self.colors)
self._color_vbo.set_data(prim_colors)
self.widget.update() | python | def update_colors(self, colors):
'''Update the colors inplace'''
self.colors = np.array(colors, dtype='uint8')
prim_colors = self._gen_colors(self.colors)
self._color_vbo.set_data(prim_colors)
self.widget.update() | [
"def",
"update_colors",
"(",
"self",
",",
"colors",
")",
":",
"self",
".",
"colors",
"=",
"np",
".",
"array",
"(",
"colors",
",",
"dtype",
"=",
"'uint8'",
")",
"prim_colors",
"=",
"self",
".",
"_gen_colors",
"(",
"self",
".",
"colors",
")",
"self",
"... | Update the colors inplace | [
"Update",
"the",
"colors",
"inplace"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/cylinder_imp.py#L226-L232 |
16,354 | chemlab/chemlab | chemlab/notebook/display.py | Display.system | def system(self, object, highlight=None, alpha=1.0, color=None,
transparent=None):
'''Display System object'''
if self.backend == 'povray':
kwargs = {}
if color is not None:
kwargs['color'] = color
else:
kwargs['co... | python | def system(self, object, highlight=None, alpha=1.0, color=None,
transparent=None):
'''Display System object'''
if self.backend == 'povray':
kwargs = {}
if color is not None:
kwargs['color'] = color
else:
kwargs['co... | [
"def",
"system",
"(",
"self",
",",
"object",
",",
"highlight",
"=",
"None",
",",
"alpha",
"=",
"1.0",
",",
"color",
"=",
"None",
",",
"transparent",
"=",
"None",
")",
":",
"if",
"self",
".",
"backend",
"==",
"'povray'",
":",
"kwargs",
"=",
"{",
"}"... | Display System object | [
"Display",
"System",
"object"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/notebook/display.py#L17-L29 |
16,355 | chemlab/chemlab | chemlab/contrib/gromacs.py | make_gromacs | def make_gromacs(simulation, directory, clean=False):
"""Create gromacs directory structure"""
if clean is False and os.path.exists(directory):
raise ValueError(
'Cannot override {}, use option clean=True'.format(directory))
else:
shutil.rmtree(directory, ignore_errors=True)
... | python | def make_gromacs(simulation, directory, clean=False):
"""Create gromacs directory structure"""
if clean is False and os.path.exists(directory):
raise ValueError(
'Cannot override {}, use option clean=True'.format(directory))
else:
shutil.rmtree(directory, ignore_errors=True)
... | [
"def",
"make_gromacs",
"(",
"simulation",
",",
"directory",
",",
"clean",
"=",
"False",
")",
":",
"if",
"clean",
"is",
"False",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot override {}, use option ... | Create gromacs directory structure | [
"Create",
"gromacs",
"directory",
"structure"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/contrib/gromacs.py#L125-L175 |
16,356 | chemlab/chemlab | chemlab/graphics/renderers/triangles.py | TriangleRenderer.update_vertices | def update_vertices(self, vertices):
"""
Update the triangle vertices.
"""
vertices = np.array(vertices, dtype=np.float32)
self._vbo_v.set_data(vertices) | python | def update_vertices(self, vertices):
"""
Update the triangle vertices.
"""
vertices = np.array(vertices, dtype=np.float32)
self._vbo_v.set_data(vertices) | [
"def",
"update_vertices",
"(",
"self",
",",
"vertices",
")",
":",
"vertices",
"=",
"np",
".",
"array",
"(",
"vertices",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"self",
".",
"_vbo_v",
".",
"set_data",
"(",
"vertices",
")"
] | Update the triangle vertices. | [
"Update",
"the",
"triangle",
"vertices",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/triangles.py#L86-L92 |
16,357 | chemlab/chemlab | chemlab/graphics/renderers/triangles.py | TriangleRenderer.update_normals | def update_normals(self, normals):
"""
Update the triangle normals.
"""
normals = np.array(normals, dtype=np.float32)
self._vbo_n.set_data(normals) | python | def update_normals(self, normals):
"""
Update the triangle normals.
"""
normals = np.array(normals, dtype=np.float32)
self._vbo_n.set_data(normals) | [
"def",
"update_normals",
"(",
"self",
",",
"normals",
")",
":",
"normals",
"=",
"np",
".",
"array",
"(",
"normals",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"self",
".",
"_vbo_n",
".",
"set_data",
"(",
"normals",
")"
] | Update the triangle normals. | [
"Update",
"the",
"triangle",
"normals",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/renderers/triangles.py#L94-L100 |
16,358 | chemlab/chemlab | chemlab/graphics/qt/qttrajectory.py | TrajectoryControls.set_ticks | def set_ticks(self, number):
'''Set the number of frames to animate.
'''
self.max_index = number
self.current_index = 0
self.slider.setMaximum(self.max_index-1)
self.slider.setMinimum(0)
self.slider.setPageStep(1) | python | def set_ticks(self, number):
'''Set the number of frames to animate.
'''
self.max_index = number
self.current_index = 0
self.slider.setMaximum(self.max_index-1)
self.slider.setMinimum(0)
self.slider.setPageStep(1) | [
"def",
"set_ticks",
"(",
"self",
",",
"number",
")",
":",
"self",
".",
"max_index",
"=",
"number",
"self",
".",
"current_index",
"=",
"0",
"self",
".",
"slider",
".",
"setMaximum",
"(",
"self",
".",
"max_index",
"-",
"1",
")",
"self",
".",
"slider",
... | Set the number of frames to animate. | [
"Set",
"the",
"number",
"of",
"frames",
"to",
"animate",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/qt/qttrajectory.py#L229-L237 |
16,359 | chemlab/chemlab | chemlab/graphics/qt/qttrajectory.py | QtTrajectoryViewer.set_text | def set_text(self, text):
'''Update the time indicator in the interface.
'''
self.traj_controls.timelabel.setText(self.traj_controls._label_tmp.format(text)) | python | def set_text(self, text):
'''Update the time indicator in the interface.
'''
self.traj_controls.timelabel.setText(self.traj_controls._label_tmp.format(text)) | [
"def",
"set_text",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"traj_controls",
".",
"timelabel",
".",
"setText",
"(",
"self",
".",
"traj_controls",
".",
"_label_tmp",
".",
"format",
"(",
"text",
")",
")"
] | Update the time indicator in the interface. | [
"Update",
"the",
"time",
"indicator",
"in",
"the",
"interface",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/qt/qttrajectory.py#L316-L320 |
16,360 | chemlab/chemlab | chemlab/graphics/qt/qttrajectory.py | QtTrajectoryViewer.update_function | def update_function(self, func, frames=None):
'''Set the function to be called when it's time to display a frame.
*func* should be a function that takes one integer argument that
represents the frame that has to be played::
def func(index):
# Update the renderers to... | python | def update_function(self, func, frames=None):
'''Set the function to be called when it's time to display a frame.
*func* should be a function that takes one integer argument that
represents the frame that has to be played::
def func(index):
# Update the renderers to... | [
"def",
"update_function",
"(",
"self",
",",
"func",
",",
"frames",
"=",
"None",
")",
":",
"# Back-compatibility",
"if",
"frames",
"is",
"not",
"None",
":",
"self",
".",
"traj_controls",
".",
"set_ticks",
"(",
"frames",
")",
"self",
".",
"_update_function",
... | Set the function to be called when it's time to display a frame.
*func* should be a function that takes one integer argument that
represents the frame that has to be played::
def func(index):
# Update the renderers to match the
# current animation index | [
"Set",
"the",
"function",
"to",
"be",
"called",
"when",
"it",
"s",
"time",
"to",
"display",
"a",
"frame",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/qt/qttrajectory.py#L371-L386 |
16,361 | chemlab/chemlab | chemlab/graphics/transformations.py | rotation_matrix | def rotation_matrix(angle, direction):
"""
Create a rotation matrix corresponding to the rotation around a general
axis by a specified angle.
R = dd^T + cos(a) (I - dd^T) + sin(a) skew(d)
Parameters:
angle : float a
direction : array d
"""
d = numpy.array(directio... | python | def rotation_matrix(angle, direction):
"""
Create a rotation matrix corresponding to the rotation around a general
axis by a specified angle.
R = dd^T + cos(a) (I - dd^T) + sin(a) skew(d)
Parameters:
angle : float a
direction : array d
"""
d = numpy.array(directio... | [
"def",
"rotation_matrix",
"(",
"angle",
",",
"direction",
")",
":",
"d",
"=",
"numpy",
".",
"array",
"(",
"direction",
",",
"dtype",
"=",
"numpy",
".",
"float64",
")",
"d",
"/=",
"numpy",
".",
"linalg",
".",
"norm",
"(",
"d",
")",
"eye",
"=",
"nump... | Create a rotation matrix corresponding to the rotation around a general
axis by a specified angle.
R = dd^T + cos(a) (I - dd^T) + sin(a) skew(d)
Parameters:
angle : float a
direction : array d | [
"Create",
"a",
"rotation",
"matrix",
"corresponding",
"to",
"the",
"rotation",
"around",
"a",
"general",
"axis",
"by",
"a",
"specified",
"angle",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L341-L366 |
16,362 | chemlab/chemlab | chemlab/graphics/transformations.py | rotation_from_matrix | def rotation_from_matrix(matrix):
"""Return rotation angle and axis from rotation matrix.
>>> angle = (random.random() - 0.5) * (2*math.pi)
>>> direc = numpy.random.random(3) - 0.5
>>> point = numpy.random.random(3) - 0.5
>>> R0 = rotation_matrix(angle, direc, point)
>>> angle, direc, point = r... | python | def rotation_from_matrix(matrix):
"""Return rotation angle and axis from rotation matrix.
>>> angle = (random.random() - 0.5) * (2*math.pi)
>>> direc = numpy.random.random(3) - 0.5
>>> point = numpy.random.random(3) - 0.5
>>> R0 = rotation_matrix(angle, direc, point)
>>> angle, direc, point = r... | [
"def",
"rotation_from_matrix",
"(",
"matrix",
")",
":",
"R",
"=",
"numpy",
".",
"array",
"(",
"matrix",
",",
"dtype",
"=",
"numpy",
".",
"float64",
",",
"copy",
"=",
"False",
")",
"R33",
"=",
"R",
"[",
":",
"3",
",",
":",
"3",
"]",
"# direction: un... | Return rotation angle and axis from rotation matrix.
>>> angle = (random.random() - 0.5) * (2*math.pi)
>>> direc = numpy.random.random(3) - 0.5
>>> point = numpy.random.random(3) - 0.5
>>> R0 = rotation_matrix(angle, direc, point)
>>> angle, direc, point = rotation_from_matrix(R0)
>>> R1 = rota... | [
"Return",
"rotation",
"angle",
"and",
"axis",
"from",
"rotation",
"matrix",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L369-L406 |
16,363 | chemlab/chemlab | chemlab/graphics/transformations.py | scale_from_matrix | def scale_from_matrix(matrix):
"""Return scaling factor, origin and direction from scaling matrix.
>>> factor = random.random() * 10 - 5
>>> origin = numpy.random.random(3) - 0.5
>>> direct = numpy.random.random(3) - 0.5
>>> S0 = scale_matrix(factor, origin)
>>> factor, origin, direction = scal... | python | def scale_from_matrix(matrix):
"""Return scaling factor, origin and direction from scaling matrix.
>>> factor = random.random() * 10 - 5
>>> origin = numpy.random.random(3) - 0.5
>>> direct = numpy.random.random(3) - 0.5
>>> S0 = scale_matrix(factor, origin)
>>> factor, origin, direction = scal... | [
"def",
"scale_from_matrix",
"(",
"matrix",
")",
":",
"M",
"=",
"numpy",
".",
"array",
"(",
"matrix",
",",
"dtype",
"=",
"numpy",
".",
"float64",
",",
"copy",
"=",
"False",
")",
"M33",
"=",
"M",
"[",
":",
"3",
",",
":",
"3",
"]",
"factor",
"=",
... | Return scaling factor, origin and direction from scaling matrix.
>>> factor = random.random() * 10 - 5
>>> origin = numpy.random.random(3) - 0.5
>>> direct = numpy.random.random(3) - 0.5
>>> S0 = scale_matrix(factor, origin)
>>> factor, origin, direction = scale_from_matrix(S0)
>>> S1 = scale_m... | [
"Return",
"scaling",
"factor",
"origin",
"and",
"direction",
"from",
"scaling",
"matrix",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L443-L481 |
16,364 | chemlab/chemlab | chemlab/graphics/transformations.py | orthogonalization_matrix | def orthogonalization_matrix(lengths, angles):
"""Return orthogonalization matrix for crystallographic cell coordinates.
Angles are expected in degrees.
The de-orthogonalization matrix is the inverse.
>>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90])
>>> numpy.allclose(O[:3, :3], numpy... | python | def orthogonalization_matrix(lengths, angles):
"""Return orthogonalization matrix for crystallographic cell coordinates.
Angles are expected in degrees.
The de-orthogonalization matrix is the inverse.
>>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90])
>>> numpy.allclose(O[:3, :3], numpy... | [
"def",
"orthogonalization_matrix",
"(",
"lengths",
",",
"angles",
")",
":",
"a",
",",
"b",
",",
"c",
"=",
"lengths",
"angles",
"=",
"numpy",
".",
"radians",
"(",
"angles",
")",
"sina",
",",
"sinb",
",",
"_",
"=",
"numpy",
".",
"sin",
"(",
"angles",
... | Return orthogonalization matrix for crystallographic cell coordinates.
Angles are expected in degrees.
The de-orthogonalization matrix is the inverse.
>>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90])
>>> numpy.allclose(O[:3, :3], numpy.identity(3, float) * 10)
True
>>> O = orthogo... | [
"Return",
"orthogonalization",
"matrix",
"for",
"crystallographic",
"cell",
"coordinates",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L903-L927 |
16,365 | chemlab/chemlab | chemlab/graphics/transformations.py | superimposition_matrix | def superimposition_matrix(v0, v1, scale=False, usesvd=True):
"""Return matrix to transform given 3D point set into second point set.
v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points.
The parameters scale and usesvd are explained in the more general
affine_matrix_from_points function... | python | def superimposition_matrix(v0, v1, scale=False, usesvd=True):
"""Return matrix to transform given 3D point set into second point set.
v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points.
The parameters scale and usesvd are explained in the more general
affine_matrix_from_points function... | [
"def",
"superimposition_matrix",
"(",
"v0",
",",
"v1",
",",
"scale",
"=",
"False",
",",
"usesvd",
"=",
"True",
")",
":",
"v0",
"=",
"numpy",
".",
"array",
"(",
"v0",
",",
"dtype",
"=",
"numpy",
".",
"float64",
",",
"copy",
"=",
"False",
")",
"[",
... | Return matrix to transform given 3D point set into second point set.
v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points.
The parameters scale and usesvd are explained in the more general
affine_matrix_from_points function.
The returned matrix is a similarity or Eucledian transformatio... | [
"Return",
"matrix",
"to",
"transform",
"given",
"3D",
"point",
"set",
"into",
"second",
"point",
"set",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L1039-L1087 |
16,366 | chemlab/chemlab | chemlab/graphics/transformations.py | quaternion_matrix | def quaternion_matrix(quaternion):
"""Return homogeneous rotation matrix from quaternion.
>>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0])
>>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0]))
True
>>> M = quaternion_matrix([1, 0, 0, 0])
>>> numpy.allclose(M, numpy.identity(4))
... | python | def quaternion_matrix(quaternion):
"""Return homogeneous rotation matrix from quaternion.
>>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0])
>>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0]))
True
>>> M = quaternion_matrix([1, 0, 0, 0])
>>> numpy.allclose(M, numpy.identity(4))
... | [
"def",
"quaternion_matrix",
"(",
"quaternion",
")",
":",
"q",
"=",
"numpy",
".",
"array",
"(",
"quaternion",
",",
"dtype",
"=",
"numpy",
".",
"float64",
",",
"copy",
"=",
"True",
")",
"n",
"=",
"numpy",
".",
"dot",
"(",
"q",
",",
"q",
")",
"if",
... | Return homogeneous rotation matrix from quaternion.
>>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0])
>>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0]))
True
>>> M = quaternion_matrix([1, 0, 0, 0])
>>> numpy.allclose(M, numpy.identity(4))
True
>>> M = quaternion_matrix([0, 1, ... | [
"Return",
"homogeneous",
"rotation",
"matrix",
"from",
"quaternion",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L1295-L1319 |
16,367 | chemlab/chemlab | chemlab/graphics/transformations.py | quaternion_multiply | def quaternion_multiply(quaternion1, quaternion0):
"""Return multiplication of two quaternions.
>>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7])
>>> numpy.allclose(q, [28, -44, -14, 48])
True
"""
w0, x0, y0, z0 = quaternion0
w1, x1, y1, z1 = quaternion1
return numpy.array([-x1... | python | def quaternion_multiply(quaternion1, quaternion0):
"""Return multiplication of two quaternions.
>>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7])
>>> numpy.allclose(q, [28, -44, -14, 48])
True
"""
w0, x0, y0, z0 = quaternion0
w1, x1, y1, z1 = quaternion1
return numpy.array([-x1... | [
"def",
"quaternion_multiply",
"(",
"quaternion1",
",",
"quaternion0",
")",
":",
"w0",
",",
"x0",
",",
"y0",
",",
"z0",
"=",
"quaternion0",
"w1",
",",
"x1",
",",
"y1",
",",
"z1",
"=",
"quaternion1",
"return",
"numpy",
".",
"array",
"(",
"[",
"-",
"x1"... | Return multiplication of two quaternions.
>>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7])
>>> numpy.allclose(q, [28, -44, -14, 48])
True | [
"Return",
"multiplication",
"of",
"two",
"quaternions",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L1399-L1412 |
16,368 | chemlab/chemlab | chemlab/graphics/transformations.py | angle_between_vectors | def angle_between_vectors(v0, v1, directed=True, axis=0):
"""Return angle between vectors.
If directed is False, the input vectors are interpreted as undirected axes,
i.e. the maximum angle is pi/2.
>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3])
>>> numpy.allclose(a, math.pi)
True
... | python | def angle_between_vectors(v0, v1, directed=True, axis=0):
"""Return angle between vectors.
If directed is False, the input vectors are interpreted as undirected axes,
i.e. the maximum angle is pi/2.
>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3])
>>> numpy.allclose(a, math.pi)
True
... | [
"def",
"angle_between_vectors",
"(",
"v0",
",",
"v1",
",",
"directed",
"=",
"True",
",",
"axis",
"=",
"0",
")",
":",
"v0",
"=",
"numpy",
".",
"array",
"(",
"v0",
",",
"dtype",
"=",
"numpy",
".",
"float64",
",",
"copy",
"=",
"False",
")",
"v1",
"=... | Return angle between vectors.
If directed is False, the input vectors are interpreted as undirected axes,
i.e. the maximum angle is pi/2.
>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3])
>>> numpy.allclose(a, math.pi)
True
>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3], directed=F... | [
"Return",
"angle",
"between",
"vectors",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L1846-L1874 |
16,369 | chemlab/chemlab | chemlab/graphics/transformations.py | Arcball.drag | def drag(self, point):
"""Update current cursor window coordinates."""
vnow = arcball_map_to_sphere(point, self._center, self._radius)
if self._axis is not None:
vnow = arcball_constrain_to_axis(vnow, self._axis)
self._qpre = self._qnow
t = numpy.cross(self._vdown, vn... | python | def drag(self, point):
"""Update current cursor window coordinates."""
vnow = arcball_map_to_sphere(point, self._center, self._radius)
if self._axis is not None:
vnow = arcball_constrain_to_axis(vnow, self._axis)
self._qpre = self._qnow
t = numpy.cross(self._vdown, vn... | [
"def",
"drag",
"(",
"self",
",",
"point",
")",
":",
"vnow",
"=",
"arcball_map_to_sphere",
"(",
"point",
",",
"self",
".",
"_center",
",",
"self",
".",
"_radius",
")",
"if",
"self",
".",
"_axis",
"is",
"not",
"None",
":",
"vnow",
"=",
"arcball_constrain... | Update current cursor window coordinates. | [
"Update",
"current",
"cursor",
"window",
"coordinates",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/transformations.py#L1633-L1644 |
16,370 | chemlab/chemlab | chemlab/notebook/__init__.py | load_trajectory | def load_trajectory(name, format=None, skip=1):
'''Read a trajectory from a file.
.. seealso:: `chemlab.io.datafile`
'''
df = datafile(name, format=format)
ret = {}
t, coords = df.read('trajectory', skip=skip)
boxes = df.read('boxes')
ret['t'] = t
ret['coords'] = coords
ret['b... | python | def load_trajectory(name, format=None, skip=1):
'''Read a trajectory from a file.
.. seealso:: `chemlab.io.datafile`
'''
df = datafile(name, format=format)
ret = {}
t, coords = df.read('trajectory', skip=skip)
boxes = df.read('boxes')
ret['t'] = t
ret['coords'] = coords
ret['b... | [
"def",
"load_trajectory",
"(",
"name",
",",
"format",
"=",
"None",
",",
"skip",
"=",
"1",
")",
":",
"df",
"=",
"datafile",
"(",
"name",
",",
"format",
"=",
"format",
")",
"ret",
"=",
"{",
"}",
"t",
",",
"coords",
"=",
"df",
".",
"read",
"(",
"'... | Read a trajectory from a file.
.. seealso:: `chemlab.io.datafile` | [
"Read",
"a",
"trajectory",
"from",
"a",
"file",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/notebook/__init__.py#L78-L93 |
16,371 | chemlab/chemlab | chemlab/mviewer/api/selections.py | select_atoms | def select_atoms(indices):
'''Select atoms by their indices.
You can select the first 3 atoms as follows::
select_atoms([0, 1, 2])
Return the current selection dictionary.
'''
rep = current_representation()
rep.select({'atoms': Selection(indices, current_system().n_atoms)})
ret... | python | def select_atoms(indices):
'''Select atoms by their indices.
You can select the first 3 atoms as follows::
select_atoms([0, 1, 2])
Return the current selection dictionary.
'''
rep = current_representation()
rep.select({'atoms': Selection(indices, current_system().n_atoms)})
ret... | [
"def",
"select_atoms",
"(",
"indices",
")",
":",
"rep",
"=",
"current_representation",
"(",
")",
"rep",
".",
"select",
"(",
"{",
"'atoms'",
":",
"Selection",
"(",
"indices",
",",
"current_system",
"(",
")",
".",
"n_atoms",
")",
"}",
")",
"return",
"rep",... | Select atoms by their indices.
You can select the first 3 atoms as follows::
select_atoms([0, 1, 2])
Return the current selection dictionary. | [
"Select",
"atoms",
"by",
"their",
"indices",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L20-L32 |
16,372 | chemlab/chemlab | chemlab/mviewer/api/selections.py | select_connected_bonds | def select_connected_bonds():
'''Select the bonds connected to the currently selected atoms.'''
s = current_system()
start, end = s.bonds.transpose()
selected = np.zeros(s.n_bonds, 'bool')
for i in selected_atoms():
selected |= (i == start) | (i == end)
csel = current_selection()
bs... | python | def select_connected_bonds():
'''Select the bonds connected to the currently selected atoms.'''
s = current_system()
start, end = s.bonds.transpose()
selected = np.zeros(s.n_bonds, 'bool')
for i in selected_atoms():
selected |= (i == start) | (i == end)
csel = current_selection()
bs... | [
"def",
"select_connected_bonds",
"(",
")",
":",
"s",
"=",
"current_system",
"(",
")",
"start",
",",
"end",
"=",
"s",
".",
"bonds",
".",
"transpose",
"(",
")",
"selected",
"=",
"np",
".",
"zeros",
"(",
"s",
".",
"n_bonds",
",",
"'bool'",
")",
"for",
... | Select the bonds connected to the currently selected atoms. | [
"Select",
"the",
"bonds",
"connected",
"to",
"the",
"currently",
"selected",
"atoms",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L54-L69 |
16,373 | chemlab/chemlab | chemlab/mviewer/api/selections.py | select_molecules | def select_molecules(name):
'''Select all the molecules corresponding to the formulas.'''
mol_formula = current_system().get_derived_molecule_array('formula')
mask = mol_formula == name
ind = current_system().mol_to_atom_indices(mask.nonzero()[0])
selection = {'atoms': Selection(ind, current_system... | python | def select_molecules(name):
'''Select all the molecules corresponding to the formulas.'''
mol_formula = current_system().get_derived_molecule_array('formula')
mask = mol_formula == name
ind = current_system().mol_to_atom_indices(mask.nonzero()[0])
selection = {'atoms': Selection(ind, current_system... | [
"def",
"select_molecules",
"(",
"name",
")",
":",
"mol_formula",
"=",
"current_system",
"(",
")",
".",
"get_derived_molecule_array",
"(",
"'formula'",
")",
"mask",
"=",
"mol_formula",
"==",
"name",
"ind",
"=",
"current_system",
"(",
")",
".",
"mol_to_atom_indice... | Select all the molecules corresponding to the formulas. | [
"Select",
"all",
"the",
"molecules",
"corresponding",
"to",
"the",
"formulas",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L85-L105 |
16,374 | chemlab/chemlab | chemlab/mviewer/api/selections.py | hide_selected | def hide_selected():
'''Hide the selected objects.'''
ss = current_representation().selection_state
hs = current_representation().hidden_state
res = {}
for k in ss:
res[k] = hs[k].add(ss[k])
current_representation().hide(res) | python | def hide_selected():
'''Hide the selected objects.'''
ss = current_representation().selection_state
hs = current_representation().hidden_state
res = {}
for k in ss:
res[k] = hs[k].add(ss[k])
current_representation().hide(res) | [
"def",
"hide_selected",
"(",
")",
":",
"ss",
"=",
"current_representation",
"(",
")",
".",
"selection_state",
"hs",
"=",
"current_representation",
"(",
")",
".",
"hidden_state",
"res",
"=",
"{",
"}",
"for",
"k",
"in",
"ss",
":",
"res",
"[",
"k",
"]",
"... | Hide the selected objects. | [
"Hide",
"the",
"selected",
"objects",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L113-L122 |
16,375 | chemlab/chemlab | chemlab/mviewer/api/selections.py | unhide_selected | def unhide_selected():
'''Unhide the selected objects'''
hidden_state = current_representation().hidden_state
selection_state = current_representation().selection_state
res = {}
# Take the hidden state and flip the selected atoms bits.
for k in selection_state:
visible = hidden_sta... | python | def unhide_selected():
'''Unhide the selected objects'''
hidden_state = current_representation().hidden_state
selection_state = current_representation().selection_state
res = {}
# Take the hidden state and flip the selected atoms bits.
for k in selection_state:
visible = hidden_sta... | [
"def",
"unhide_selected",
"(",
")",
":",
"hidden_state",
"=",
"current_representation",
"(",
")",
".",
"hidden_state",
"selection_state",
"=",
"current_representation",
"(",
")",
".",
"selection_state",
"res",
"=",
"{",
"}",
"# Take the hidden state and flip the selecte... | Unhide the selected objects | [
"Unhide",
"the",
"selected",
"objects"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L137-L150 |
16,376 | chemlab/chemlab | chemlab/graphics/camera.py | Camera.mouse_rotate | def mouse_rotate(self, dx, dy):
'''Convenience function to implement the mouse rotation by
giving two displacements in the x and y directions.
'''
fact = 1.5
self.orbit_y(-dx*fact)
self.orbit_x(dy*fact) | python | def mouse_rotate(self, dx, dy):
'''Convenience function to implement the mouse rotation by
giving two displacements in the x and y directions.
'''
fact = 1.5
self.orbit_y(-dx*fact)
self.orbit_x(dy*fact) | [
"def",
"mouse_rotate",
"(",
"self",
",",
"dx",
",",
"dy",
")",
":",
"fact",
"=",
"1.5",
"self",
".",
"orbit_y",
"(",
"-",
"dx",
"*",
"fact",
")",
"self",
".",
"orbit_x",
"(",
"dy",
"*",
"fact",
")"
] | Convenience function to implement the mouse rotation by
giving two displacements in the x and y directions. | [
"Convenience",
"function",
"to",
"implement",
"the",
"mouse",
"rotation",
"by",
"giving",
"two",
"displacements",
"in",
"the",
"x",
"and",
"y",
"directions",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/camera.py#L148-L155 |
16,377 | chemlab/chemlab | chemlab/graphics/camera.py | Camera.mouse_zoom | def mouse_zoom(self, inc):
'''Convenience function to implement a zoom function.
This is achieved by moving ``Camera.position`` in the
direction of the ``Camera.c`` vector.
'''
# Square Distance from pivot
dsq = np.linalg.norm(self.position - self.pivot)
minsq =... | python | def mouse_zoom(self, inc):
'''Convenience function to implement a zoom function.
This is achieved by moving ``Camera.position`` in the
direction of the ``Camera.c`` vector.
'''
# Square Distance from pivot
dsq = np.linalg.norm(self.position - self.pivot)
minsq =... | [
"def",
"mouse_zoom",
"(",
"self",
",",
"inc",
")",
":",
"# Square Distance from pivot",
"dsq",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"position",
"-",
"self",
".",
"pivot",
")",
"minsq",
"=",
"1.0",
"**",
"2",
"# How near can we be to the... | Convenience function to implement a zoom function.
This is achieved by moving ``Camera.position`` in the
direction of the ``Camera.c`` vector. | [
"Convenience",
"function",
"to",
"implement",
"a",
"zoom",
"function",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/camera.py#L157-L179 |
16,378 | chemlab/chemlab | chemlab/graphics/camera.py | Camera.unproject | def unproject(self, x, y, z=-1.0):
"""Receive x and y as screen coordinates and returns a point
in world coordinates.
This function comes in handy each time we have to convert a 2d
mouse click to a 3d point in our space.
**Parameters**
x: float in the interval ... | python | def unproject(self, x, y, z=-1.0):
"""Receive x and y as screen coordinates and returns a point
in world coordinates.
This function comes in handy each time we have to convert a 2d
mouse click to a 3d point in our space.
**Parameters**
x: float in the interval ... | [
"def",
"unproject",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
"=",
"-",
"1.0",
")",
":",
"source",
"=",
"np",
".",
"array",
"(",
"[",
"x",
",",
"y",
",",
"z",
",",
"1.0",
"]",
")",
"# Invert the combined matrix",
"matrix",
"=",
"self",
".",
"p... | Receive x and y as screen coordinates and returns a point
in world coordinates.
This function comes in handy each time we have to convert a 2d
mouse click to a 3d point in our space.
**Parameters**
x: float in the interval [-1.0, 1.0]
Horizontal coordinate,... | [
"Receive",
"x",
"and",
"y",
"as",
"screen",
"coordinates",
"and",
"returns",
"a",
"point",
"in",
"world",
"coordinates",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/camera.py#L230-L261 |
16,379 | chemlab/chemlab | chemlab/graphics/camera.py | Camera.state | def state(self):
'''Return the current camera state as a dictionary, it can be
restored with `Camera.restore`.
'''
return dict(a=self.a.tolist(), b=self.b.tolist(), c=self.c.tolist(),
pivot=self.pivot.tolist(), position=self.position.tolist()) | python | def state(self):
'''Return the current camera state as a dictionary, it can be
restored with `Camera.restore`.
'''
return dict(a=self.a.tolist(), b=self.b.tolist(), c=self.c.tolist(),
pivot=self.pivot.tolist(), position=self.position.tolist()) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"a",
"=",
"self",
".",
"a",
".",
"tolist",
"(",
")",
",",
"b",
"=",
"self",
".",
"b",
".",
"tolist",
"(",
")",
",",
"c",
"=",
"self",
".",
"c",
".",
"tolist",
"(",
")",
",",
"p... | Return the current camera state as a dictionary, it can be
restored with `Camera.restore`. | [
"Return",
"the",
"current",
"camera",
"state",
"as",
"a",
"dictionary",
"it",
"can",
"be",
"restored",
"with",
"Camera",
".",
"restore",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/camera.py#L316-L322 |
16,380 | chemlab/chemlab | chemlab/graphics/pickers.py | ray_spheres_intersection | def ray_spheres_intersection(origin, direction, centers, radii):
"""Calculate the intersection points between a ray and multiple
spheres.
**Returns**
intersections
distances
Ordered by closest to farther
"""
b_v = 2.0 * ((origin - centers) * direction).sum(axis=1)
c_v = (... | python | def ray_spheres_intersection(origin, direction, centers, radii):
"""Calculate the intersection points between a ray and multiple
spheres.
**Returns**
intersections
distances
Ordered by closest to farther
"""
b_v = 2.0 * ((origin - centers) * direction).sum(axis=1)
c_v = (... | [
"def",
"ray_spheres_intersection",
"(",
"origin",
",",
"direction",
",",
"centers",
",",
"radii",
")",
":",
"b_v",
"=",
"2.0",
"*",
"(",
"(",
"origin",
"-",
"centers",
")",
"*",
"direction",
")",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"c_v",
"=",
... | Calculate the intersection points between a ray and multiple
spheres.
**Returns**
intersections
distances
Ordered by closest to farther | [
"Calculate",
"the",
"intersection",
"points",
"between",
"a",
"ray",
"and",
"multiple",
"spheres",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/pickers.py#L8-L40 |
16,381 | chemlab/chemlab | chemlab/graphics/colors.py | any_to_rgb | def any_to_rgb(color):
'''If color is an rgb tuple return it, if it is a string, parse it
and return the respective rgb tuple.
'''
if isinstance(color, tuple):
if len(color) == 3:
color = color + (255,)
return color
if isinstance(color, str):
return pars... | python | def any_to_rgb(color):
'''If color is an rgb tuple return it, if it is a string, parse it
and return the respective rgb tuple.
'''
if isinstance(color, tuple):
if len(color) == 3:
color = color + (255,)
return color
if isinstance(color, str):
return pars... | [
"def",
"any_to_rgb",
"(",
"color",
")",
":",
"if",
"isinstance",
"(",
"color",
",",
"tuple",
")",
":",
"if",
"len",
"(",
"color",
")",
"==",
"3",
":",
"color",
"=",
"color",
"+",
"(",
"255",
",",
")",
"return",
"color",
"if",
"isinstance",
"(",
"... | If color is an rgb tuple return it, if it is a string, parse it
and return the respective rgb tuple. | [
"If",
"color",
"is",
"an",
"rgb",
"tuple",
"return",
"it",
"if",
"it",
"is",
"a",
"string",
"parse",
"it",
"and",
"return",
"the",
"respective",
"rgb",
"tuple",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/colors.py#L167-L180 |
16,382 | chemlab/chemlab | chemlab/graphics/colors.py | parse_color | def parse_color(color):
'''Return the RGB 0-255 representation of the current string
passed.
It first tries to match the string with DVI color names.
'''
# Let's parse the color string
if isinstance(color, str):
# Try dvi names
try:
col = get(color)
exc... | python | def parse_color(color):
'''Return the RGB 0-255 representation of the current string
passed.
It first tries to match the string with DVI color names.
'''
# Let's parse the color string
if isinstance(color, str):
# Try dvi names
try:
col = get(color)
exc... | [
"def",
"parse_color",
"(",
"color",
")",
":",
"# Let's parse the color string",
"if",
"isinstance",
"(",
"color",
",",
"str",
")",
":",
"# Try dvi names",
"try",
":",
"col",
"=",
"get",
"(",
"color",
")",
"except",
"ValueError",
":",
"# String is not present",
... | Return the RGB 0-255 representation of the current string
passed.
It first tries to match the string with DVI color names. | [
"Return",
"the",
"RGB",
"0",
"-",
"255",
"representation",
"of",
"the",
"current",
"string",
"passed",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/colors.py#L197-L220 |
16,383 | chemlab/chemlab | chemlab/graphics/colors.py | hsl_to_rgb | def hsl_to_rgb(arr):
"""
Converts HSL color array to RGB array
H = [0..360]
S = [0..1]
l = [0..1]
http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL
Returns R,G,B in [0..255]
"""
H, S, L = arr.T
H = (H.copy()/255.0) * 360
S = S.copy()/255.0
L = L.copy()/255.0
... | python | def hsl_to_rgb(arr):
"""
Converts HSL color array to RGB array
H = [0..360]
S = [0..1]
l = [0..1]
http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL
Returns R,G,B in [0..255]
"""
H, S, L = arr.T
H = (H.copy()/255.0) * 360
S = S.copy()/255.0
L = L.copy()/255.0
... | [
"def",
"hsl_to_rgb",
"(",
"arr",
")",
":",
"H",
",",
"S",
",",
"L",
"=",
"arr",
".",
"T",
"H",
"=",
"(",
"H",
".",
"copy",
"(",
")",
"/",
"255.0",
")",
"*",
"360",
"S",
"=",
"S",
".",
"copy",
"(",
")",
"/",
"255.0",
"L",
"=",
"L",
".",
... | Converts HSL color array to RGB array
H = [0..360]
S = [0..1]
l = [0..1]
http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL
Returns R,G,B in [0..255] | [
"Converts",
"HSL",
"color",
"array",
"to",
"RGB",
"array"
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/graphics/colors.py#L309-L372 |
16,384 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | format_symbol | def format_symbol(symbol):
"""Returns well formatted Hermann-Mauguin symbol as extected by
the database, by correcting the case and adding missing or
removing dublicated spaces."""
fixed = []
s = symbol.strip()
s = s[0].upper() + s[1:].lower()
for c in s:
if c.isalpha():
... | python | def format_symbol(symbol):
"""Returns well formatted Hermann-Mauguin symbol as extected by
the database, by correcting the case and adding missing or
removing dublicated spaces."""
fixed = []
s = symbol.strip()
s = s[0].upper() + s[1:].lower()
for c in s:
if c.isalpha():
... | [
"def",
"format_symbol",
"(",
"symbol",
")",
":",
"fixed",
"=",
"[",
"]",
"s",
"=",
"symbol",
".",
"strip",
"(",
")",
"s",
"=",
"s",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"s",
"[",
"1",
":",
"]",
".",
"lower",
"(",
")",
"for",
"c",
"... | Returns well formatted Hermann-Mauguin symbol as extected by
the database, by correcting the case and adding missing or
removing dublicated spaces. | [
"Returns",
"well",
"formatted",
"Hermann",
"-",
"Mauguin",
"symbol",
"as",
"extected",
"by",
"the",
"database",
"by",
"correcting",
"the",
"case",
"and",
"adding",
"missing",
"or",
"removing",
"dublicated",
"spaces",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L484-L503 |
16,385 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | _skip_to_blank | def _skip_to_blank(f, spacegroup, setting):
"""Read lines from f until a blank line is encountered."""
while True:
line = f.readline()
if not line:
raise SpacegroupNotFoundError(
'invalid spacegroup %s, setting %i not found in data base' %
( spacegrou... | python | def _skip_to_blank(f, spacegroup, setting):
"""Read lines from f until a blank line is encountered."""
while True:
line = f.readline()
if not line:
raise SpacegroupNotFoundError(
'invalid spacegroup %s, setting %i not found in data base' %
( spacegrou... | [
"def",
"_skip_to_blank",
"(",
"f",
",",
"spacegroup",
",",
"setting",
")",
":",
"while",
"True",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"raise",
"SpacegroupNotFoundError",
"(",
"'invalid spacegroup %s, setting %i not found in... | Read lines from f until a blank line is encountered. | [
"Read",
"lines",
"from",
"f",
"until",
"a",
"blank",
"line",
"is",
"encountered",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L513-L522 |
16,386 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | _read_datafile_entry | def _read_datafile_entry(spg, no, symbol, setting, f):
"""Read space group data from f to spg."""
spg._no = no
spg._symbol = symbol.strip()
spg._setting = setting
spg._centrosymmetric = bool(int(f.readline().split()[1]))
# primitive vectors
f.readline()
spg._scaled_primitive_cell = np.ar... | python | def _read_datafile_entry(spg, no, symbol, setting, f):
"""Read space group data from f to spg."""
spg._no = no
spg._symbol = symbol.strip()
spg._setting = setting
spg._centrosymmetric = bool(int(f.readline().split()[1]))
# primitive vectors
f.readline()
spg._scaled_primitive_cell = np.ar... | [
"def",
"_read_datafile_entry",
"(",
"spg",
",",
"no",
",",
"symbol",
",",
"setting",
",",
"f",
")",
":",
"spg",
".",
"_no",
"=",
"no",
"spg",
".",
"_symbol",
"=",
"symbol",
".",
"strip",
"(",
")",
"spg",
".",
"_setting",
"=",
"setting",
"spg",
".",... | Read space group data from f to spg. | [
"Read",
"space",
"group",
"data",
"from",
"f",
"to",
"spg",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L541-L570 |
16,387 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | parse_sitesym | def parse_sitesym(symlist, sep=','):
"""Parses a sequence of site symmetries in the form used by
International Tables and returns corresponding rotation and
translation arrays.
Example:
>>> symlist = [
... 'x,y,z',
... '-y+1/2,x+1/2,z',
... '-y,-x,-z',
... ]
>>> rot... | python | def parse_sitesym(symlist, sep=','):
"""Parses a sequence of site symmetries in the form used by
International Tables and returns corresponding rotation and
translation arrays.
Example:
>>> symlist = [
... 'x,y,z',
... '-y+1/2,x+1/2,z',
... '-y,-x,-z',
... ]
>>> rot... | [
"def",
"parse_sitesym",
"(",
"symlist",
",",
"sep",
"=",
"','",
")",
":",
"nsym",
"=",
"len",
"(",
"symlist",
")",
"rot",
"=",
"np",
".",
"zeros",
"(",
"(",
"nsym",
",",
"3",
",",
"3",
")",
",",
"dtype",
"=",
"'int'",
")",
"trans",
"=",
"np",
... | Parses a sequence of site symmetries in the form used by
International Tables and returns corresponding rotation and
translation arrays.
Example:
>>> symlist = [
... 'x,y,z',
... '-y+1/2,x+1/2,z',
... '-y,-x,-z',
... ]
>>> rot, trans = parse_sitesym(symlist)
>>> rot... | [
"Parses",
"a",
"sequence",
"of",
"site",
"symmetries",
"in",
"the",
"form",
"used",
"by",
"International",
"Tables",
"and",
"returns",
"corresponding",
"rotation",
"and",
"translation",
"arrays",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L596-L657 |
16,388 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | spacegroup_from_data | def spacegroup_from_data(no=None, symbol=None, setting=1,
centrosymmetric=None, scaled_primitive_cell=None,
reciprocal_cell=None, subtrans=None, sitesym=None,
rotations=None, translations=None, datafile=None):
"""Manually create a new spa... | python | def spacegroup_from_data(no=None, symbol=None, setting=1,
centrosymmetric=None, scaled_primitive_cell=None,
reciprocal_cell=None, subtrans=None, sitesym=None,
rotations=None, translations=None, datafile=None):
"""Manually create a new spa... | [
"def",
"spacegroup_from_data",
"(",
"no",
"=",
"None",
",",
"symbol",
"=",
"None",
",",
"setting",
"=",
"1",
",",
"centrosymmetric",
"=",
"None",
",",
"scaled_primitive_cell",
"=",
"None",
",",
"reciprocal_cell",
"=",
"None",
",",
"subtrans",
"=",
"None",
... | Manually create a new space group instance. This might be
usefull when reading crystal data with its own spacegroup
definitions. | [
"Manually",
"create",
"a",
"new",
"space",
"group",
"instance",
".",
"This",
"might",
"be",
"usefull",
"when",
"reading",
"crystal",
"data",
"with",
"its",
"own",
"spacegroup",
"definitions",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L660-L698 |
16,389 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | Spacegroup._get_nsymop | def _get_nsymop(self):
"""Returns total number of symmetry operations."""
if self.centrosymmetric:
return 2 * len(self._rotations) * len(self._subtrans)
else:
return len(self._rotations) * len(self._subtrans) | python | def _get_nsymop(self):
"""Returns total number of symmetry operations."""
if self.centrosymmetric:
return 2 * len(self._rotations) * len(self._subtrans)
else:
return len(self._rotations) * len(self._subtrans) | [
"def",
"_get_nsymop",
"(",
"self",
")",
":",
"if",
"self",
".",
"centrosymmetric",
":",
"return",
"2",
"*",
"len",
"(",
"self",
".",
"_rotations",
")",
"*",
"len",
"(",
"self",
".",
"_subtrans",
")",
"else",
":",
"return",
"len",
"(",
"self",
".",
... | Returns total number of symmetry operations. | [
"Returns",
"total",
"number",
"of",
"symmetry",
"operations",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L86-L91 |
16,390 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | Spacegroup.get_rotations | def get_rotations(self):
"""Return all rotations, including inversions for
centrosymmetric crystals."""
if self.centrosymmetric:
return np.vstack((self.rotations, -self.rotations))
else:
return self.rotations | python | def get_rotations(self):
"""Return all rotations, including inversions for
centrosymmetric crystals."""
if self.centrosymmetric:
return np.vstack((self.rotations, -self.rotations))
else:
return self.rotations | [
"def",
"get_rotations",
"(",
"self",
")",
":",
"if",
"self",
".",
"centrosymmetric",
":",
"return",
"np",
".",
"vstack",
"(",
"(",
"self",
".",
"rotations",
",",
"-",
"self",
".",
"rotations",
")",
")",
"else",
":",
"return",
"self",
".",
"rotations"
] | Return all rotations, including inversions for
centrosymmetric crystals. | [
"Return",
"all",
"rotations",
"including",
"inversions",
"for",
"centrosymmetric",
"crystals",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L221-L227 |
16,391 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | Spacegroup.equivalent_reflections | def equivalent_reflections(self, hkl):
"""Return all equivalent reflections to the list of Miller indices
in hkl.
Example:
>>> from ase.lattice.spacegroup import Spacegroup
>>> sg = Spacegroup(225) # fcc
>>> sg.equivalent_reflections([[0, 0, 2]])
array([[ 0, 0... | python | def equivalent_reflections(self, hkl):
"""Return all equivalent reflections to the list of Miller indices
in hkl.
Example:
>>> from ase.lattice.spacegroup import Spacegroup
>>> sg = Spacegroup(225) # fcc
>>> sg.equivalent_reflections([[0, 0, 2]])
array([[ 0, 0... | [
"def",
"equivalent_reflections",
"(",
"self",
",",
"hkl",
")",
":",
"hkl",
"=",
"np",
".",
"array",
"(",
"hkl",
",",
"dtype",
"=",
"'int'",
",",
"ndmin",
"=",
"2",
")",
"rot",
"=",
"self",
".",
"get_rotations",
"(",
")",
"n",
",",
"nrot",
"=",
"l... | Return all equivalent reflections to the list of Miller indices
in hkl.
Example:
>>> from ase.lattice.spacegroup import Spacegroup
>>> sg = Spacegroup(225) # fcc
>>> sg.equivalent_reflections([[0, 0, 2]])
array([[ 0, 0, -2],
[ 0, -2, 0],
... | [
"Return",
"all",
"equivalent",
"reflections",
"to",
"the",
"list",
"of",
"Miller",
"indices",
"in",
"hkl",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L229-L254 |
16,392 | chemlab/chemlab | chemlab/core/spacegroup/spacegroup.py | Spacegroup.equivalent_sites | def equivalent_sites(self, scaled_positions, ondublicates='error',
symprec=1e-3):
"""Returns the scaled positions and all their equivalent sites.
Parameters:
scaled_positions: list | array
List of non-equivalent sites given in unit cell coordinates.
... | python | def equivalent_sites(self, scaled_positions, ondublicates='error',
symprec=1e-3):
"""Returns the scaled positions and all their equivalent sites.
Parameters:
scaled_positions: list | array
List of non-equivalent sites given in unit cell coordinates.
... | [
"def",
"equivalent_sites",
"(",
"self",
",",
"scaled_positions",
",",
"ondublicates",
"=",
"'error'",
",",
"symprec",
"=",
"1e-3",
")",
":",
"kinds",
"=",
"[",
"]",
"sites",
"=",
"[",
"]",
"symprec2",
"=",
"symprec",
"**",
"2",
"scaled",
"=",
"np",
"."... | Returns the scaled positions and all their equivalent sites.
Parameters:
scaled_positions: list | array
List of non-equivalent sites given in unit cell coordinates.
ondublicates : 'keep' | 'replace' | 'warn' | 'error'
Action if `scaled_positions` contain symmetry-equiva... | [
"Returns",
"the",
"scaled",
"positions",
"and",
"all",
"their",
"equivalent",
"sites",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L302-L387 |
16,393 | chemlab/chemlab | chemlab/io/handlers/utils.py | guess_type | def guess_type(typ):
'''Guess the atom type from purely heuristic considerations.'''
# Strip useless numbers
match = re.match("([a-zA-Z]+)\d*", typ)
if match:
typ = match.groups()[0]
return typ | python | def guess_type(typ):
'''Guess the atom type from purely heuristic considerations.'''
# Strip useless numbers
match = re.match("([a-zA-Z]+)\d*", typ)
if match:
typ = match.groups()[0]
return typ | [
"def",
"guess_type",
"(",
"typ",
")",
":",
"# Strip useless numbers",
"match",
"=",
"re",
".",
"match",
"(",
"\"([a-zA-Z]+)\\d*\"",
",",
"typ",
")",
"if",
"match",
":",
"typ",
"=",
"match",
".",
"groups",
"(",
")",
"[",
"0",
"]",
"return",
"typ"
] | Guess the atom type from purely heuristic considerations. | [
"Guess",
"the",
"atom",
"type",
"from",
"purely",
"heuristic",
"considerations",
"."
] | c8730966316d101e24f39ac3b96b51282aba0abe | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/handlers/utils.py#L3-L9 |
16,394 | janpipek/physt | physt/plotting/matplotlib.py | register | def register(*dim: List[int], use_3d: bool = False, use_polar: bool = False, collection: bool = False):
"""Decorator to wrap common plotting functionality.
Parameters
----------
dim : Dimensionality of histogram for which it is applicable
use_3d : If True, the figure will be 3D.
use_polar : If ... | python | def register(*dim: List[int], use_3d: bool = False, use_polar: bool = False, collection: bool = False):
"""Decorator to wrap common plotting functionality.
Parameters
----------
dim : Dimensionality of histogram for which it is applicable
use_3d : If True, the figure will be 3D.
use_polar : If ... | [
"def",
"register",
"(",
"*",
"dim",
":",
"List",
"[",
"int",
"]",
",",
"use_3d",
":",
"bool",
"=",
"False",
",",
"use_polar",
":",
"bool",
"=",
"False",
",",
"collection",
":",
"bool",
"=",
"False",
")",
":",
"if",
"use_3d",
"and",
"use_polar",
":"... | Decorator to wrap common plotting functionality.
Parameters
----------
dim : Dimensionality of histogram for which it is applicable
use_3d : If True, the figure will be 3D.
use_polar : If True, the figure will be in polar coordinates.
collection : Whether to allow histogram collections to be us... | [
"Decorator",
"to",
"wrap",
"common",
"plotting",
"functionality",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L63-L105 |
16,395 | janpipek/physt | physt/plotting/matplotlib.py | bar | def bar(h1: Histogram1D, ax: Axes, *, errors: bool = False, **kwargs):
"""Bar plot of 1D histograms."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
value_format = kwargs.pop("value_format", None)
density = kwargs.pop("density", False)
cumulative = ... | python | def bar(h1: Histogram1D, ax: Axes, *, errors: bool = False, **kwargs):
"""Bar plot of 1D histograms."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
value_format = kwargs.pop("value_format", None)
density = kwargs.pop("density", False)
cumulative = ... | [
"def",
"bar",
"(",
"h1",
":",
"Histogram1D",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"errors",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"show_stats",
"=",
"kwargs",
".",
"pop",
"(",
"\"show_stats\"",
",",
"False",
")",
"show_val... | Bar plot of 1D histograms. | [
"Bar",
"plot",
"of",
"1D",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L109-L145 |
16,396 | janpipek/physt | physt/plotting/matplotlib.py | scatter | def scatter(h1: Histogram1D, ax: Axes, *, errors: bool = False, **kwargs):
"""Scatter plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
value_for... | python | def scatter(h1: Histogram1D, ax: Axes, *, errors: bool = False, **kwargs):
"""Scatter plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
value_for... | [
"def",
"scatter",
"(",
"h1",
":",
"Histogram1D",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"errors",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"show_stats",
"=",
"kwargs",
".",
"pop",
"(",
"\"show_stats\"",
",",
"False",
")",
"show... | Scatter plot of 1D histogram. | [
"Scatter",
"plot",
"of",
"1D",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L149-L180 |
16,397 | janpipek/physt | physt/plotting/matplotlib.py | line | def line(h1: Union[Histogram1D, "HistogramCollection"], ax: Axes, *, errors: bool = False, **kwargs):
"""Line plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulat... | python | def line(h1: Union[Histogram1D, "HistogramCollection"], ax: Axes, *, errors: bool = False, **kwargs):
"""Line plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulat... | [
"def",
"line",
"(",
"h1",
":",
"Union",
"[",
"Histogram1D",
",",
"\"HistogramCollection\"",
"]",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"errors",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"show_stats",
"=",
"kwargs",
".",
"pop",
... | Line plot of 1D histogram. | [
"Line",
"plot",
"of",
"1D",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L184-L211 |
16,398 | janpipek/physt | physt/plotting/matplotlib.py | fill | def fill(h1: Histogram1D, ax: Axes, **kwargs):
"""Fill plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
# show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
kwargs["label"] = kwargs.get("label", ... | python | def fill(h1: Histogram1D, ax: Axes, **kwargs):
"""Fill plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
# show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
kwargs["label"] = kwargs.get("label", ... | [
"def",
"fill",
"(",
"h1",
":",
"Histogram1D",
",",
"ax",
":",
"Axes",
",",
"*",
"*",
"kwargs",
")",
":",
"show_stats",
"=",
"kwargs",
".",
"pop",
"(",
"\"show_stats\"",
",",
"False",
")",
"# show_values = kwargs.pop(\"show_values\", False)",
"density",
"=",
... | Fill plot of 1D histogram. | [
"Fill",
"plot",
"of",
"1D",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L215-L234 |
16,399 | janpipek/physt | physt/plotting/matplotlib.py | step | def step(h1: Histogram1D, ax: Axes, **kwargs):
"""Step line-plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
value_format = kwargs.pop("value_fo... | python | def step(h1: Histogram1D, ax: Axes, **kwargs):
"""Step line-plot of 1D histogram."""
show_stats = kwargs.pop("show_stats", False)
show_values = kwargs.pop("show_values", False)
density = kwargs.pop("density", False)
cumulative = kwargs.pop("cumulative", False)
value_format = kwargs.pop("value_fo... | [
"def",
"step",
"(",
"h1",
":",
"Histogram1D",
",",
"ax",
":",
"Axes",
",",
"*",
"*",
"kwargs",
")",
":",
"show_stats",
"=",
"kwargs",
".",
"pop",
"(",
"\"show_stats\"",
",",
"False",
")",
"show_values",
"=",
"kwargs",
".",
"pop",
"(",
"\"show_values\""... | Step line-plot of 1D histogram. | [
"Step",
"line",
"-",
"plot",
"of",
"1D",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L238-L258 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.