repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.has_face_color | def has_face_color(self):
"""Return True if this data set has face color information"""
for v in (self._face_colors, self._face_colors_indexed_by_faces,
self._face_colors_indexed_by_edges):
if v is not None:
return True
return False | python | def has_face_color(self):
"""Return True if this data set has face color information"""
for v in (self._face_colors, self._face_colors_indexed_by_faces,
self._face_colors_indexed_by_edges):
if v is not None:
return True
return False | [
"def",
"has_face_color",
"(",
"self",
")",
":",
"for",
"v",
"in",
"(",
"self",
".",
"_face_colors",
",",
"self",
".",
"_face_colors_indexed_by_faces",
",",
"self",
".",
"_face_colors_indexed_by_edges",
")",
":",
"if",
"v",
"is",
"not",
"None",
":",
"return",... | Return True if this data set has face color information | [
"Return",
"True",
"if",
"this",
"data",
"set",
"has",
"face",
"color",
"information"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L268-L274 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.get_face_normals | def get_face_normals(self, indexed=None):
"""Get face normals
Parameters
----------
indexed : str | None
If None, return an array (Nf, 3) of normal vectors for each face.
If 'faces', then instead return an indexed array (Nf, 3, 3)
(this is just the sa... | python | def get_face_normals(self, indexed=None):
"""Get face normals
Parameters
----------
indexed : str | None
If None, return an array (Nf, 3) of normal vectors for each face.
If 'faces', then instead return an indexed array (Nf, 3, 3)
(this is just the sa... | [
"def",
"get_face_normals",
"(",
"self",
",",
"indexed",
"=",
"None",
")",
":",
"if",
"self",
".",
"_face_normals",
"is",
"None",
":",
"v",
"=",
"self",
".",
"get_vertices",
"(",
"indexed",
"=",
"'faces'",
")",
"self",
".",
"_face_normals",
"=",
"np",
"... | Get face normals
Parameters
----------
indexed : str | None
If None, return an array (Nf, 3) of normal vectors for each face.
If 'faces', then instead return an indexed array (Nf, 3, 3)
(this is just the same array with each vector copied three times).
... | [
"Get",
"face",
"normals"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L276-L306 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.get_vertex_normals | def get_vertex_normals(self, indexed=None):
"""Get vertex normals
Parameters
----------
indexed : str | None
If None, return an (N, 3) array of normal vectors with one entry
per unique vertex in the mesh. If indexed is 'faces', then the
array will con... | python | def get_vertex_normals(self, indexed=None):
"""Get vertex normals
Parameters
----------
indexed : str | None
If None, return an (N, 3) array of normal vectors with one entry
per unique vertex in the mesh. If indexed is 'faces', then the
array will con... | [
"def",
"get_vertex_normals",
"(",
"self",
",",
"indexed",
"=",
"None",
")",
":",
"if",
"self",
".",
"_vertex_normals",
"is",
"None",
":",
"faceNorms",
"=",
"self",
".",
"get_face_normals",
"(",
")",
"vertFaces",
"=",
"self",
".",
"get_vertex_faces",
"(",
"... | Get vertex normals
Parameters
----------
indexed : str | None
If None, return an (N, 3) array of normal vectors with one entry
per unique vertex in the mesh. If indexed is 'faces', then the
array will contain three normal vectors per face (and some
... | [
"Get",
"vertex",
"normals"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L308-L346 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.get_vertex_colors | def get_vertex_colors(self, indexed=None):
"""Get vertex colors
Parameters
----------
indexed : str | None
If None, return an array (Nv, 4) of vertex colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4).
Returns
... | python | def get_vertex_colors(self, indexed=None):
"""Get vertex colors
Parameters
----------
indexed : str | None
If None, return an array (Nv, 4) of vertex colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4).
Returns
... | [
"def",
"get_vertex_colors",
"(",
"self",
",",
"indexed",
"=",
"None",
")",
":",
"if",
"indexed",
"is",
"None",
":",
"return",
"self",
".",
"_vertex_colors",
"elif",
"indexed",
"==",
"'faces'",
":",
"if",
"self",
".",
"_vertex_colors_indexed_by_faces",
"is",
... | Get vertex colors
Parameters
----------
indexed : str | None
If None, return an array (Nv, 4) of vertex colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4).
Returns
-------
colors : ndarray
The ver... | [
"Get",
"vertex",
"colors"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L348-L371 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.set_vertex_colors | def set_vertex_colors(self, colors, indexed=None):
"""Set the vertex color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nv, 4) (indexing by vertex)
or shape (Nf, 3, 4) (vertices indexed by face).
indexed : str | None
... | python | def set_vertex_colors(self, colors, indexed=None):
"""Set the vertex color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nv, 4) (indexing by vertex)
or shape (Nf, 3, 4) (vertices indexed by face).
indexed : str | None
... | [
"def",
"set_vertex_colors",
"(",
"self",
",",
"colors",
",",
"indexed",
"=",
"None",
")",
":",
"colors",
"=",
"_fix_colors",
"(",
"np",
".",
"asarray",
"(",
"colors",
")",
")",
"if",
"indexed",
"is",
"None",
":",
"if",
"colors",
".",
"ndim",
"!=",
"2... | Set the vertex color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nv, 4) (indexing by vertex)
or shape (Nf, 3, 4) (vertices indexed by face).
indexed : str | None
Should be 'faces' if colors are indexed by faces. | [
"Set",
"the",
"vertex",
"color",
"array"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L373-L401 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.get_face_colors | def get_face_colors(self, indexed=None):
"""Get the face colors
Parameters
----------
indexed : str | None
If indexed is None, return (Nf, 4) array of face colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4) (note this is jus... | python | def get_face_colors(self, indexed=None):
"""Get the face colors
Parameters
----------
indexed : str | None
If indexed is None, return (Nf, 4) array of face colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4) (note this is jus... | [
"def",
"get_face_colors",
"(",
"self",
",",
"indexed",
"=",
"None",
")",
":",
"if",
"indexed",
"is",
"None",
":",
"return",
"self",
".",
"_face_colors",
"elif",
"indexed",
"==",
"'faces'",
":",
"if",
"(",
"self",
".",
"_face_colors_indexed_by_faces",
"is",
... | Get the face colors
Parameters
----------
indexed : str | None
If indexed is None, return (Nf, 4) array of face colors.
If indexed=='faces', then instead return an indexed array
(Nf, 3, 4) (note this is just the same array with each color
repeate... | [
"Get",
"the",
"face",
"colors"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L403-L431 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.set_face_colors | def set_face_colors(self, colors, indexed=None):
"""Set the face color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nf, 4) (indexed by face),
or shape (Nf, 3, 4) (face colors indexed by faces).
indexed : str | None
... | python | def set_face_colors(self, colors, indexed=None):
"""Set the face color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nf, 4) (indexed by face),
or shape (Nf, 3, 4) (face colors indexed by faces).
indexed : str | None
... | [
"def",
"set_face_colors",
"(",
"self",
",",
"colors",
",",
"indexed",
"=",
"None",
")",
":",
"colors",
"=",
"_fix_colors",
"(",
"colors",
")",
"if",
"colors",
".",
"shape",
"[",
"0",
"]",
"!=",
"self",
".",
"n_faces",
":",
"raise",
"ValueError",
"(",
... | Set the face color array
Parameters
----------
colors : array
Array of colors. Must have shape (Nf, 4) (indexed by face),
or shape (Nf, 3, 4) (face colors indexed by faces).
indexed : str | None
Should be 'faces' if colors are indexed by faces. | [
"Set",
"the",
"face",
"color",
"array"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L433-L459 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.n_faces | def n_faces(self):
"""The number of faces in the mesh"""
if self._faces is not None:
return self._faces.shape[0]
elif self._vertices_indexed_by_faces is not None:
return self._vertices_indexed_by_faces.shape[0] | python | def n_faces(self):
"""The number of faces in the mesh"""
if self._faces is not None:
return self._faces.shape[0]
elif self._vertices_indexed_by_faces is not None:
return self._vertices_indexed_by_faces.shape[0] | [
"def",
"n_faces",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_faces",
".",
"shape",
"[",
"0",
"]",
"elif",
"self",
".",
"_vertices_indexed_by_faces",
"is",
"not",
"None",
":",
"return",
"self",... | The number of faces in the mesh | [
"The",
"number",
"of",
"faces",
"in",
"the",
"mesh"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L462-L467 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.get_vertex_faces | def get_vertex_faces(self):
"""
List mapping each vertex index to a list of face indices that use it.
"""
if self._vertex_faces is None:
self._vertex_faces = [[] for i in xrange(len(self.get_vertices()))]
for i in xrange(self._faces.shape[0]):
face... | python | def get_vertex_faces(self):
"""
List mapping each vertex index to a list of face indices that use it.
"""
if self._vertex_faces is None:
self._vertex_faces = [[] for i in xrange(len(self.get_vertices()))]
for i in xrange(self._faces.shape[0]):
face... | [
"def",
"get_vertex_faces",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vertex_faces",
"is",
"None",
":",
"self",
".",
"_vertex_faces",
"=",
"[",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"self",
".",
"get_vertices",
"(",
")",
")",
")",
... | List mapping each vertex index to a list of face indices that use it. | [
"List",
"mapping",
"each",
"vertex",
"index",
"to",
"a",
"list",
"of",
"face",
"indices",
"that",
"use",
"it",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L510-L520 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.save | def save(self):
"""Serialize this mesh to a string appropriate for disk storage
Returns
-------
state : dict
The state.
"""
import pickle
if self._faces is not None:
names = ['_vertices', '_faces']
else:
names = ['_vert... | python | def save(self):
"""Serialize this mesh to a string appropriate for disk storage
Returns
-------
state : dict
The state.
"""
import pickle
if self._faces is not None:
names = ['_vertices', '_faces']
else:
names = ['_vert... | [
"def",
"save",
"(",
"self",
")",
":",
"import",
"pickle",
"if",
"self",
".",
"_faces",
"is",
"not",
"None",
":",
"names",
"=",
"[",
"'_vertices'",
",",
"'_faces'",
"]",
"else",
":",
"names",
"=",
"[",
"'_vertices_indexed_by_faces'",
"]",
"if",
"self",
... | Serialize this mesh to a string appropriate for disk storage
Returns
-------
state : dict
The state. | [
"Serialize",
"this",
"mesh",
"to",
"a",
"string",
"appropriate",
"for",
"disk",
"storage"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L558-L583 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/meshdata.py | MeshData.restore | def restore(self, state):
"""Restore the state of a mesh previously saved using save()
Parameters
----------
state : dict
The previous state.
"""
import pickle
state = pickle.loads(state)
for k in state:
if isinstance(state[k], lis... | python | def restore(self, state):
"""Restore the state of a mesh previously saved using save()
Parameters
----------
state : dict
The previous state.
"""
import pickle
state = pickle.loads(state)
for k in state:
if isinstance(state[k], lis... | [
"def",
"restore",
"(",
"self",
",",
"state",
")",
":",
"import",
"pickle",
"state",
"=",
"pickle",
".",
"loads",
"(",
"state",
")",
"for",
"k",
"in",
"state",
":",
"if",
"isinstance",
"(",
"state",
"[",
"k",
"]",
",",
"list",
")",
":",
"state",
"... | Restore the state of a mesh previously saved using save()
Parameters
----------
state : dict
The previous state. | [
"Restore",
"the",
"state",
"of",
"a",
"mesh",
"previously",
"saved",
"using",
"save",
"()"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/meshdata.py#L585-L598 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/cubehelix.py | cubehelix | def cubehelix(start=0.5, rot=1, gamma=1.0, reverse=True, nlev=256.,
minSat=1.2, maxSat=1.2, minLight=0., maxLight=1.,
**kwargs):
"""
A full implementation of Dave Green's "cubehelix" for Matplotlib.
Based on the FORTRAN 77 code provided in
D.A. Green, 2011, BASI, 39, 289.
http://a... | python | def cubehelix(start=0.5, rot=1, gamma=1.0, reverse=True, nlev=256.,
minSat=1.2, maxSat=1.2, minLight=0., maxLight=1.,
**kwargs):
"""
A full implementation of Dave Green's "cubehelix" for Matplotlib.
Based on the FORTRAN 77 code provided in
D.A. Green, 2011, BASI, 39, 289.
http://a... | [
"def",
"cubehelix",
"(",
"start",
"=",
"0.5",
",",
"rot",
"=",
"1",
",",
"gamma",
"=",
"1.0",
",",
"reverse",
"=",
"True",
",",
"nlev",
"=",
"256.",
",",
"minSat",
"=",
"1.2",
",",
"maxSat",
"=",
"1.2",
",",
"minLight",
"=",
"0.",
",",
"maxLight"... | A full implementation of Dave Green's "cubehelix" for Matplotlib.
Based on the FORTRAN 77 code provided in
D.A. Green, 2011, BASI, 39, 289.
http://adsabs.harvard.edu/abs/2011arXiv1108.5083G
User can adjust all parameters of the cubehelix algorithm.
This enables much greater flexibility in choosing... | [
"A",
"full",
"implementation",
"of",
"Dave",
"Green",
"s",
"cubehelix",
"for",
"Matplotlib",
".",
"Based",
"on",
"the",
"FORTRAN",
"77",
"code",
"provided",
"in",
"D",
".",
"A",
".",
"Green",
"2011",
"BASI",
"39",
"289",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/cubehelix.py#L35-L138 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | color_to_hex | def color_to_hex(color):
"""Convert matplotlib color code to hex color code"""
if color is None or colorConverter.to_rgba(color)[3] == 0:
return 'none'
else:
rgb = colorConverter.to_rgb(color)
return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb)) | python | def color_to_hex(color):
"""Convert matplotlib color code to hex color code"""
if color is None or colorConverter.to_rgba(color)[3] == 0:
return 'none'
else:
rgb = colorConverter.to_rgb(color)
return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb)) | [
"def",
"color_to_hex",
"(",
"color",
")",
":",
"if",
"color",
"is",
"None",
"or",
"colorConverter",
".",
"to_rgba",
"(",
"color",
")",
"[",
"3",
"]",
"==",
"0",
":",
"return",
"'none'",
"else",
":",
"rgb",
"=",
"colorConverter",
".",
"to_rgb",
"(",
"... | Convert matplotlib color code to hex color code | [
"Convert",
"matplotlib",
"color",
"code",
"to",
"hex",
"color",
"code"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L21-L27 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | _many_to_one | def _many_to_one(input_dict):
"""Convert a many-to-one mapping to a one-to-one mapping"""
return dict((key, val)
for keys, val in input_dict.items()
for key in keys) | python | def _many_to_one(input_dict):
"""Convert a many-to-one mapping to a one-to-one mapping"""
return dict((key, val)
for keys, val in input_dict.items()
for key in keys) | [
"def",
"_many_to_one",
"(",
"input_dict",
")",
":",
"return",
"dict",
"(",
"(",
"key",
",",
"val",
")",
"for",
"keys",
",",
"val",
"in",
"input_dict",
".",
"items",
"(",
")",
"for",
"key",
"in",
"keys",
")"
] | Convert a many-to-one mapping to a one-to-one mapping | [
"Convert",
"a",
"many",
"-",
"to",
"-",
"one",
"mapping",
"to",
"a",
"one",
"-",
"to",
"-",
"one",
"mapping"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L30-L34 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_dasharray | def get_dasharray(obj):
"""Get an SVG dash array for the given matplotlib linestyle
Parameters
----------
obj : matplotlib object
The matplotlib line or path object, which must have a get_linestyle()
method which returns a valid matplotlib line code
Returns
-------
dasharra... | python | def get_dasharray(obj):
"""Get an SVG dash array for the given matplotlib linestyle
Parameters
----------
obj : matplotlib object
The matplotlib line or path object, which must have a get_linestyle()
method which returns a valid matplotlib line code
Returns
-------
dasharra... | [
"def",
"get_dasharray",
"(",
"obj",
")",
":",
"if",
"obj",
".",
"__dict__",
".",
"get",
"(",
"'_dashSeq'",
",",
"None",
")",
"is",
"not",
"None",
":",
"return",
"','",
".",
"join",
"(",
"map",
"(",
"str",
",",
"obj",
".",
"_dashSeq",
")",
")",
"e... | Get an SVG dash array for the given matplotlib linestyle
Parameters
----------
obj : matplotlib object
The matplotlib line or path object, which must have a get_linestyle()
method which returns a valid matplotlib line code
Returns
-------
dasharray : string
The HTML/SVG... | [
"Get",
"an",
"SVG",
"dash",
"array",
"for",
"the",
"given",
"matplotlib",
"linestyle"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L43-L66 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | SVG_path | def SVG_path(path, transform=None, simplify=False):
"""Construct the vertices and SVG codes for the path
Parameters
----------
path : matplotlib.Path object
transform : matplotlib transform (optional)
if specified, the path will be transformed before computing the output.
Returns
... | python | def SVG_path(path, transform=None, simplify=False):
"""Construct the vertices and SVG codes for the path
Parameters
----------
path : matplotlib.Path object
transform : matplotlib transform (optional)
if specified, the path will be transformed before computing the output.
Returns
... | [
"def",
"SVG_path",
"(",
"path",
",",
"transform",
"=",
"None",
",",
"simplify",
"=",
"False",
")",
":",
"if",
"transform",
"is",
"not",
"None",
":",
"path",
"=",
"path",
".",
"transformed",
"(",
"transform",
")",
"vc_tuples",
"=",
"[",
"(",
"vertices",... | Construct the vertices and SVG codes for the path
Parameters
----------
path : matplotlib.Path object
transform : matplotlib transform (optional)
if specified, the path will be transformed before computing the output.
Returns
-------
vertices : array
The shape (M, 2) array... | [
"Construct",
"the",
"vertices",
"and",
"SVG",
"codes",
"for",
"the",
"path"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L76-L111 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_path_style | def get_path_style(path, fill=True):
"""Get the style dictionary for matplotlib path objects"""
style = {}
style['alpha'] = path.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['edgecolor'] = color_to_hex(path.get_edgecolor())
if fill:
style['facecolor'] = color_t... | python | def get_path_style(path, fill=True):
"""Get the style dictionary for matplotlib path objects"""
style = {}
style['alpha'] = path.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['edgecolor'] = color_to_hex(path.get_edgecolor())
if fill:
style['facecolor'] = color_t... | [
"def",
"get_path_style",
"(",
"path",
",",
"fill",
"=",
"True",
")",
":",
"style",
"=",
"{",
"}",
"style",
"[",
"'alpha'",
"]",
"=",
"path",
".",
"get_alpha",
"(",
")",
"if",
"style",
"[",
"'alpha'",
"]",
"is",
"None",
":",
"style",
"[",
"'alpha'",... | Get the style dictionary for matplotlib path objects | [
"Get",
"the",
"style",
"dictionary",
"for",
"matplotlib",
"path",
"objects"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L114-L128 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_line_style | def get_line_style(line):
"""Get the style dictionary for matplotlib line objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['color'] = color_to_hex(line.get_color())
style['linewidth'] = line.get_linewidth()
style['dasharray']... | python | def get_line_style(line):
"""Get the style dictionary for matplotlib line objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['color'] = color_to_hex(line.get_color())
style['linewidth'] = line.get_linewidth()
style['dasharray']... | [
"def",
"get_line_style",
"(",
"line",
")",
":",
"style",
"=",
"{",
"}",
"style",
"[",
"'alpha'",
"]",
"=",
"line",
".",
"get_alpha",
"(",
")",
"if",
"style",
"[",
"'alpha'",
"]",
"is",
"None",
":",
"style",
"[",
"'alpha'",
"]",
"=",
"1",
"style",
... | Get the style dictionary for matplotlib line objects | [
"Get",
"the",
"style",
"dictionary",
"for",
"matplotlib",
"line",
"objects"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L131-L141 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_marker_style | def get_marker_style(line):
"""Get the style dictionary for matplotlib marker objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['facecolor'] = color_to_hex(line.get_markerfacecolor())
style['edgecolor'] = color_to_hex(line.get_ma... | python | def get_marker_style(line):
"""Get the style dictionary for matplotlib marker objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['facecolor'] = color_to_hex(line.get_markerfacecolor())
style['edgecolor'] = color_to_hex(line.get_ma... | [
"def",
"get_marker_style",
"(",
"line",
")",
":",
"style",
"=",
"{",
"}",
"style",
"[",
"'alpha'",
"]",
"=",
"line",
".",
"get_alpha",
"(",
")",
"if",
"style",
"[",
"'alpha'",
"]",
"is",
"None",
":",
"style",
"[",
"'alpha'",
"]",
"=",
"1",
"style",... | Get the style dictionary for matplotlib marker objects | [
"Get",
"the",
"style",
"dictionary",
"for",
"matplotlib",
"marker",
"objects"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L144-L164 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_text_style | def get_text_style(text):
"""Return the text style dict for a text instance"""
style = {}
style['alpha'] = text.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['fontsize'] = text.get_size()
style['color'] = color_to_hex(text.get_color())
style['halign'] = text.get_hor... | python | def get_text_style(text):
"""Return the text style dict for a text instance"""
style = {}
style['alpha'] = text.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['fontsize'] = text.get_size()
style['color'] = color_to_hex(text.get_color())
style['halign'] = text.get_hor... | [
"def",
"get_text_style",
"(",
"text",
")",
":",
"style",
"=",
"{",
"}",
"style",
"[",
"'alpha'",
"]",
"=",
"text",
".",
"get_alpha",
"(",
")",
"if",
"style",
"[",
"'alpha'",
"]",
"is",
"None",
":",
"style",
"[",
"'alpha'",
"]",
"=",
"1",
"style",
... | Return the text style dict for a text instance | [
"Return",
"the",
"text",
"style",
"dict",
"for",
"a",
"text",
"instance"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L167-L180 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | get_axis_properties | def get_axis_properties(axis):
"""Return the property dictionary for a matplotlib.Axis instance"""
props = {}
label1On = axis._major_tick_kw.get('label1On', True)
if isinstance(axis, matplotlib.axis.XAxis):
if label1On:
props['position'] = "bottom"
else:
props['p... | python | def get_axis_properties(axis):
"""Return the property dictionary for a matplotlib.Axis instance"""
props = {}
label1On = axis._major_tick_kw.get('label1On', True)
if isinstance(axis, matplotlib.axis.XAxis):
if label1On:
props['position'] = "bottom"
else:
props['p... | [
"def",
"get_axis_properties",
"(",
"axis",
")",
":",
"props",
"=",
"{",
"}",
"label1On",
"=",
"axis",
".",
"_major_tick_kw",
".",
"get",
"(",
"'label1On'",
",",
"True",
")",
"if",
"isinstance",
"(",
"axis",
",",
"matplotlib",
".",
"axis",
".",
"XAxis",
... | Return the property dictionary for a matplotlib.Axis instance | [
"Return",
"the",
"property",
"dictionary",
"for",
"a",
"matplotlib",
".",
"Axis",
"instance"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L183-L233 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | iter_all_children | def iter_all_children(obj, skipContainers=False):
"""
Returns an iterator over all childen and nested children using
obj's get_children() method
if skipContainers is true, only childless objects are returned.
"""
if hasattr(obj, 'get_children') and len(obj.get_children()) > 0:
for child... | python | def iter_all_children(obj, skipContainers=False):
"""
Returns an iterator over all childen and nested children using
obj's get_children() method
if skipContainers is true, only childless objects are returned.
"""
if hasattr(obj, 'get_children') and len(obj.get_children()) > 0:
for child... | [
"def",
"iter_all_children",
"(",
"obj",
",",
"skipContainers",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'get_children'",
")",
"and",
"len",
"(",
"obj",
".",
"get_children",
"(",
")",
")",
">",
"0",
":",
"for",
"child",
"in",
"obj",
... | Returns an iterator over all childen and nested children using
obj's get_children() method
if skipContainers is true, only childless objects are returned. | [
"Returns",
"an",
"iterator",
"over",
"all",
"childen",
"and",
"nested",
"children",
"using",
"obj",
"s",
"get_children",
"()",
"method"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L304-L319 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | image_to_base64 | def image_to_base64(image):
"""
Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png imag... | python | def image_to_base64(image):
"""
Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png imag... | [
"def",
"image_to_base64",
"(",
"image",
")",
":",
"ax",
"=",
"image",
".",
"axes",
"binary_buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"# image is saved in axes coordinates: we need to temporarily",
"# set the correct limits to get the correct image",
"lim",
"=",
"ax",
... | Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png image. | [
"Convert",
"a",
"matplotlib",
"image",
"to",
"a",
"base64",
"png",
"representation"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L328-L353 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/inputhook.py | set_interactive | def set_interactive(enabled=True, app=None):
"""Activate the IPython hook for VisPy. If the app is not specified, the
default is used.
"""
if enabled:
inputhook_manager.enable_gui('vispy', app)
else:
inputhook_manager.disable_gui() | python | def set_interactive(enabled=True, app=None):
"""Activate the IPython hook for VisPy. If the app is not specified, the
default is used.
"""
if enabled:
inputhook_manager.enable_gui('vispy', app)
else:
inputhook_manager.disable_gui() | [
"def",
"set_interactive",
"(",
"enabled",
"=",
"True",
",",
"app",
"=",
"None",
")",
":",
"if",
"enabled",
":",
"inputhook_manager",
".",
"enable_gui",
"(",
"'vispy'",
",",
"app",
")",
"else",
":",
"inputhook_manager",
".",
"disable_gui",
"(",
")"
] | Activate the IPython hook for VisPy. If the app is not specified, the
default is used. | [
"Activate",
"the",
"IPython",
"hook",
"for",
"VisPy",
".",
"If",
"the",
"app",
"is",
"not",
"specified",
"the",
"default",
"is",
"used",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/inputhook.py#L17-L24 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._resize_buffers | def _resize_buffers(self, font_scale):
"""Resize buffers only if necessary"""
new_sizes = (font_scale,) + self.size
if new_sizes == self._current_sizes: # don't need resize
return
self._n_rows = int(max(self.size[1] /
(self._char_height * font_... | python | def _resize_buffers(self, font_scale):
"""Resize buffers only if necessary"""
new_sizes = (font_scale,) + self.size
if new_sizes == self._current_sizes: # don't need resize
return
self._n_rows = int(max(self.size[1] /
(self._char_height * font_... | [
"def",
"_resize_buffers",
"(",
"self",
",",
"font_scale",
")",
":",
"new_sizes",
"=",
"(",
"font_scale",
",",
")",
"+",
"self",
".",
"size",
"if",
"new_sizes",
"==",
"self",
".",
"_current_sizes",
":",
"# don't need resize",
"return",
"self",
".",
"_n_rows",... | Resize buffers only if necessary | [
"Resize",
"buffers",
"only",
"if",
"necessary"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L245-L268 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual.clear | def clear(self):
"""Clear the console"""
if hasattr(self, '_bytes_012'):
self._bytes_012.fill(0)
self._bytes_345.fill(0)
self._text_lines = [] * self._n_rows
self._pending_writes = [] | python | def clear(self):
"""Clear the console"""
if hasattr(self, '_bytes_012'):
self._bytes_012.fill(0)
self._bytes_345.fill(0)
self._text_lines = [] * self._n_rows
self._pending_writes = [] | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_bytes_012'",
")",
":",
"self",
".",
"_bytes_012",
".",
"fill",
"(",
"0",
")",
"self",
".",
"_bytes_345",
".",
"fill",
"(",
"0",
")",
"self",
".",
"_text_lines",
"=",
"[",
... | Clear the console | [
"Clear",
"the",
"console"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L292-L298 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual.write | def write(self, text='', wrap=True):
"""Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages w... | python | def write(self, text='', wrap=True):
"""Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages w... | [
"def",
"write",
"(",
"self",
",",
"text",
"=",
"''",
",",
"wrap",
"=",
"True",
")",
":",
"# Clear line",
"if",
"not",
"isinstance",
"(",
"text",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'text must be a string'",
")",
"# ensure we only have ... | Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages will be wrapped to span multiple lines. | [
"Write",
"text",
"and",
"scroll"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L300-L317 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._do_pending_writes | def _do_pending_writes(self):
"""Do any pending text writes"""
for text, wrap in self._pending_writes:
# truncate in case of *really* long messages
text = text[-self._n_cols*self._n_rows:]
text = text.split('\n')
text = [t if len(t) > 0 else '' for t in te... | python | def _do_pending_writes(self):
"""Do any pending text writes"""
for text, wrap in self._pending_writes:
# truncate in case of *really* long messages
text = text[-self._n_cols*self._n_rows:]
text = text.split('\n')
text = [t if len(t) > 0 else '' for t in te... | [
"def",
"_do_pending_writes",
"(",
"self",
")",
":",
"for",
"text",
",",
"wrap",
"in",
"self",
".",
"_pending_writes",
":",
"# truncate in case of *really* long messages",
"text",
"=",
"text",
"[",
"-",
"self",
".",
"_n_cols",
"*",
"self",
".",
"_n_rows",
":",
... | Do any pending text writes | [
"Do",
"any",
"pending",
"text",
"writes"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L319-L338 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._insert_text_buf | def _insert_text_buf(self, line, idx):
"""Insert text into bytes buffers"""
self._bytes_012[idx] = 0
self._bytes_345[idx] = 0
# Crop text if necessary
I = np.array([ord(c) - 32 for c in line[:self._n_cols]])
I = np.clip(I, 0, len(__font_6x8__)-1)
if len(I) > 0:
... | python | def _insert_text_buf(self, line, idx):
"""Insert text into bytes buffers"""
self._bytes_012[idx] = 0
self._bytes_345[idx] = 0
# Crop text if necessary
I = np.array([ord(c) - 32 for c in line[:self._n_cols]])
I = np.clip(I, 0, len(__font_6x8__)-1)
if len(I) > 0:
... | [
"def",
"_insert_text_buf",
"(",
"self",
",",
"line",
",",
"idx",
")",
":",
"self",
".",
"_bytes_012",
"[",
"idx",
"]",
"=",
"0",
"self",
".",
"_bytes_345",
"[",
"idx",
"]",
"=",
"0",
"# Crop text if necessary",
"I",
"=",
"np",
".",
"array",
"(",
"[",... | Insert text into bytes buffers | [
"Insert",
"text",
"into",
"bytes",
"buffers"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L340-L350 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function.replace | def replace(self, str1, str2):
""" Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
... | python | def replace(self, str1, str2):
""" Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
... | [
"def",
"replace",
"(",
"self",
",",
"str1",
",",
"str2",
")",
":",
"if",
"str2",
"!=",
"self",
".",
"_replacements",
".",
"get",
"(",
"str1",
",",
"None",
")",
":",
"self",
".",
"_replacements",
"[",
"str1",
"]",
"=",
"str2",
"self",
".",
"changed"... | Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
----------
str1 : str
S... | [
"Set",
"verbatim",
"code",
"replacement",
"It",
"is",
"strongly",
"recommended",
"to",
"use",
"function",
"[",
"$foo",
"]",
"=",
"bar",
"where",
"possible",
"because",
"template",
"variables",
"are",
"less",
"likely",
"to",
"changed",
"than",
"the",
"code",
... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L378-L394 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._parse_template_vars | def _parse_template_vars(self):
""" find all template variables in self._code, excluding the
function name.
"""
template_vars = set()
for var in parsing.find_template_variables(self._code):
var = var.lstrip('$')
if var == self.name:
contin... | python | def _parse_template_vars(self):
""" find all template variables in self._code, excluding the
function name.
"""
template_vars = set()
for var in parsing.find_template_variables(self._code):
var = var.lstrip('$')
if var == self.name:
contin... | [
"def",
"_parse_template_vars",
"(",
"self",
")",
":",
"template_vars",
"=",
"set",
"(",
")",
"for",
"var",
"in",
"parsing",
".",
"find_template_variables",
"(",
"self",
".",
"_code",
")",
":",
"var",
"=",
"var",
".",
"lstrip",
"(",
"'$'",
")",
"if",
"v... | find all template variables in self._code, excluding the
function name. | [
"find",
"all",
"template",
"variables",
"in",
"self",
".",
"_code",
"excluding",
"the",
"function",
"name",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L399-L412 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._get_replaced_code | def _get_replaced_code(self, names):
""" Return code, with new name, expressions, and replacements applied.
"""
code = self._code
# Modify name
fname = names[self]
code = code.replace(" " + self.name + "(", " " + fname + "(")
# Apply string replacements ... | python | def _get_replaced_code(self, names):
""" Return code, with new name, expressions, and replacements applied.
"""
code = self._code
# Modify name
fname = names[self]
code = code.replace(" " + self.name + "(", " " + fname + "(")
# Apply string replacements ... | [
"def",
"_get_replaced_code",
"(",
"self",
",",
"names",
")",
":",
"code",
"=",
"self",
".",
"_code",
"# Modify name",
"fname",
"=",
"names",
"[",
"self",
"]",
"code",
"=",
"code",
".",
"replace",
"(",
"\" \"",
"+",
"self",
".",
"name",
"+",
"\"(\"",
... | Return code, with new name, expressions, and replacements applied. | [
"Return",
"code",
"with",
"new",
"name",
"expressions",
"and",
"replacements",
"applied",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L414-L472 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._clean_code | def _clean_code(self, code):
""" Return *code* with indentation and leading/trailing blank lines
removed.
"""
lines = code.split("\n")
min_indent = 100
for line in lines:
if line.strip() != "":
indent = len(line) - len(line.lstrip())
... | python | def _clean_code(self, code):
""" Return *code* with indentation and leading/trailing blank lines
removed.
"""
lines = code.split("\n")
min_indent = 100
for line in lines:
if line.strip() != "":
indent = len(line) - len(line.lstrip())
... | [
"def",
"_clean_code",
"(",
"self",
",",
"code",
")",
":",
"lines",
"=",
"code",
".",
"split",
"(",
"\"\\n\"",
")",
"min_indent",
"=",
"100",
"for",
"line",
"in",
"lines",
":",
"if",
"line",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"indent",
"=",
... | Return *code* with indentation and leading/trailing blank lines
removed. | [
"Return",
"*",
"code",
"*",
"with",
"indentation",
"and",
"leading",
"/",
"trailing",
"blank",
"lines",
"removed",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L480-L493 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | MainFunction.add_chain | def add_chain(self, var):
"""
Create a new ChainFunction and attach to $var.
"""
chain = FunctionChain(var, [])
self._chains[var] = chain
self[var] = chain | python | def add_chain(self, var):
"""
Create a new ChainFunction and attach to $var.
"""
chain = FunctionChain(var, [])
self._chains[var] = chain
self[var] = chain | [
"def",
"add_chain",
"(",
"self",
",",
"var",
")",
":",
"chain",
"=",
"FunctionChain",
"(",
"var",
",",
"[",
"]",
")",
"self",
".",
"_chains",
"[",
"var",
"]",
"=",
"chain",
"self",
"[",
"var",
"]",
"=",
"chain"
] | Create a new ChainFunction and attach to $var. | [
"Create",
"a",
"new",
"ChainFunction",
"and",
"attach",
"to",
"$var",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L540-L546 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.append | def append(self, function, update=True):
""" Append a new function to the end of this chain.
"""
self._funcs.append(function)
self._add_dep(function)
if update:
self._update() | python | def append(self, function, update=True):
""" Append a new function to the end of this chain.
"""
self._funcs.append(function)
self._add_dep(function)
if update:
self._update() | [
"def",
"append",
"(",
"self",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"append",
"(",
"function",
")",
"self",
".",
"_add_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
".",
"_update",
"(",
")"
] | Append a new function to the end of this chain. | [
"Append",
"a",
"new",
"function",
"to",
"the",
"end",
"of",
"this",
"chain",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L655-L661 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.insert | def insert(self, index, function, update=True):
""" Insert a new function into the chain at *index*.
"""
self._funcs.insert(index, function)
self._add_dep(function)
if update:
self._update() | python | def insert(self, index, function, update=True):
""" Insert a new function into the chain at *index*.
"""
self._funcs.insert(index, function)
self._add_dep(function)
if update:
self._update() | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"insert",
"(",
"index",
",",
"function",
")",
"self",
".",
"_add_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
... | Insert a new function into the chain at *index*. | [
"Insert",
"a",
"new",
"function",
"into",
"the",
"chain",
"at",
"*",
"index",
"*",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L673-L679 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.remove | def remove(self, function, update=True):
""" Remove a function from the chain.
"""
self._funcs.remove(function)
self._remove_dep(function)
if update:
self._update() | python | def remove(self, function, update=True):
""" Remove a function from the chain.
"""
self._funcs.remove(function)
self._remove_dep(function)
if update:
self._update() | [
"def",
"remove",
"(",
"self",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"remove",
"(",
"function",
")",
"self",
".",
"_remove_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
".",
"_update",
"(",
")"
] | Remove a function from the chain. | [
"Remove",
"a",
"function",
"from",
"the",
"chain",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L681-L687 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | StatementList.add | def add(self, item, position=5):
"""Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code.
"""
if item in self.items:
return
self.items[item] = position
... | python | def add(self, item, position=5):
"""Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code.
"""
if item in self.items:
return
self.items[item] = position
... | [
"def",
"add",
"(",
"self",
",",
"item",
",",
"position",
"=",
"5",
")",
":",
"if",
"item",
"in",
"self",
".",
"items",
":",
"return",
"self",
".",
"items",
"[",
"item",
"]",
"=",
"position",
"self",
".",
"_add_dep",
"(",
"item",
")",
"self",
".",... | Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code. | [
"Add",
"an",
"item",
"to",
"the",
"list",
"unless",
"it",
"is",
"already",
"present",
".",
"If",
"the",
"item",
"is",
"an",
"expression",
"then",
"a",
"semicolon",
"will",
"be",
"appended",
"to",
"it",
"in",
"the",
"final",
"compiled",
"code",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L748-L759 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | StatementList.remove | def remove(self, item):
"""Remove an item from the list.
"""
self.items.pop(item)
self._remove_dep(item)
self.order = None
self.changed(code_changed=True) | python | def remove(self, item):
"""Remove an item from the list.
"""
self.items.pop(item)
self._remove_dep(item)
self.order = None
self.changed(code_changed=True) | [
"def",
"remove",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"items",
".",
"pop",
"(",
"item",
")",
"self",
".",
"_remove_dep",
"(",
"item",
")",
"self",
".",
"order",
"=",
"None",
"self",
".",
"changed",
"(",
"code_changed",
"=",
"True",
")"
... | Remove an item from the list. | [
"Remove",
"an",
"item",
"from",
"the",
"list",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L761-L767 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.faces | def faces(self):
"""Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces ... | python | def faces(self):
"""Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces ... | [
"def",
"faces",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_faces"
] | Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"(",
"Nf",
"3",
")",
"of",
"vertex",
"indexes",
"three",
"per",
"triangular",
"face",
"in",
"the",
"mesh",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L36-L49 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.vertices | def vertices(self):
"""Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
if self._vertices is None:
... | python | def vertices(self):
"""Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
if self._vertices is None:
... | [
"def",
"vertices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_vertices"
] | Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"(",
"Nf",
"3",
")",
"of",
"vertices",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L60-L72 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.convex_hull | def convex_hull(self):
"""Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
... | python | def convex_hull(self):
"""Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
... | [
"def",
"convex_hull",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_convex_hull"
] | Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"of",
"vertex",
"indexes",
"representing",
"the",
"convex",
"hull",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L98-L109 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.triangulate | def triangulate(self):
"""
Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull.
"""
npts = self._vertices.shape[0]
if np.any(self._vertices[0] != self._vertices[1]):
# start != end, so edges must wrap around to... | python | def triangulate(self):
"""
Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull.
"""
npts = self._vertices.shape[0]
if np.any(self._vertices[0] != self._vertices[1]):
# start != end, so edges must wrap around to... | [
"def",
"triangulate",
"(",
"self",
")",
":",
"npts",
"=",
"self",
".",
"_vertices",
".",
"shape",
"[",
"0",
"]",
"if",
"np",
".",
"any",
"(",
"self",
".",
"_vertices",
"[",
"0",
"]",
"!=",
"self",
".",
"_vertices",
"[",
"1",
"]",
")",
":",
"# s... | Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull. | [
"Triangulates",
"the",
"set",
"of",
"vertices",
"and",
"stores",
"the",
"triangles",
"in",
"faces",
"and",
"the",
"convex",
"hull",
"in",
"convex_hull",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L111-L131 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/glsl/__init__.py | find | def find(name):
"""Locate a filename into the shader library."""
if op.exists(name):
return name
path = op.dirname(__file__) or '.'
paths = [path] + config['include_path']
for path in paths:
filename = op.abspath(op.join(path, name))
if op.exists(filename):
re... | python | def find(name):
"""Locate a filename into the shader library."""
if op.exists(name):
return name
path = op.dirname(__file__) or '.'
paths = [path] + config['include_path']
for path in paths:
filename = op.abspath(op.join(path, name))
if op.exists(filename):
re... | [
"def",
"find",
"(",
"name",
")",
":",
"if",
"op",
".",
"exists",
"(",
"name",
")",
":",
"return",
"name",
"path",
"=",
"op",
".",
"dirname",
"(",
"__file__",
")",
"or",
"'.'",
"paths",
"=",
"[",
"path",
"]",
"+",
"config",
"[",
"'include_path'",
... | Locate a filename into the shader library. | [
"Locate",
"a",
"filename",
"into",
"the",
"shader",
"library",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/__init__.py#L12-L34 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/glsl/__init__.py | get | def get(name):
"""Retrieve code from the given filename."""
filename = find(name)
if filename is None:
raise RuntimeError('Could not find %s' % name)
with open(filename) as fid:
return fid.read() | python | def get(name):
"""Retrieve code from the given filename."""
filename = find(name)
if filename is None:
raise RuntimeError('Could not find %s' % name)
with open(filename) as fid:
return fid.read() | [
"def",
"get",
"(",
"name",
")",
":",
"filename",
"=",
"find",
"(",
"name",
")",
"if",
"filename",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Could not find %s'",
"%",
"name",
")",
"with",
"open",
"(",
"filename",
")",
"as",
"fid",
":",
"return"... | Retrieve code from the given filename. | [
"Retrieve",
"code",
"from",
"the",
"given",
"filename",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/__init__.py#L37-L44 |
federico123579/Trading212-API | tradingAPI/utils.py | expect | def expect(func, args, times=7, sleep_t=0.5):
"""try many times as in times with sleep time"""
while times > 0:
try:
return func(*args)
except Exception as e:
times -= 1
logger.debug("expect failed - attempts left: %d" % times)
time.sleep(sleep_t)
... | python | def expect(func, args, times=7, sleep_t=0.5):
"""try many times as in times with sleep time"""
while times > 0:
try:
return func(*args)
except Exception as e:
times -= 1
logger.debug("expect failed - attempts left: %d" % times)
time.sleep(sleep_t)
... | [
"def",
"expect",
"(",
"func",
",",
"args",
",",
"times",
"=",
"7",
",",
"sleep_t",
"=",
"0.5",
")",
":",
"while",
"times",
">",
"0",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
")",
"except",
"Exception",
"as",
"e",
":",
"times",
"-=",
... | try many times as in times with sleep time | [
"try",
"many",
"times",
"as",
"in",
"times",
"with",
"sleep",
"time"
] | train | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L20-L30 |
federico123579/Trading212-API | tradingAPI/utils.py | num | def num(string):
"""convert a string to float"""
if not isinstance(string, type('')):
raise ValueError(type(''))
try:
string = re.sub('[^a-zA-Z0-9\.\-]', '', string)
number = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", string)
return float(number[0])
except Exception as e:
... | python | def num(string):
"""convert a string to float"""
if not isinstance(string, type('')):
raise ValueError(type(''))
try:
string = re.sub('[^a-zA-Z0-9\.\-]', '', string)
number = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", string)
return float(number[0])
except Exception as e:
... | [
"def",
"num",
"(",
"string",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"type",
"(",
"''",
")",
")",
":",
"raise",
"ValueError",
"(",
"type",
"(",
"''",
")",
")",
"try",
":",
"string",
"=",
"re",
".",
"sub",
"(",
"'[^a-zA-Z0-9\\.\\-]'... | convert a string to float | [
"convert",
"a",
"string",
"to",
"float"
] | train | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L33-L45 |
federico123579/Trading212-API | tradingAPI/utils.py | get_number_unit | def get_number_unit(number):
"""get the unit of number"""
n = str(float(number))
mult, submult = n.split('.')
if float(submult) != 0:
unit = '0.' + (len(submult)-1)*'0' + '1'
return float(unit)
else:
return float(1) | python | def get_number_unit(number):
"""get the unit of number"""
n = str(float(number))
mult, submult = n.split('.')
if float(submult) != 0:
unit = '0.' + (len(submult)-1)*'0' + '1'
return float(unit)
else:
return float(1) | [
"def",
"get_number_unit",
"(",
"number",
")",
":",
"n",
"=",
"str",
"(",
"float",
"(",
"number",
")",
")",
"mult",
",",
"submult",
"=",
"n",
".",
"split",
"(",
"'.'",
")",
"if",
"float",
"(",
"submult",
")",
"!=",
"0",
":",
"unit",
"=",
"'0.'",
... | get the unit of number | [
"get",
"the",
"unit",
"of",
"number"
] | train | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L48-L56 |
federico123579/Trading212-API | tradingAPI/utils.py | get_pip | def get_pip(mov=None, api=None, name=None):
"""get value of pip"""
# ~ check args
if mov is None and api is None:
logger.error("need at least one of those")
raise ValueError()
elif mov is not None and api is not None:
logger.error("mov and api are exclusive")
raise ValueE... | python | def get_pip(mov=None, api=None, name=None):
"""get value of pip"""
# ~ check args
if mov is None and api is None:
logger.error("need at least one of those")
raise ValueError()
elif mov is not None and api is not None:
logger.error("mov and api are exclusive")
raise ValueE... | [
"def",
"get_pip",
"(",
"mov",
"=",
"None",
",",
"api",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# ~ check args",
"if",
"mov",
"is",
"None",
"and",
"api",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"need at least one of those\"",
")",
"r... | get value of pip | [
"get",
"value",
"of",
"pip"
] | train | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L59-L117 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.itemsize | def itemsize(self):
""" Individual item sizes """
return self._items[:self._count, 1] - self._items[:self._count, 0] | python | def itemsize(self):
""" Individual item sizes """
return self._items[:self._count, 1] - self._items[:self._count, 0] | [
"def",
"itemsize",
"(",
"self",
")",
":",
"return",
"self",
".",
"_items",
"[",
":",
"self",
".",
"_count",
",",
"1",
"]",
"-",
"self",
".",
"_items",
"[",
":",
"self",
".",
"_count",
",",
"0",
"]"
] | Individual item sizes | [
"Individual",
"item",
"sizes"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L126-L128 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.reserve | def reserve(self, capacity):
""" Set current capacity of the underlying array"""
if capacity >= self._data.size:
capacity = int(2 ** np.ceil(np.log2(capacity)))
self._data = np.resize(self._data, capacity) | python | def reserve(self, capacity):
""" Set current capacity of the underlying array"""
if capacity >= self._data.size:
capacity = int(2 ** np.ceil(np.log2(capacity)))
self._data = np.resize(self._data, capacity) | [
"def",
"reserve",
"(",
"self",
",",
"capacity",
")",
":",
"if",
"capacity",
">=",
"self",
".",
"_data",
".",
"size",
":",
"capacity",
"=",
"int",
"(",
"2",
"**",
"np",
".",
"ceil",
"(",
"np",
".",
"log2",
"(",
"capacity",
")",
")",
")",
"self",
... | Set current capacity of the underlying array | [
"Set",
"current",
"capacity",
"of",
"the",
"underlying",
"array"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L135-L140 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.insert | def insert(self, index, data, itemsize=None):
""" Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __arr... | python | def insert(self, index, data, itemsize=None):
""" Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __arr... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"data",
",",
"itemsize",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_sizeable",
":",
"raise",
"AttributeError",
"(",
"\"List is not sizeable\"",
")",
"if",
"isinstance",
"(",
"data",
",",
"(",
"list... | Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
... | [
"Insert",
"data",
"before",
"index"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L285-L391 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.append | def append(self, data, itemsize=None):
"""
Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: ... | python | def append(self, data, itemsize=None):
"""
Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: ... | [
"def",
"append",
"(",
"self",
",",
"data",
",",
"itemsize",
"=",
"None",
")",
":",
"self",
".",
"insert",
"(",
"len",
"(",
"self",
")",
",",
"data",
",",
"itemsize",
")"
] | Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: int or 1-D array
If `itemsize is an integer, N... | [
"Append",
"data",
"to",
"the",
"end",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L393-L415 |
andim/scipydirect | scipydirect/__init__.py | minimize | def minimize(func, bounds=None, nvar=None, args=(), disp=False,
eps=1e-4,
maxf=20000,
maxT=6000,
algmethod=0,
fglobal=-1e100,
fglper=0.01,
volper=-1.0,
sigmaper=-1.0,
**kwargs
):
... | python | def minimize(func, bounds=None, nvar=None, args=(), disp=False,
eps=1e-4,
maxf=20000,
maxT=6000,
algmethod=0,
fglobal=-1e100,
fglper=0.01,
volper=-1.0,
sigmaper=-1.0,
**kwargs
):
... | [
"def",
"minimize",
"(",
"func",
",",
"bounds",
"=",
"None",
",",
"nvar",
"=",
"None",
",",
"args",
"=",
"(",
")",
",",
"disp",
"=",
"False",
",",
"eps",
"=",
"1e-4",
",",
"maxf",
"=",
"20000",
",",
"maxT",
"=",
"6000",
",",
"algmethod",
"=",
"0... | Solve an optimization problem using the DIRECT (Dividing Rectangles) algorithm.
It can be used to solve general nonlinear programming problems of the form:
.. math::
\min_ {x \in R^n} f(x)
subject to
.. math::
x_L \leq x \leq x_U
Where :math:`x` are the... | [
"Solve",
"an",
"optimization",
"problem",
"using",
"the",
"DIRECT",
"(",
"Dividing",
"Rectangles",
")",
"algorithm",
".",
"It",
"can",
"be",
"used",
"to",
"solve",
"general",
"nonlinear",
"programming",
"problems",
"of",
"the",
"form",
":",
"..",
"math",
"::... | train | https://github.com/andim/scipydirect/blob/ad36ab19e6ad64054a1d2abd22f1c993fc4b87be/scipydirect/__init__.py#L111-L258 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/dpi/_win32.py | get_dpi | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
try:
user32.SetProcessDPIAware(... | python | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
try:
user32.SetProcessDPIAware(... | [
"def",
"get_dpi",
"(",
"raise_error",
"=",
"True",
")",
":",
"try",
":",
"user32",
".",
"SetProcessDPIAware",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"# not present on XP",
"dc",
"=",
"user32",
".",
"GetDC",
"(",
"0",
")",
"h_size",
"=",
"gdi32"... | Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen. | [
"Get",
"screen",
"DPI",
"from",
"the",
"OS"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/dpi/_win32.py#L11-L34 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/program.py | ModularProgram.build_if_needed | def build_if_needed(self):
""" Reset shader source if necesssary.
"""
if self._need_build:
self._build()
self._need_build = False
self.update_variables() | python | def build_if_needed(self):
""" Reset shader source if necesssary.
"""
if self._need_build:
self._build()
self._need_build = False
self.update_variables() | [
"def",
"build_if_needed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_need_build",
":",
"self",
".",
"_build",
"(",
")",
"self",
".",
"_need_build",
"=",
"False",
"self",
".",
"update_variables",
"(",
")"
] | Reset shader source if necesssary. | [
"Reset",
"shader",
"source",
"if",
"necesssary",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/program.py#L79-L85 |
antonagestam/nmap | nmap/nmap.py | nmap | def nmap(a, b, c, d, curvefn=None, normfn=None):
"""
Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output.
"""
if not curvefn:
cur... | python | def nmap(a, b, c, d, curvefn=None, normfn=None):
"""
Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output.
"""
if not curvefn:
cur... | [
"def",
"nmap",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"curvefn",
"=",
"None",
",",
"normfn",
"=",
"None",
")",
":",
"if",
"not",
"curvefn",
":",
"curvefn",
"=",
"lambda",
"x",
":",
"x",
"def",
"map",
"(",
"n",
")",
":",
"r",
"=",
"1.0... | Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output. | [
"Returns",
"a",
"function",
"that",
"maps",
"a",
"number",
"n",
"from",
"range",
"(",
"a",
"b",
")",
"onto",
"a",
"range",
"(",
"c",
"d",
")",
".",
"If",
"no",
"curvefn",
"is",
"given",
"linear",
"mapping",
"will",
"be",
"used",
".",
"Optionally",
... | train | https://github.com/antonagestam/nmap/blob/dd6d90d6a04b4cfc39687af1c081c5d6c4602dea/nmap/nmap.py#L1-L16 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/axis.py | AxisWidget.link_view | def link_view(self, view):
"""Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link.
"""
if view is self._link... | python | def link_view(self, view):
"""Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link.
"""
if view is self._link... | [
"def",
"link_view",
"(",
"self",
",",
"view",
")",
":",
"if",
"view",
"is",
"self",
".",
"_linked_view",
":",
"return",
"if",
"self",
".",
"_linked_view",
"is",
"not",
"None",
":",
"self",
".",
"_linked_view",
".",
"scene",
".",
"transform",
".",
"chan... | Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link. | [
"Link",
"this",
"axis",
"to",
"a",
"ViewBox"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/axis.py#L61-L79 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/axis.py | AxisWidget._view_changed | def _view_changed(self, event=None):
"""Linked view transform has changed; update ticks.
"""
tr = self.node_transform(self._linked_view.scene)
p1, p2 = tr.map(self._axis_ends())
if self.orientation in ('left', 'right'):
self.axis.domain = (p1[1], p2[1])
else:
... | python | def _view_changed(self, event=None):
"""Linked view transform has changed; update ticks.
"""
tr = self.node_transform(self._linked_view.scene)
p1, p2 = tr.map(self._axis_ends())
if self.orientation in ('left', 'right'):
self.axis.domain = (p1[1], p2[1])
else:
... | [
"def",
"_view_changed",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"tr",
"=",
"self",
".",
"node_transform",
"(",
"self",
".",
"_linked_view",
".",
"scene",
")",
"p1",
",",
"p2",
"=",
"tr",
".",
"map",
"(",
"self",
".",
"_axis_ends",
"(",
")... | Linked view transform has changed; update ticks. | [
"Linked",
"view",
"transform",
"has",
"changed",
";",
"update",
"ticks",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/axis.py#L81-L89 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py | MagnifyCamera.viewbox_mouse_event | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event.
"""
# When the attached ViewBox reseives a mouse event, it is sent to the
# camera here.
self.mouse_... | python | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event.
"""
# When the attached ViewBox reseives a mouse event, it is sent to the
# camera here.
self.mouse_... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"# When the attached ViewBox reseives a mouse event, it is sent to the",
"# camera here.",
"self",
".",
"mouse_pos",
"=",
"event",
".",
"pos",
"[",
":",
"2",
"]",
"if",
"event",
".",
"type",
"==",
... | ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event. | [
"ViewBox",
"mouse",
"event",
"handler"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py#L83-L110 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py | MagnifyCamera.on_timer | def on_timer(self, event=None):
"""Timer event handler
Parameters
----------
event : instance of Event
The timer event.
"""
# Smoothly update center and magnification properties of the transform
k = np.clip(100. / self.mag.mag, 10, 100)
s = 10... | python | def on_timer(self, event=None):
"""Timer event handler
Parameters
----------
event : instance of Event
The timer event.
"""
# Smoothly update center and magnification properties of the transform
k = np.clip(100. / self.mag.mag, 10, 100)
s = 10... | [
"def",
"on_timer",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Smoothly update center and magnification properties of the transform",
"k",
"=",
"np",
".",
"clip",
"(",
"100.",
"/",
"self",
".",
"mag",
".",
"mag",
",",
"10",
",",
"100",
")",
"s",
"... | Timer event handler
Parameters
----------
event : instance of Event
The timer event. | [
"Timer",
"event",
"handler"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py#L112-L137 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/gl/_gl2.py | glBufferData | def glBufferData(target, data, usage):
""" Data can be numpy array or the size of data to allocate.
"""
if isinstance(data, int):
size = data
data = ctypes.c_voidp(0)
else:
if not data.flags['C_CONTIGUOUS'] or not data.flags['ALIGNED']:
data = data.copy('C')
d... | python | def glBufferData(target, data, usage):
""" Data can be numpy array or the size of data to allocate.
"""
if isinstance(data, int):
size = data
data = ctypes.c_voidp(0)
else:
if not data.flags['C_CONTIGUOUS'] or not data.flags['ALIGNED']:
data = data.copy('C')
d... | [
"def",
"glBufferData",
"(",
"target",
",",
"data",
",",
"usage",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"int",
")",
":",
"size",
"=",
"data",
"data",
"=",
"ctypes",
".",
"c_voidp",
"(",
"0",
")",
"else",
":",
"if",
"not",
"data",
".",
"f... | Data can be numpy array or the size of data to allocate. | [
"Data",
"can",
"be",
"numpy",
"array",
"or",
"the",
"size",
"of",
"data",
"to",
"allocate",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/gl/_gl2.py#L123-L139 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | next_power_of_2 | def next_power_of_2(n):
""" Return next power of 2 greater than or equal to n """
n -= 1 # greater than OR EQUAL TO n
shift = 1
while (n + 1) & n: # n+1 is not a power of 2 yet
n |= n >> shift
shift *= 2
return max(4, n + 1) | python | def next_power_of_2(n):
""" Return next power of 2 greater than or equal to n """
n -= 1 # greater than OR EQUAL TO n
shift = 1
while (n + 1) & n: # n+1 is not a power of 2 yet
n |= n >> shift
shift *= 2
return max(4, n + 1) | [
"def",
"next_power_of_2",
"(",
"n",
")",
":",
"n",
"-=",
"1",
"# greater than OR EQUAL TO n",
"shift",
"=",
"1",
"while",
"(",
"n",
"+",
"1",
")",
"&",
"n",
":",
"# n+1 is not a power of 2 yet",
"n",
"|=",
"n",
">>",
"shift",
"shift",
"*=",
"2",
"return"... | Return next power of 2 greater than or equal to n | [
"Return",
"next",
"power",
"of",
"2",
"greater",
"than",
"or",
"equal",
"to",
"n"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L22-L29 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection.append | def append(self, vertices, uniforms=None, indices=None, itemsize=None):
"""
Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
... | python | def append(self, vertices, uniforms=None, indices=None, itemsize=None):
"""
Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
... | [
"def",
"append",
"(",
"self",
",",
"vertices",
",",
"uniforms",
"=",
"None",
",",
"indices",
"=",
"None",
",",
"itemsize",
"=",
"None",
")",
":",
"# Vertices",
"# -----------------------------",
"vertices",
"=",
"np",
".",
"array",
"(",
"vertices",
")",
".... | Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
indices : numpy array
An array whose dtype is compatible with self.idtype
... | [
"Parameters",
"----------"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L229-L313 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection._compute_texture_shape | def _compute_texture_shape(self, size=1):
""" Compute uniform texture shape """
# We should use this line but we may not have a GL context yet
# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)
linesize = 1024
count = self._uniforms_float_count
cols = 4 * linesize // i... | python | def _compute_texture_shape(self, size=1):
""" Compute uniform texture shape """
# We should use this line but we may not have a GL context yet
# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)
linesize = 1024
count = self._uniforms_float_count
cols = 4 * linesize // i... | [
"def",
"_compute_texture_shape",
"(",
"self",
",",
"size",
"=",
"1",
")",
":",
"# We should use this line but we may not have a GL context yet",
"# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)",
"linesize",
"=",
"1024",
"count",
"=",
"self",
".",
"_uniforms_float_count",
... | Compute uniform texture shape | [
"Compute",
"uniform",
"texture",
"shape"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L453-L464 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection._update | def _update(self):
""" Update vertex buffers & texture """
if self._vertices_buffer is not None:
self._vertices_buffer.delete()
self._vertices_buffer = VertexBuffer(self._vertices_list.data)
if self.itype is not None:
if self._indices_buffer is not None:
... | python | def _update(self):
""" Update vertex buffers & texture """
if self._vertices_buffer is not None:
self._vertices_buffer.delete()
self._vertices_buffer = VertexBuffer(self._vertices_list.data)
if self.itype is not None:
if self._indices_buffer is not None:
... | [
"def",
"_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vertices_buffer",
"is",
"not",
"None",
":",
"self",
".",
"_vertices_buffer",
".",
"delete",
"(",
")",
"self",
".",
"_vertices_buffer",
"=",
"VertexBuffer",
"(",
"self",
".",
"_vertices_list",
".... | Update vertex buffers & texture | [
"Update",
"vertex",
"buffers",
"&",
"texture"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L466-L498 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/__init__.py | get_layout | def get_layout(name, *args, **kwargs):
"""
Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all av... | python | def get_layout(name, *args, **kwargs):
"""
Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all av... | [
"def",
"get_layout",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"not",
"in",
"_layout_map",
":",
"raise",
"KeyError",
"(",
"\"Graph layout '%s' not found. Should be one of %s\"",
"%",
"(",
"name",
",",
"AVAILABLE_LAYOUTS",
... | Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all available layouts.
*args
Positional argum... | [
"Retrieve",
"a",
"graph",
"layout"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/__init__.py#L22-L53 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/common/compat.py | update_viewer_state | def update_viewer_state(rec, context):
"""
Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place.
"""
if '_protocol' not in rec:
rec.pop('properties')
rec['... | python | def update_viewer_state(rec, context):
"""
Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place.
"""
if '_protocol' not in rec:
rec.pop('properties')
rec['... | [
"def",
"update_viewer_state",
"(",
"rec",
",",
"context",
")",
":",
"if",
"'_protocol'",
"not",
"in",
"rec",
":",
"rec",
".",
"pop",
"(",
"'properties'",
")",
"rec",
"[",
"'state'",
"]",
"=",
"{",
"}",
"rec",
"[",
"'state'",
"]",
"[",
"'values'",
"]"... | Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place. | [
"Given",
"viewer",
"session",
"information",
"make",
"sure",
"the",
"session",
"information",
"is",
"compatible",
"with",
"the",
"current",
"version",
"of",
"the",
"viewers",
"and",
"if",
"not",
"update",
"the",
"session",
"information",
"in",
"-",
"place",
".... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/common/compat.py#L18-L55 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/preprocessor.py | remove_comments | def remove_comments(code):
"""Remove C-style comment from GLSL code string."""
pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*\n)"
# first group captures quoted strings (double or single)
# second group captures comments (//single-line or /* multi-line */)
regex = re.compile(pattern, re.MULTILI... | python | def remove_comments(code):
"""Remove C-style comment from GLSL code string."""
pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*\n)"
# first group captures quoted strings (double or single)
# second group captures comments (//single-line or /* multi-line */)
regex = re.compile(pattern, re.MULTILI... | [
"def",
"remove_comments",
"(",
"code",
")",
":",
"pattern",
"=",
"r\"(\\\".*?\\\"|\\'.*?\\')|(/\\*.*?\\*/|//[^\\r\\n]*\\n)\"",
"# first group captures quoted strings (double or single)",
"# second group captures comments (//single-line or /* multi-line */)",
"regex",
"=",
"re",
".",
"c... | Remove C-style comment from GLSL code string. | [
"Remove",
"C",
"-",
"style",
"comment",
"from",
"GLSL",
"code",
"string",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/preprocessor.py#L12-L28 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/preprocessor.py | merge_includes | def merge_includes(code):
"""Merge all includes recursively."""
pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
regex = re.compile(pattern)
includes = []
def replace(match):
filename = match.group("filename")
if filename not in includes:
includes.append... | python | def merge_includes(code):
"""Merge all includes recursively."""
pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
regex = re.compile(pattern)
includes = []
def replace(match):
filename = match.group("filename")
if filename not in includes:
includes.append... | [
"def",
"merge_includes",
"(",
"code",
")",
":",
"pattern",
"=",
"'\\#\\s*include\\s*\"(?P<filename>[a-zA-Z0-9\\_\\-\\.\\/]+)\"'",
"regex",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"includes",
"=",
"[",
"]",
"def",
"replace",
"(",
"match",
")",
":",
"filen... | Merge all includes recursively. | [
"Merge",
"all",
"includes",
"recursively",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/preprocessor.py#L31-L61 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_widget | def add_widget(self, widget=None, row=None, col=None, row_span=1,
col_span=1, **kwargs):
"""
Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Paramet... | python | def add_widget(self, widget=None, row=None, col=None, row_span=1,
col_span=1, **kwargs):
"""
Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Paramet... | [
"def",
"add_widget",
"(",
"self",
",",
"widget",
"=",
"None",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"row",
"is",
"None",
":",
"row",
"=",... | Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Parameters
----------
widget : Widget | None
The Widget to add. New widget is constructed if widget is None... | [
"Add",
"a",
"new",
"widget",
"to",
"this",
"grid",
".",
"This",
"will",
"cause",
"other",
"widgets",
"in",
"the",
"grid",
"to",
"be",
"resized",
"to",
"make",
"room",
"for",
"the",
"new",
"widget",
".",
"Can",
"be",
"used",
"to",
"replace",
"a",
"wid... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L85-L148 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.remove_widget | def remove_widget(self, widget):
"""Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove
"""
self._grid_widgets = dict((key, val)
for (key, val) in self._grid_widgets.items()
... | python | def remove_widget(self, widget):
"""Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove
"""
self._grid_widgets = dict((key, val)
for (key, val) in self._grid_widgets.items()
... | [
"def",
"remove_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_grid_widgets",
"=",
"dict",
"(",
"(",
"key",
",",
"val",
")",
"for",
"(",
"key",
",",
"val",
")",
"in",
"self",
".",
"_grid_widgets",
".",
"items",
"(",
")",
"if",
"val",
... | Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove | [
"Remove",
"a",
"widget",
"from",
"this",
"grid"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L150-L163 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.resize_widget | def resize_widget(self, widget, row_span, col_span):
"""Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
... | python | def resize_widget(self, widget, row_span, col_span):
"""Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
... | [
"def",
"resize_widget",
"(",
"self",
",",
"widget",
",",
"row_span",
",",
"col_span",
")",
":",
"row",
"=",
"None",
"col",
"=",
"None",
"for",
"(",
"r",
",",
"c",
",",
"rspan",
",",
"cspan",
",",
"w",
")",
"in",
"self",
".",
"_grid_widgets",
".",
... | Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
The number of columns to be occupied by this widget. | [
"Resize",
"a",
"widget",
"in",
"the",
"grid",
"to",
"new",
"dimensions",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L165-L193 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_grid | def add_grid(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The ... | python | def add_grid(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The ... | [
"def",
"add_grid",
"(",
"self",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"grid",
"import",
"Grid",
"grid",
"=",
"Grid",
"(",
"*",
"*"... | Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The column in which to add the widget (0 is the leftmost column)
row_span : int
The number of r... | [
"Create",
"a",
"new",
"Grid",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L198-L218 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_view | def add_view(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
T... | python | def add_view(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
T... | [
"def",
"add_view",
"(",
"self",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"viewbox",
"import",
"ViewBox",
"view",
"=",
"ViewBox",
"(",
"... | Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The column in which to add the widget (0 is the leftmost column)
row_span : int
The number o... | [
"Create",
"a",
"new",
"ViewBox",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L220-L240 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/fontconfig.py | find_font | def find_font(face, bold, italic):
"""Find font"""
bold = FC_WEIGHT_BOLD if bold else FC_WEIGHT_REGULAR
italic = FC_SLANT_ITALIC if italic else FC_SLANT_ROMAN
face = face.encode('utf8')
fontconfig.FcInit()
pattern = fontconfig.FcPatternCreate()
fontconfig.FcPatternAddInteger(pattern, FC_WEIG... | python | def find_font(face, bold, italic):
"""Find font"""
bold = FC_WEIGHT_BOLD if bold else FC_WEIGHT_REGULAR
italic = FC_SLANT_ITALIC if italic else FC_SLANT_ROMAN
face = face.encode('utf8')
fontconfig.FcInit()
pattern = fontconfig.FcPatternCreate()
fontconfig.FcPatternAddInteger(pattern, FC_WEIG... | [
"def",
"find_font",
"(",
"face",
",",
"bold",
",",
"italic",
")",
":",
"bold",
"=",
"FC_WEIGHT_BOLD",
"if",
"bold",
"else",
"FC_WEIGHT_REGULAR",
"italic",
"=",
"FC_SLANT_ITALIC",
"if",
"italic",
"else",
"FC_SLANT_ROMAN",
"face",
"=",
"face",
".",
"encode",
"... | Find font | [
"Find",
"font"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/fontconfig.py#L85-L111 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/fontconfig.py | _list_fonts | def _list_fonts():
"""List system fonts"""
stdout_, stderr = run_subprocess(['fc-list', ':scalable=true', 'family'])
vals = [v.split(',')[0] for v in stdout_.strip().splitlines(False)]
return vals | python | def _list_fonts():
"""List system fonts"""
stdout_, stderr = run_subprocess(['fc-list', ':scalable=true', 'family'])
vals = [v.split(',')[0] for v in stdout_.strip().splitlines(False)]
return vals | [
"def",
"_list_fonts",
"(",
")",
":",
"stdout_",
",",
"stderr",
"=",
"run_subprocess",
"(",
"[",
"'fc-list'",
",",
"':scalable=true'",
",",
"'family'",
"]",
")",
"vals",
"=",
"[",
"v",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
"for",
"v",
"in",
... | List system fonts | [
"List",
"system",
"fonts"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/fontconfig.py#L114-L118 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _get_vispy_caller | def _get_vispy_caller():
"""Helper to get vispy calling function from the stack"""
records = inspect.stack()
# first few records are vispy-based logging calls
for record in records[5:]:
module = record[0].f_globals['__name__']
if module.startswith('vispy'):
line = str(record[... | python | def _get_vispy_caller():
"""Helper to get vispy calling function from the stack"""
records = inspect.stack()
# first few records are vispy-based logging calls
for record in records[5:]:
module = record[0].f_globals['__name__']
if module.startswith('vispy'):
line = str(record[... | [
"def",
"_get_vispy_caller",
"(",
")",
":",
"records",
"=",
"inspect",
".",
"stack",
"(",
")",
"# first few records are vispy-based logging calls",
"for",
"record",
"in",
"records",
"[",
"5",
":",
"]",
":",
"module",
"=",
"record",
"[",
"0",
"]",
".",
"f_glob... | Helper to get vispy calling function from the stack | [
"Helper",
"to",
"get",
"vispy",
"calling",
"function",
"from",
"the",
"stack"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L22-L35 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | set_log_level | def set_log_level(verbose, match=None, return_old=False):
"""Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that thes... | python | def set_log_level(verbose, match=None, return_old=False):
"""Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that thes... | [
"def",
"set_log_level",
"(",
"verbose",
",",
"match",
"=",
"None",
",",
"return_old",
"=",
"False",
")",
":",
"# This method is responsible for setting properties of the handler and",
"# formatter such that proper messages (possibly with the vispy caller",
"# prepended) are displayed... | Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that these are for
convenience and are equivalent to passing in lo... | [
"Convenience",
"function",
"for",
"setting",
"the",
"logging",
"level"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L129-L183 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | log_exception | def log_exception(level='warning', tb_skip=2):
"""
Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the... | python | def log_exception(level='warning', tb_skip=2):
"""
Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the... | [
"def",
"log_exception",
"(",
"level",
"=",
"'warning'",
",",
"tb_skip",
"=",
"2",
")",
":",
"stack",
"=",
"\"\"",
".",
"join",
"(",
"traceback",
".",
"format_stack",
"(",
")",
"[",
":",
"-",
"tb_skip",
"]",
")",
"tb",
"=",
"traceback",
".",
"format_e... | Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the exception was caught.
Parameters
----------
... | [
"Send",
"an",
"exception",
"and",
"traceback",
"to",
"the",
"logger",
".",
"This",
"function",
"is",
"used",
"in",
"cases",
"where",
"an",
"exception",
"is",
"handled",
"safely",
"but",
"nevertheless",
"should",
"generate",
"a",
"descriptive",
"error",
"messag... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L249-L271 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _handle_exception | def _handle_exception(ignore_callback_errors, print_callback_errors, obj,
cb_event=None, node=None):
"""Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example.
"""
if not hasattr(obj, '_vispy_err_registry'):
obj._vispy_err_registry = {}
... | python | def _handle_exception(ignore_callback_errors, print_callback_errors, obj,
cb_event=None, node=None):
"""Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example.
"""
if not hasattr(obj, '_vispy_err_registry'):
obj._vispy_err_registry = {}
... | [
"def",
"_handle_exception",
"(",
"ignore_callback_errors",
",",
"print_callback_errors",
",",
"obj",
",",
"cb_event",
"=",
"None",
",",
"node",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'_vispy_err_registry'",
")",
":",
"obj",
".",
"_v... | Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example. | [
"Helper",
"for",
"prining",
"errors",
"in",
"callbacks"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L276-L334 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _serialize_buffer | def _serialize_buffer(buffer, array_serialization=None):
"""Serialize a NumPy array."""
if array_serialization == 'binary':
# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()
# but tostring() is still here for now for backward compatibility.
return buffer.ravel().tostring(... | python | def _serialize_buffer(buffer, array_serialization=None):
"""Serialize a NumPy array."""
if array_serialization == 'binary':
# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()
# but tostring() is still here for now for backward compatibility.
return buffer.ravel().tostring(... | [
"def",
"_serialize_buffer",
"(",
"buffer",
",",
"array_serialization",
"=",
"None",
")",
":",
"if",
"array_serialization",
"==",
"'binary'",
":",
"# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()",
"# but tostring() is still here for now for backward compatibility.",... | Serialize a NumPy array. | [
"Serialize",
"a",
"NumPy",
"array",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L337-L348 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _VispyStreamHandler._vispy_emit_match_andor_record | def _vispy_emit_match_andor_record(self, record):
"""Log message emitter that optionally matches and/or records"""
test = record.getMessage()
match = self._vispy_match
if (match is None or re.search(match, test) or
re.search(match, _get_vispy_caller())):
if se... | python | def _vispy_emit_match_andor_record(self, record):
"""Log message emitter that optionally matches and/or records"""
test = record.getMessage()
match = self._vispy_match
if (match is None or re.search(match, test) or
re.search(match, _get_vispy_caller())):
if se... | [
"def",
"_vispy_emit_match_andor_record",
"(",
"self",
",",
"record",
")",
":",
"test",
"=",
"record",
".",
"getMessage",
"(",
")",
"match",
"=",
"self",
".",
"_vispy_match",
"if",
"(",
"match",
"is",
"None",
"or",
"re",
".",
"search",
"(",
"match",
",",
... | Log message emitter that optionally matches and/or records | [
"Log",
"message",
"emitter",
"that",
"optionally",
"matches",
"and",
"/",
"or",
"records"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L82-L94 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.create | def create(self, obj, ref=None):
""" Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*.
"""
if isinstance(ref, Variable):
ref = ref.name
elif isinstance(ref, string_types) and ref.startswith('gl_'):
... | python | def create(self, obj, ref=None):
""" Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*.
"""
if isinstance(ref, Variable):
ref = ref.name
elif isinstance(ref, string_types) and ref.startswith('gl_'):
... | [
"def",
"create",
"(",
"self",
",",
"obj",
",",
"ref",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"ref",
",",
"Variable",
")",
":",
"ref",
"=",
"ref",
".",
"name",
"elif",
"isinstance",
"(",
"ref",
",",
"string_types",
")",
"and",
"ref",
".",
... | Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*. | [
"Convert",
"*",
"obj",
"*",
"to",
"a",
"new",
"ShaderObject",
".",
"If",
"the",
"output",
"is",
"a",
"Variable",
"with",
"no",
"name",
"then",
"set",
"its",
"name",
"using",
"*",
"ref",
"*",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L24-L50 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.dependencies | def dependencies(self, sort=False):
""" Return all dependencies required to use this object. The last item
in the list is *self*.
"""
alldeps = []
if sort:
def key(obj):
# sort deps such that we get functions, variables, self.
if not i... | python | def dependencies(self, sort=False):
""" Return all dependencies required to use this object. The last item
in the list is *self*.
"""
alldeps = []
if sort:
def key(obj):
# sort deps such that we get functions, variables, self.
if not i... | [
"def",
"dependencies",
"(",
"self",
",",
"sort",
"=",
"False",
")",
":",
"alldeps",
"=",
"[",
"]",
"if",
"sort",
":",
"def",
"key",
"(",
"obj",
")",
":",
"# sort deps such that we get functions, variables, self.",
"if",
"not",
"isinstance",
"(",
"obj",
",",
... | Return all dependencies required to use this object. The last item
in the list is *self*. | [
"Return",
"all",
"dependencies",
"required",
"to",
"use",
"this",
"object",
".",
"The",
"last",
"item",
"in",
"the",
"list",
"is",
"*",
"self",
"*",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L77-L97 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._add_dep | def _add_dep(self, dep):
""" Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event.
"""
if dep in self._deps:
self._deps[dep] += 1
else:
self._deps[dep] = 1
dep._dependents[self] = None | python | def _add_dep(self, dep):
""" Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event.
"""
if dep in self._deps:
self._deps[dep] += 1
else:
self._deps[dep] = 1
dep._dependents[self] = None | [
"def",
"_add_dep",
"(",
"self",
",",
"dep",
")",
":",
"if",
"dep",
"in",
"self",
".",
"_deps",
":",
"self",
".",
"_deps",
"[",
"dep",
"]",
"+=",
"1",
"else",
":",
"self",
".",
"_deps",
"[",
"dep",
"]",
"=",
"1",
"dep",
".",
"_dependents",
"[",
... | Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event. | [
"Increment",
"the",
"reference",
"count",
"for",
"*",
"dep",
"*",
".",
"If",
"this",
"is",
"a",
"new",
"dependency",
"then",
"connect",
"to",
"its",
"*",
"changed",
"*",
"event",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L108-L116 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._remove_dep | def _remove_dep(self, dep):
""" Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected.
"""
refcount = self._deps[dep]
if refcount == 1:
self._deps.pop(dep)
... | python | def _remove_dep(self, dep):
""" Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected.
"""
refcount = self._deps[dep]
if refcount == 1:
self._deps.pop(dep)
... | [
"def",
"_remove_dep",
"(",
"self",
",",
"dep",
")",
":",
"refcount",
"=",
"self",
".",
"_deps",
"[",
"dep",
"]",
"if",
"refcount",
"==",
"1",
":",
"self",
".",
"_deps",
".",
"pop",
"(",
"dep",
")",
"dep",
".",
"_dependents",
".",
"pop",
"(",
"sel... | Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected. | [
"Decrement",
"the",
"reference",
"count",
"for",
"*",
"dep",
"*",
".",
"If",
"the",
"reference",
"count",
"reaches",
"0",
"then",
"the",
"dependency",
"is",
"removed",
"and",
"its",
"*",
"changed",
"*",
"event",
"is",
"disconnected",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L118-L128 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._dep_changed | def _dep_changed(self, dep, code_changed=False, value_changed=False):
""" Called when a dependency's expression has changed.
"""
self.changed(code_changed, value_changed) | python | def _dep_changed(self, dep, code_changed=False, value_changed=False):
""" Called when a dependency's expression has changed.
"""
self.changed(code_changed, value_changed) | [
"def",
"_dep_changed",
"(",
"self",
",",
"dep",
",",
"code_changed",
"=",
"False",
",",
"value_changed",
"=",
"False",
")",
":",
"self",
".",
"changed",
"(",
"code_changed",
",",
"value_changed",
")"
] | Called when a dependency's expression has changed. | [
"Called",
"when",
"a",
"dependency",
"s",
"expression",
"has",
"changed",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L130-L133 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.changed | def changed(self, code_changed=False, value_changed=False):
"""Inform dependents that this shaderobject has changed.
"""
for d in self._dependents:
d._dep_changed(self, code_changed=code_changed,
value_changed=value_changed) | python | def changed(self, code_changed=False, value_changed=False):
"""Inform dependents that this shaderobject has changed.
"""
for d in self._dependents:
d._dep_changed(self, code_changed=code_changed,
value_changed=value_changed) | [
"def",
"changed",
"(",
"self",
",",
"code_changed",
"=",
"False",
",",
"value_changed",
"=",
"False",
")",
":",
"for",
"d",
"in",
"self",
".",
"_dependents",
":",
"d",
".",
"_dep_changed",
"(",
"self",
",",
"code_changed",
"=",
"code_changed",
",",
"valu... | Inform dependents that this shaderobject has changed. | [
"Inform",
"dependents",
"that",
"this",
"shaderobject",
"has",
"changed",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L135-L140 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/eq.py | eq | def eq(a, b):
""" The great missing equivalence function: Guaranteed evaluation
to a single bool value.
"""
if a is b:
return True
if a is None or b is None:
return True if a is None and b is None else False
try:
e = a == b
except ValueError:
return False
... | python | def eq(a, b):
""" The great missing equivalence function: Guaranteed evaluation
to a single bool value.
"""
if a is b:
return True
if a is None or b is None:
return True if a is None and b is None else False
try:
e = a == b
except ValueError:
return False
... | [
"def",
"eq",
"(",
"a",
",",
"b",
")",
":",
"if",
"a",
"is",
"b",
":",
"return",
"True",
"if",
"a",
"is",
"None",
"or",
"b",
"is",
"None",
":",
"return",
"True",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
"else",
"False",
"try",
":",
... | The great missing equivalence function: Guaranteed evaluation
to a single bool value. | [
"The",
"great",
"missing",
"equivalence",
"function",
":",
"Guaranteed",
"evaluation",
"to",
"a",
"single",
"bool",
"value",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/eq.py#L5-L41 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.zoom | def zoom(self, factor, center=None):
""" Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 ... | python | def zoom(self, factor, center=None):
""" Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 ... | [
"def",
"zoom",
"(",
"self",
",",
"factor",
",",
"center",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"center",
")",
"in",
"(",
"2",
",",
"3",
",",
"4",
")",
"# Get scale factor, take scale ratio into account",
"if",
"np",
".",
"isscalar",
"(",
"factor"... | Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 elements
The center of the view. If n... | [
"Zoom",
"in",
"(",
"or",
"out",
")",
"at",
"the",
"given",
"center"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L76-L114 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.pan | def pan(self, *pan):
"""Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene.
"""
if len(pan) == 1:
pan = pan[0]
self.rect = self.rect + pan | python | def pan(self, *pan):
"""Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene.
"""
if len(pan) == 1:
pan = pan[0]
self.rect = self.rect + pan | [
"def",
"pan",
"(",
"self",
",",
"*",
"pan",
")",
":",
"if",
"len",
"(",
"pan",
")",
"==",
"1",
":",
"pan",
"=",
"pan",
"[",
"0",
"]",
"self",
".",
"rect",
"=",
"self",
".",
"rect",
"+",
"pan"
] | Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene. | [
"Pan",
"the",
"view",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L116-L127 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.viewbox_mouse_event | def viewbox_mouse_event(self, event):
"""
The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event.
"""
if event.handled or not self.interactive:
return
#... | python | def viewbox_mouse_event(self, event):
"""
The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event.
"""
if event.handled or not self.interactive:
return
#... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"# Scrolling",
"BaseCamera",
".",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
... | The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event. | [
"The",
"SubScene",
"received",
"a",
"mouse",
"event",
";",
"update",
"transform",
"accordingly",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L191-L244 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/volume.py | VolumeVisual.set_data | def set_data(self, vol, clim=None):
""" Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values.
"""
# Check volume
if not isinstance... | python | def set_data(self, vol, clim=None):
""" Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values.
"""
# Check volume
if not isinstance... | [
"def",
"set_data",
"(",
"self",
",",
"vol",
",",
"clim",
"=",
"None",
")",
":",
"# Check volume",
"if",
"not",
"isinstance",
"(",
"vol",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"'Volume visual needs a numpy array.'",
")",
"if",
"no... | Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values. | [
"Set",
"the",
"volume",
"data",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/volume.py#L450-L496 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/volume.py | VolumeVisual._create_vertex_data | def _create_vertex_data(self):
""" Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total.
"""
shape = self._vol_shape
# Get corner coordinates. The -0.... | python | def _create_vertex_data(self):
""" Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total.
"""
shape = self._vol_shape
# Get corner coordinates. The -0.... | [
"def",
"_create_vertex_data",
"(",
"self",
")",
":",
"shape",
"=",
"self",
".",
"_vol_shape",
"# Get corner coordinates. The -0.5 offset is to center",
"# pixels/voxels. This works correctly for anisotropic data.",
"x0",
",",
"x1",
"=",
"-",
"0.5",
",",
"shape",
"[",
"2",... | Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total. | [
"Create",
"and",
"set",
"positions",
"and",
"texture",
"coords",
"from",
"the",
"given",
"shape",
"We",
"have",
"six",
"faces",
"with",
"1",
"quad",
"(",
"2",
"triangles",
")",
"each",
"resulting",
"in",
"6",
"*",
"2",
"*",
"3",
"=",
"36",
"vertices",
... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/volume.py#L583-L625 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/linear_region.py | LinearRegionVisual.set_data | def set_data(self, pos=None, color=None):
"""Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have ... | python | def set_data(self, pos=None, color=None):
"""Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have ... | [
"def",
"set_data",
"(",
"self",
",",
"pos",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"new_pos",
"=",
"self",
".",
"_pos",
"new_color",
"=",
"self",
".",
"_color",
"if",
"pos",
"is",
"not",
"None",
":",
"num_elements",
"=",
"len",
"(",
"pos... | Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have a shape of
(1, 4) for a single color regi... | [
"Set",
"the",
"data"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/linear_region.py#L87-L142 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/linear_region.py | LinearRegionVisual._prepare_draw | def _prepare_draw(self, view=None):
"""This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn.
"""
if self._changed['pos']:
self.pos_buf.set_data(self._pos)
self._changed['pos'] = False
if self.... | python | def _prepare_draw(self, view=None):
"""This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn.
"""
if self._changed['pos']:
self.pos_buf.set_data(self._pos)
self._changed['pos'] = False
if self.... | [
"def",
"_prepare_draw",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"if",
"self",
".",
"_changed",
"[",
"'pos'",
"]",
":",
"self",
".",
"pos_buf",
".",
"set_data",
"(",
"self",
".",
"_pos",
")",
"self",
".",
"_changed",
"[",
"'pos'",
"]",
"=",... | This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn. | [
"This",
"method",
"is",
"called",
"immediately",
"before",
"each",
"draw",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/linear_region.py#L180-L195 |
anjishnu/ask-alexa-pykit | examples/useful_science/useful_science.py | SimplePostsCache.refresh_cache | def refresh_cache(self, cat_id):
'''
Repopulate cache
'''
self.cache[cat_id] = most_recent_25_posts_by_category(cat_id)
self.last_refresh[cat_id] = datetime.now()
print ('Cache refresh at...', str(self.last_refresh[cat_id])) | python | def refresh_cache(self, cat_id):
'''
Repopulate cache
'''
self.cache[cat_id] = most_recent_25_posts_by_category(cat_id)
self.last_refresh[cat_id] = datetime.now()
print ('Cache refresh at...', str(self.last_refresh[cat_id])) | [
"def",
"refresh_cache",
"(",
"self",
",",
"cat_id",
")",
":",
"self",
".",
"cache",
"[",
"cat_id",
"]",
"=",
"most_recent_25_posts_by_category",
"(",
"cat_id",
")",
"self",
".",
"last_refresh",
"[",
"cat_id",
"]",
"=",
"datetime",
".",
"now",
"(",
")",
"... | Repopulate cache | [
"Repopulate",
"cache"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/useful_science/useful_science.py#L57-L63 |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet._merge_intervals | def _merge_intervals(self, min_depth):
"""
Merge overlapping intervals.
This method is called only once in the constructor.
"""
def add_interval(ret, start, stop):
if min_depth is not None:
shift = 2 * (29 - min_depth)
mask = (int(1) <... | python | def _merge_intervals(self, min_depth):
"""
Merge overlapping intervals.
This method is called only once in the constructor.
"""
def add_interval(ret, start, stop):
if min_depth is not None:
shift = 2 * (29 - min_depth)
mask = (int(1) <... | [
"def",
"_merge_intervals",
"(",
"self",
",",
"min_depth",
")",
":",
"def",
"add_interval",
"(",
"ret",
",",
"start",
",",
"stop",
")",
":",
"if",
"min_depth",
"is",
"not",
"None",
":",
"shift",
"=",
"2",
"*",
"(",
"29",
"-",
"min_depth",
")",
"mask",... | Merge overlapping intervals.
This method is called only once in the constructor. | [
"Merge",
"overlapping",
"intervals",
"."
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L98-L147 |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet.union | def union(self, another_is):
"""
Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is... | python | def union(self, another_is):
"""
Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is... | [
"def",
"union",
"(",
"self",
",",
"another_is",
")",
":",
"result",
"=",
"IntervalSet",
"(",
")",
"if",
"another_is",
".",
"empty",
"(",
")",
":",
"result",
".",
"_intervals",
"=",
"self",
".",
"_intervals",
"elif",
"self",
".",
"empty",
"(",
")",
":... | Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is``. | [
"Return",
"the",
"union",
"between",
"self",
"and",
"another_is",
"."
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L149-L172 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.