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
partition
stringclasses
1 value
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", ":", "kwargs"...
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
train
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", ",", "o...
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
train
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
train
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
train
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", "(", "ui"...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", ":", "if", "frames", "is", "not", "None", ":", "self", ".", "traj_controls", ".", "set_ticks", "(", "frames", ")", "self", ".", "_update_function", "=", "func" ]
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
train
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
train
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", "]", "w", ",", "W...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", "=", "{", "}", "for", "k", "in", "selection_state", ...
Unhide the selected objects
[ "Unhide", "the", "selected", "objects" ]
c8730966316d101e24f39ac3b96b51282aba0abe
https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L137-L150
train
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
train
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", ")", ":", "dsq", "=", "np", ".", "linalg", ".", "norm", "(", "self", ".", "position", "-", "self", ".", "pivot", ")", "minsq", "=", "1.0", "**", "2", "maxsq", "=", "7.0", "**", "2", "scalefac", "=", ...
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
train
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", "]", ")", "matrix", "=", "self", ".", "projection", ".", "dot", "(",...
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
train
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
train
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
train
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
train
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", ")", ":", "if", "isinstance", "(", "color", ",", "str", ")", ":", "try", ":", "col", "=", "get", "(", "color", ")", "except", "ValueError", ":", "pass", "try", ":", "col", "=", "html_to_rgb", "(", "color", ")", "...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", ":", "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
train
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
train
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_values", ...
Bar plot of 1D histograms.
[ "Bar", "plot", "of", "1D", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L109-L145
train
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_value...
Scatter plot of 1D histogram.
[ "Scatter", "plot", "of", "1D", "histogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L149-L180
train
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
train
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", ")", "density", "=", "kwargs", ".", "pop", "(", "\"density\"", ",", "Fa...
Fill plot of 1D histogram.
[ "Fill", "plot", "of", "1D", "histogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L215-L234
train
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
train
janpipek/physt
physt/plotting/matplotlib.py
bar3d
def bar3d(h2: Histogram2D, ax: Axes3D, **kwargs): """Plot of 2D histograms as 3D boxes.""" density = kwargs.pop("density", False) data = get_data(h2, cumulative=False, flatten=True, density=density) if "cmap" in kwargs: cmap = _get_cmap(kwargs) _, cmap_data = _get_cmap_data(data, kwargs...
python
def bar3d(h2: Histogram2D, ax: Axes3D, **kwargs): """Plot of 2D histograms as 3D boxes.""" density = kwargs.pop("density", False) data = get_data(h2, cumulative=False, flatten=True, density=density) if "cmap" in kwargs: cmap = _get_cmap(kwargs) _, cmap_data = _get_cmap_data(data, kwargs...
[ "def", "bar3d", "(", "h2", ":", "Histogram2D", ",", "ax", ":", "Axes3D", ",", "**", "kwargs", ")", ":", "density", "=", "kwargs", ".", "pop", "(", "\"density\"", ",", "False", ")", "data", "=", "get_data", "(", "h2", ",", "cumulative", "=", "False", ...
Plot of 2D histograms as 3D boxes.
[ "Plot", "of", "2D", "histograms", "as", "3D", "boxes", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L393-L411
train
janpipek/physt
physt/plotting/matplotlib.py
image
def image(h2: Histogram2D, ax: Axes, *, show_colorbar: bool = True, interpolation: str = "nearest", **kwargs): """Plot of 2D histograms based on pixmaps. Similar to map, but it: - has fewer options - is much more effective (enables thousands) - does not support irregular bins Parameters --...
python
def image(h2: Histogram2D, ax: Axes, *, show_colorbar: bool = True, interpolation: str = "nearest", **kwargs): """Plot of 2D histograms based on pixmaps. Similar to map, but it: - has fewer options - is much more effective (enables thousands) - does not support irregular bins Parameters --...
[ "def", "image", "(", "h2", ":", "Histogram2D", ",", "ax", ":", "Axes", ",", "*", ",", "show_colorbar", ":", "bool", "=", "True", ",", "interpolation", ":", "str", "=", "\"nearest\"", ",", "**", "kwargs", ")", ":", "cmap", "=", "_get_cmap", "(", "kwar...
Plot of 2D histograms based on pixmaps. Similar to map, but it: - has fewer options - is much more effective (enables thousands) - does not support irregular bins Parameters ---------- interpolation: interpolation parameter passed to imshow, default: "nearest" (creates rectangles)
[ "Plot", "of", "2D", "histograms", "based", "on", "pixmaps", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L415-L450
train
janpipek/physt
physt/plotting/matplotlib.py
polar_map
def polar_map(hist: Histogram2D, ax: Axes, *, show_zero: bool = True, show_colorbar: bool = True, **kwargs): """Polar map of polar histograms. Similar to map, but supports less parameters.""" data = get_data(hist, cumulative=False, flatten=True, density=kwargs.pop("density", False)) ...
python
def polar_map(hist: Histogram2D, ax: Axes, *, show_zero: bool = True, show_colorbar: bool = True, **kwargs): """Polar map of polar histograms. Similar to map, but supports less parameters.""" data = get_data(hist, cumulative=False, flatten=True, density=kwargs.pop("density", False)) ...
[ "def", "polar_map", "(", "hist", ":", "Histogram2D", ",", "ax", ":", "Axes", ",", "*", ",", "show_zero", ":", "bool", "=", "True", ",", "show_colorbar", ":", "bool", "=", "True", ",", "**", "kwargs", ")", ":", "data", "=", "get_data", "(", "hist", ...
Polar map of polar histograms. Similar to map, but supports less parameters.
[ "Polar", "map", "of", "polar", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L454-L487
train
janpipek/physt
physt/plotting/matplotlib.py
globe_map
def globe_map(hist: Union[Histogram2D, DirectionalHistogram], ax: Axes3D, *, show_zero: bool = True, **kwargs): """Heat map plotted on the surface of a sphere.""" data = get_data(hist, cumulative=False, flatten=False, density=kwargs.pop("density", False)) cmap = _get_cmap(kwargs) no...
python
def globe_map(hist: Union[Histogram2D, DirectionalHistogram], ax: Axes3D, *, show_zero: bool = True, **kwargs): """Heat map plotted on the surface of a sphere.""" data = get_data(hist, cumulative=False, flatten=False, density=kwargs.pop("density", False)) cmap = _get_cmap(kwargs) no...
[ "def", "globe_map", "(", "hist", ":", "Union", "[", "Histogram2D", ",", "DirectionalHistogram", "]", ",", "ax", ":", "Axes3D", ",", "*", ",", "show_zero", ":", "bool", "=", "True", ",", "**", "kwargs", ")", ":", "data", "=", "get_data", "(", "hist", ...
Heat map plotted on the surface of a sphere.
[ "Heat", "map", "plotted", "on", "the", "surface", "of", "a", "sphere", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L491-L529
train
janpipek/physt
physt/plotting/matplotlib.py
pair_bars
def pair_bars(first: Histogram1D, second: Histogram2D, *, orientation: str = "vertical", kind: str = "bar", **kwargs): """Draw two different histograms mirrored in one figure. Parameters ---------- first: Histogram1D second: Histogram1D color1: color2: orientation: str Returns ...
python
def pair_bars(first: Histogram1D, second: Histogram2D, *, orientation: str = "vertical", kind: str = "bar", **kwargs): """Draw two different histograms mirrored in one figure. Parameters ---------- first: Histogram1D second: Histogram1D color1: color2: orientation: str Returns ...
[ "def", "pair_bars", "(", "first", ":", "Histogram1D", ",", "second", ":", "Histogram2D", ",", "*", ",", "orientation", ":", "str", "=", "\"vertical\"", ",", "kind", ":", "str", "=", "\"bar\"", ",", "**", "kwargs", ")", ":", "_", ",", "ax", "=", "_get...
Draw two different histograms mirrored in one figure. Parameters ---------- first: Histogram1D second: Histogram1D color1: color2: orientation: str Returns ------- plt.Axes
[ "Draw", "two", "different", "histograms", "mirrored", "in", "one", "figure", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L648-L681
train
janpipek/physt
physt/plotting/matplotlib.py
_get_axes
def _get_axes(kwargs: Dict[str, Any], *, use_3d: bool = False, use_polar: bool = False) -> Tuple[Figure, Union[Axes, Axes3D]]: """Prepare the axis to draw into. Parameters ---------- use_3d: If True, an axis with 3D projection is created. use_polar: If True, the plot will have polar coordinates. ...
python
def _get_axes(kwargs: Dict[str, Any], *, use_3d: bool = False, use_polar: bool = False) -> Tuple[Figure, Union[Axes, Axes3D]]: """Prepare the axis to draw into. Parameters ---------- use_3d: If True, an axis with 3D projection is created. use_polar: If True, the plot will have polar coordinates. ...
[ "def", "_get_axes", "(", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ",", "*", ",", "use_3d", ":", "bool", "=", "False", ",", "use_polar", ":", "bool", "=", "False", ")", "->", "Tuple", "[", "Figure", ",", "Union", "[", "Axes", ",", "Axes...
Prepare the axis to draw into. Parameters ---------- use_3d: If True, an axis with 3D projection is created. use_polar: If True, the plot will have polar coordinates. Kwargs ------ ax: Optional[plt.Axes] An already existing axis to be used. figsize: Optional[tuple] Size...
[ "Prepare", "the", "axis", "to", "draw", "into", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L684-L716
train
janpipek/physt
physt/plotting/matplotlib.py
_get_cmap
def _get_cmap(kwargs: dict) -> colors.Colormap: """Get the colour map for plots that support it. Parameters ---------- cmap : str or colors.Colormap or list of colors A map or an instance of cmap. This can also be a seaborn palette (if seaborn is installed). """ from matplotlib....
python
def _get_cmap(kwargs: dict) -> colors.Colormap: """Get the colour map for plots that support it. Parameters ---------- cmap : str or colors.Colormap or list of colors A map or an instance of cmap. This can also be a seaborn palette (if seaborn is installed). """ from matplotlib....
[ "def", "_get_cmap", "(", "kwargs", ":", "dict", ")", "->", "colors", ".", "Colormap", ":", "from", "matplotlib", ".", "colors", "import", "ListedColormap", "cmap", "=", "kwargs", ".", "pop", "(", "\"cmap\"", ",", "default_cmap", ")", "if", "isinstance", "(...
Get the colour map for plots that support it. Parameters ---------- cmap : str or colors.Colormap or list of colors A map or an instance of cmap. This can also be a seaborn palette (if seaborn is installed).
[ "Get", "the", "colour", "map", "for", "plots", "that", "support", "it", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L719-L744
train
janpipek/physt
physt/plotting/matplotlib.py
_get_cmap_data
def _get_cmap_data(data, kwargs) -> Tuple[colors.Normalize, np.ndarray]: """Get normalized values to be used with a colormap. Parameters ---------- data : array_like cmap_min : Optional[float] or "min" By default 0. If "min", minimum value of the data. cmap_max : Optional[float] ...
python
def _get_cmap_data(data, kwargs) -> Tuple[colors.Normalize, np.ndarray]: """Get normalized values to be used with a colormap. Parameters ---------- data : array_like cmap_min : Optional[float] or "min" By default 0. If "min", minimum value of the data. cmap_max : Optional[float] ...
[ "def", "_get_cmap_data", "(", "data", ",", "kwargs", ")", "->", "Tuple", "[", "colors", ".", "Normalize", ",", "np", ".", "ndarray", "]", ":", "norm", "=", "kwargs", ".", "pop", "(", "\"cmap_normalize\"", ",", "None", ")", "if", "norm", "==", "\"log\""...
Get normalized values to be used with a colormap. Parameters ---------- data : array_like cmap_min : Optional[float] or "min" By default 0. If "min", minimum value of the data. cmap_max : Optional[float] By default, maximum value of the data cmap_normalize : str or colors.Normal...
[ "Get", "normalized", "values", "to", "be", "used", "with", "a", "colormap", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L747-L775
train
janpipek/physt
physt/plotting/matplotlib.py
_get_alpha_data
def _get_alpha_data(data: np.ndarray, kwargs) -> Union[float, np.ndarray]: """Get alpha values for all data points. Parameters ---------- alpha: Callable or float This can be a fixed value or a function of the data. """ alpha = kwargs.pop("alpha", 1) if hasattr(alpha, "__call__"): ...
python
def _get_alpha_data(data: np.ndarray, kwargs) -> Union[float, np.ndarray]: """Get alpha values for all data points. Parameters ---------- alpha: Callable or float This can be a fixed value or a function of the data. """ alpha = kwargs.pop("alpha", 1) if hasattr(alpha, "__call__"): ...
[ "def", "_get_alpha_data", "(", "data", ":", "np", ".", "ndarray", ",", "kwargs", ")", "->", "Union", "[", "float", ",", "np", ".", "ndarray", "]", ":", "alpha", "=", "kwargs", ".", "pop", "(", "\"alpha\"", ",", "1", ")", "if", "hasattr", "(", "alph...
Get alpha values for all data points. Parameters ---------- alpha: Callable or float This can be a fixed value or a function of the data.
[ "Get", "alpha", "values", "for", "all", "data", "points", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L778-L789
train
janpipek/physt
physt/plotting/matplotlib.py
_add_values
def _add_values(ax: Axes, h1: Histogram1D, data, *, value_format=lambda x: x, **kwargs): """Show values next to each bin in a 1D plot. Parameters ---------- ax : plt.Axes h1 : physt.histogram1d.Histogram1D data : array_like The values to be displayed kwargs : dict Parameters...
python
def _add_values(ax: Axes, h1: Histogram1D, data, *, value_format=lambda x: x, **kwargs): """Show values next to each bin in a 1D plot. Parameters ---------- ax : plt.Axes h1 : physt.histogram1d.Histogram1D data : array_like The values to be displayed kwargs : dict Parameters...
[ "def", "_add_values", "(", "ax", ":", "Axes", ",", "h1", ":", "Histogram1D", ",", "data", ",", "*", ",", "value_format", "=", "lambda", "x", ":", "x", ",", "**", "kwargs", ")", ":", "from", ".", "common", "import", "get_value_format", "value_format", "...
Show values next to each bin in a 1D plot. Parameters ---------- ax : plt.Axes h1 : physt.histogram1d.Histogram1D data : array_like The values to be displayed kwargs : dict Parameters to be passed to matplotlib to override standard text params.
[ "Show", "values", "next", "to", "each", "bin", "in", "a", "1D", "plot", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L810-L828
train
janpipek/physt
physt/plotting/matplotlib.py
_add_colorbar
def _add_colorbar(ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize): """Show a colorbar right of the plot.""" fig = ax.get_figure() mappable = cm.ScalarMappable(cmap=cmap, norm=norm) mappable.set_array(cmap_data) # TODO: Or what??? fig.colorbar(mappable, ax=ax)
python
def _add_colorbar(ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize): """Show a colorbar right of the plot.""" fig = ax.get_figure() mappable = cm.ScalarMappable(cmap=cmap, norm=norm) mappable.set_array(cmap_data) # TODO: Or what??? fig.colorbar(mappable, ax=ax)
[ "def", "_add_colorbar", "(", "ax", ":", "Axes", ",", "cmap", ":", "colors", ".", "Colormap", ",", "cmap_data", ":", "np", ".", "ndarray", ",", "norm", ":", "colors", ".", "Normalize", ")", ":", "fig", "=", "ax", ".", "get_figure", "(", ")", "mappable...
Show a colorbar right of the plot.
[ "Show", "a", "colorbar", "right", "of", "the", "plot", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L831-L836
train
janpipek/physt
physt/plotting/matplotlib.py
_add_stats_box
def _add_stats_box(h1: Histogram1D, ax: Axes, stats: Union[str, bool] = "all"): """Insert a small legend-like box with statistical information. Parameters ---------- stats : "all" | "total" | True What info to display Note ---- Very basic implementation. """ # place a text...
python
def _add_stats_box(h1: Histogram1D, ax: Axes, stats: Union[str, bool] = "all"): """Insert a small legend-like box with statistical information. Parameters ---------- stats : "all" | "total" | True What info to display Note ---- Very basic implementation. """ # place a text...
[ "def", "_add_stats_box", "(", "h1", ":", "Histogram1D", ",", "ax", ":", "Axes", ",", "stats", ":", "Union", "[", "str", ",", "bool", "]", "=", "\"all\"", ")", ":", "if", "stats", "in", "[", "\"all\"", ",", "True", "]", ":", "text", "=", "\"Total: {...
Insert a small legend-like box with statistical information. Parameters ---------- stats : "all" | "total" | True What info to display Note ---- Very basic implementation.
[ "Insert", "a", "small", "legend", "-", "like", "box", "with", "statistical", "information", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L839-L862
train
janpipek/physt
physt/examples/__init__.py
normal_h1
def normal_h1(size: int = 10000, mean: float = 0, sigma: float = 1) -> Histogram1D: """A simple 1D histogram with normal distribution. Parameters ---------- size : Number of points mean : Mean of the distribution sigma : Sigma of the distribution """ data = np.random.normal(mean, sigma,...
python
def normal_h1(size: int = 10000, mean: float = 0, sigma: float = 1) -> Histogram1D: """A simple 1D histogram with normal distribution. Parameters ---------- size : Number of points mean : Mean of the distribution sigma : Sigma of the distribution """ data = np.random.normal(mean, sigma,...
[ "def", "normal_h1", "(", "size", ":", "int", "=", "10000", ",", "mean", ":", "float", "=", "0", ",", "sigma", ":", "float", "=", "1", ")", "->", "Histogram1D", ":", "data", "=", "np", ".", "random", ".", "normal", "(", "mean", ",", "sigma", ",", ...
A simple 1D histogram with normal distribution. Parameters ---------- size : Number of points mean : Mean of the distribution sigma : Sigma of the distribution
[ "A", "simple", "1D", "histogram", "with", "normal", "distribution", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L12-L22
train
janpipek/physt
physt/examples/__init__.py
normal_h2
def normal_h2(size: int = 10000) -> Histogram2D: """A simple 2D histogram with normal distribution. Parameters ---------- size : Number of points """ data1 = np.random.normal(0, 1, (size,)) data2 = np.random.normal(0, 1, (size,)) return h2(data1, data2, name="normal", axis_names=tuple("...
python
def normal_h2(size: int = 10000) -> Histogram2D: """A simple 2D histogram with normal distribution. Parameters ---------- size : Number of points """ data1 = np.random.normal(0, 1, (size,)) data2 = np.random.normal(0, 1, (size,)) return h2(data1, data2, name="normal", axis_names=tuple("...
[ "def", "normal_h2", "(", "size", ":", "int", "=", "10000", ")", "->", "Histogram2D", ":", "data1", "=", "np", ".", "random", ".", "normal", "(", "0", ",", "1", ",", "(", "size", ",", ")", ")", "data2", "=", "np", ".", "random", ".", "normal", "...
A simple 2D histogram with normal distribution. Parameters ---------- size : Number of points
[ "A", "simple", "2D", "histogram", "with", "normal", "distribution", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L25-L34
train
janpipek/physt
physt/examples/__init__.py
normal_h3
def normal_h3(size: int = 10000) -> HistogramND: """A simple 3D histogram with normal distribution. Parameters ---------- size : Number of points """ data1 = np.random.normal(0, 1, (size,)) data2 = np.random.normal(0, 1, (size,)) data3 = np.random.normal(0, 1, (size,)) return h3([da...
python
def normal_h3(size: int = 10000) -> HistogramND: """A simple 3D histogram with normal distribution. Parameters ---------- size : Number of points """ data1 = np.random.normal(0, 1, (size,)) data2 = np.random.normal(0, 1, (size,)) data3 = np.random.normal(0, 1, (size,)) return h3([da...
[ "def", "normal_h3", "(", "size", ":", "int", "=", "10000", ")", "->", "HistogramND", ":", "data1", "=", "np", ".", "random", ".", "normal", "(", "0", ",", "1", ",", "(", "size", ",", ")", ")", "data2", "=", "np", ".", "random", ".", "normal", "...
A simple 3D histogram with normal distribution. Parameters ---------- size : Number of points
[ "A", "simple", "3D", "histogram", "with", "normal", "distribution", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L37-L47
train
janpipek/physt
physt/examples/__init__.py
fist
def fist() -> Histogram1D: """A simple histogram in the shape of a fist.""" import numpy as np from ..histogram1d import Histogram1D widths = [0, 1.2, 0.2, 1, 0.1, 1, 0.1, 0.9, 0.1, 0.8] edges = np.cumsum(widths) heights = np.asarray([4, 1, 7.5, 6, 7.6, 6, 7.5, 6, 7.2]) + 5 return Histogram1...
python
def fist() -> Histogram1D: """A simple histogram in the shape of a fist.""" import numpy as np from ..histogram1d import Histogram1D widths = [0, 1.2, 0.2, 1, 0.1, 1, 0.1, 0.9, 0.1, 0.8] edges = np.cumsum(widths) heights = np.asarray([4, 1, 7.5, 6, 7.6, 6, 7.5, 6, 7.2]) + 5 return Histogram1...
[ "def", "fist", "(", ")", "->", "Histogram1D", ":", "import", "numpy", "as", "np", "from", ".", ".", "histogram1d", "import", "Histogram1D", "widths", "=", "[", "0", ",", "1.2", ",", "0.2", ",", "1", ",", "0.1", ",", "1", ",", "0.1", ",", "0.9", "...
A simple histogram in the shape of a fist.
[ "A", "simple", "histogram", "in", "the", "shape", "of", "a", "fist", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L50-L57
train
janpipek/physt
physt/io/__init__.py
require_compatible_version
def require_compatible_version(compatible_version, word="File"): """Check that compatible version of input data is not too new.""" if isinstance(compatible_version, str): compatible_version = parse_version(compatible_version) elif not isinstance(compatible_version, Version): raise ValueError...
python
def require_compatible_version(compatible_version, word="File"): """Check that compatible version of input data is not too new.""" if isinstance(compatible_version, str): compatible_version = parse_version(compatible_version) elif not isinstance(compatible_version, Version): raise ValueError...
[ "def", "require_compatible_version", "(", "compatible_version", ",", "word", "=", "\"File\"", ")", ":", "if", "isinstance", "(", "compatible_version", ",", "str", ")", ":", "compatible_version", "=", "parse_version", "(", "compatible_version", ")", "elif", "not", ...
Check that compatible version of input data is not too new.
[ "Check", "that", "compatible", "version", "of", "input", "data", "is", "not", "too", "new", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/__init__.py#L52-L63
train
janpipek/physt
physt/io/json.py
save_json
def save_json(histogram: Union[HistogramBase, HistogramCollection], path: Optional[str] = None, **kwargs) -> str: """Save histogram to JSON format. Parameters ---------- histogram : Any histogram path : If set, also writes to the path. Returns ------- json : The JSON representation of ...
python
def save_json(histogram: Union[HistogramBase, HistogramCollection], path: Optional[str] = None, **kwargs) -> str: """Save histogram to JSON format. Parameters ---------- histogram : Any histogram path : If set, also writes to the path. Returns ------- json : The JSON representation of ...
[ "def", "save_json", "(", "histogram", ":", "Union", "[", "HistogramBase", ",", "HistogramCollection", "]", ",", "path", ":", "Optional", "[", "str", "]", "=", "None", ",", "**", "kwargs", ")", "->", "str", ":", "data", "=", "histogram", ".", "to_dict", ...
Save histogram to JSON format. Parameters ---------- histogram : Any histogram path : If set, also writes to the path. Returns ------- json : The JSON representation of the histogram
[ "Save", "histogram", "to", "JSON", "format", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L13-L40
train
janpipek/physt
physt/io/json.py
load_json
def load_json(path: str, encoding: str = "utf-8") -> HistogramBase: """Load histogram from a JSON file.""" with open(path, "r", encoding=encoding) as f: text = f.read() return parse_json(text)
python
def load_json(path: str, encoding: str = "utf-8") -> HistogramBase: """Load histogram from a JSON file.""" with open(path, "r", encoding=encoding) as f: text = f.read() return parse_json(text)
[ "def", "load_json", "(", "path", ":", "str", ",", "encoding", ":", "str", "=", "\"utf-8\"", ")", "->", "HistogramBase", ":", "with", "open", "(", "path", ",", "\"r\"", ",", "encoding", "=", "encoding", ")", "as", "f", ":", "text", "=", "f", ".", "r...
Load histogram from a JSON file.
[ "Load", "histogram", "from", "a", "JSON", "file", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L43-L47
train
janpipek/physt
physt/io/json.py
parse_json
def parse_json(text: str, encoding: str = "utf-8") -> HistogramBase: """Create histogram from a JSON string.""" data = json.loads(text, encoding=encoding) return create_from_dict(data, format_name="JSON")
python
def parse_json(text: str, encoding: str = "utf-8") -> HistogramBase: """Create histogram from a JSON string.""" data = json.loads(text, encoding=encoding) return create_from_dict(data, format_name="JSON")
[ "def", "parse_json", "(", "text", ":", "str", ",", "encoding", ":", "str", "=", "\"utf-8\"", ")", "->", "HistogramBase", ":", "data", "=", "json", ".", "loads", "(", "text", ",", "encoding", "=", "encoding", ")", "return", "create_from_dict", "(", "data"...
Create histogram from a JSON string.
[ "Create", "histogram", "from", "a", "JSON", "string", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L50-L53
train
janpipek/physt
physt/__init__.py
histogram
def histogram(data, bins=None, *args, **kwargs): """Facade function to create 1D histograms. This proceeds in three steps: 1) Based on magical parameter bins, construct bins for the histogram 2) Calculate frequencies for the bins 3) Construct the histogram object itself *Guiding principle:* pa...
python
def histogram(data, bins=None, *args, **kwargs): """Facade function to create 1D histograms. This proceeds in three steps: 1) Based on magical parameter bins, construct bins for the histogram 2) Calculate frequencies for the bins 3) Construct the histogram object itself *Guiding principle:* pa...
[ "def", "histogram", "(", "data", ",", "bins", "=", "None", ",", "*", "args", ",", "**", "kwargs", ")", ":", "import", "numpy", "as", "np", "from", ".", "histogram1d", "import", "Histogram1D", ",", "calculate_frequencies", "from", ".", "binnings", "import",...
Facade function to create 1D histograms. This proceeds in three steps: 1) Based on magical parameter bins, construct bins for the histogram 2) Calculate frequencies for the bins 3) Construct the histogram object itself *Guiding principle:* parameters understood by numpy.histogram should be und...
[ "Facade", "function", "to", "create", "1D", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L16-L127
train
janpipek/physt
physt/__init__.py
histogram2d
def histogram2d(data1, data2, bins=10, *args, **kwargs): """Facade function to create 2D histograms. For implementation and parameters, see histogramdd. This function is also aliased as "h2". Returns ------- physt.histogram_nd.Histogram2D See Also -------- numpy.histogram2d h...
python
def histogram2d(data1, data2, bins=10, *args, **kwargs): """Facade function to create 2D histograms. For implementation and parameters, see histogramdd. This function is also aliased as "h2". Returns ------- physt.histogram_nd.Histogram2D See Also -------- numpy.histogram2d h...
[ "def", "histogram2d", "(", "data1", ",", "data2", ",", "bins", "=", "10", ",", "*", "args", ",", "**", "kwargs", ")", ":", "import", "numpy", "as", "np", "if", "\"axis_names\"", "not", "in", "kwargs", ":", "if", "hasattr", "(", "data1", ",", "\"name\...
Facade function to create 2D histograms. For implementation and parameters, see histogramdd. This function is also aliased as "h2". Returns ------- physt.histogram_nd.Histogram2D See Also -------- numpy.histogram2d histogramdd
[ "Facade", "function", "to", "create", "2D", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L130-L159
train
janpipek/physt
physt/__init__.py
histogramdd
def histogramdd(data, bins=10, *args, **kwargs): """Facade function to create n-dimensional histograms. 3D variant of this function is also aliased as "h3". Parameters ---------- data : array_like Container of all the values bins: Any weights: array_like, optional (as numpy...
python
def histogramdd(data, bins=10, *args, **kwargs): """Facade function to create n-dimensional histograms. 3D variant of this function is also aliased as "h3". Parameters ---------- data : array_like Container of all the values bins: Any weights: array_like, optional (as numpy...
[ "def", "histogramdd", "(", "data", ",", "bins", "=", "10", ",", "*", "args", ",", "**", "kwargs", ")", ":", "import", "numpy", "as", "np", "from", ".", "import", "histogram_nd", "from", ".", "binnings", "import", "calculate_bins_nd", "adaptive", "=", "kw...
Facade function to create n-dimensional histograms. 3D variant of this function is also aliased as "h3". Parameters ---------- data : array_like Container of all the values bins: Any weights: array_like, optional (as numpy.histogram) dropna: bool whether to clear da...
[ "Facade", "function", "to", "create", "n", "-", "dimensional", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L162-L254
train
janpipek/physt
physt/__init__.py
h3
def h3(data, *args, **kwargs): """Facade function to create 3D histograms. Parameters ---------- data : array_like or list[array_like] or tuple[array_like] Can be a single array (with three columns) or three different arrays (for each component) Returns ------- physt.histog...
python
def h3(data, *args, **kwargs): """Facade function to create 3D histograms. Parameters ---------- data : array_like or list[array_like] or tuple[array_like] Can be a single array (with three columns) or three different arrays (for each component) Returns ------- physt.histog...
[ "def", "h3", "(", "data", ",", "*", "args", ",", "**", "kwargs", ")", ":", "import", "numpy", "as", "np", "if", "data", "is", "not", "None", "and", "isinstance", "(", "data", ",", "(", "list", ",", "tuple", ")", ")", "and", "not", "np", ".", "i...
Facade function to create 3D histograms. Parameters ---------- data : array_like or list[array_like] or tuple[array_like] Can be a single array (with three columns) or three different arrays (for each component) Returns ------- physt.histogram_nd.HistogramND
[ "Facade", "function", "to", "create", "3D", "histograms", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L263-L284
train
janpipek/physt
physt/__init__.py
collection
def collection(data, bins=10, *args, **kwargs): """Create histogram collection with shared binnning.""" from physt.histogram_collection import HistogramCollection if hasattr(data, "columns"): data = {column: data[column] for column in data.columns} return HistogramCollection.multi_h1(data, bins,...
python
def collection(data, bins=10, *args, **kwargs): """Create histogram collection with shared binnning.""" from physt.histogram_collection import HistogramCollection if hasattr(data, "columns"): data = {column: data[column] for column in data.columns} return HistogramCollection.multi_h1(data, bins,...
[ "def", "collection", "(", "data", ",", "bins", "=", "10", ",", "*", "args", ",", "**", "kwargs", ")", ":", "from", "physt", ".", "histogram_collection", "import", "HistogramCollection", "if", "hasattr", "(", "data", ",", "\"columns\"", ")", ":", "data", ...
Create histogram collection with shared binnning.
[ "Create", "histogram", "collection", "with", "shared", "binnning", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L287-L292
train
janpipek/physt
physt/io/root.py
write_root
def write_root(histogram: HistogramBase, hfile: uproot.write.TFile.TFileUpdate, name: str): """Write histogram to an open ROOT file. Parameters ---------- histogram : Any histogram hfile : Updateable uproot file object name : The name of the histogram inside the file """ hfile[name] = h...
python
def write_root(histogram: HistogramBase, hfile: uproot.write.TFile.TFileUpdate, name: str): """Write histogram to an open ROOT file. Parameters ---------- histogram : Any histogram hfile : Updateable uproot file object name : The name of the histogram inside the file """ hfile[name] = h...
[ "def", "write_root", "(", "histogram", ":", "HistogramBase", ",", "hfile", ":", "uproot", ".", "write", ".", "TFile", ".", "TFileUpdate", ",", "name", ":", "str", ")", ":", "hfile", "[", "name", "]", "=", "histogram" ]
Write histogram to an open ROOT file. Parameters ---------- histogram : Any histogram hfile : Updateable uproot file object name : The name of the histogram inside the file
[ "Write", "histogram", "to", "an", "open", "ROOT", "file", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/root.py#L16-L25
train
janpipek/physt
physt/io/protobuf/__init__.py
write
def write(histogram): """Convert a histogram to a protobuf message. Note: Currently, all binnings are converted to static form. When you load the histogram again, you will lose any related behaviour. Note: A histogram collection is also planned. Parameters ---------- histogram...
python
def write(histogram): """Convert a histogram to a protobuf message. Note: Currently, all binnings are converted to static form. When you load the histogram again, you will lose any related behaviour. Note: A histogram collection is also planned. Parameters ---------- histogram...
[ "def", "write", "(", "histogram", ")", ":", "histogram_dict", "=", "histogram", ".", "to_dict", "(", ")", "message", "=", "Histogram", "(", ")", "for", "field", "in", "SIMPLE_CONVERSION_FIELDS", ":", "setattr", "(", "message", ",", "field", ",", "histogram_d...
Convert a histogram to a protobuf message. Note: Currently, all binnings are converted to static form. When you load the histogram again, you will lose any related behaviour. Note: A histogram collection is also planned. Parameters ---------- histogram : HistogramBase | list | dic...
[ "Convert", "a", "histogram", "to", "a", "protobuf", "message", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/protobuf/__init__.py#L24-L76
train
janpipek/physt
physt/io/protobuf/__init__.py
read
def read(message): """Convert a parsed protobuf message into a histogram.""" require_compatible_version(message.physt_compatible) # Currently the only implementation a_dict = _dict_from_v0342(message) return create_from_dict(a_dict, "Message")
python
def read(message): """Convert a parsed protobuf message into a histogram.""" require_compatible_version(message.physt_compatible) # Currently the only implementation a_dict = _dict_from_v0342(message) return create_from_dict(a_dict, "Message")
[ "def", "read", "(", "message", ")", ":", "require_compatible_version", "(", "message", ".", "physt_compatible", ")", "a_dict", "=", "_dict_from_v0342", "(", "message", ")", "return", "create_from_dict", "(", "a_dict", ",", "\"Message\"", ")" ]
Convert a parsed protobuf message into a histogram.
[ "Convert", "a", "parsed", "protobuf", "message", "into", "a", "histogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/protobuf/__init__.py#L79-L85
train
janpipek/physt
physt/bin_utils.py
make_bin_array
def make_bin_array(bins) -> np.ndarray: """Turn bin data into array understood by HistogramXX classes. Parameters ---------- bins: array_like Array of edges or array of edge tuples Examples -------- >>> make_bin_array([0, 1, 2]) array([[0, 1], [1, 2]]) >>> make_b...
python
def make_bin_array(bins) -> np.ndarray: """Turn bin data into array understood by HistogramXX classes. Parameters ---------- bins: array_like Array of edges or array of edge tuples Examples -------- >>> make_bin_array([0, 1, 2]) array([[0, 1], [1, 2]]) >>> make_b...
[ "def", "make_bin_array", "(", "bins", ")", "->", "np", ".", "ndarray", ":", "bins", "=", "np", ".", "asarray", "(", "bins", ")", "if", "bins", ".", "ndim", "==", "1", ":", "return", "np", ".", "hstack", "(", "(", "bins", "[", ":", "-", "1", ","...
Turn bin data into array understood by HistogramXX classes. Parameters ---------- bins: array_like Array of edges or array of edge tuples Examples -------- >>> make_bin_array([0, 1, 2]) array([[0, 1], [1, 2]]) >>> make_bin_array([[0, 1], [2, 3]]) array([[0, 1], ...
[ "Turn", "bin", "data", "into", "array", "understood", "by", "HistogramXX", "classes", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L7-L36
train
janpipek/physt
physt/bin_utils.py
to_numpy_bins
def to_numpy_bins(bins) -> np.ndarray: """Convert physt bin format to numpy edges. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: all edges """ bins = np.asarray(bins) if bins.ndim == 1: # Already in the proper for...
python
def to_numpy_bins(bins) -> np.ndarray: """Convert physt bin format to numpy edges. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: all edges """ bins = np.asarray(bins) if bins.ndim == 1: # Already in the proper for...
[ "def", "to_numpy_bins", "(", "bins", ")", "->", "np", ".", "ndarray", ":", "bins", "=", "np", ".", "asarray", "(", "bins", ")", "if", "bins", ".", "ndim", "==", "1", ":", "return", "bins", "if", "not", "is_consecutive", "(", "bins", ")", ":", "rais...
Convert physt bin format to numpy edges. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: all edges
[ "Convert", "physt", "bin", "format", "to", "numpy", "edges", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L39-L56
train
janpipek/physt
physt/bin_utils.py
to_numpy_bins_with_mask
def to_numpy_bins_with_mask(bins) -> Tuple[np.ndarray, np.ndarray]: """Numpy binning edges including gaps. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: np.ndarray all edges mask: np.ndarray List of indices th...
python
def to_numpy_bins_with_mask(bins) -> Tuple[np.ndarray, np.ndarray]: """Numpy binning edges including gaps. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: np.ndarray all edges mask: np.ndarray List of indices th...
[ "def", "to_numpy_bins_with_mask", "(", "bins", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "np", ".", "ndarray", "]", ":", "bins", "=", "np", ".", "asarray", "(", "bins", ")", "if", "bins", ".", "ndim", "==", "1", ":", "edges", "=", "bins",...
Numpy binning edges including gaps. Parameters ---------- bins: array_like 1-D (n) or 2-D (n, 2) array of edges Returns ------- edges: np.ndarray all edges mask: np.ndarray List of indices that correspond to bins that have to be included Examples -------- ...
[ "Numpy", "binning", "edges", "including", "gaps", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L59-L108
train
janpipek/physt
physt/bin_utils.py
is_rising
def is_rising(bins) -> bool: """Check whether the bins are in raising order. Does not check if the bins are consecutive. Parameters ---------- bins: array_like """ # TODO: Optimize for numpy bins bins = make_bin_array(bins) if np.any(bins[:, 0] >= bins[:, 1]): return False ...
python
def is_rising(bins) -> bool: """Check whether the bins are in raising order. Does not check if the bins are consecutive. Parameters ---------- bins: array_like """ # TODO: Optimize for numpy bins bins = make_bin_array(bins) if np.any(bins[:, 0] >= bins[:, 1]): return False ...
[ "def", "is_rising", "(", "bins", ")", "->", "bool", ":", "bins", "=", "make_bin_array", "(", "bins", ")", "if", "np", ".", "any", "(", "bins", "[", ":", ",", "0", "]", ">=", "bins", "[", ":", ",", "1", "]", ")", ":", "return", "False", "if", ...
Check whether the bins are in raising order. Does not check if the bins are consecutive. Parameters ---------- bins: array_like
[ "Check", "whether", "the", "bins", "are", "in", "raising", "order", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L111-L126
train
janpipek/physt
physt/plotting/common.py
get_data
def get_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray: """Get histogram data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumulative sums...
python
def get_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray: """Get histogram data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumulative sums...
[ "def", "get_data", "(", "histogram", ":", "HistogramBase", ",", "density", ":", "bool", "=", "False", ",", "cumulative", ":", "bool", "=", "False", ",", "flatten", ":", "bool", "=", "False", ")", "->", "np", ".", "ndarray", ":", "if", "density", ":", ...
Get histogram data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumulative sums instead of individual flatten : Whether to flatten multidimensional bins
[ "Get", "histogram", "data", "based", "on", "plotting", "parameters", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L15-L37
train
janpipek/physt
physt/plotting/common.py
get_err_data
def get_err_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray: """Get histogram error data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumul...
python
def get_err_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray: """Get histogram error data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumul...
[ "def", "get_err_data", "(", "histogram", ":", "HistogramBase", ",", "density", ":", "bool", "=", "False", ",", "cumulative", ":", "bool", "=", "False", ",", "flatten", ":", "bool", "=", "False", ")", "->", "np", ".", "ndarray", ":", "if", "cumulative", ...
Get histogram error data based on plotting parameters. Parameters ---------- density : Whether to divide bin contents by bin size cumulative : Whether to return cumulative sums instead of individual flatten : Whether to flatten multidimensional bins
[ "Get", "histogram", "error", "data", "based", "on", "plotting", "parameters", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L40-L57
train
janpipek/physt
physt/plotting/common.py
get_value_format
def get_value_format(value_format: Union[Callable, str] = str) -> Callable[[float], str]: """Create a formatting function from a generic value_format argument. """ if value_format is None: value_format = "" if isinstance(value_format, str): format_str = "{0:" + value_format + "}" ...
python
def get_value_format(value_format: Union[Callable, str] = str) -> Callable[[float], str]: """Create a formatting function from a generic value_format argument. """ if value_format is None: value_format = "" if isinstance(value_format, str): format_str = "{0:" + value_format + "}" ...
[ "def", "get_value_format", "(", "value_format", ":", "Union", "[", "Callable", ",", "str", "]", "=", "str", ")", "->", "Callable", "[", "[", "float", "]", ",", "str", "]", ":", "if", "value_format", "is", "None", ":", "value_format", "=", "\"\"", "if",...
Create a formatting function from a generic value_format argument.
[ "Create", "a", "formatting", "function", "from", "a", "generic", "value_format", "argument", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L60-L70
train
janpipek/physt
physt/plotting/common.py
pop_kwargs_with_prefix
def pop_kwargs_with_prefix(prefix: str, kwargs: dict) -> dict: """Pop all items from a dictionary that have keys beginning with a prefix. Parameters ---------- prefix : str kwargs : dict Returns ------- kwargs : dict Items popped from the original directory, with prefix removed...
python
def pop_kwargs_with_prefix(prefix: str, kwargs: dict) -> dict: """Pop all items from a dictionary that have keys beginning with a prefix. Parameters ---------- prefix : str kwargs : dict Returns ------- kwargs : dict Items popped from the original directory, with prefix removed...
[ "def", "pop_kwargs_with_prefix", "(", "prefix", ":", "str", ",", "kwargs", ":", "dict", ")", "->", "dict", ":", "keys", "=", "[", "key", "for", "key", "in", "kwargs", "if", "key", ".", "startswith", "(", "prefix", ")", "]", "return", "{", "key", "[",...
Pop all items from a dictionary that have keys beginning with a prefix. Parameters ---------- prefix : str kwargs : dict Returns ------- kwargs : dict Items popped from the original directory, with prefix removed.
[ "Pop", "all", "items", "from", "a", "dictionary", "that", "have", "keys", "beginning", "with", "a", "prefix", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L73-L87
train
janpipek/physt
physt/histogram_nd.py
HistogramND.bins
def bins(self) -> List[np.ndarray]: """List of bin matrices.""" return [binning.bins for binning in self._binnings]
python
def bins(self) -> List[np.ndarray]: """List of bin matrices.""" return [binning.bins for binning in self._binnings]
[ "def", "bins", "(", "self", ")", "->", "List", "[", "np", ".", "ndarray", "]", ":", "return", "[", "binning", ".", "bins", "for", "binning", "in", "self", ".", "_binnings", "]" ]
List of bin matrices.
[ "List", "of", "bin", "matrices", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L54-L56
train
janpipek/physt
physt/histogram_nd.py
HistogramND.select
def select(self, axis: AxisIdentifier, index, force_copy: bool = False) -> HistogramBase: """Select in an axis. Parameters ---------- axis: int or str Axis, in which we select. index: int or slice Index of bin (as in numpy). force_copy: bool ...
python
def select(self, axis: AxisIdentifier, index, force_copy: bool = False) -> HistogramBase: """Select in an axis. Parameters ---------- axis: int or str Axis, in which we select. index: int or slice Index of bin (as in numpy). force_copy: bool ...
[ "def", "select", "(", "self", ",", "axis", ":", "AxisIdentifier", ",", "index", ",", "force_copy", ":", "bool", "=", "False", ")", "->", "HistogramBase", ":", "if", "index", "==", "slice", "(", "None", ")", "and", "not", "force_copy", ":", "return", "s...
Select in an axis. Parameters ---------- axis: int or str Axis, in which we select. index: int or slice Index of bin (as in numpy). force_copy: bool If True, identity slice force a copy to be made.
[ "Select", "in", "an", "axis", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L71-L104
train
janpipek/physt
physt/histogram_nd.py
HistogramND.accumulate
def accumulate(self, axis: AxisIdentifier) -> HistogramBase: """Calculate cumulative frequencies along a certain axis. Returns ------- new_hist: Histogram of the same type & size """ # TODO: Merge with Histogram1D.cumulative_frequencies # TODO: Deal with errors a...
python
def accumulate(self, axis: AxisIdentifier) -> HistogramBase: """Calculate cumulative frequencies along a certain axis. Returns ------- new_hist: Histogram of the same type & size """ # TODO: Merge with Histogram1D.cumulative_frequencies # TODO: Deal with errors a...
[ "def", "accumulate", "(", "self", ",", "axis", ":", "AxisIdentifier", ")", "->", "HistogramBase", ":", "new_one", "=", "self", ".", "copy", "(", ")", "axis_id", "=", "self", ".", "_get_axis", "(", "axis", ")", "new_one", ".", "_frequencies", "=", "np", ...
Calculate cumulative frequencies along a certain axis. Returns ------- new_hist: Histogram of the same type & size
[ "Calculate", "cumulative", "frequencies", "along", "a", "certain", "axis", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L338-L351
train
janpipek/physt
physt/histogram_nd.py
Histogram2D.T
def T(self) -> "Histogram2D": """Histogram with swapped axes. Returns ------- Histogram2D - a copy with swapped axes """ a_copy = self.copy() a_copy._binnings = list(reversed(a_copy._binnings)) a_copy.axis_names = list(reversed(a_copy.axis_names)) ...
python
def T(self) -> "Histogram2D": """Histogram with swapped axes. Returns ------- Histogram2D - a copy with swapped axes """ a_copy = self.copy() a_copy._binnings = list(reversed(a_copy._binnings)) a_copy.axis_names = list(reversed(a_copy.axis_names)) ...
[ "def", "T", "(", "self", ")", "->", "\"Histogram2D\"", ":", "a_copy", "=", "self", ".", "copy", "(", ")", "a_copy", ".", "_binnings", "=", "list", "(", "reversed", "(", "a_copy", ".", "_binnings", ")", ")", "a_copy", ".", "axis_names", "=", "list", "...
Histogram with swapped axes. Returns ------- Histogram2D - a copy with swapped axes
[ "Histogram", "with", "swapped", "axes", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L414-L426
train
janpipek/physt
physt/histogram_nd.py
Histogram2D.partial_normalize
def partial_normalize(self, axis: AxisIdentifier = 0, inplace: bool = False): """Normalize in rows or columns. Parameters ---------- axis: int or str Along which axis to sum (numpy-sense) inplace: bool Update the object itself Returns ---...
python
def partial_normalize(self, axis: AxisIdentifier = 0, inplace: bool = False): """Normalize in rows or columns. Parameters ---------- axis: int or str Along which axis to sum (numpy-sense) inplace: bool Update the object itself Returns ---...
[ "def", "partial_normalize", "(", "self", ",", "axis", ":", "AxisIdentifier", "=", "0", ",", "inplace", ":", "bool", "=", "False", ")", ":", "axis", "=", "self", ".", "_get_axis", "(", "axis", ")", "if", "not", "inplace", ":", "copy", "=", "self", "."...
Normalize in rows or columns. Parameters ---------- axis: int or str Along which axis to sum (numpy-sense) inplace: bool Update the object itself Returns ------- hist : Histogram2D
[ "Normalize", "in", "rows", "or", "columns", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L428-L457
train
janpipek/physt
physt/binnings.py
numpy_binning
def numpy_binning(data, bins=10, range=None, *args, **kwargs) -> NumpyBinning: """Construct binning schema compatible with numpy.histogram Parameters ---------- data: array_like, optional This is optional if both bins and range are set bins: int or array_like range: Optional[tuple] ...
python
def numpy_binning(data, bins=10, range=None, *args, **kwargs) -> NumpyBinning: """Construct binning schema compatible with numpy.histogram Parameters ---------- data: array_like, optional This is optional if both bins and range are set bins: int or array_like range: Optional[tuple] ...
[ "def", "numpy_binning", "(", "data", ",", "bins", "=", "10", ",", "range", "=", "None", ",", "*", "args", ",", "**", "kwargs", ")", "->", "NumpyBinning", ":", "if", "isinstance", "(", "bins", ",", "int", ")", ":", "if", "range", ":", "bins", "=", ...
Construct binning schema compatible with numpy.histogram Parameters ---------- data: array_like, optional This is optional if both bins and range are set bins: int or array_like range: Optional[tuple] (min, max) includes_right_edge: Optional[bool] default: True See ...
[ "Construct", "binning", "schema", "compatible", "with", "numpy", ".", "histogram" ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L596-L625
train