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
vtkiorg/vtki
vtki/pointset.py
UnstructuredGrid.extract_cells
def extract_cells(self, ind): """ Returns a subset of the grid Parameters ---------- ind : np.ndarray Numpy array of cell indices to be extracted. Returns ------- subgrid : vtki.UnstructuredGrid Subselected grid """ ...
python
def extract_cells(self, ind): """ Returns a subset of the grid Parameters ---------- ind : np.ndarray Numpy array of cell indices to be extracted. Returns ------- subgrid : vtki.UnstructuredGrid Subselected grid """ ...
[ "def", "extract_cells", "(", "self", ",", "ind", ")", ":", "if", "not", "isinstance", "(", "ind", ",", "np", ".", "ndarray", ")", ":", "ind", "=", "np", ".", "array", "(", "ind", ",", "np", ".", "ndarray", ")", "if", "ind", ".", "dtype", "==", ...
Returns a subset of the grid Parameters ---------- ind : np.ndarray Numpy array of cell indices to be extracted. Returns ------- subgrid : vtki.UnstructuredGrid Subselected grid
[ "Returns", "a", "subset", "of", "the", "grid" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2087-L2137
train
vtkiorg/vtki
vtki/pointset.py
UnstructuredGrid.merge
def merge(self, grid=None, merge_points=True, inplace=False, main_has_priority=True): """ Join one or many other grids to this grid. Grid is updated in-place by default. Can be used to merge points of adjcent cells when no grids are input. Parameters ...
python
def merge(self, grid=None, merge_points=True, inplace=False, main_has_priority=True): """ Join one or many other grids to this grid. Grid is updated in-place by default. Can be used to merge points of adjcent cells when no grids are input. Parameters ...
[ "def", "merge", "(", "self", ",", "grid", "=", "None", ",", "merge_points", "=", "True", ",", "inplace", "=", "False", ",", "main_has_priority", "=", "True", ")", ":", "append_filter", "=", "vtk", ".", "vtkAppendFilter", "(", ")", "append_filter", ".", "...
Join one or many other grids to this grid. Grid is updated in-place by default. Can be used to merge points of adjcent cells when no grids are input. Parameters ---------- grid : vtk.UnstructuredGrid or list of vtk.UnstructuredGrids Grids to merge to this g...
[ "Join", "one", "or", "many", "other", "grids", "to", "this", "grid", ".", "Grid", "is", "updated", "in", "-", "place", "by", "default", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2175-L2233
train
vtkiorg/vtki
vtki/pointset.py
UnstructuredGrid.delaunay_2d
def delaunay_2d(self, tol=1e-05, alpha=0.0, offset=1.0, bound=False): """Apply a delaunay 2D filter along the best fitting plane. This extracts the grid's points and perfoms the triangulation on those alone. """ return PolyData(self.points).delaunay_2d(tol=tol, alpha=alpha, offset=offset...
python
def delaunay_2d(self, tol=1e-05, alpha=0.0, offset=1.0, bound=False): """Apply a delaunay 2D filter along the best fitting plane. This extracts the grid's points and perfoms the triangulation on those alone. """ return PolyData(self.points).delaunay_2d(tol=tol, alpha=alpha, offset=offset...
[ "def", "delaunay_2d", "(", "self", ",", "tol", "=", "1e-05", ",", "alpha", "=", "0.0", ",", "offset", "=", "1.0", ",", "bound", "=", "False", ")", ":", "return", "PolyData", "(", "self", ".", "points", ")", ".", "delaunay_2d", "(", "tol", "=", "tol...
Apply a delaunay 2D filter along the best fitting plane. This extracts the grid's points and perfoms the triangulation on those alone.
[ "Apply", "a", "delaunay", "2D", "filter", "along", "the", "best", "fitting", "plane", ".", "This", "extracts", "the", "grid", "s", "points", "and", "perfoms", "the", "triangulation", "on", "those", "alone", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2235-L2239
train
vtkiorg/vtki
vtki/pointset.py
StructuredGrid._from_arrays
def _from_arrays(self, x, y, z): """ Create VTK structured grid directly from numpy arrays. Parameters ---------- x : np.ndarray Position of the points in x direction. y : np.ndarray Position of the points in y direction. z : np.ndarray ...
python
def _from_arrays(self, x, y, z): """ Create VTK structured grid directly from numpy arrays. Parameters ---------- x : np.ndarray Position of the points in x direction. y : np.ndarray Position of the points in y direction. z : np.ndarray ...
[ "def", "_from_arrays", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "if", "not", "(", "x", ".", "shape", "==", "y", ".", "shape", "==", "z", ".", "shape", ")", ":", "raise", "Exception", "(", "'Input point array shapes must match exactly'", ")"...
Create VTK structured grid directly from numpy arrays. Parameters ---------- x : np.ndarray Position of the points in x direction. y : np.ndarray Position of the points in y direction. z : np.ndarray Position of the points in z direction.
[ "Create", "VTK", "structured", "grid", "directly", "from", "numpy", "arrays", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2303-L2334
train
vtkiorg/vtki
vtki/pointset.py
StructuredGrid.save
def save(self, filename, binary=True): """ Writes a structured grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ...
python
def save(self, filename, binary=True): """ Writes a structured grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ...
[ "def", "save", "(", "self", ",", "filename", ",", "binary", "=", "True", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", "# Use legacy writer if vtk is in filename", "if", ...
Writes a structured grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ".vts" will select the VTK XML writer. binary ...
[ "Writes", "a", "structured", "grid", "to", "disk", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2376-L2418
train
vtkiorg/vtki
vtki/pointset.py
StructuredGrid.dimensions
def dimensions(self, dims): """Sets the dataset dimensions. Pass a length three tuple of integers""" nx, ny, nz = dims[0], dims[1], dims[2] self.SetDimensions(nx, ny, nz) self.Modified()
python
def dimensions(self, dims): """Sets the dataset dimensions. Pass a length three tuple of integers""" nx, ny, nz = dims[0], dims[1], dims[2] self.SetDimensions(nx, ny, nz) self.Modified()
[ "def", "dimensions", "(", "self", ",", "dims", ")", ":", "nx", ",", "ny", ",", "nz", "=", "dims", "[", "0", "]", ",", "dims", "[", "1", "]", ",", "dims", "[", "2", "]", "self", ".", "SetDimensions", "(", "nx", ",", "ny", ",", "nz", ")", "se...
Sets the dataset dimensions. Pass a length three tuple of integers
[ "Sets", "the", "dataset", "dimensions", ".", "Pass", "a", "length", "three", "tuple", "of", "integers" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/pointset.py#L2426-L2430
train
vtkiorg/vtki
vtki/grid.py
RectilinearGrid._from_arrays
def _from_arrays(self, x, y, z): """ Create VTK rectilinear grid directly from numpy arrays. Each array gives the uniques coordinates of the mesh along each axial direction. To help ensure you are using this correctly, we take the unique values of each argument. Paramete...
python
def _from_arrays(self, x, y, z): """ Create VTK rectilinear grid directly from numpy arrays. Each array gives the uniques coordinates of the mesh along each axial direction. To help ensure you are using this correctly, we take the unique values of each argument. Paramete...
[ "def", "_from_arrays", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "x", "=", "np", ".", "unique", "(", "x", ".", "ravel", "(", ")", ")", "y", "=", "np", ".", "unique", "(", "y", ".", "ravel", "(", ")", ")", "z", "=", "np", ".", ...
Create VTK rectilinear grid directly from numpy arrays. Each array gives the uniques coordinates of the mesh along each axial direction. To help ensure you are using this correctly, we take the unique values of each argument. Parameters ---------- x : np.ndarray ...
[ "Create", "VTK", "rectilinear", "grid", "directly", "from", "numpy", "arrays", ".", "Each", "array", "gives", "the", "uniques", "coordinates", "of", "the", "mesh", "along", "each", "axial", "direction", ".", "To", "help", "ensure", "you", "are", "using", "th...
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L108-L133
train
vtkiorg/vtki
vtki/grid.py
RectilinearGrid._load_file
def _load_file(self, filename): """ Load a rectilinear grid from a file. The file extension will select the type of reader to use. A .vtk extension will use the legacy reader, while .vtr will select the VTK XML reader. Parameters ---------- filename : s...
python
def _load_file(self, filename): """ Load a rectilinear grid from a file. The file extension will select the type of reader to use. A .vtk extension will use the legacy reader, while .vtr will select the VTK XML reader. Parameters ---------- filename : s...
[ "def", "_load_file", "(", "self", ",", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", "# check file exists", "if", "not", "os", ".", "path", ".", "isfile",...
Load a rectilinear grid from a file. The file extension will select the type of reader to use. A .vtk extension will use the legacy reader, while .vtr will select the VTK XML reader. Parameters ---------- filename : str Filename of grid to be loaded.
[ "Load", "a", "rectilinear", "grid", "from", "a", "file", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L160-L198
train
vtkiorg/vtki
vtki/grid.py
RectilinearGrid.save
def save(self, filename, binary=True): """ Writes a rectilinear grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ...
python
def save(self, filename, binary=True): """ Writes a rectilinear grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ...
[ "def", "save", "(", "self", ",", "filename", ",", "binary", "=", "True", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", "# Use legacy writer if vtk is in filename", "if", ...
Writes a rectilinear grid to disk. Parameters ---------- filename : str Filename of grid to be written. The file extension will select the type of writer to use. ".vtk" will use the legacy writer, while ".vtr" will select the VTK XML writer. binary...
[ "Writes", "a", "rectilinear", "grid", "to", "disk", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L200-L238
train
vtkiorg/vtki
vtki/grid.py
UniformGrid.origin
def origin(self, origin): """Set the origin. Pass a length three tuple of floats""" ox, oy, oz = origin[0], origin[1], origin[2] self.SetOrigin(ox, oy, oz) self.Modified()
python
def origin(self, origin): """Set the origin. Pass a length three tuple of floats""" ox, oy, oz = origin[0], origin[1], origin[2] self.SetOrigin(ox, oy, oz) self.Modified()
[ "def", "origin", "(", "self", ",", "origin", ")", ":", "ox", ",", "oy", ",", "oz", "=", "origin", "[", "0", "]", ",", "origin", "[", "1", "]", ",", "origin", "[", "2", "]", "self", ".", "SetOrigin", "(", "ox", ",", "oy", ",", "oz", ")", "se...
Set the origin. Pass a length three tuple of floats
[ "Set", "the", "origin", ".", "Pass", "a", "length", "three", "tuple", "of", "floats" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L533-L537
train
vtkiorg/vtki
vtki/grid.py
UniformGrid.spacing
def spacing(self, spacing): """Set the spacing in each axial direction. Pass a length three tuple of floats""" dx, dy, dz = spacing[0], spacing[1], spacing[2] self.SetSpacing(dx, dy, dz) self.Modified()
python
def spacing(self, spacing): """Set the spacing in each axial direction. Pass a length three tuple of floats""" dx, dy, dz = spacing[0], spacing[1], spacing[2] self.SetSpacing(dx, dy, dz) self.Modified()
[ "def", "spacing", "(", "self", ",", "spacing", ")", ":", "dx", ",", "dy", ",", "dz", "=", "spacing", "[", "0", "]", ",", "spacing", "[", "1", "]", ",", "spacing", "[", "2", "]", "self", ".", "SetSpacing", "(", "dx", ",", "dy", ",", "dz", ")",...
Set the spacing in each axial direction. Pass a length three tuple of floats
[ "Set", "the", "spacing", "in", "each", "axial", "direction", ".", "Pass", "a", "length", "three", "tuple", "of", "floats" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L545-L550
train
vtkiorg/vtki
vtki/qt_plotting.py
resample_image
def resample_image(arr, max_size=400): """Resamples a square image to an image of max_size""" dim = np.max(arr.shape[0:2]) if dim < max_size: max_size = dim x, y, _ = arr.shape sx = int(np.ceil(x / max_size)) sy = int(np.ceil(y / max_size)) img = np.zeros((max_size, max_size, 3), dty...
python
def resample_image(arr, max_size=400): """Resamples a square image to an image of max_size""" dim = np.max(arr.shape[0:2]) if dim < max_size: max_size = dim x, y, _ = arr.shape sx = int(np.ceil(x / max_size)) sy = int(np.ceil(y / max_size)) img = np.zeros((max_size, max_size, 3), dty...
[ "def", "resample_image", "(", "arr", ",", "max_size", "=", "400", ")", ":", "dim", "=", "np", ".", "max", "(", "arr", ".", "shape", "[", "0", ":", "2", "]", ")", "if", "dim", "<", "max_size", ":", "max_size", "=", "dim", "x", ",", "y", ",", "...
Resamples a square image to an image of max_size
[ "Resamples", "a", "square", "image", "to", "an", "image", "of", "max_size" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L229-L242
train
vtkiorg/vtki
vtki/qt_plotting.py
pad_image
def pad_image(arr, max_size=400): """Pads an image to a square then resamples to max_size""" dim = np.max(arr.shape) img = np.zeros((dim, dim, 3), dtype=arr.dtype) xl = (dim - arr.shape[0]) // 2 yl = (dim - arr.shape[1]) // 2 img[xl:arr.shape[0]+xl, yl:arr.shape[1]+yl, :] = arr return resamp...
python
def pad_image(arr, max_size=400): """Pads an image to a square then resamples to max_size""" dim = np.max(arr.shape) img = np.zeros((dim, dim, 3), dtype=arr.dtype) xl = (dim - arr.shape[0]) // 2 yl = (dim - arr.shape[1]) // 2 img[xl:arr.shape[0]+xl, yl:arr.shape[1]+yl, :] = arr return resamp...
[ "def", "pad_image", "(", "arr", ",", "max_size", "=", "400", ")", ":", "dim", "=", "np", ".", "max", "(", "arr", ".", "shape", ")", "img", "=", "np", ".", "zeros", "(", "(", "dim", ",", "dim", ",", "3", ")", ",", "dtype", "=", "arr", ".", "...
Pads an image to a square then resamples to max_size
[ "Pads", "an", "image", "to", "a", "square", "then", "resamples", "to", "max_size" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L245-L252
train
vtkiorg/vtki
vtki/qt_plotting.py
FileDialog.emit_accepted
def emit_accepted(self): """ Sends signal that the file dialog was closed properly. Sends: filename """ if self.result(): filename = self.selectedFiles()[0] if os.path.isdir(os.path.dirname(filename)): self.dlg_accepted.emit(filena...
python
def emit_accepted(self): """ Sends signal that the file dialog was closed properly. Sends: filename """ if self.result(): filename = self.selectedFiles()[0] if os.path.isdir(os.path.dirname(filename)): self.dlg_accepted.emit(filena...
[ "def", "emit_accepted", "(", "self", ")", ":", "if", "self", ".", "result", "(", ")", ":", "filename", "=", "self", ".", "selectedFiles", "(", ")", "[", "0", "]", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "dirname", "(",...
Sends signal that the file dialog was closed properly. Sends: filename
[ "Sends", "signal", "that", "the", "file", "dialog", "was", "closed", "properly", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L92-L102
train
vtkiorg/vtki
vtki/qt_plotting.py
ScaleAxesDialog.update_scale
def update_scale(self, value): """ updates the scale of all actors in the plotter """ self.plotter.set_scale(self.x_slider_group.value, self.y_slider_group.value, self.z_slider_group.value)
python
def update_scale(self, value): """ updates the scale of all actors in the plotter """ self.plotter.set_scale(self.x_slider_group.value, self.y_slider_group.value, self.z_slider_group.value)
[ "def", "update_scale", "(", "self", ",", "value", ")", ":", "self", ".", "plotter", ".", "set_scale", "(", "self", ".", "x_slider_group", ".", "value", ",", "self", ".", "y_slider_group", ".", "value", ",", "self", ".", "z_slider_group", ".", "value", ")...
updates the scale of all actors in the plotter
[ "updates", "the", "scale", "of", "all", "actors", "in", "the", "plotter" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L222-L226
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.scale_axes_dialog
def scale_axes_dialog(self, show=True): """ Open scale axes dialog """ return ScaleAxesDialog(self.app_window, self, show=show)
python
def scale_axes_dialog(self, show=True): """ Open scale axes dialog """ return ScaleAxesDialog(self.app_window, self, show=show)
[ "def", "scale_axes_dialog", "(", "self", ",", "show", "=", "True", ")", ":", "return", "ScaleAxesDialog", "(", "self", ".", "app_window", ",", "self", ",", "show", "=", "show", ")" ]
Open scale axes dialog
[ "Open", "scale", "axes", "dialog" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L418-L420
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.clear_camera_positions
def clear_camera_positions(self): """ clears all camera positions """ for action in self.saved_camera_menu.actions(): self.saved_camera_menu.removeAction(action)
python
def clear_camera_positions(self): """ clears all camera positions """ for action in self.saved_camera_menu.actions(): self.saved_camera_menu.removeAction(action)
[ "def", "clear_camera_positions", "(", "self", ")", ":", "for", "action", "in", "self", ".", "saved_camera_menu", ".", "actions", "(", ")", ":", "self", ".", "saved_camera_menu", ".", "removeAction", "(", "action", ")" ]
clears all camera positions
[ "clears", "all", "camera", "positions" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L422-L425
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.save_camera_position
def save_camera_position(self): """ Saves camera position to saved camera menu for recall """ self.saved_camera_positions.append(self.camera_position) ncam = len(self.saved_camera_positions) camera_position = self.camera_position[:] # py2.7 copy compatibility def load_camera_po...
python
def save_camera_position(self): """ Saves camera position to saved camera menu for recall """ self.saved_camera_positions.append(self.camera_position) ncam = len(self.saved_camera_positions) camera_position = self.camera_position[:] # py2.7 copy compatibility def load_camera_po...
[ "def", "save_camera_position", "(", "self", ")", ":", "self", ".", "saved_camera_positions", ".", "append", "(", "self", ".", "camera_position", ")", "ncam", "=", "len", "(", "self", ".", "saved_camera_positions", ")", "camera_position", "=", "self", ".", "cam...
Saves camera position to saved camera menu for recall
[ "Saves", "camera", "position", "to", "saved", "camera", "menu", "for", "recall" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L427-L437
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter._spawn_background_rendering
def _spawn_background_rendering(self, rate=5.0): """ Spawns a thread that updates the render window. Sometimes directly modifiying object data doesn't trigger Modified() and upstream objects won't be updated. This ensures the render window stays updated without consuming too ...
python
def _spawn_background_rendering(self, rate=5.0): """ Spawns a thread that updates the render window. Sometimes directly modifiying object data doesn't trigger Modified() and upstream objects won't be updated. This ensures the render window stays updated without consuming too ...
[ "def", "_spawn_background_rendering", "(", "self", ",", "rate", "=", "5.0", ")", ":", "self", ".", "render_trigger", ".", "connect", "(", "self", ".", "ren_win", ".", "Render", ")", "twait", "=", "rate", "**", "-", "1", "def", "render", "(", ")", ":", ...
Spawns a thread that updates the render window. Sometimes directly modifiying object data doesn't trigger Modified() and upstream objects won't be updated. This ensures the render window stays updated without consuming too many resources.
[ "Spawns", "a", "thread", "that", "updates", "the", "render", "window", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L439-L457
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.update_app_icon
def update_app_icon(self): """ Update the app icon if the user is not trying to resize the window. """ if os.name == 'nt' or not hasattr(self, '_last_window_size'): # pragma: no cover # DO NOT EVEN ATTEMPT TO UPDATE ICON ON WINDOWS return cur_time = time....
python
def update_app_icon(self): """ Update the app icon if the user is not trying to resize the window. """ if os.name == 'nt' or not hasattr(self, '_last_window_size'): # pragma: no cover # DO NOT EVEN ATTEMPT TO UPDATE ICON ON WINDOWS return cur_time = time....
[ "def", "update_app_icon", "(", "self", ")", ":", "if", "os", ".", "name", "==", "'nt'", "or", "not", "hasattr", "(", "self", ",", "'_last_window_size'", ")", ":", "# pragma: no cover", "# DO NOT EVEN ATTEMPT TO UPDATE ICON ON WINDOWS", "return", "cur_time", "=", "...
Update the app icon if the user is not trying to resize the window.
[ "Update", "the", "app", "icon", "if", "the", "user", "is", "not", "trying", "to", "resize", "the", "window", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L472-L501
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter._qt_export_vtkjs
def _qt_export_vtkjs(self, show=True): """ Spawn an save file dialog to export a vtkjs file. """ return FileDialog(self.app_window, filefilter=['VTK JS File(*.vtkjs)'], show=show, directory=os.getcwd(), ...
python
def _qt_export_vtkjs(self, show=True): """ Spawn an save file dialog to export a vtkjs file. """ return FileDialog(self.app_window, filefilter=['VTK JS File(*.vtkjs)'], show=show, directory=os.getcwd(), ...
[ "def", "_qt_export_vtkjs", "(", "self", ",", "show", "=", "True", ")", ":", "return", "FileDialog", "(", "self", ".", "app_window", ",", "filefilter", "=", "[", "'VTK JS File(*.vtkjs)'", "]", ",", "show", "=", "show", ",", "directory", "=", "os", ".", "g...
Spawn an save file dialog to export a vtkjs file.
[ "Spawn", "an", "save", "file", "dialog", "to", "export", "a", "vtkjs", "file", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L511-L519
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.window_size
def window_size(self): """ returns render window size """ the_size = self.app_window.baseSize() return the_size.width(), the_size.height()
python
def window_size(self): """ returns render window size """ the_size = self.app_window.baseSize() return the_size.width(), the_size.height()
[ "def", "window_size", "(", "self", ")", ":", "the_size", "=", "self", ".", "app_window", ".", "baseSize", "(", ")", "return", "the_size", ".", "width", "(", ")", ",", "the_size", ".", "height", "(", ")" ]
returns render window size
[ "returns", "render", "window", "size" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L532-L535
train
vtkiorg/vtki
vtki/qt_plotting.py
BackgroundPlotter.window_size
def window_size(self, window_size): """ set the render window size """ BasePlotter.window_size.fset(self, window_size) self.app_window.setBaseSize(*window_size)
python
def window_size(self, window_size): """ set the render window size """ BasePlotter.window_size.fset(self, window_size) self.app_window.setBaseSize(*window_size)
[ "def", "window_size", "(", "self", ",", "window_size", ")", ":", "BasePlotter", ".", "window_size", ".", "fset", "(", "self", ",", "window_size", ")", "self", ".", "app_window", ".", "setBaseSize", "(", "*", "window_size", ")" ]
set the render window size
[ "set", "the", "render", "window", "size" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L539-L542
train
vtkiorg/vtki
vtki/colors.py
hex_to_rgb
def hex_to_rgb(h): """ Returns 0 to 1 rgb from a hex list or tuple """ h = h.lstrip('#') return tuple(int(h[i:i+2], 16)/255. for i in (0, 2 ,4))
python
def hex_to_rgb(h): """ Returns 0 to 1 rgb from a hex list or tuple """ h = h.lstrip('#') return tuple(int(h[i:i+2], 16)/255. for i in (0, 2 ,4))
[ "def", "hex_to_rgb", "(", "h", ")", ":", "h", "=", "h", ".", "lstrip", "(", "'#'", ")", "return", "tuple", "(", "int", "(", "h", "[", "i", ":", "i", "+", "2", "]", ",", "16", ")", "/", "255.", "for", "i", "in", "(", "0", ",", "2", ",", ...
Returns 0 to 1 rgb from a hex list or tuple
[ "Returns", "0", "to", "1", "rgb", "from", "a", "hex", "list", "or", "tuple" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/colors.py#L321-L324
train
vtkiorg/vtki
vtki/errors.py
set_error_output_file
def set_error_output_file(filename): """Sets a file to write out the VTK errors""" filename = os.path.abspath(os.path.expanduser(filename)) fileOutputWindow = vtk.vtkFileOutputWindow() fileOutputWindow.SetFileName(filename) outputWindow = vtk.vtkOutputWindow() outputWindow.SetInstance(fileOutput...
python
def set_error_output_file(filename): """Sets a file to write out the VTK errors""" filename = os.path.abspath(os.path.expanduser(filename)) fileOutputWindow = vtk.vtkFileOutputWindow() fileOutputWindow.SetFileName(filename) outputWindow = vtk.vtkOutputWindow() outputWindow.SetInstance(fileOutput...
[ "def", "set_error_output_file", "(", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", "fileOutputWindow", "=", "vtk", ".", "vtkFileOutputWindow", "(", ")", "file...
Sets a file to write out the VTK errors
[ "Sets", "a", "file", "to", "write", "out", "the", "VTK", "errors" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/errors.py#L8-L15
train
vtkiorg/vtki
vtki/errors.py
Observer.log_message
def log_message(self, kind, alert): """Parses different event types and passes them to logging""" if kind == 'ERROR': logging.error(alert) else: logging.warning(alert) return
python
def log_message(self, kind, alert): """Parses different event types and passes them to logging""" if kind == 'ERROR': logging.error(alert) else: logging.warning(alert) return
[ "def", "log_message", "(", "self", ",", "kind", ",", "alert", ")", ":", "if", "kind", "==", "'ERROR'", ":", "logging", ".", "error", "(", "alert", ")", "else", ":", "logging", ".", "warning", "(", "alert", ")", "return" ]
Parses different event types and passes them to logging
[ "Parses", "different", "event", "types", "and", "passes", "them", "to", "logging" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/errors.py#L40-L46
train
vtkiorg/vtki
vtki/errors.py
Observer.observe
def observe(self, algorithm): """Make this an observer of an algorithm """ if self.__observing: raise RuntimeError('This error observer is already observing an algorithm.') if hasattr(algorithm, 'GetExecutive') and algorithm.GetExecutive() is not None: algorithm.G...
python
def observe(self, algorithm): """Make this an observer of an algorithm """ if self.__observing: raise RuntimeError('This error observer is already observing an algorithm.') if hasattr(algorithm, 'GetExecutive') and algorithm.GetExecutive() is not None: algorithm.G...
[ "def", "observe", "(", "self", ",", "algorithm", ")", ":", "if", "self", ".", "__observing", ":", "raise", "RuntimeError", "(", "'This error observer is already observing an algorithm.'", ")", "if", "hasattr", "(", "algorithm", ",", "'GetExecutive'", ")", "and", "...
Make this an observer of an algorithm
[ "Make", "this", "an", "observer", "of", "an", "algorithm" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/errors.py#L75-L84
train
vtkiorg/vtki
vtki/export.py
get_range_info
def get_range_info(array, component): """Get the data range of the array's component""" r = array.GetRange(component) comp_range = {} comp_range['min'] = r[0] comp_range['max'] = r[1] comp_range['component'] = array.GetComponentName(component) return comp_range
python
def get_range_info(array, component): """Get the data range of the array's component""" r = array.GetRange(component) comp_range = {} comp_range['min'] = r[0] comp_range['max'] = r[1] comp_range['component'] = array.GetComponentName(component) return comp_range
[ "def", "get_range_info", "(", "array", ",", "component", ")", ":", "r", "=", "array", ".", "GetRange", "(", "component", ")", "comp_range", "=", "{", "}", "comp_range", "[", "'min'", "]", "=", "r", "[", "0", "]", "comp_range", "[", "'max'", "]", "=",...
Get the data range of the array's component
[ "Get", "the", "data", "range", "of", "the", "array", "s", "component" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L78-L85
train
vtkiorg/vtki
vtki/export.py
get_object_id
def get_object_id(obj): """Get object identifier""" try: idx = objIds.index(obj) return idx + 1 except ValueError: objIds.append(obj) return len(objIds)
python
def get_object_id(obj): """Get object identifier""" try: idx = objIds.index(obj) return idx + 1 except ValueError: objIds.append(obj) return len(objIds)
[ "def", "get_object_id", "(", "obj", ")", ":", "try", ":", "idx", "=", "objIds", ".", "index", "(", "obj", ")", "return", "idx", "+", "1", "except", "ValueError", ":", "objIds", ".", "append", "(", "obj", ")", "return", "len", "(", "objIds", ")" ]
Get object identifier
[ "Get", "object", "identifier" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L104-L111
train
vtkiorg/vtki
vtki/export.py
dump_data_array
def dump_data_array(dataset_dir, data_dir, array, root=None, compress=True): """Dump vtkjs data arry""" if root is None: root = {} if not array: return None if array.GetDataType() == 12: # IdType need to be converted to Uint32 array_size = array.GetNumberOfTuples() * arr...
python
def dump_data_array(dataset_dir, data_dir, array, root=None, compress=True): """Dump vtkjs data arry""" if root is None: root = {} if not array: return None if array.GetDataType() == 12: # IdType need to be converted to Uint32 array_size = array.GetNumberOfTuples() * arr...
[ "def", "dump_data_array", "(", "dataset_dir", ",", "data_dir", ",", "array", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "if", "not", "array", ":", "return", "None", "if", ...
Dump vtkjs data arry
[ "Dump", "vtkjs", "data", "arry" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L116-L160
train
vtkiorg/vtki
vtki/export.py
dump_color_array
def dump_color_array(dataset_dir, data_dir, color_array_info, root=None, compress=True): """Dump vtkjs color array""" if root is None: root = {} root['pointData'] = { 'vtkClass': 'vtkDataSetAttributes', "activeGlobalIds": -1, "activeNormals": -1, "activePedigreeIds": ...
python
def dump_color_array(dataset_dir, data_dir, color_array_info, root=None, compress=True): """Dump vtkjs color array""" if root is None: root = {} root['pointData'] = { 'vtkClass': 'vtkDataSetAttributes', "activeGlobalIds": -1, "activeNormals": -1, "activePedigreeIds": ...
[ "def", "dump_color_array", "(", "dataset_dir", ",", "data_dir", ",", "color_array_info", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "root", "[", "'pointData'", "]", "=", "{"...
Dump vtkjs color array
[ "Dump", "vtkjs", "color", "array" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L165-L212
train
vtkiorg/vtki
vtki/export.py
dump_t_coords
def dump_t_coords(dataset_dir, data_dir, dataset, root=None, compress=True): """dump vtkjs texture coordinates""" if root is None: root = {} tcoords = dataset.GetPointData().GetTCoords() if tcoords: dumped_array = dump_data_array(dataset_dir, data_dir, tcoords, {}, compress) root...
python
def dump_t_coords(dataset_dir, data_dir, dataset, root=None, compress=True): """dump vtkjs texture coordinates""" if root is None: root = {} tcoords = dataset.GetPointData().GetTCoords() if tcoords: dumped_array = dump_data_array(dataset_dir, data_dir, tcoords, {}, compress) root...
[ "def", "dump_t_coords", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "tcoords", "=", "dataset", ".", "GetPointData", "(", ...
dump vtkjs texture coordinates
[ "dump", "vtkjs", "texture", "coordinates" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L217-L225
train
vtkiorg/vtki
vtki/export.py
dump_normals
def dump_normals(dataset_dir, data_dir, dataset, root=None, compress=True): """dump vtkjs normal vectors""" if root is None: root = {} normals = dataset.GetPointData().GetNormals() if normals: dumped_array = dump_data_array(dataset_dir, data_dir, normals, {}, compress) root['poin...
python
def dump_normals(dataset_dir, data_dir, dataset, root=None, compress=True): """dump vtkjs normal vectors""" if root is None: root = {} normals = dataset.GetPointData().GetNormals() if normals: dumped_array = dump_data_array(dataset_dir, data_dir, normals, {}, compress) root['poin...
[ "def", "dump_normals", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "normals", "=", "dataset", ".", "GetPointData", "(", ...
dump vtkjs normal vectors
[ "dump", "vtkjs", "normal", "vectors" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L230-L238
train
vtkiorg/vtki
vtki/export.py
dump_all_arrays
def dump_all_arrays(dataset_dir, data_dir, dataset, root=None, compress=True): """Dump all data arrays to vtkjs""" if root is None: root = {} root['pointData'] = { 'vtkClass': 'vtkDataSetAttributes', "activeGlobalIds": -1, "activeNormals": -1, "activePedigreeIds": -1,...
python
def dump_all_arrays(dataset_dir, data_dir, dataset, root=None, compress=True): """Dump all data arrays to vtkjs""" if root is None: root = {} root['pointData'] = { 'vtkClass': 'vtkDataSetAttributes', "activeGlobalIds": -1, "activeNormals": -1, "activePedigreeIds": -1,...
[ "def", "dump_all_arrays", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "root", "[", "'pointData'", "]", "=", "{", "'vtkC...
Dump all data arrays to vtkjs
[ "Dump", "all", "data", "arrays", "to", "vtkjs" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L243-L303
train
vtkiorg/vtki
vtki/export.py
dump_poly_data
def dump_poly_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True): """Dump poly data object to vtkjs""" if root is None: root = {} root['vtkClass'] = 'vtkPolyData' container = root # Points points = dump_data_array(dataset_dir, data_dir, ...
python
def dump_poly_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True): """Dump poly data object to vtkjs""" if root is None: root = {} root['vtkClass'] = 'vtkPolyData' container = root # Points points = dump_data_array(dataset_dir, data_dir, ...
[ "def", "dump_poly_data", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "color_array_info", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "root", "[", "'vtkClass'", ...
Dump poly data object to vtkjs
[ "Dump", "poly", "data", "object", "to", "vtkjs" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L308-L358
train
vtkiorg/vtki
vtki/export.py
dump_image_data
def dump_image_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True): """Dump image data object to vtkjs""" if root is None: root = {} root['vtkClass'] = 'vtkImageData' container = root container['spacing'] = dataset.GetSpacing() container['origin'] = dataset....
python
def dump_image_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True): """Dump image data object to vtkjs""" if root is None: root = {} root['vtkClass'] = 'vtkImageData' container = root container['spacing'] = dataset.GetSpacing() container['origin'] = dataset....
[ "def", "dump_image_data", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "color_array_info", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "root", "[", "'vtkClass'", ...
Dump image data object to vtkjs
[ "Dump", "image", "data", "object", "to", "vtkjs" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L366-L379
train
vtkiorg/vtki
vtki/export.py
write_data_set
def write_data_set(file_path, dataset, output_dir, color_array_info, new_name=None, compress=True): """write dataset to vtkjs""" fileName = new_name if new_name else os.path.basename(file_path) dataset_dir = os.path.join(output_dir, fileName) data_dir = os.path.join(dataset_dir, 'data') if not os.p...
python
def write_data_set(file_path, dataset, output_dir, color_array_info, new_name=None, compress=True): """write dataset to vtkjs""" fileName = new_name if new_name else os.path.basename(file_path) dataset_dir = os.path.join(output_dir, fileName) data_dir = os.path.join(dataset_dir, 'data') if not os.p...
[ "def", "write_data_set", "(", "file_path", ",", "dataset", ",", "output_dir", ",", "color_array_info", ",", "new_name", "=", "None", ",", "compress", "=", "True", ")", ":", "fileName", "=", "new_name", "if", "new_name", "else", "os", ".", "path", ".", "bas...
write dataset to vtkjs
[ "write", "dataset", "to", "vtkjs" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L387-L409
train
vtkiorg/vtki
vtki/common.py
Common.active_vectors
def active_vectors(self): """The active vectors array""" field, name = self.active_vectors_info if name: if field is POINT_DATA_FIELD: return self.point_arrays[name] if field is CELL_DATA_FIELD: return self.cell_arrays[name]
python
def active_vectors(self): """The active vectors array""" field, name = self.active_vectors_info if name: if field is POINT_DATA_FIELD: return self.point_arrays[name] if field is CELL_DATA_FIELD: return self.cell_arrays[name]
[ "def", "active_vectors", "(", "self", ")", ":", "field", ",", "name", "=", "self", ".", "active_vectors_info", "if", "name", ":", "if", "field", "is", "POINT_DATA_FIELD", ":", "return", "self", ".", "point_arrays", "[", "name", "]", "if", "field", "is", ...
The active vectors array
[ "The", "active", "vectors", "array" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L81-L88
train
vtkiorg/vtki
vtki/common.py
Common.arrows
def arrows(self): """ Returns a glyph representation of the active vector data as arrows. Arrows will be located at the points of the mesh and their size will be dependent on the length of the vector. Their direction will be the "direction" of the vector Returns ...
python
def arrows(self): """ Returns a glyph representation of the active vector data as arrows. Arrows will be located at the points of the mesh and their size will be dependent on the length of the vector. Their direction will be the "direction" of the vector Returns ...
[ "def", "arrows", "(", "self", ")", ":", "if", "self", ".", "active_vectors", "is", "None", ":", "return", "arrow", "=", "vtk", ".", "vtkArrowSource", "(", ")", "arrow", ".", "Update", "(", ")", "alg", "=", "vtk", ".", "vtkGlyph3D", "(", ")", "alg", ...
Returns a glyph representation of the active vector data as arrows. Arrows will be located at the points of the mesh and their size will be dependent on the length of the vector. Their direction will be the "direction" of the vector Returns ------- arrows : vtki.PolyDat...
[ "Returns", "a", "glyph", "representation", "of", "the", "active", "vector", "data", "as", "arrows", ".", "Arrows", "will", "be", "located", "at", "the", "points", "of", "the", "mesh", "and", "their", "size", "will", "be", "dependent", "on", "the", "length"...
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L128-L153
train
vtkiorg/vtki
vtki/common.py
Common.vectors
def vectors(self, array): """ Sets the active vector """ if array.ndim != 2: raise AssertionError('vector array must be a 2-dimensional array') elif array.shape[1] != 3: raise RuntimeError('vector array must be 3D') elif array.shape[0] != self.n_points: ...
python
def vectors(self, array): """ Sets the active vector """ if array.ndim != 2: raise AssertionError('vector array must be a 2-dimensional array') elif array.shape[1] != 3: raise RuntimeError('vector array must be 3D') elif array.shape[0] != self.n_points: ...
[ "def", "vectors", "(", "self", ",", "array", ")", ":", "if", "array", ".", "ndim", "!=", "2", ":", "raise", "AssertionError", "(", "'vector array must be a 2-dimensional array'", ")", "elif", "array", ".", "shape", "[", "1", "]", "!=", "3", ":", "raise", ...
Sets the active vector
[ "Sets", "the", "active", "vector" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L161-L171
train
vtkiorg/vtki
vtki/common.py
Common.t_coords
def t_coords(self, t_coords): """Set the array to use as the texture coordinates""" if not isinstance(t_coords, np.ndarray): raise TypeError('Texture coordinates must be a numpy array') if t_coords.ndim != 2: raise AssertionError('Texture coordinates must be a 2-dimension...
python
def t_coords(self, t_coords): """Set the array to use as the texture coordinates""" if not isinstance(t_coords, np.ndarray): raise TypeError('Texture coordinates must be a numpy array') if t_coords.ndim != 2: raise AssertionError('Texture coordinates must be a 2-dimension...
[ "def", "t_coords", "(", "self", ",", "t_coords", ")", ":", "if", "not", "isinstance", "(", "t_coords", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "'Texture coordinates must be a numpy array'", ")", "if", "t_coords", ".", "ndim", "!=", "2...
Set the array to use as the texture coordinates
[ "Set", "the", "array", "to", "use", "as", "the", "texture", "coordinates" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L181-L198
train
vtkiorg/vtki
vtki/common.py
Common._activate_texture
def _activate_texture(mesh, name): """Grab a texture and update the active texture coordinates. This makes sure to not destroy old texture coordinates Parameters ---------- name : str The name of the texture and texture coordinates to activate Return ...
python
def _activate_texture(mesh, name): """Grab a texture and update the active texture coordinates. This makes sure to not destroy old texture coordinates Parameters ---------- name : str The name of the texture and texture coordinates to activate Return ...
[ "def", "_activate_texture", "(", "mesh", ",", "name", ")", ":", "if", "name", "==", "True", "or", "isinstance", "(", "name", ",", "int", ")", ":", "keys", "=", "list", "(", "mesh", ".", "textures", ".", "keys", "(", ")", ")", "# Grab the first name ava...
Grab a texture and update the active texture coordinates. This makes sure to not destroy old texture coordinates Parameters ---------- name : str The name of the texture and texture coordinates to activate Return ------ vtk.vtkTexture : The active te...
[ "Grab", "a", "texture", "and", "update", "the", "active", "texture", "coordinates", ".", "This", "makes", "sure", "to", "not", "destroy", "old", "texture", "coordinates" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L210-L248
train
vtkiorg/vtki
vtki/common.py
Common.set_active_scalar
def set_active_scalar(self, name, preference='cell'): """Finds the scalar by name and appropriately sets it as active""" _, field = get_scalar(self, name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.GetPointData().SetActiveScalars(name) elif field == ...
python
def set_active_scalar(self, name, preference='cell'): """Finds the scalar by name and appropriately sets it as active""" _, field = get_scalar(self, name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.GetPointData().SetActiveScalars(name) elif field == ...
[ "def", "set_active_scalar", "(", "self", ",", "name", ",", "preference", "=", "'cell'", ")", ":", "_", ",", "field", "=", "get_scalar", "(", "self", ",", "name", ",", "preference", "=", "preference", ",", "info", "=", "True", ")", "if", "field", "==", ...
Finds the scalar by name and appropriately sets it as active
[ "Finds", "the", "scalar", "by", "name", "and", "appropriately", "sets", "it", "as", "active" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L250-L259
train
vtkiorg/vtki
vtki/common.py
Common.set_active_vectors
def set_active_vectors(self, name, preference='cell'): """Finds the vectors by name and appropriately sets it as active""" _, field = get_scalar(self, name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.GetPointData().SetActiveVectors(name) elif field =...
python
def set_active_vectors(self, name, preference='cell'): """Finds the vectors by name and appropriately sets it as active""" _, field = get_scalar(self, name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.GetPointData().SetActiveVectors(name) elif field =...
[ "def", "set_active_vectors", "(", "self", ",", "name", ",", "preference", "=", "'cell'", ")", ":", "_", ",", "field", "=", "get_scalar", "(", "self", ",", "name", ",", "preference", "=", "preference", ",", "info", "=", "True", ")", "if", "field", "==",...
Finds the vectors by name and appropriately sets it as active
[ "Finds", "the", "vectors", "by", "name", "and", "appropriately", "sets", "it", "as", "active" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L261-L270
train
vtkiorg/vtki
vtki/common.py
Common.rename_scalar
def rename_scalar(self, old_name, new_name, preference='cell'): """Changes array name by searching for the array then renaming it""" _, field = get_scalar(self, old_name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.point_arrays[new_name] = self.point_arrays.p...
python
def rename_scalar(self, old_name, new_name, preference='cell'): """Changes array name by searching for the array then renaming it""" _, field = get_scalar(self, old_name, preference=preference, info=True) if field == POINT_DATA_FIELD: self.point_arrays[new_name] = self.point_arrays.p...
[ "def", "rename_scalar", "(", "self", ",", "old_name", ",", "new_name", ",", "preference", "=", "'cell'", ")", ":", "_", ",", "field", "=", "get_scalar", "(", "self", ",", "old_name", ",", "preference", "=", "preference", ",", "info", "=", "True", ")", ...
Changes array name by searching for the array then renaming it
[ "Changes", "array", "name", "by", "searching", "for", "the", "array", "then", "renaming", "it" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L272-L282
train
vtkiorg/vtki
vtki/common.py
Common.active_scalar
def active_scalar(self): """Returns the active scalar as an array""" field, name = self.active_scalar_info if name is None: return None if field == POINT_DATA_FIELD: return self._point_scalar(name) elif field == CELL_DATA_FIELD: return self._ce...
python
def active_scalar(self): """Returns the active scalar as an array""" field, name = self.active_scalar_info if name is None: return None if field == POINT_DATA_FIELD: return self._point_scalar(name) elif field == CELL_DATA_FIELD: return self._ce...
[ "def", "active_scalar", "(", "self", ")", ":", "field", ",", "name", "=", "self", ".", "active_scalar_info", "if", "name", "is", "None", ":", "return", "None", "if", "field", "==", "POINT_DATA_FIELD", ":", "return", "self", ".", "_point_scalar", "(", "name...
Returns the active scalar as an array
[ "Returns", "the", "active", "scalar", "as", "an", "array" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L285-L293
train
vtkiorg/vtki
vtki/common.py
Common._add_point_scalar
def _add_point_scalar(self, scalars, name, set_active=False, deep=True): """ Adds point scalars to the mesh Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars to ad...
python
def _add_point_scalar(self, scalars, name, set_active=False, deep=True): """ Adds point scalars to the mesh Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars to ad...
[ "def", "_add_point_scalar", "(", "self", ",", "scalars", ",", "name", ",", "set_active", "=", "False", ",", "deep", "=", "True", ")", ":", "if", "not", "isinstance", "(", "scalars", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "'Inpu...
Adds point scalars to the mesh Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars to add. set_active : bool, optional Sets the scalars to the active plotting s...
[ "Adds", "point", "scalars", "to", "the", "mesh" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L330-L372
train
vtkiorg/vtki
vtki/common.py
Common.points_to_double
def points_to_double(self): """ Makes points double precision """ if self.points.dtype != np.double: self.points = self.points.astype(np.double)
python
def points_to_double(self): """ Makes points double precision """ if self.points.dtype != np.double: self.points = self.points.astype(np.double)
[ "def", "points_to_double", "(", "self", ")", ":", "if", "self", ".", "points", ".", "dtype", "!=", "np", ".", "double", ":", "self", ".", "points", "=", "self", ".", "points", ".", "astype", "(", "np", ".", "double", ")" ]
Makes points double precision
[ "Makes", "points", "double", "precision" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L374-L377
train
vtkiorg/vtki
vtki/common.py
Common.rotate_x
def rotate_x(self, angle): """ Rotates mesh about the x-axis. Parameters ---------- angle : float Angle in degrees to rotate about the x-axis. """ axis_rotation(self.points, angle, inplace=True, axis='x')
python
def rotate_x(self, angle): """ Rotates mesh about the x-axis. Parameters ---------- angle : float Angle in degrees to rotate about the x-axis. """ axis_rotation(self.points, angle, inplace=True, axis='x')
[ "def", "rotate_x", "(", "self", ",", "angle", ")", ":", "axis_rotation", "(", "self", ".", "points", ",", "angle", ",", "inplace", "=", "True", ",", "axis", "=", "'x'", ")" ]
Rotates mesh about the x-axis. Parameters ---------- angle : float Angle in degrees to rotate about the x-axis.
[ "Rotates", "mesh", "about", "the", "x", "-", "axis", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L379-L389
train
vtkiorg/vtki
vtki/common.py
Common.rotate_y
def rotate_y(self, angle): """ Rotates mesh about the y-axis. Parameters ---------- angle : float Angle in degrees to rotate about the y-axis. """ axis_rotation(self.points, angle, inplace=True, axis='y')
python
def rotate_y(self, angle): """ Rotates mesh about the y-axis. Parameters ---------- angle : float Angle in degrees to rotate about the y-axis. """ axis_rotation(self.points, angle, inplace=True, axis='y')
[ "def", "rotate_y", "(", "self", ",", "angle", ")", ":", "axis_rotation", "(", "self", ".", "points", ",", "angle", ",", "inplace", "=", "True", ",", "axis", "=", "'y'", ")" ]
Rotates mesh about the y-axis. Parameters ---------- angle : float Angle in degrees to rotate about the y-axis.
[ "Rotates", "mesh", "about", "the", "y", "-", "axis", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L391-L401
train
vtkiorg/vtki
vtki/common.py
Common.rotate_z
def rotate_z(self, angle): """ Rotates mesh about the z-axis. Parameters ---------- angle : float Angle in degrees to rotate about the z-axis. """ axis_rotation(self.points, angle, inplace=True, axis='z')
python
def rotate_z(self, angle): """ Rotates mesh about the z-axis. Parameters ---------- angle : float Angle in degrees to rotate about the z-axis. """ axis_rotation(self.points, angle, inplace=True, axis='z')
[ "def", "rotate_z", "(", "self", ",", "angle", ")", ":", "axis_rotation", "(", "self", ".", "points", ",", "angle", ",", "inplace", "=", "True", ",", "axis", "=", "'z'", ")" ]
Rotates mesh about the z-axis. Parameters ---------- angle : float Angle in degrees to rotate about the z-axis.
[ "Rotates", "mesh", "about", "the", "z", "-", "axis", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L403-L413
train
vtkiorg/vtki
vtki/common.py
Common.transform
def transform(self, trans): """ Compute a transformation in place using a 4x4 transform. Parameters ---------- trans : vtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray Accepts a vtk transformation object or a 4x4 transformation matrix. """ if isinst...
python
def transform(self, trans): """ Compute a transformation in place using a 4x4 transform. Parameters ---------- trans : vtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray Accepts a vtk transformation object or a 4x4 transformation matrix. """ if isinst...
[ "def", "transform", "(", "self", ",", "trans", ")", ":", "if", "isinstance", "(", "trans", ",", "vtk", ".", "vtkMatrix4x4", ")", ":", "t", "=", "vtki", ".", "trans_from_matrix", "(", "trans", ")", "elif", "isinstance", "(", "trans", ",", "vtk", ".", ...
Compute a transformation in place using a 4x4 transform. Parameters ---------- trans : vtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray Accepts a vtk transformation object or a 4x4 transformation matrix.
[ "Compute", "a", "transformation", "in", "place", "using", "a", "4x4", "transform", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L427-L458
train
vtkiorg/vtki
vtki/common.py
Common._cell_scalar
def _cell_scalar(self, name=None): """ Returns the cell scalars of a vtk object Parameters ---------- name : str Name of cell scalars to retrive. Returns ------- scalars : np.ndarray Numpy array of scalars """ if ...
python
def _cell_scalar(self, name=None): """ Returns the cell scalars of a vtk object Parameters ---------- name : str Name of cell scalars to retrive. Returns ------- scalars : np.ndarray Numpy array of scalars """ if ...
[ "def", "_cell_scalar", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "# use active scalar array", "field", ",", "name", "=", "self", ".", "active_scalar_info", "if", "field", "!=", "CELL_DATA_FIELD", ":", "raise", "Runtime...
Returns the cell scalars of a vtk object Parameters ---------- name : str Name of cell scalars to retrive. Returns ------- scalars : np.ndarray Numpy array of scalars
[ "Returns", "the", "cell", "scalars", "of", "a", "vtk", "object" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L460-L494
train
vtkiorg/vtki
vtki/common.py
Common._add_cell_scalar
def _add_cell_scalar(self, scalars, name, set_active=False, deep=True): """ Adds cell scalars to the vtk object. Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars ...
python
def _add_cell_scalar(self, scalars, name, set_active=False, deep=True): """ Adds cell scalars to the vtk object. Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars ...
[ "def", "_add_cell_scalar", "(", "self", ",", "scalars", ",", "name", ",", "set_active", "=", "False", ",", "deep", "=", "True", ")", ":", "if", "not", "isinstance", "(", "scalars", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "'Input...
Adds cell scalars to the vtk object. Parameters ---------- scalars : numpy.ndarray Numpy array of scalars. Must match number of points. name : str Name of point scalars to add. set_active : bool, optional Sets the scalars to the active plot...
[ "Adds", "cell", "scalars", "to", "the", "vtk", "object", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L496-L534
train
vtkiorg/vtki
vtki/common.py
Common.copy_meta_from
def copy_meta_from(self, ido): """Copies vtki meta data onto this object from another object""" self._active_scalar_info = ido.active_scalar_info self._active_vectors_info = ido.active_vectors_info if hasattr(ido, '_textures'): self._textures = ido._textures
python
def copy_meta_from(self, ido): """Copies vtki meta data onto this object from another object""" self._active_scalar_info = ido.active_scalar_info self._active_vectors_info = ido.active_vectors_info if hasattr(ido, '_textures'): self._textures = ido._textures
[ "def", "copy_meta_from", "(", "self", ",", "ido", ")", ":", "self", ".", "_active_scalar_info", "=", "ido", ".", "active_scalar_info", "self", ".", "_active_vectors_info", "=", "ido", ".", "active_vectors_info", "if", "hasattr", "(", "ido", ",", "'_textures'", ...
Copies vtki meta data onto this object from another object
[ "Copies", "vtki", "meta", "data", "onto", "this", "object", "from", "another", "object" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L536-L541
train
vtkiorg/vtki
vtki/common.py
Common.copy
def copy(self, deep=True): """ Returns a copy of the object Parameters ---------- deep : bool, optional When True makes a full copy of the object. Returns ------- newobject : same as input Deep or shallow copy of the input. ...
python
def copy(self, deep=True): """ Returns a copy of the object Parameters ---------- deep : bool, optional When True makes a full copy of the object. Returns ------- newobject : same as input Deep or shallow copy of the input. ...
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ")", ":", "thistype", "=", "type", "(", "self", ")", "newobject", "=", "thistype", "(", ")", "if", "deep", ":", "newobject", ".", "DeepCopy", "(", "self", ")", "else", ":", "newobject", ".", "Sh...
Returns a copy of the object Parameters ---------- deep : bool, optional When True makes a full copy of the object. Returns ------- newobject : same as input Deep or shallow copy of the input.
[ "Returns", "a", "copy", "of", "the", "object" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L543-L564
train
vtkiorg/vtki
vtki/common.py
Common.point_arrays
def point_arrays(self): """ Returns the all point arrays """ pdata = self.GetPointData() narr = pdata.GetNumberOfArrays() # Update data if necessary if hasattr(self, '_point_arrays'): keys = list(self._point_arrays.keys()) if narr == len(keys): ...
python
def point_arrays(self): """ Returns the all point arrays """ pdata = self.GetPointData() narr = pdata.GetNumberOfArrays() # Update data if necessary if hasattr(self, '_point_arrays'): keys = list(self._point_arrays.keys()) if narr == len(keys): ...
[ "def", "point_arrays", "(", "self", ")", ":", "pdata", "=", "self", ".", "GetPointData", "(", ")", "narr", "=", "pdata", ".", "GetNumberOfArrays", "(", ")", "# Update data if necessary", "if", "hasattr", "(", "self", ",", "'_point_arrays'", ")", ":", "keys",...
Returns the all point arrays
[ "Returns", "the", "all", "point", "arrays" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L572-L595
train
vtkiorg/vtki
vtki/common.py
Common.cell_arrays
def cell_arrays(self): """ Returns the all cell arrays """ cdata = self.GetCellData() narr = cdata.GetNumberOfArrays() # Update data if necessary if hasattr(self, '_cell_arrays'): keys = list(self._cell_arrays.keys()) if narr == len(keys): ...
python
def cell_arrays(self): """ Returns the all cell arrays """ cdata = self.GetCellData() narr = cdata.GetNumberOfArrays() # Update data if necessary if hasattr(self, '_cell_arrays'): keys = list(self._cell_arrays.keys()) if narr == len(keys): ...
[ "def", "cell_arrays", "(", "self", ")", ":", "cdata", "=", "self", ".", "GetCellData", "(", ")", "narr", "=", "cdata", ".", "GetNumberOfArrays", "(", ")", "# Update data if necessary", "if", "hasattr", "(", "self", ",", "'_cell_arrays'", ")", ":", "keys", ...
Returns the all cell arrays
[ "Returns", "the", "all", "cell", "arrays" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L602-L625
train
vtkiorg/vtki
vtki/common.py
Common.get_data_range
def get_data_range(self, arr=None, preference='cell'): """Get the non-NaN min and max of a named scalar array Parameters ---------- arr : str, np.ndarray, optional The name of the array to get the range. If None, the active scalar is used preference : st...
python
def get_data_range(self, arr=None, preference='cell'): """Get the non-NaN min and max of a named scalar array Parameters ---------- arr : str, np.ndarray, optional The name of the array to get the range. If None, the active scalar is used preference : st...
[ "def", "get_data_range", "(", "self", ",", "arr", "=", "None", ",", "preference", "=", "'cell'", ")", ":", "if", "arr", "is", "None", ":", "# use active scalar array", "_", ",", "arr", "=", "self", ".", "active_scalar_info", "if", "isinstance", "(", "arr",...
Get the non-NaN min and max of a named scalar array Parameters ---------- arr : str, np.ndarray, optional The name of the array to get the range. If None, the active scalar is used preference : str, optional When scalars is specified, this is the per...
[ "Get", "the", "non", "-", "NaN", "min", "and", "max", "of", "a", "named", "scalar", "array" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L685-L708
train
vtkiorg/vtki
vtki/common.py
Common.scalar_names
def scalar_names(self): """A list of scalar names for the dataset. This makes sure to put the active scalar's name first in the list.""" names = [] for i in range(self.GetPointData().GetNumberOfArrays()): names.append(self.GetPointData().GetArrayName(i)) for i in rang...
python
def scalar_names(self): """A list of scalar names for the dataset. This makes sure to put the active scalar's name first in the list.""" names = [] for i in range(self.GetPointData().GetNumberOfArrays()): names.append(self.GetPointData().GetArrayName(i)) for i in rang...
[ "def", "scalar_names", "(", "self", ")", ":", "names", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "GetPointData", "(", ")", ".", "GetNumberOfArrays", "(", ")", ")", ":", "names", ".", "append", "(", "self", ".", "GetPointData", "(", ...
A list of scalar names for the dataset. This makes sure to put the active scalar's name first in the list.
[ "A", "list", "of", "scalar", "names", "for", "the", "dataset", ".", "This", "makes", "sure", "to", "put", "the", "active", "scalar", "s", "name", "first", "in", "the", "list", "." ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L749-L762
train
vtkiorg/vtki
vtki/common.py
Common.head
def head(self, display=True, html=None): """Return the header stats of this dataset. If in IPython, this will be formatted to HTML. Otherwise returns a console friendly string""" # Generate the output if html: fmt = "" # HTML version fmt += "\n" ...
python
def head(self, display=True, html=None): """Return the header stats of this dataset. If in IPython, this will be formatted to HTML. Otherwise returns a console friendly string""" # Generate the output if html: fmt = "" # HTML version fmt += "\n" ...
[ "def", "head", "(", "self", ",", "display", "=", "True", ",", "html", "=", "None", ")", ":", "# Generate the output", "if", "html", ":", "fmt", "=", "\"\"", "# HTML version", "fmt", "+=", "\"\\n\"", "fmt", "+=", "\"<table>\\n\"", "fmt", "+=", "\"<tr><th>{}...
Return the header stats of this dataset. If in IPython, this will be formatted to HTML. Otherwise returns a console friendly string
[ "Return", "the", "header", "stats", "of", "this", "dataset", ".", "If", "in", "IPython", "this", "will", "be", "formatted", "to", "HTML", ".", "Otherwise", "returns", "a", "console", "friendly", "string" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L779-L814
train
vtkiorg/vtki
vtki/common.py
Common._repr_html_
def _repr_html_(self): """A pretty representation for Jupyter notebooks that includes header details and information about all scalar arrays""" fmt = "" if self.n_scalars > 0: fmt += "<table>" fmt += "<tr><th>Header</th><th>Data Arrays</th></tr>" fmt +...
python
def _repr_html_(self): """A pretty representation for Jupyter notebooks that includes header details and information about all scalar arrays""" fmt = "" if self.n_scalars > 0: fmt += "<table>" fmt += "<tr><th>Header</th><th>Data Arrays</th></tr>" fmt +...
[ "def", "_repr_html_", "(", "self", ")", ":", "fmt", "=", "\"\"", "if", "self", ".", "n_scalars", ">", "0", ":", "fmt", "+=", "\"<table>\"", "fmt", "+=", "\"<tr><th>Header</th><th>Data Arrays</th></tr>\"", "fmt", "+=", "\"<tr><td>\"", "# Get the header info", "fmt"...
A pretty representation for Jupyter notebooks that includes header details and information about all scalar arrays
[ "A", "pretty", "representation", "for", "Jupyter", "notebooks", "that", "includes", "header", "details", "and", "information", "about", "all", "scalar", "arrays" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L817-L853
train
vtkiorg/vtki
vtki/common.py
Common.overwrite
def overwrite(self, mesh): """ Overwrites this mesh inplace with the new mesh's geometries and data Parameters ---------- mesh : vtk.vtkDataSet The overwriting mesh. """ self.DeepCopy(mesh) if is_vtki_obj(mesh): self.copy_meta_fro...
python
def overwrite(self, mesh): """ Overwrites this mesh inplace with the new mesh's geometries and data Parameters ---------- mesh : vtk.vtkDataSet The overwriting mesh. """ self.DeepCopy(mesh) if is_vtki_obj(mesh): self.copy_meta_fro...
[ "def", "overwrite", "(", "self", ",", "mesh", ")", ":", "self", ".", "DeepCopy", "(", "mesh", ")", "if", "is_vtki_obj", "(", "mesh", ")", ":", "self", ".", "copy_meta_from", "(", "mesh", ")" ]
Overwrites this mesh inplace with the new mesh's geometries and data Parameters ---------- mesh : vtk.vtkDataSet The overwriting mesh.
[ "Overwrites", "this", "mesh", "inplace", "with", "the", "new", "mesh", "s", "geometries", "and", "data" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L864-L876
train
vtkiorg/vtki
vtki/common.py
_ScalarsDict.pop
def pop(self, key): """Get and remove an element by key name""" arr = dict.pop(self, key).copy() self.remover(key) return arr
python
def pop(self, key): """Get and remove an element by key name""" arr = dict.pop(self, key).copy() self.remover(key) return arr
[ "def", "pop", "(", "self", ",", "key", ")", ":", "arr", "=", "dict", ".", "pop", "(", "self", ",", "key", ")", ".", "copy", "(", ")", "self", ".", "remover", "(", "key", ")", "return", "arr" ]
Get and remove an element by key name
[ "Get", "and", "remove", "an", "element", "by", "key", "name" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L901-L905
train
vtkiorg/vtki
vtki/common.py
_ScalarsDict.update
def update(self, data): """ Update this dictionary with th key-value pairs from a given dictionary """ if not isinstance(data, dict): raise TypeError('Data to update must be in a dictionary.') for k, v in data.items(): arr = np.array(v) ...
python
def update(self, data): """ Update this dictionary with th key-value pairs from a given dictionary """ if not isinstance(data, dict): raise TypeError('Data to update must be in a dictionary.') for k, v in data.items(): arr = np.array(v) ...
[ "def", "update", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "'Data to update must be in a dictionary.'", ")", "for", "k", ",", "v", "in", "data", ".", "items", "(", ")", ...
Update this dictionary with th key-value pairs from a given dictionary
[ "Update", "this", "dictionary", "with", "th", "key", "-", "value", "pairs", "from", "a", "given", "dictionary" ]
5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L907-L920
train
chardet/chardet
convert_language_model.py
convert_sbcs_model
def convert_sbcs_model(old_model, alphabet): """Create a SingleByteCharSetModel object representing the charset.""" # Setup tables necessary for computing transition frequencies for model char_to_order = {i: order for i, order in enumerate(old_model['char_to_order_map'])} pos_ratio ...
python
def convert_sbcs_model(old_model, alphabet): """Create a SingleByteCharSetModel object representing the charset.""" # Setup tables necessary for computing transition frequencies for model char_to_order = {i: order for i, order in enumerate(old_model['char_to_order_map'])} pos_ratio ...
[ "def", "convert_sbcs_model", "(", "old_model", ",", "alphabet", ")", ":", "# Setup tables necessary for computing transition frequencies for model", "char_to_order", "=", "{", "i", ":", "order", "for", "i", ",", "order", "in", "enumerate", "(", "old_model", "[", "'cha...
Create a SingleByteCharSetModel object representing the charset.
[ "Create", "a", "SingleByteCharSetModel", "object", "representing", "the", "charset", "." ]
b5194bf8250b7d180ac4edff51e09cab9d99febe
https://github.com/chardet/chardet/blob/b5194bf8250b7d180ac4edff51e09cab9d99febe/convert_language_model.py#L57-L73
train
chardet/chardet
bench.py
get_py_impl
def get_py_impl(): """Return what kind of Python this is""" if hasattr(sys, 'pypy_version_info'): pyimpl = 'PyPy' elif sys.platform.startswith('java'): pyimpl = 'Jython' elif sys.platform == 'cli': pyimpl = 'IronPython' else: pyimpl = 'CPython' return pyimpl
python
def get_py_impl(): """Return what kind of Python this is""" if hasattr(sys, 'pypy_version_info'): pyimpl = 'PyPy' elif sys.platform.startswith('java'): pyimpl = 'Jython' elif sys.platform == 'cli': pyimpl = 'IronPython' else: pyimpl = 'CPython' return pyimpl
[ "def", "get_py_impl", "(", ")", ":", "if", "hasattr", "(", "sys", ",", "'pypy_version_info'", ")", ":", "pyimpl", "=", "'PyPy'", "elif", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", ":", "pyimpl", "=", "'Jython'", "elif", "sys", ".", ...
Return what kind of Python this is
[ "Return", "what", "kind", "of", "Python", "this", "is" ]
b5194bf8250b7d180ac4edff51e09cab9d99febe
https://github.com/chardet/chardet/blob/b5194bf8250b7d180ac4edff51e09cab9d99febe/bench.py#L36-L46
train
chardet/chardet
chardet/__init__.py
detect_all
def detect_all(byte_str): """ Detect all the possible encodings of the given byte string. :param byte_str: The byte sequence to examine. :type byte_str: ``bytes`` or ``bytearray`` """ if not isinstance(byte_str, bytearray): if not isinstance(byte_str, bytes): raise ...
python
def detect_all(byte_str): """ Detect all the possible encodings of the given byte string. :param byte_str: The byte sequence to examine. :type byte_str: ``bytes`` or ``bytearray`` """ if not isinstance(byte_str, bytearray): if not isinstance(byte_str, bytes): raise ...
[ "def", "detect_all", "(", "byte_str", ")", ":", "if", "not", "isinstance", "(", "byte_str", ",", "bytearray", ")", ":", "if", "not", "isinstance", "(", "byte_str", ",", "bytes", ")", ":", "raise", "TypeError", "(", "'Expected object of type bytes or bytearray, g...
Detect all the possible encodings of the given byte string. :param byte_str: The byte sequence to examine. :type byte_str: ``bytes`` or ``bytearray``
[ "Detect", "all", "the", "possible", "encodings", "of", "the", "given", "byte", "string", "." ]
b5194bf8250b7d180ac4edff51e09cab9d99febe
https://github.com/chardet/chardet/blob/b5194bf8250b7d180ac4edff51e09cab9d99febe/chardet/__init__.py#L45-L82
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
geojson_to_wkt
def geojson_to_wkt(geojson_obj, feature_number=0, decimals=4): """Convert a GeoJSON object to Well-Known Text. Intended for use with OpenSearch queries. In case of FeatureCollection, only one of the features is used (the first by default). 3D points are converted to 2D. Parameters ---------- g...
python
def geojson_to_wkt(geojson_obj, feature_number=0, decimals=4): """Convert a GeoJSON object to Well-Known Text. Intended for use with OpenSearch queries. In case of FeatureCollection, only one of the features is used (the first by default). 3D points are converted to 2D. Parameters ---------- g...
[ "def", "geojson_to_wkt", "(", "geojson_obj", ",", "feature_number", "=", "0", ",", "decimals", "=", "4", ")", ":", "if", "'coordinates'", "in", "geojson_obj", ":", "geometry", "=", "geojson_obj", "elif", "'geometry'", "in", "geojson_obj", ":", "geometry", "=",...
Convert a GeoJSON object to Well-Known Text. Intended for use with OpenSearch queries. In case of FeatureCollection, only one of the features is used (the first by default). 3D points are converted to 2D. Parameters ---------- geojson_obj : dict a GeoJSON object feature_number : int, o...
[ "Convert", "a", "GeoJSON", "object", "to", "Well", "-", "Known", "Text", ".", "Intended", "for", "use", "with", "OpenSearch", "queries", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L889-L940
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
_check_scihub_response
def _check_scihub_response(response, test_json=True): """Check that the response from server has status code 2xx and that the response is valid JSON. """ # Prevent requests from needing to guess the encoding # SciHub appears to be using UTF-8 in all of their responses response.encoding = 'utf-8' ...
python
def _check_scihub_response(response, test_json=True): """Check that the response from server has status code 2xx and that the response is valid JSON. """ # Prevent requests from needing to guess the encoding # SciHub appears to be using UTF-8 in all of their responses response.encoding = 'utf-8' ...
[ "def", "_check_scihub_response", "(", "response", ",", "test_json", "=", "True", ")", ":", "# Prevent requests from needing to guess the encoding", "# SciHub appears to be using UTF-8 in all of their responses", "response", ".", "encoding", "=", "'utf-8'", "try", ":", "response...
Check that the response from server has status code 2xx and that the response is valid JSON.
[ "Check", "that", "the", "response", "from", "server", "has", "status", "code", "2xx", "and", "that", "the", "response", "is", "valid", "JSON", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L997-L1027
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
_parse_odata_timestamp
def _parse_odata_timestamp(in_date): """Convert the timestamp received from OData JSON API to a datetime object. """ timestamp = int(in_date.replace('/Date(', '').replace(')/', '')) seconds = timestamp // 1000 ms = timestamp % 1000 return datetime.utcfromtimestamp(seconds) + timedelta(millisecon...
python
def _parse_odata_timestamp(in_date): """Convert the timestamp received from OData JSON API to a datetime object. """ timestamp = int(in_date.replace('/Date(', '').replace(')/', '')) seconds = timestamp // 1000 ms = timestamp % 1000 return datetime.utcfromtimestamp(seconds) + timedelta(millisecon...
[ "def", "_parse_odata_timestamp", "(", "in_date", ")", ":", "timestamp", "=", "int", "(", "in_date", ".", "replace", "(", "'/Date('", ",", "''", ")", ".", "replace", "(", "')/'", ",", "''", ")", ")", "seconds", "=", "timestamp", "//", "1000", "ms", "=",...
Convert the timestamp received from OData JSON API to a datetime object.
[ "Convert", "the", "timestamp", "received", "from", "OData", "JSON", "API", "to", "a", "datetime", "object", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L1066-L1072
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
_parse_opensearch_response
def _parse_opensearch_response(products): """Convert a query response to a dictionary. The resulting dictionary structure is {<product id>: {<property>: <value>}}. The property values are converted to their respective Python types unless `parse_values` is set to `False`. """ converters = {'dat...
python
def _parse_opensearch_response(products): """Convert a query response to a dictionary. The resulting dictionary structure is {<product id>: {<property>: <value>}}. The property values are converted to their respective Python types unless `parse_values` is set to `False`. """ converters = {'dat...
[ "def", "_parse_opensearch_response", "(", "products", ")", ":", "converters", "=", "{", "'date'", ":", "_parse_iso_date", ",", "'int'", ":", "int", ",", "'long'", ":", "int", ",", "'float'", ":", "float", ",", "'double'", ":", "float", "}", "# Keep the strin...
Convert a query response to a dictionary. The resulting dictionary structure is {<product id>: {<property>: <value>}}. The property values are converted to their respective Python types unless `parse_values` is set to `False`.
[ "Convert", "a", "query", "response", "to", "a", "dictionary", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L1075-L1116
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.query
def query(self, area=None, date=None, raw=None, area_relation='Intersects', order_by=None, limit=None, offset=0, **keywords): """Query the OpenSearch API with the coordinates of an area, a date interval and any other search keywords accepted by the API. Parameters --------...
python
def query(self, area=None, date=None, raw=None, area_relation='Intersects', order_by=None, limit=None, offset=0, **keywords): """Query the OpenSearch API with the coordinates of an area, a date interval and any other search keywords accepted by the API. Parameters --------...
[ "def", "query", "(", "self", ",", "area", "=", "None", ",", "date", "=", "None", ",", "raw", "=", "None", ",", "area_relation", "=", "'Intersects'", ",", "order_by", "=", "None", ",", "limit", "=", "None", ",", "offset", "=", "0", ",", "*", "*", ...
Query the OpenSearch API with the coordinates of an area, a date interval and any other search keywords accepted by the API. Parameters ---------- area : str, optional The area of interest formatted as a Well-Known Text string. date : tuple of (str or datetime) or st...
[ "Query", "the", "OpenSearch", "API", "with", "the", "coordinates", "of", "an", "area", "a", "date", "interval", "and", "any", "other", "search", "keywords", "accepted", "by", "the", "API", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L77-L149
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.format_query
def format_query(area=None, date=None, raw=None, area_relation='Intersects', **keywords): """Create a OpenSearch API query string. """ if area_relation.lower() not in {"intersects", "contains", "iswithin"}: raise ValueError("Incorrect AOI relation provided ({})"....
python
def format_query(area=None, date=None, raw=None, area_relation='Intersects', **keywords): """Create a OpenSearch API query string. """ if area_relation.lower() not in {"intersects", "contains", "iswithin"}: raise ValueError("Incorrect AOI relation provided ({})"....
[ "def", "format_query", "(", "area", "=", "None", ",", "date", "=", "None", ",", "raw", "=", "None", ",", "area_relation", "=", "'Intersects'", ",", "*", "*", "keywords", ")", ":", "if", "area_relation", ".", "lower", "(", ")", "not", "in", "{", "\"in...
Create a OpenSearch API query string.
[ "Create", "a", "OpenSearch", "API", "query", "string", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L152-L214
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.count
def count(self, area=None, date=None, raw=None, area_relation='Intersects', **keywords): """Get the number of products matching a query. Accepted parameters are identical to :meth:`SentinelAPI.query()`. This is a significantly more efficient alternative to doing `len(api.query())`, whi...
python
def count(self, area=None, date=None, raw=None, area_relation='Intersects', **keywords): """Get the number of products matching a query. Accepted parameters are identical to :meth:`SentinelAPI.query()`. This is a significantly more efficient alternative to doing `len(api.query())`, whi...
[ "def", "count", "(", "self", ",", "area", "=", "None", ",", "date", "=", "None", ",", "raw", "=", "None", ",", "area_relation", "=", "'Intersects'", ",", "*", "*", "keywords", ")", ":", "for", "kw", "in", "[", "'order_by'", ",", "'limit'", ",", "'o...
Get the number of products matching a query. Accepted parameters are identical to :meth:`SentinelAPI.query()`. This is a significantly more efficient alternative to doing `len(api.query())`, which can take minutes to run for queries matching thousands of products. Returns ----...
[ "Get", "the", "number", "of", "products", "matching", "a", "query", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L249-L269
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.to_geojson
def to_geojson(products): """Return the products from a query response as a GeoJSON with the values in their appropriate Python types. """ feature_list = [] for i, (product_id, props) in enumerate(products.items()): props = props.copy() props['id'] = produ...
python
def to_geojson(products): """Return the products from a query response as a GeoJSON with the values in their appropriate Python types. """ feature_list = [] for i, (product_id, props) in enumerate(products.items()): props = props.copy() props['id'] = produ...
[ "def", "to_geojson", "(", "products", ")", ":", "feature_list", "=", "[", "]", "for", "i", ",", "(", "product_id", ",", "props", ")", "in", "enumerate", "(", "products", ".", "items", "(", ")", ")", ":", "props", "=", "props", ".", "copy", "(", ")"...
Return the products from a query response as a GeoJSON with the values in their appropriate Python types.
[ "Return", "the", "products", "from", "a", "query", "response", "as", "a", "GeoJSON", "with", "the", "values", "in", "their", "appropriate", "Python", "types", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L340-L358
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.to_dataframe
def to_dataframe(products): """Return the products from a query response as a Pandas DataFrame with the values in their appropriate Python types. """ try: import pandas as pd except ImportError: raise ImportError("to_dataframe requires the optional depende...
python
def to_dataframe(products): """Return the products from a query response as a Pandas DataFrame with the values in their appropriate Python types. """ try: import pandas as pd except ImportError: raise ImportError("to_dataframe requires the optional depende...
[ "def", "to_dataframe", "(", "products", ")", ":", "try", ":", "import", "pandas", "as", "pd", "except", "ImportError", ":", "raise", "ImportError", "(", "\"to_dataframe requires the optional dependency Pandas.\"", ")", "return", "pd", ".", "DataFrame", ".", "from_di...
Return the products from a query response as a Pandas DataFrame with the values in their appropriate Python types.
[ "Return", "the", "products", "from", "a", "query", "response", "as", "a", "Pandas", "DataFrame", "with", "the", "values", "in", "their", "appropriate", "Python", "types", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L361-L370
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.to_geodataframe
def to_geodataframe(products): """Return the products from a query response as a GeoPandas GeoDataFrame with the values in their appropriate Python types. """ try: import geopandas as gpd import shapely.wkt except ImportError: raise ImportError...
python
def to_geodataframe(products): """Return the products from a query response as a GeoPandas GeoDataFrame with the values in their appropriate Python types. """ try: import geopandas as gpd import shapely.wkt except ImportError: raise ImportError...
[ "def", "to_geodataframe", "(", "products", ")", ":", "try", ":", "import", "geopandas", "as", "gpd", "import", "shapely", ".", "wkt", "except", "ImportError", ":", "raise", "ImportError", "(", "\"to_geodataframe requires the optional dependencies GeoPandas and Shapely.\""...
Return the products from a query response as a GeoPandas GeoDataFrame with the values in their appropriate Python types.
[ "Return", "the", "products", "from", "a", "query", "response", "as", "a", "GeoPandas", "GeoDataFrame", "with", "the", "values", "in", "their", "appropriate", "Python", "types", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L373-L391
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.get_product_odata
def get_product_odata(self, id, full=False): """Access OData API to get info about a product. Returns a dict containing the id, title, size, md5sum, date, footprint and download url of the product. The date field corresponds to the Start ContentDate value. If `full` is set to True, the...
python
def get_product_odata(self, id, full=False): """Access OData API to get info about a product. Returns a dict containing the id, title, size, md5sum, date, footprint and download url of the product. The date field corresponds to the Start ContentDate value. If `full` is set to True, the...
[ "def", "get_product_odata", "(", "self", ",", "id", ",", "full", "=", "False", ")", ":", "url", "=", "urljoin", "(", "self", ".", "api_url", ",", "u\"odata/v1/Products('{}')?$format=json\"", ".", "format", "(", "id", ")", ")", "if", "full", ":", "url", "...
Access OData API to get info about a product. Returns a dict containing the id, title, size, md5sum, date, footprint and download url of the product. The date field corresponds to the Start ContentDate value. If `full` is set to True, then the full, detailed metadata of the product is returned...
[ "Access", "OData", "API", "to", "get", "info", "about", "a", "product", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L393-L429
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI._trigger_offline_retrieval
def _trigger_offline_retrieval(self, url): """ Triggers retrieval of an offline product Trying to download an offline product triggers its retrieval from the long term archive. The returned HTTP status code conveys whether this was successful. Parameters ---------- url ...
python
def _trigger_offline_retrieval(self, url): """ Triggers retrieval of an offline product Trying to download an offline product triggers its retrieval from the long term archive. The returned HTTP status code conveys whether this was successful. Parameters ---------- url ...
[ "def", "_trigger_offline_retrieval", "(", "self", ",", "url", ")", ":", "with", "self", ".", "session", ".", "get", "(", "url", ",", "auth", "=", "self", ".", "session", ".", "auth", ",", "timeout", "=", "self", ".", "timeout", ")", "as", "r", ":", ...
Triggers retrieval of an offline product Trying to download an offline product triggers its retrieval from the long term archive. The returned HTTP status code conveys whether this was successful. Parameters ---------- url : string URL for downloading the product ...
[ "Triggers", "retrieval", "of", "an", "offline", "product" ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L431-L461
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.download
def download(self, id, directory_path='.', checksum=True): """Download a product. Uses the filename on the server for the downloaded file, e.g. "S1A_EW_GRDH_1SDH_20141003T003840_20141003T003920_002658_002F54_4DD1.zip". Incomplete downloads are continued and complete files are skipped. ...
python
def download(self, id, directory_path='.', checksum=True): """Download a product. Uses the filename on the server for the downloaded file, e.g. "S1A_EW_GRDH_1SDH_20141003T003840_20141003T003920_002658_002F54_4DD1.zip". Incomplete downloads are continued and complete files are skipped. ...
[ "def", "download", "(", "self", ",", "id", ",", "directory_path", "=", "'.'", ",", "checksum", "=", "True", ")", ":", "product_info", "=", "self", ".", "get_product_odata", "(", "id", ")", "path", "=", "join", "(", "directory_path", ",", "product_info", ...
Download a product. Uses the filename on the server for the downloaded file, e.g. "S1A_EW_GRDH_1SDH_20141003T003840_20141003T003920_002658_002F54_4DD1.zip". Incomplete downloads are continued and complete files are skipped. Parameters ---------- id : string ...
[ "Download", "a", "product", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L463-L552
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.download_all
def download_all(self, products, directory_path='.', max_attempts=10, checksum=True): """Download a list of products. Takes a list of product IDs as input. This means that the return value of query() can be passed directly to this method. File names on the server are used for the downl...
python
def download_all(self, products, directory_path='.', max_attempts=10, checksum=True): """Download a list of products. Takes a list of product IDs as input. This means that the return value of query() can be passed directly to this method. File names on the server are used for the downl...
[ "def", "download_all", "(", "self", ",", "products", ",", "directory_path", "=", "'.'", ",", "max_attempts", "=", "10", ",", "checksum", "=", "True", ")", ":", "product_ids", "=", "list", "(", "products", ")", "self", ".", "logger", ".", "info", "(", "...
Download a list of products. Takes a list of product IDs as input. This means that the return value of query() can be passed directly to this method. File names on the server are used for the downloaded files, e.g. "S1A_EW_GRDH_1SDH_20141003T003840_20141003T003920_002658_002F54_4DD1.zi...
[ "Download", "a", "list", "of", "products", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L554-L627
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.get_products_size
def get_products_size(products): """Return the total file size in GB of all products in the OpenSearch response.""" size_total = 0 for title, props in products.items(): size_product = props["size"] size_value = float(size_product.split(" ")[0]) size_unit = str...
python
def get_products_size(products): """Return the total file size in GB of all products in the OpenSearch response.""" size_total = 0 for title, props in products.items(): size_product = props["size"] size_value = float(size_product.split(" ")[0]) size_unit = str...
[ "def", "get_products_size", "(", "products", ")", ":", "size_total", "=", "0", "for", "title", ",", "props", "in", "products", ".", "items", "(", ")", ":", "size_product", "=", "props", "[", "\"size\"", "]", "size_value", "=", "float", "(", "size_product",...
Return the total file size in GB of all products in the OpenSearch response.
[ "Return", "the", "total", "file", "size", "in", "GB", "of", "all", "products", "in", "the", "OpenSearch", "response", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L630-L642
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI.check_files
def check_files(self, paths=None, ids=None, directory=None, delete=False): """Verify the integrity of product files on disk. Integrity is checked by comparing the size and checksum of the file with the respective values on the server. The input can be a list of products to check or a l...
python
def check_files(self, paths=None, ids=None, directory=None, delete=False): """Verify the integrity of product files on disk. Integrity is checked by comparing the size and checksum of the file with the respective values on the server. The input can be a list of products to check or a l...
[ "def", "check_files", "(", "self", ",", "paths", "=", "None", ",", "ids", "=", "None", ",", "directory", "=", "None", ",", "delete", "=", "False", ")", ":", "if", "not", "ids", "and", "not", "paths", ":", "raise", "ValueError", "(", "\"Must provide eit...
Verify the integrity of product files on disk. Integrity is checked by comparing the size and checksum of the file with the respective values on the server. The input can be a list of products to check or a list of IDs and a directory. In cases where multiple products with different I...
[ "Verify", "the", "integrity", "of", "product", "files", "on", "disk", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L702-L793
train
sentinelsat/sentinelsat
sentinelsat/sentinel.py
SentinelAPI._md5_compare
def _md5_compare(self, file_path, checksum, block_size=2 ** 13): """Compare a given MD5 checksum with one calculated from a file.""" with closing(self._tqdm(desc="MD5 checksumming", total=getsize(file_path), unit="B", unit_scale=True)) as progress: md5 = hashl...
python
def _md5_compare(self, file_path, checksum, block_size=2 ** 13): """Compare a given MD5 checksum with one calculated from a file.""" with closing(self._tqdm(desc="MD5 checksumming", total=getsize(file_path), unit="B", unit_scale=True)) as progress: md5 = hashl...
[ "def", "_md5_compare", "(", "self", ",", "file_path", ",", "checksum", ",", "block_size", "=", "2", "**", "13", ")", ":", "with", "closing", "(", "self", ".", "_tqdm", "(", "desc", "=", "\"MD5 checksumming\"", ",", "total", "=", "getsize", "(", "file_pat...
Compare a given MD5 checksum with one calculated from a file.
[ "Compare", "a", "given", "MD5", "checksum", "with", "one", "calculated", "from", "a", "file", "." ]
eacfd79ff4e7e939147db9dfdd393c67d64eecaa
https://github.com/sentinelsat/sentinelsat/blob/eacfd79ff4e7e939147db9dfdd393c67d64eecaa/sentinelsat/sentinel.py#L795-L807
train
celery/django-celery
djcelery/managers.py
transaction_retry
def transaction_retry(max_retries=1): """Decorator for methods doing database operations. If the database operation fails, it will retry the operation at most ``max_retries`` times. """ def _outer(fun): @wraps(fun) def _inner(*args, **kwargs): _max_retries = kwargs.pop...
python
def transaction_retry(max_retries=1): """Decorator for methods doing database operations. If the database operation fails, it will retry the operation at most ``max_retries`` times. """ def _outer(fun): @wraps(fun) def _inner(*args, **kwargs): _max_retries = kwargs.pop...
[ "def", "transaction_retry", "(", "max_retries", "=", "1", ")", ":", "def", "_outer", "(", "fun", ")", ":", "@", "wraps", "(", "fun", ")", "def", "_inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_max_retries", "=", "kwargs", ".", "pop...
Decorator for methods doing database operations. If the database operation fails, it will retry the operation at most ``max_retries`` times.
[ "Decorator", "for", "methods", "doing", "database", "operations", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L31-L60
train
celery/django-celery
djcelery/managers.py
ResultManager.delete_expired
def delete_expired(self, expires): """Delete all expired taskset results.""" meta = self.model._meta with commit_on_success(): self.get_all_expired(expires).update(hidden=True) cursor = self.connection_for_write().cursor() cursor.execute( 'DELE...
python
def delete_expired(self, expires): """Delete all expired taskset results.""" meta = self.model._meta with commit_on_success(): self.get_all_expired(expires).update(hidden=True) cursor = self.connection_for_write().cursor() cursor.execute( 'DELE...
[ "def", "delete_expired", "(", "self", ",", "expires", ")", ":", "meta", "=", "self", ".", "model", ".", "_meta", "with", "commit_on_success", "(", ")", ":", "self", ".", "get_all_expired", "(", "expires", ")", ".", "update", "(", "hidden", "=", "True", ...
Delete all expired taskset results.
[ "Delete", "all", "expired", "taskset", "results", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L115-L124
train
celery/django-celery
djcelery/managers.py
TaskManager.get_task
def get_task(self, task_id): """Get task meta for task by ``task_id``. :keyword exception_retry_count: How many times to retry by transaction rollback on exception. This could theoretically happen in a race condition if another worker is trying to create the same tas...
python
def get_task(self, task_id): """Get task meta for task by ``task_id``. :keyword exception_retry_count: How many times to retry by transaction rollback on exception. This could theoretically happen in a race condition if another worker is trying to create the same tas...
[ "def", "get_task", "(", "self", ",", "task_id", ")", ":", "try", ":", "return", "self", ".", "get", "(", "task_id", "=", "task_id", ")", "except", "self", ".", "model", ".", "DoesNotExist", ":", "if", "self", ".", "_last_id", "==", "task_id", ":", "s...
Get task meta for task by ``task_id``. :keyword exception_retry_count: How many times to retry by transaction rollback on exception. This could theoretically happen in a race condition if another worker is trying to create the same task. The default is to retry once.
[ "Get", "task", "meta", "for", "task", "by", "task_id", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L140-L155
train
celery/django-celery
djcelery/managers.py
TaskManager.store_result
def store_result(self, task_id, result, status, traceback=None, children=None): """Store the result and status of a task. :param task_id: task id :param result: The return value of the task, or an exception instance raised by the task. :param status: T...
python
def store_result(self, task_id, result, status, traceback=None, children=None): """Store the result and status of a task. :param task_id: task id :param result: The return value of the task, or an exception instance raised by the task. :param status: T...
[ "def", "store_result", "(", "self", ",", "task_id", ",", "result", ",", "status", ",", "traceback", "=", "None", ",", "children", "=", "None", ")", ":", "return", "self", ".", "update_or_create", "(", "task_id", "=", "task_id", ",", "defaults", "=", "{",...
Store the result and status of a task. :param task_id: task id :param result: The return value of the task, or an exception instance raised by the task. :param status: Task status. See :meth:`celery.result.AsyncResult.get_status` for a list of possible stat...
[ "Store", "the", "result", "and", "status", "of", "a", "task", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L158-L187
train
celery/django-celery
djcelery/managers.py
TaskSetManager.restore_taskset
def restore_taskset(self, taskset_id): """Get the async result instance by taskset id.""" try: return self.get(taskset_id=taskset_id) except self.model.DoesNotExist: pass
python
def restore_taskset(self, taskset_id): """Get the async result instance by taskset id.""" try: return self.get(taskset_id=taskset_id) except self.model.DoesNotExist: pass
[ "def", "restore_taskset", "(", "self", ",", "taskset_id", ")", ":", "try", ":", "return", "self", ".", "get", "(", "taskset_id", "=", "taskset_id", ")", "except", "self", ".", "model", ".", "DoesNotExist", ":", "pass" ]
Get the async result instance by taskset id.
[ "Get", "the", "async", "result", "instance", "by", "taskset", "id", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L205-L210
train
celery/django-celery
djcelery/managers.py
TaskSetManager.delete_taskset
def delete_taskset(self, taskset_id): """Delete a saved taskset result.""" s = self.restore_taskset(taskset_id) if s: s.delete()
python
def delete_taskset(self, taskset_id): """Delete a saved taskset result.""" s = self.restore_taskset(taskset_id) if s: s.delete()
[ "def", "delete_taskset", "(", "self", ",", "taskset_id", ")", ":", "s", "=", "self", ".", "restore_taskset", "(", "taskset_id", ")", "if", "s", ":", "s", ".", "delete", "(", ")" ]
Delete a saved taskset result.
[ "Delete", "a", "saved", "taskset", "result", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L212-L216
train
celery/django-celery
djcelery/managers.py
TaskSetManager.store_result
def store_result(self, taskset_id, result): """Store the async result instance of a taskset. :param taskset_id: task set id :param result: The return value of the taskset """ return self.update_or_create(taskset_id=taskset_id, defaults={'re...
python
def store_result(self, taskset_id, result): """Store the async result instance of a taskset. :param taskset_id: task set id :param result: The return value of the taskset """ return self.update_or_create(taskset_id=taskset_id, defaults={'re...
[ "def", "store_result", "(", "self", ",", "taskset_id", ",", "result", ")", ":", "return", "self", ".", "update_or_create", "(", "taskset_id", "=", "taskset_id", ",", "defaults", "=", "{", "'result'", ":", "result", "}", ")" ]
Store the async result instance of a taskset. :param taskset_id: task set id :param result: The return value of the taskset
[ "Store", "the", "async", "result", "instance", "of", "a", "taskset", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/managers.py#L219-L228
train
celery/django-celery
djcelery/backends/database.py
DatabaseBackend._store_result
def _store_result(self, task_id, result, status, traceback=None, request=None): """Store return value and status of an executed task.""" self.TaskModel._default_manager.store_result( task_id, result, status, traceback=traceback, children=self.current_task_ch...
python
def _store_result(self, task_id, result, status, traceback=None, request=None): """Store return value and status of an executed task.""" self.TaskModel._default_manager.store_result( task_id, result, status, traceback=traceback, children=self.current_task_ch...
[ "def", "_store_result", "(", "self", ",", "task_id", ",", "result", ",", "status", ",", "traceback", "=", "None", ",", "request", "=", "None", ")", ":", "self", ".", "TaskModel", ".", "_default_manager", ".", "store_result", "(", "task_id", ",", "result", ...
Store return value and status of an executed task.
[ "Store", "return", "value", "and", "status", "of", "an", "executed", "task", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/backends/database.py#L28-L35
train
celery/django-celery
djcelery/backends/database.py
DatabaseBackend._save_group
def _save_group(self, group_id, result): """Store the result of an executed group.""" self.TaskSetModel._default_manager.store_result(group_id, result) return result
python
def _save_group(self, group_id, result): """Store the result of an executed group.""" self.TaskSetModel._default_manager.store_result(group_id, result) return result
[ "def", "_save_group", "(", "self", ",", "group_id", ",", "result", ")", ":", "self", ".", "TaskSetModel", ".", "_default_manager", ".", "store_result", "(", "group_id", ",", "result", ")", "return", "result" ]
Store the result of an executed group.
[ "Store", "the", "result", "of", "an", "executed", "group", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/backends/database.py#L37-L40
train
celery/django-celery
djcelery/backends/database.py
DatabaseBackend._restore_group
def _restore_group(self, group_id): """Get group metadata for a group by id.""" meta = self.TaskSetModel._default_manager.restore_taskset(group_id) if meta: return meta.to_dict()
python
def _restore_group(self, group_id): """Get group metadata for a group by id.""" meta = self.TaskSetModel._default_manager.restore_taskset(group_id) if meta: return meta.to_dict()
[ "def", "_restore_group", "(", "self", ",", "group_id", ")", ":", "meta", "=", "self", ".", "TaskSetModel", ".", "_default_manager", ".", "restore_taskset", "(", "group_id", ")", "if", "meta", ":", "return", "meta", ".", "to_dict", "(", ")" ]
Get group metadata for a group by id.
[ "Get", "group", "metadata", "for", "a", "group", "by", "id", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/backends/database.py#L46-L50
train
celery/django-celery
djcelery/backends/database.py
DatabaseBackend.cleanup
def cleanup(self): """Delete expired metadata.""" expires = maybe_timedelta(self.expires) for model in self.TaskModel, self.TaskSetModel: model._default_manager.delete_expired(expires)
python
def cleanup(self): """Delete expired metadata.""" expires = maybe_timedelta(self.expires) for model in self.TaskModel, self.TaskSetModel: model._default_manager.delete_expired(expires)
[ "def", "cleanup", "(", "self", ")", ":", "expires", "=", "maybe_timedelta", "(", "self", ".", "expires", ")", "for", "model", "in", "self", ".", "TaskModel", ",", "self", ".", "TaskSetModel", ":", "model", ".", "_default_manager", ".", "delete_expired", "(...
Delete expired metadata.
[ "Delete", "expired", "metadata", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/backends/database.py#L61-L65
train
celery/django-celery
djcelery/snapshot.py
Camera.handle_task
def handle_task(self, uuid_task, worker=None): """Handle snapshotted event.""" uuid, task = uuid_task if task.worker and task.worker.hostname: worker = self.handle_worker( (task.worker.hostname, task.worker), ) defaults = { 'name': tas...
python
def handle_task(self, uuid_task, worker=None): """Handle snapshotted event.""" uuid, task = uuid_task if task.worker and task.worker.hostname: worker = self.handle_worker( (task.worker.hostname, task.worker), ) defaults = { 'name': tas...
[ "def", "handle_task", "(", "self", ",", "uuid_task", ",", "worker", "=", "None", ")", ":", "uuid", ",", "task", "=", "uuid_task", "if", "task", ".", "worker", "and", "task", ".", "worker", ".", "hostname", ":", "worker", "=", "self", ".", "handle_worke...
Handle snapshotted event.
[ "Handle", "snapshotted", "event", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/snapshot.py#L73-L100
train
celery/django-celery
djcelery/common.py
respect_language
def respect_language(language): """Context manager that changes the current translation language for all code inside the following block. Can e.g. be used inside tasks like this:: from celery import task from djcelery.common import respect_language @task def my_task(langua...
python
def respect_language(language): """Context manager that changes the current translation language for all code inside the following block. Can e.g. be used inside tasks like this:: from celery import task from djcelery.common import respect_language @task def my_task(langua...
[ "def", "respect_language", "(", "language", ")", ":", "if", "language", ":", "prev", "=", "translation", ".", "get_language", "(", ")", "translation", ".", "activate", "(", "language", ")", "try", ":", "yield", "finally", ":", "translation", ".", "activate",...
Context manager that changes the current translation language for all code inside the following block. Can e.g. be used inside tasks like this:: from celery import task from djcelery.common import respect_language @task def my_task(language=None): with respect_lang...
[ "Context", "manager", "that", "changes", "the", "current", "translation", "language", "for", "all", "code", "inside", "the", "following", "block", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/common.py#L10-L32
train
celery/django-celery
djcelery/loaders.py
autodiscover
def autodiscover(): """Include tasks for all applications in ``INSTALLED_APPS``.""" global _RACE_PROTECTION if _RACE_PROTECTION: return _RACE_PROTECTION = True try: return filter(None, [find_related_module(app, 'tasks') for app in settings.INSTALLED_APPS...
python
def autodiscover(): """Include tasks for all applications in ``INSTALLED_APPS``.""" global _RACE_PROTECTION if _RACE_PROTECTION: return _RACE_PROTECTION = True try: return filter(None, [find_related_module(app, 'tasks') for app in settings.INSTALLED_APPS...
[ "def", "autodiscover", "(", ")", ":", "global", "_RACE_PROTECTION", "if", "_RACE_PROTECTION", ":", "return", "_RACE_PROTECTION", "=", "True", "try", ":", "return", "filter", "(", "None", ",", "[", "find_related_module", "(", "app", ",", "'tasks'", ")", "for", ...
Include tasks for all applications in ``INSTALLED_APPS``.
[ "Include", "tasks", "for", "all", "applications", "in", "INSTALLED_APPS", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/loaders.py#L167-L178
train
celery/django-celery
djcelery/loaders.py
find_related_module
def find_related_module(app, related_name): """Given an application name and a module name, tries to find that module in the application.""" try: app_path = importlib.import_module(app).__path__ except ImportError as exc: warn('Autodiscover: Error importing %s.%s: %r' % ( ap...
python
def find_related_module(app, related_name): """Given an application name and a module name, tries to find that module in the application.""" try: app_path = importlib.import_module(app).__path__ except ImportError as exc: warn('Autodiscover: Error importing %s.%s: %r' % ( ap...
[ "def", "find_related_module", "(", "app", ",", "related_name", ")", ":", "try", ":", "app_path", "=", "importlib", ".", "import_module", "(", "app", ")", ".", "__path__", "except", "ImportError", "as", "exc", ":", "warn", "(", "'Autodiscover: Error importing %s....
Given an application name and a module name, tries to find that module in the application.
[ "Given", "an", "application", "name", "and", "a", "module", "name", "tries", "to", "find", "that", "module", "in", "the", "application", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/loaders.py#L181-L202
train