repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
glue-viz/glue-vispy-viewers | glue_vispy_viewers/volume/layer_artist.py | VolumeLayerArtist.remove | def remove(self):
"""
Remove the layer artist for good
"""
self._multivol.deallocate(self.id)
ARRAY_CACHE.pop(self.id, None)
PIXEL_CACHE.pop(self.id, None) | python | def remove(self):
"""
Remove the layer artist for good
"""
self._multivol.deallocate(self.id)
ARRAY_CACHE.pop(self.id, None)
PIXEL_CACHE.pop(self.id, None) | [
"def",
"remove",
"(",
"self",
")",
":",
"self",
".",
"_multivol",
".",
"deallocate",
"(",
"self",
".",
"id",
")",
"ARRAY_CACHE",
".",
"pop",
"(",
"self",
".",
"id",
",",
"None",
")",
"PIXEL_CACHE",
".",
"pop",
"(",
"self",
".",
"id",
",",
"None",
... | Remove the layer artist for good | [
"Remove",
"the",
"layer",
"artist",
"for",
"good"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/volume/layer_artist.py#L151-L157 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py | _inject | def _inject():
""" Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API.
"""
# Get namespaces
NS = globals()
GLNS = _GL.__dict__
# Get names that we use in our API
used_names = []
used_names.extend([names[0] ... | python | def _inject():
""" Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API.
"""
# Get namespaces
NS = globals()
GLNS = _GL.__dict__
# Get names that we use in our API
used_names = []
used_names.extend([names[0] ... | [
"def",
"_inject",
"(",
")",
":",
"# Get namespaces",
"NS",
"=",
"globals",
"(",
")",
"GLNS",
"=",
"_GL",
".",
"__dict__",
"# Get names that we use in our API",
"used_names",
"=",
"[",
"]",
"used_names",
".",
"extend",
"(",
"[",
"names",
"[",
"0",
"]",
"for... | Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API. | [
"Inject",
"functions",
"and",
"constants",
"from",
"PyOpenGL",
"but",
"leave",
"out",
"the",
"names",
"that",
"are",
"deprecated",
"or",
"that",
"we",
"provide",
"in",
"our",
"API",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py#L17-L53 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/six.py | _find_module | def _find_module(name, path=None):
"""
Alternative to `imp.find_module` that can also search in subpackages.
"""
parts = name.split('.')
for part in parts:
if path is not None:
path = [path]
fh, path, descr = imp.find_module(part, path)
if fh is not None and pa... | python | def _find_module(name, path=None):
"""
Alternative to `imp.find_module` that can also search in subpackages.
"""
parts = name.split('.')
for part in parts:
if path is not None:
path = [path]
fh, path, descr = imp.find_module(part, path)
if fh is not None and pa... | [
"def",
"_find_module",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"for",
"part",
"in",
"parts",
":",
"if",
"path",
"is",
"not",
"None",
":",
"path",
"=",
"[",
"path",
"]",
"fh",
",",
"p... | Alternative to `imp.find_module` that can also search in subpackages. | [
"Alternative",
"to",
"imp",
".",
"find_module",
"that",
"can",
"also",
"search",
"in",
"subpackages",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/six.py#L25-L40 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | triangulate | def triangulate(vertices):
"""Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles.
"""
n = len(vertices)
vertices = np.asarray... | python | def triangulate(vertices):
"""Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles.
"""
n = len(vertices)
vertices = np.asarray... | [
"def",
"triangulate",
"(",
"vertices",
")",
":",
"n",
"=",
"len",
"(",
"vertices",
")",
"vertices",
"=",
"np",
".",
"asarray",
"(",
"vertices",
")",
"zmean",
"=",
"vertices",
"[",
":",
",",
"2",
"]",
".",
"mean",
"(",
")",
"vertices_2d",
"=",
"vert... | Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles. | [
"Triangulate",
"a",
"set",
"of",
"vertices"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L999-L1029 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation.triangulate | def triangulate(self):
"""Do the triangulation
"""
self._initialize()
pts = self.pts
front = self._front
## Begin sweep (sec. 3.4)
for i in range(3, pts.shape[0]):
pi = pts[i]
#debug("========== New point %d: %s ==========... | python | def triangulate(self):
"""Do the triangulation
"""
self._initialize()
pts = self.pts
front = self._front
## Begin sweep (sec. 3.4)
for i in range(3, pts.shape[0]):
pi = pts[i]
#debug("========== New point %d: %s ==========... | [
"def",
"triangulate",
"(",
"self",
")",
":",
"self",
".",
"_initialize",
"(",
")",
"pts",
"=",
"self",
".",
"pts",
"front",
"=",
"self",
".",
"_front",
"## Begin sweep (sec. 3.4)",
"for",
"i",
"in",
"range",
"(",
"3",
",",
"pts",
".",
"shape",
"[",
"... | Do the triangulation | [
"Do",
"the",
"triangulation"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L128-L214 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edge_event | def _edge_event(self, i, j):
"""
Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge.
"""
front_index = self._front.index(i)
#debug(" == edge event ==")
front = self._fro... | python | def _edge_event(self, i, j):
"""
Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge.
"""
front_index = self._front.index(i)
#debug(" == edge event ==")
front = self._fro... | [
"def",
"_edge_event",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"front_index",
"=",
"self",
".",
"_front",
".",
"index",
"(",
"i",
")",
"#debug(\" == edge event ==\")",
"front",
"=",
"self",
".",
"_front",
"# First just see whether this edge is already present",... | Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge. | [
"Force",
"edge",
"(",
"i",
"j",
")",
"to",
"be",
"present",
"in",
"mesh",
".",
"This",
"works",
"by",
"removing",
"intersected",
"triangles",
"and",
"filling",
"holes",
"up",
"to",
"the",
"cutting",
"edge",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L279-L493 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._find_cut_triangle | def _find_cut_triangle(self, edge):
"""
Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found.
"""
edges = [] # opposite edge for each triangle attached to edge[0]
for tri in self.tris:
... | python | def _find_cut_triangle(self, edge):
"""
Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found.
"""
edges = [] # opposite edge for each triangle attached to edge[0]
for tri in self.tris:
... | [
"def",
"_find_cut_triangle",
"(",
"self",
",",
"edge",
")",
":",
"edges",
"=",
"[",
"]",
"# opposite edge for each triangle attached to edge[0]",
"for",
"tri",
"in",
"self",
".",
"tris",
":",
"if",
"edge",
"[",
"0",
"]",
"in",
"tri",
":",
"edges",
".",
"ap... | Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found. | [
"Return",
"the",
"triangle",
"that",
"has",
"edge",
"[",
"0",
"]",
"as",
"one",
"of",
"its",
"vertices",
"and",
"is",
"bisected",
"by",
"edge",
".",
"Return",
"None",
"if",
"no",
"triangle",
"is",
"found",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L497-L518 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edge_in_front | def _edge_in_front(self, edge):
""" Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1
"""
e = (list(edge), list(edge)[::-1])
for i in range(len(self._front)-1):
if self._front[i:i+2] in e:
return i
... | python | def _edge_in_front(self, edge):
""" Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1
"""
e = (list(edge), list(edge)[::-1])
for i in range(len(self._front)-1):
if self._front[i:i+2] in e:
return i
... | [
"def",
"_edge_in_front",
"(",
"self",
",",
"edge",
")",
":",
"e",
"=",
"(",
"list",
"(",
"edge",
")",
",",
"list",
"(",
"edge",
")",
"[",
":",
":",
"-",
"1",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_front",
")",
... | Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1 | [
"Return",
"the",
"index",
"where",
"*",
"edge",
"*",
"appears",
"in",
"the",
"current",
"front",
".",
"If",
"the",
"edge",
"is",
"not",
"in",
"the",
"front",
"return",
"-",
"1"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L520-L528 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edge_opposite_point | def _edge_opposite_point(self, tri, i):
""" Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri.
"""
ind = tri.index(i)
return (tri[(ind+1) % 3], tri[(ind+2) % 3]) | python | def _edge_opposite_point(self, tri, i):
""" Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri.
"""
ind = tri.index(i)
return (tri[(ind+1) % 3], tri[(ind+2) % 3]) | [
"def",
"_edge_opposite_point",
"(",
"self",
",",
"tri",
",",
"i",
")",
":",
"ind",
"=",
"tri",
".",
"index",
"(",
"i",
")",
"return",
"(",
"tri",
"[",
"(",
"ind",
"+",
"1",
")",
"%",
"3",
"]",
",",
"tri",
"[",
"(",
"ind",
"+",
"2",
")",
"%"... | Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri. | [
"Given",
"a",
"triangle",
"return",
"the",
"edge",
"that",
"is",
"opposite",
"point",
"i",
".",
"Vertexes",
"are",
"returned",
"in",
"the",
"same",
"orientation",
"as",
"in",
"tri",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L530-L535 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._adjacent_tri | def _adjacent_tri(self, edge, i):
"""
Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle.
"""
if not np.isscalar(i):
i = [x for x in i if x not in edge][0]
try:
pt1 = self.... | python | def _adjacent_tri(self, edge, i):
"""
Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle.
"""
if not np.isscalar(i):
i = [x for x in i if x not in edge][0]
try:
pt1 = self.... | [
"def",
"_adjacent_tri",
"(",
"self",
",",
"edge",
",",
"i",
")",
":",
"if",
"not",
"np",
".",
"isscalar",
"(",
"i",
")",
":",
"i",
"=",
"[",
"x",
"for",
"x",
"in",
"i",
"if",
"x",
"not",
"in",
"edge",
"]",
"[",
"0",
"]",
"try",
":",
"pt1",
... | Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle. | [
"Given",
"a",
"triangle",
"formed",
"by",
"edge",
"and",
"i",
"return",
"the",
"triangle",
"that",
"shares",
"edge",
".",
"*",
"i",
"*",
"may",
"be",
"either",
"a",
"point",
"or",
"the",
"entire",
"triangle",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L537-L557 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._tri_from_edge | def _tri_from_edge(self, edge):
"""Return the only tri that contains *edge*. If two tris share this
edge, raise an exception.
"""
edge = tuple(edge)
p1 = self._edges_lookup.get(edge, None)
p2 = self._edges_lookup.get(edge[::-1], None)
if p1 is None:
if... | python | def _tri_from_edge(self, edge):
"""Return the only tri that contains *edge*. If two tris share this
edge, raise an exception.
"""
edge = tuple(edge)
p1 = self._edges_lookup.get(edge, None)
p2 = self._edges_lookup.get(edge[::-1], None)
if p1 is None:
if... | [
"def",
"_tri_from_edge",
"(",
"self",
",",
"edge",
")",
":",
"edge",
"=",
"tuple",
"(",
"edge",
")",
"p1",
"=",
"self",
".",
"_edges_lookup",
".",
"get",
"(",
"edge",
",",
"None",
")",
"p2",
"=",
"self",
".",
"_edges_lookup",
".",
"get",
"(",
"edge... | Return the only tri that contains *edge*. If two tris share this
edge, raise an exception. | [
"Return",
"the",
"only",
"tri",
"that",
"contains",
"*",
"edge",
"*",
".",
"If",
"two",
"tris",
"share",
"this",
"edge",
"raise",
"an",
"exception",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L559-L573 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edges_in_tri_except | def _edges_in_tri_except(self, tri, edge):
"""Return the edges in *tri*, excluding *edge*.
"""
edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)]
try:
edges.remove(tuple(edge))
except ValueError:
edges.remove(tuple(edge[::-1]))
return edges | python | def _edges_in_tri_except(self, tri, edge):
"""Return the edges in *tri*, excluding *edge*.
"""
edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)]
try:
edges.remove(tuple(edge))
except ValueError:
edges.remove(tuple(edge[::-1]))
return edges | [
"def",
"_edges_in_tri_except",
"(",
"self",
",",
"tri",
",",
"edge",
")",
":",
"edges",
"=",
"[",
"(",
"tri",
"[",
"i",
"]",
",",
"tri",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"3",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"3",
")",
"]",
"try",... | Return the edges in *tri*, excluding *edge*. | [
"Return",
"the",
"edges",
"in",
"*",
"tri",
"*",
"excluding",
"*",
"edge",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L575-L583 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edge_below_front | def _edge_below_front(self, edge, front_index):
"""Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*.
"""
f0 = self._front[front_index-1]
f1 = self._front[front_index+1]
return (self._orientati... | python | def _edge_below_front(self, edge, front_index):
"""Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*.
"""
f0 = self._front[front_index-1]
f1 = self._front[front_index+1]
return (self._orientati... | [
"def",
"_edge_below_front",
"(",
"self",
",",
"edge",
",",
"front_index",
")",
":",
"f0",
"=",
"self",
".",
"_front",
"[",
"front_index",
"-",
"1",
"]",
"f1",
"=",
"self",
".",
"_front",
"[",
"front_index",
"+",
"1",
"]",
"return",
"(",
"self",
".",
... | Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*. | [
"Return",
"True",
"if",
"*",
"edge",
"*",
"is",
"below",
"the",
"current",
"front",
".",
"One",
"of",
"the",
"points",
"in",
"*",
"edge",
"*",
"must",
"be",
"_on_",
"the",
"front",
"at",
"*",
"front_index",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L585-L593 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._intersected_edge | def _intersected_edge(self, edges, cut_edge):
""" Given a list of *edges*, return the first that is intersected by
*cut_edge*.
"""
for edge in edges:
if self._edges_intersect(edge, cut_edge):
return edge | python | def _intersected_edge(self, edges, cut_edge):
""" Given a list of *edges*, return the first that is intersected by
*cut_edge*.
"""
for edge in edges:
if self._edges_intersect(edge, cut_edge):
return edge | [
"def",
"_intersected_edge",
"(",
"self",
",",
"edges",
",",
"cut_edge",
")",
":",
"for",
"edge",
"in",
"edges",
":",
"if",
"self",
".",
"_edges_intersect",
"(",
"edge",
",",
"cut_edge",
")",
":",
"return",
"edge"
] | Given a list of *edges*, return the first that is intersected by
*cut_edge*. | [
"Given",
"a",
"list",
"of",
"*",
"edges",
"*",
"return",
"the",
"first",
"that",
"is",
"intersected",
"by",
"*",
"cut_edge",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L601-L607 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._find_edge_intersections | def _find_edge_intersections(self):
"""
Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split.
"""
edges = self.pts[self.edges]
cuts = {} # { edge: [(intercept, point), ...], ... }
for i in range(ed... | python | def _find_edge_intersections(self):
"""
Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split.
"""
edges = self.pts[self.edges]
cuts = {} # { edge: [(intercept, point), ...], ... }
for i in range(ed... | [
"def",
"_find_edge_intersections",
"(",
"self",
")",
":",
"edges",
"=",
"self",
".",
"pts",
"[",
"self",
".",
"edges",
"]",
"cuts",
"=",
"{",
"}",
"# { edge: [(intercept, point), ...], ... }",
"for",
"i",
"in",
"range",
"(",
"edges",
".",
"shape",
"[",
"0"... | Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split. | [
"Return",
"a",
"dictionary",
"containing",
"for",
"each",
"edge",
"in",
"self",
".",
"edges",
"a",
"list",
"of",
"the",
"positions",
"at",
"which",
"the",
"edge",
"should",
"be",
"split",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L609-L655 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._projection | def _projection(self, a, b, c):
"""Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes.
"""
ab = b - a
ac = c - a
return a + ((ab*ac).sum() / (ac*ac).sum()) * ac | python | def _projection(self, a, b, c):
"""Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes.
"""
ab = b - a
ac = c - a
return a + ((ab*ac).sum() / (ac*ac).sum()) * ac | [
"def",
"_projection",
"(",
"self",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"ab",
"=",
"b",
"-",
"a",
"ac",
"=",
"c",
"-",
"a",
"return",
"a",
"+",
"(",
"(",
"ab",
"*",
"ac",
")",
".",
"sum",
"(",
")",
"/",
"(",
"ac",
"*",
"ac",
")",
"... | Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes. | [
"Return",
"projection",
"of",
"(",
"a",
"b",
")",
"onto",
"(",
"a",
"c",
")",
"Arguments",
"are",
"point",
"locations",
"not",
"indexes",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L760-L766 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._edges_intersect | def _edges_intersect(self, edge1, edge2):
"""
Return 1 if edges intersect completely (endpoints excluded)
"""
h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)],
self.pts[np.array(edge2)])
h21 = self._intersect_edge_arrays(self.... | python | def _edges_intersect(self, edge1, edge2):
"""
Return 1 if edges intersect completely (endpoints excluded)
"""
h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)],
self.pts[np.array(edge2)])
h21 = self._intersect_edge_arrays(self.... | [
"def",
"_edges_intersect",
"(",
"self",
",",
"edge1",
",",
"edge2",
")",
":",
"h12",
"=",
"self",
".",
"_intersect_edge_arrays",
"(",
"self",
".",
"pts",
"[",
"np",
".",
"array",
"(",
"edge1",
")",
"]",
",",
"self",
".",
"pts",
"[",
"np",
".",
"arr... | Return 1 if edges intersect completely (endpoints excluded) | [
"Return",
"1",
"if",
"edges",
"intersect",
"completely",
"(",
"endpoints",
"excluded",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L809-L823 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._intersection_matrix | def _intersection_matrix(self, lines):
"""
Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).... | python | def _intersection_matrix(self, lines):
"""
Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).... | [
"def",
"_intersection_matrix",
"(",
"self",
",",
"lines",
")",
":",
"return",
"self",
".",
"_intersect_edge_arrays",
"(",
"lines",
"[",
":",
",",
"np",
".",
"newaxis",
",",
"...",
"]",
",",
"lines",
"[",
"np",
".",
"newaxis",
",",
"...",
"]",
")"
] | Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).
The intercept is described in intersect_e... | [
"Return",
"a",
"2D",
"array",
"of",
"intercepts",
"such",
"that",
"intercepts",
"[",
"i",
"j",
"]",
"is",
"the",
"intercept",
"of",
"lines",
"[",
"i",
"]",
"onto",
"lines",
"[",
"j",
"]",
".",
"*",
"lines",
"*",
"must",
"be",
"an",
"array",
"of",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L825-L836 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._intersect_edge_arrays | def _intersect_edge_arrays(self, lines1, lines2):
"""Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pa... | python | def _intersect_edge_arrays(self, lines1, lines2):
"""Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pa... | [
"def",
"_intersect_edge_arrays",
"(",
"self",
",",
"lines1",
",",
"lines2",
")",
":",
"# vector for each line in lines1",
"l1",
"=",
"lines1",
"[",
"...",
",",
"1",
",",
":",
"]",
"-",
"lines1",
"[",
"...",
",",
"0",
",",
":",
"]",
"# vector for each line ... | Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pair per point
Lines are compared elementwise across t... | [
"Return",
"the",
"intercepts",
"of",
"all",
"lines",
"defined",
"in",
"*",
"lines1",
"*",
"as",
"they",
"intersect",
"all",
"lines",
"in",
"*",
"lines2",
"*",
".",
"Arguments",
"are",
"of",
"shape",
"(",
"...",
"2",
"2",
")",
"where",
"axes",
"are",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L838-L878 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | Triangulation._orientation | def _orientation(self, edge, point):
""" Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel.
"""
v1 = self.pts[point] - self.pts[edge[0]]
v2 = self.pts[edge[1]] - self.pts[edge[0]]
c = np.cross(v1, v2) # positive i... | python | def _orientation(self, edge, point):
""" Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel.
"""
v1 = self.pts[point] - self.pts[edge[0]]
v2 = self.pts[edge[1]] - self.pts[edge[0]]
c = np.cross(v1, v2) # positive i... | [
"def",
"_orientation",
"(",
"self",
",",
"edge",
",",
"point",
")",
":",
"v1",
"=",
"self",
".",
"pts",
"[",
"point",
"]",
"-",
"self",
".",
"pts",
"[",
"edge",
"[",
"0",
"]",
"]",
"v2",
"=",
"self",
".",
"pts",
"[",
"edge",
"[",
"1",
"]",
... | Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel. | [
"Returns",
"+",
"1",
"if",
"edge",
"[",
"0",
"]",
"-",
">",
"point",
"is",
"clockwise",
"from",
"edge",
"[",
"0",
"]",
"-",
">",
"edge",
"[",
"1",
"]",
"-",
"1",
"if",
"counterclockwise",
"and",
"0",
"if",
"parallel",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L880-L887 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ipython/ipython.py | load_ipython_extension | def load_ipython_extension(ipython):
""" Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension
"""
import IPython
# don't continue if IPython version is < 3.0
... | python | def load_ipython_extension(ipython):
""" Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension
"""
import IPython
# don't continue if IPython version is < 3.0
... | [
"def",
"load_ipython_extension",
"(",
"ipython",
")",
":",
"import",
"IPython",
"# don't continue if IPython version is < 3.0",
"ipy_version",
"=",
"LooseVersion",
"(",
"IPython",
".",
"__version__",
")",
"if",
"ipy_version",
"<",
"LooseVersion",
"(",
"\"3.0.0\"",
")",
... | Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension | [
"Entry",
"point",
"of",
"the",
"IPython",
"extension"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L9-L30 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ipython/ipython.py | _load_webgl_backend | def _load_webgl_backend(ipython):
""" Load the webgl backend for the IPython notebook"""
from .. import app
app_instance = app.use_app("ipynb_webgl")
if app_instance.backend_name == "ipynb_webgl":
ipython.write("Vispy IPython module has loaded successfully")
else:
# TODO: Improve t... | python | def _load_webgl_backend(ipython):
""" Load the webgl backend for the IPython notebook"""
from .. import app
app_instance = app.use_app("ipynb_webgl")
if app_instance.backend_name == "ipynb_webgl":
ipython.write("Vispy IPython module has loaded successfully")
else:
# TODO: Improve t... | [
"def",
"_load_webgl_backend",
"(",
"ipython",
")",
":",
"from",
".",
".",
"import",
"app",
"app_instance",
"=",
"app",
".",
"use_app",
"(",
"\"ipynb_webgl\"",
")",
"if",
"app_instance",
".",
"backend_name",
"==",
"\"ipynb_webgl\"",
":",
"ipython",
".",
"write"... | Load the webgl backend for the IPython notebook | [
"Load",
"the",
"webgl",
"backend",
"for",
"the",
"IPython",
"notebook"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L33-L43 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/collection.py | Collection.draw | def draw(self, mode=None):
""" Draw collection """
if self._need_update:
self._update()
program = self._programs[0]
mode = mode or self._mode
if self._indices_list is not None:
program.draw(mode, self._indices_buffer)
else:
program.d... | python | def draw(self, mode=None):
""" Draw collection """
if self._need_update:
self._update()
program = self._programs[0]
mode = mode or self._mode
if self._indices_list is not None:
program.draw(mode, self._indices_buffer)
else:
program.d... | [
"def",
"draw",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"self",
".",
"_need_update",
":",
"self",
".",
"_update",
"(",
")",
"program",
"=",
"self",
".",
"_programs",
"[",
"0",
"]",
"mode",
"=",
"mode",
"or",
"self",
".",
"_mode",
"i... | Draw collection | [
"Draw",
"collection"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/collection.py#L197-L209 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/filter.py | gaussian_filter | def gaussian_filter(data, sigma):
"""
Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter)
"""
if np.isscalar(sigma):
sigma = (sigma,) * data.ndim
baseline = data.mean()
filtered = data - baseline
... | python | def gaussian_filter(data, sigma):
"""
Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter)
"""
if np.isscalar(sigma):
sigma = (sigma,) * data.ndim
baseline = data.mean()
filtered = data - baseline
... | [
"def",
"gaussian_filter",
"(",
"data",
",",
"sigma",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"sigma",
")",
":",
"sigma",
"=",
"(",
"sigma",
",",
")",
"*",
"data",
".",
"ndim",
"baseline",
"=",
"data",
".",
"mean",
"(",
")",
"filtered",
"=",
"... | Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter) | [
"Drop",
"-",
"in",
"replacement",
"for",
"scipy",
".",
"ndimage",
".",
"gaussian_filter",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/filter.py#L8-L44 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/transforms.py | translate | def translate(offset, dtype=None):
"""Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix descr... | python | def translate(offset, dtype=None):
"""Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix descr... | [
"def",
"translate",
"(",
"offset",
",",
"dtype",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"offset",
")",
"==",
"3",
"x",
",",
"y",
",",
"z",
"=",
"offset",
"M",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1.",
",",
"0.",
",",
"0.",
",",
"0... | Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing the translation. | [
"Translate",
"by",
"an",
"offset",
"(",
"x",
"y",
"z",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L15-L36 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/transforms.py | scale | def scale(s, dtype=None):
"""Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing ... | python | def scale(s, dtype=None):
"""Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing ... | [
"def",
"scale",
"(",
"s",
",",
"dtype",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"s",
")",
"==",
"3",
"return",
"np",
".",
"array",
"(",
"np",
".",
"diag",
"(",
"np",
".",
"concatenate",
"(",
"[",
"s",
",",
"(",
"1.",
",",
")",
"]",
")"... | Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing the scaling. | [
"Non",
"-",
"uniform",
"scaling",
"along",
"the",
"x",
"y",
"and",
"z",
"axes"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L39-L55 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/transforms.py | rotate | def rotate(angle, axis, dtype=None):
"""The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector.
"""
angle = np.radians(angle)
assert l... | python | def rotate(angle, axis, dtype=None):
"""The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector.
"""
angle = np.radians(angle)
assert l... | [
"def",
"rotate",
"(",
"angle",
",",
"axis",
",",
"dtype",
"=",
"None",
")",
":",
"angle",
"=",
"np",
".",
"radians",
"(",
"angle",
")",
"assert",
"len",
"(",
"axis",
")",
"==",
"3",
"x",
",",
"y",
",",
"z",
"=",
"axis",
"/",
"np",
".",
"linal... | The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector. | [
"The",
"3x3",
"rotation",
"matrix",
"for",
"rotation",
"about",
"a",
"vector",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L58-L77 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/transforms.py | perspective | def perspective(fovy, aspect, znear, zfar):
"""Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
... | python | def perspective(fovy, aspect, znear, zfar):
"""Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
... | [
"def",
"perspective",
"(",
"fovy",
",",
"aspect",
",",
"znear",
",",
"zfar",
")",
":",
"assert",
"(",
"znear",
"!=",
"zfar",
")",
"h",
"=",
"math",
".",
"tan",
"(",
"fovy",
"/",
"360.0",
"*",
"math",
".",
"pi",
")",
"*",
"znear",
"w",
"=",
"h",... | Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
Far coordinate of the field of view.
Returns... | [
"Create",
"perspective",
"projection",
"matrix"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L156-L178 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/transforms.py | affine_map | def affine_map(points1, points2):
""" Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3).
"""
A = np.ones((4, 4))
A[:, :3] = points1
B = np.ones((4, 4))
B[:, :3] = points2
# solve 3 sets of linear equat... | python | def affine_map(points1, points2):
""" Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3).
"""
A = np.ones((4, 4))
A[:, :3] = points1
B = np.ones((4, 4))
B[:, :3] = points2
# solve 3 sets of linear equat... | [
"def",
"affine_map",
"(",
"points1",
",",
"points2",
")",
":",
"A",
"=",
"np",
".",
"ones",
"(",
"(",
"4",
",",
"4",
")",
")",
"A",
"[",
":",
",",
":",
"3",
"]",
"=",
"points1",
"B",
"=",
"np",
".",
"ones",
"(",
"(",
"4",
",",
"4",
")",
... | Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3). | [
"Find",
"a",
"3D",
"transformation",
"matrix",
"that",
"maps",
"points1",
"onto",
"points2",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L181-L198 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/profiler.py | Profiler.finish | def finish(self, msg=None):
"""Add a final message; flush the message list if no parent profiler.
"""
if self._finished or self.disable:
return
self._finished = True
if msg is not None:
self(msg)
self._new_msg("< Exiting %s, total time: %0.... | python | def finish(self, msg=None):
"""Add a final message; flush the message list if no parent profiler.
"""
if self._finished or self.disable:
return
self._finished = True
if msg is not None:
self(msg)
self._new_msg("< Exiting %s, total time: %0.... | [
"def",
"finish",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"self",
".",
"_finished",
"or",
"self",
".",
"disable",
":",
"return",
"self",
".",
"_finished",
"=",
"True",
"if",
"msg",
"is",
"not",
"None",
":",
"self",
"(",
"msg",
")",
"... | Add a final message; flush the message list if no parent profiler. | [
"Add",
"a",
"final",
"message",
";",
"flush",
"the",
"message",
"list",
"if",
"no",
"parent",
"profiler",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/profiler.py#L121-L133 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _init | def _init():
""" Create global Config object, parse command flags
"""
global config, _data_path, _allowed_config_keys
app_dir = _get_vispy_app_dir()
if app_dir is not None:
_data_path = op.join(app_dir, 'data')
_test_data_path = op.join(app_dir, 'test_data')
else:
_data_... | python | def _init():
""" Create global Config object, parse command flags
"""
global config, _data_path, _allowed_config_keys
app_dir = _get_vispy_app_dir()
if app_dir is not None:
_data_path = op.join(app_dir, 'data')
_test_data_path = op.join(app_dir, 'test_data')
else:
_data_... | [
"def",
"_init",
"(",
")",
":",
"global",
"config",
",",
"_data_path",
",",
"_allowed_config_keys",
"app_dir",
"=",
"_get_vispy_app_dir",
"(",
")",
"if",
"app_dir",
"is",
"not",
"None",
":",
"_data_path",
"=",
"op",
".",
"join",
"(",
"app_dir",
",",
"'data'... | Create global Config object, parse command flags | [
"Create",
"global",
"Config",
"object",
"parse",
"command",
"flags"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L35-L88 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _parse_command_line_arguments | def _parse_command_line_arguments():
""" Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace.
"""
global config
# Get command line args for vispy
argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',... | python | def _parse_command_line_arguments():
""" Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace.
"""
global config
# Get command line args for vispy
argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',... | [
"def",
"_parse_command_line_arguments",
"(",
")",
":",
"global",
"config",
"# Get command line args for vispy",
"argnames",
"=",
"[",
"'vispy-backend='",
",",
"'vispy-gl-debug'",
",",
"'vispy-glir-file='",
",",
"'vispy-log='",
",",
"'vispy-help'",
",",
"'vispy-profile='",
... | Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace. | [
"Transform",
"vispy",
"specific",
"command",
"line",
"args",
"to",
"vispy",
"config",
".",
"Put",
"into",
"a",
"function",
"so",
"that",
"any",
"variables",
"dont",
"leak",
"in",
"the",
"vispy",
"namespace",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L138-L180 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _get_vispy_app_dir | def _get_vispy_app_dir():
"""Helper to get the default directory for storing vispy data"""
# Define default user directory
user_dir = os.path.expanduser('~')
# Get system app data dir
path = None
if sys.platform.startswith('win'):
path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP... | python | def _get_vispy_app_dir():
"""Helper to get the default directory for storing vispy data"""
# Define default user directory
user_dir = os.path.expanduser('~')
# Get system app data dir
path = None
if sys.platform.startswith('win'):
path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP... | [
"def",
"_get_vispy_app_dir",
"(",
")",
":",
"# Define default user directory",
"user_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"# Get system app data dir",
"path",
"=",
"None",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'"... | Helper to get the default directory for storing vispy data | [
"Helper",
"to",
"get",
"the",
"default",
"directory",
"for",
"storing",
"vispy",
"data"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L188-L224 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _get_config_fname | def _get_config_fname():
"""Helper for the vispy config file"""
directory = _get_vispy_app_dir()
if directory is None:
return None
fname = op.join(directory, 'vispy.json')
if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None:
fname = op.join(_TempDir(), 'vispy.json')
retu... | python | def _get_config_fname():
"""Helper for the vispy config file"""
directory = _get_vispy_app_dir()
if directory is None:
return None
fname = op.join(directory, 'vispy.json')
if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None:
fname = op.join(_TempDir(), 'vispy.json')
retu... | [
"def",
"_get_config_fname",
"(",
")",
":",
"directory",
"=",
"_get_vispy_app_dir",
"(",
")",
"if",
"directory",
"is",
"None",
":",
"return",
"None",
"fname",
"=",
"op",
".",
"join",
"(",
"directory",
",",
"'vispy.json'",
")",
"if",
"os",
".",
"environ",
... | Helper for the vispy config file | [
"Helper",
"for",
"the",
"vispy",
"config",
"file"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L300-L308 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _load_config | def _load_config():
"""Helper to load prefs from ~/.vispy/vispy.json"""
fname = _get_config_fname()
if fname is None or not op.isfile(fname):
return dict()
with open(fname, 'r') as fid:
config = json.load(fid)
return config | python | def _load_config():
"""Helper to load prefs from ~/.vispy/vispy.json"""
fname = _get_config_fname()
if fname is None or not op.isfile(fname):
return dict()
with open(fname, 'r') as fid:
config = json.load(fid)
return config | [
"def",
"_load_config",
"(",
")",
":",
"fname",
"=",
"_get_config_fname",
"(",
")",
"if",
"fname",
"is",
"None",
"or",
"not",
"op",
".",
"isfile",
"(",
"fname",
")",
":",
"return",
"dict",
"(",
")",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as... | Helper to load prefs from ~/.vispy/vispy.json | [
"Helper",
"to",
"load",
"prefs",
"from",
"~",
"/",
".",
"vispy",
"/",
"vispy",
".",
"json"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L311-L318 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | save_config | def save_config(**kwargs):
"""Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file.
"""
if kwargs == {}:
kwargs = config._config
current_config = _load_config()
current_config.update(**... | python | def save_config(**kwargs):
"""Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file.
"""
if kwargs == {}:
kwargs = config._config
current_config = _load_config()
current_config.update(**... | [
"def",
"save_config",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"==",
"{",
"}",
":",
"kwargs",
"=",
"config",
".",
"_config",
"current_config",
"=",
"_load_config",
"(",
")",
"current_config",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"# wr... | Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file. | [
"Save",
"configuration",
"keys",
"to",
"vispy",
"config",
"file"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L321-L340 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | set_data_dir | def set_data_dir(directory=None, create=False, save=False):
"""Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to... | python | def set_data_dir(directory=None, create=False, save=False):
"""Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to... | [
"def",
"set_data_dir",
"(",
"directory",
"=",
"None",
",",
"create",
"=",
"False",
",",
"save",
"=",
"False",
")",
":",
"if",
"directory",
"is",
"None",
":",
"directory",
"=",
"_data_path",
"if",
"_data_path",
"is",
"None",
":",
"raise",
"IOError",
"(",
... | Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to the vispy config. | [
"Set",
"vispy",
"data",
"download",
"directory"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L343-L367 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | _enable_profiling | def _enable_profiling():
""" Start profiling and register callback to print stats when the program
exits.
"""
import cProfile
import atexit
global _profiler
_profiler = cProfile.Profile()
_profiler.enable()
atexit.register(_profile_atexit) | python | def _enable_profiling():
""" Start profiling and register callback to print stats when the program
exits.
"""
import cProfile
import atexit
global _profiler
_profiler = cProfile.Profile()
_profiler.enable()
atexit.register(_profile_atexit) | [
"def",
"_enable_profiling",
"(",
")",
":",
"import",
"cProfile",
"import",
"atexit",
"global",
"_profiler",
"_profiler",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"_profiler",
".",
"enable",
"(",
")",
"atexit",
".",
"register",
"(",
"_profile_atexit",
")"
] | Start profiling and register callback to print stats when the program
exits. | [
"Start",
"profiling",
"and",
"register",
"callback",
"to",
"print",
"stats",
"when",
"the",
"program",
"exits",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L370-L379 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/config.py | sys_info | def sys_info(fname=None, overwrite=False):
"""Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
... | python | def sys_info(fname=None, overwrite=False):
"""Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
... | [
"def",
"sys_info",
"(",
"fname",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"fname",
"is",
"not",
"None",
"and",
"op",
".",
"isfile",
"(",
"fname",
")",
"and",
"not",
"overwrite",
":",
"raise",
"IOError",
"(",
"'file exists, use overwri... | Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
The system information as a string. | [
"Get",
"relevant",
"system",
"and",
"debugging",
"information"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L390-L442 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/normals.py | compact | def compact(vertices, indices, tolerance=1e-3):
""" Compact vertices and indices within given tolerance """
# Transform vertices into a structured array for np.unique to work
n = len(vertices)
V = np.zeros(n, dtype=[("pos", np.float32, 3)])
V["pos"][:, 0] = vertices[:, 0]
V["pos"][:, 1] = verti... | python | def compact(vertices, indices, tolerance=1e-3):
""" Compact vertices and indices within given tolerance """
# Transform vertices into a structured array for np.unique to work
n = len(vertices)
V = np.zeros(n, dtype=[("pos", np.float32, 3)])
V["pos"][:, 0] = vertices[:, 0]
V["pos"][:, 1] = verti... | [
"def",
"compact",
"(",
"vertices",
",",
"indices",
",",
"tolerance",
"=",
"1e-3",
")",
":",
"# Transform vertices into a structured array for np.unique to work",
"n",
"=",
"len",
"(",
"vertices",
")",
"V",
"=",
"np",
".",
"zeros",
"(",
"n",
",",
"dtype",
"=",
... | Compact vertices and indices within given tolerance | [
"Compact",
"vertices",
"and",
"indices",
"within",
"given",
"tolerance"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L10-L49 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/normals.py | normals | def normals(vertices, indices):
"""
Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices
"""
# Compact similar vertices
vertices, indices, mapping = compact(vertices... | python | def normals(vertices, indices):
"""
Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices
"""
# Compact similar vertices
vertices, indices, mapping = compact(vertices... | [
"def",
"normals",
"(",
"vertices",
",",
"indices",
")",
":",
"# Compact similar vertices",
"vertices",
",",
"indices",
",",
"mapping",
"=",
"compact",
"(",
"vertices",
",",
"indices",
")",
"T",
"=",
"vertices",
"[",
"indices",
"]",
"N",
"=",
"np",
".",
"... | Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices | [
"Compute",
"normals",
"over",
"a",
"triangulated",
"surface"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L52-L82 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.create_native | def create_native(self):
""" Create the native widget if not already done so. If the widget
is already created, this function does nothing.
"""
if self._backend is not None:
return
# Make sure that the app is active
assert self._app.native
# Instantiat... | python | def create_native(self):
""" Create the native widget if not already done so. If the widget
is already created, this function does nothing.
"""
if self._backend is not None:
return
# Make sure that the app is active
assert self._app.native
# Instantiat... | [
"def",
"create_native",
"(",
"self",
")",
":",
"if",
"self",
".",
"_backend",
"is",
"not",
"None",
":",
"return",
"# Make sure that the app is active",
"assert",
"self",
".",
"_app",
".",
"native",
"# Instantiate the backend with the right class",
"self",
".",
"_app... | Create the native widget if not already done so. If the widget
is already created, this function does nothing. | [
"Create",
"the",
"native",
"widget",
"if",
"not",
"already",
"done",
"so",
".",
"If",
"the",
"widget",
"is",
"already",
"created",
"this",
"function",
"does",
"nothing",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L213-L231 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.connect | def connect(self, fun):
""" Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
... | python | def connect(self, fun):
""" Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
... | [
"def",
"connect",
"(",
"self",
",",
"fun",
")",
":",
"# Get and check name",
"name",
"=",
"fun",
".",
"__name__",
"if",
"not",
"name",
".",
"startswith",
"(",
"'on_'",
")",
":",
"raise",
"ValueError",
"(",
"'When connecting a function based on its name, '",
"'th... | Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
fun : callable
T... | [
"Connect",
"a",
"function",
"to",
"an",
"event"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L302-L330 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.size | def size(self):
""" The size of canvas/window """
size = self._backend._vispy_get_size()
return (size[0] // self._px_scale, size[1] // self._px_scale) | python | def size(self):
""" The size of canvas/window """
size = self._backend._vispy_get_size()
return (size[0] // self._px_scale, size[1] // self._px_scale) | [
"def",
"size",
"(",
"self",
")",
":",
"size",
"=",
"self",
".",
"_backend",
".",
"_vispy_get_size",
"(",
")",
"return",
"(",
"size",
"[",
"0",
"]",
"//",
"self",
".",
"_px_scale",
",",
"size",
"[",
"1",
"]",
"//",
"self",
".",
"_px_scale",
")"
] | The size of canvas/window | [
"The",
"size",
"of",
"canvas",
"/",
"window"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L334-L337 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.show | def show(self, visible=True, run=False):
"""Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop.
"""
self._backend._vispy_set_visible(visible)
if run:
... | python | def show(self, visible=True, run=False):
"""Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop.
"""
self._backend._vispy_set_visible(visible)
if run:
... | [
"def",
"show",
"(",
"self",
",",
"visible",
"=",
"True",
",",
"run",
"=",
"False",
")",
":",
"self",
".",
"_backend",
".",
"_vispy_set_visible",
"(",
"visible",
")",
"if",
"run",
":",
"self",
".",
"app",
".",
"run",
"(",
")"
] | Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop. | [
"Show",
"or",
"hide",
"the",
"canvas"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L419-L431 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.close | def close(self):
"""Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making t... | python | def close(self):
"""Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making t... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_backend",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"self",
".",
"events",
".",
"close",
"(",
")",
"self",
".",
"_backend",
".",
... | Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making the widget a sub-widget. | [
"Close",
"the",
"canvas"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L444-L458 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas._update_fps | def _update_fps(self, event):
"""Update the fps after every window"""
self._frame_count += 1
diff = time() - self._basetime
if (diff > self._fps_window):
self._fps = self._frame_count / diff
self._basetime = time()
self._frame_count = 0
sel... | python | def _update_fps(self, event):
"""Update the fps after every window"""
self._frame_count += 1
diff = time() - self._basetime
if (diff > self._fps_window):
self._fps = self._frame_count / diff
self._basetime = time()
self._frame_count = 0
sel... | [
"def",
"_update_fps",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_frame_count",
"+=",
"1",
"diff",
"=",
"time",
"(",
")",
"-",
"self",
".",
"_basetime",
"if",
"(",
"diff",
">",
"self",
".",
"_fps_window",
")",
":",
"self",
".",
"_fps",
"=",... | Update the fps after every window | [
"Update",
"the",
"fps",
"after",
"every",
"window"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L460-L468 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.measure_fps | def measure_fps(self, window=1, callback='%1.1f FPS'):
"""Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS... | python | def measure_fps(self, window=1, callback='%1.1f FPS'):
"""Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS... | [
"def",
"measure_fps",
"(",
"self",
",",
"window",
"=",
"1",
",",
"callback",
"=",
"'%1.1f FPS'",
")",
":",
"# Connect update_fps function to draw",
"self",
".",
"events",
".",
"draw",
".",
"disconnect",
"(",
"self",
".",
"_update_fps",
")",
"if",
"callback",
... | Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS. Default 1.0.
callback : function | str
The f... | [
"Measure",
"the",
"current",
"FPS"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L470-L499 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | Canvas.render | def render(self):
""" Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region.
"""
... | python | def render(self):
""" Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region.
"""
... | [
"def",
"render",
"(",
"self",
")",
":",
"self",
".",
"set_current",
"(",
")",
"size",
"=",
"self",
".",
"physical_size",
"fbo",
"=",
"FrameBuffer",
"(",
"color",
"=",
"RenderBuffer",
"(",
"size",
"[",
":",
":",
"-",
"1",
"]",
")",
",",
"depth",
"="... | Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region. | [
"Render",
"the",
"canvas",
"to",
"an",
"offscreen",
"buffer",
"and",
"return",
"the",
"image",
"array",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L520-L541 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | MouseEvent.drag_events | def drag_events(self):
""" Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation.
"""
if not self.is_dragging:
return None
event = self
events = []
while True:
# mouse_press ev... | python | def drag_events(self):
""" Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation.
"""
if not self.is_dragging:
return None
event = self
events = []
while True:
# mouse_press ev... | [
"def",
"drag_events",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_dragging",
":",
"return",
"None",
"event",
"=",
"self",
"events",
"=",
"[",
"]",
"while",
"True",
":",
"# mouse_press events can only be the start of a trail",
"if",
"event",
"is",
"Non... | Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation. | [
"Return",
"a",
"list",
"of",
"all",
"mouse",
"events",
"in",
"the",
"current",
"drag",
"operation",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L639-L656 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | MouseEvent.trail | def trail(self):
""" Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation.
"""
events = self.drag_events()
if events is None:
return None
trail = np.empty(... | python | def trail(self):
""" Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation.
"""
events = self.drag_events()
if events is None:
return None
trail = np.empty(... | [
"def",
"trail",
"(",
"self",
")",
":",
"events",
"=",
"self",
".",
"drag_events",
"(",
")",
"if",
"events",
"is",
"None",
":",
"return",
"None",
"trail",
"=",
"np",
".",
"empty",
"(",
"(",
"len",
"(",
"events",
")",
",",
"2",
")",
",",
"dtype",
... | Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation. | [
"Return",
"an",
"(",
"N",
"2",
")",
"array",
"of",
"mouse",
"coordinates",
"for",
"every",
"event",
"in",
"the",
"current",
"mouse",
"drag",
"operation",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L658-L672 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.width_min | def width_min(self, width_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if width_min is None:
self._width_limits[0] = 0
return
width_min = float(wi... | python | def width_min(self, width_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if width_min is None:
self._width_limits[0] = 0
return
width_min = float(wi... | [
"def",
"width_min",
"(",
"self",
",",
"width_min",
")",
":",
"if",
"width_min",
"is",
"None",
":",
"self",
".",
"_width_limits",
"[",
"0",
"]",
"=",
"0",
"return",
"width_min",
"=",
"float",
"(",
"width_min",
")",
"assert",
"(",
"0",
"<=",
"width_min",... | Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget | [
"Set",
"the",
"minimum",
"height",
"of",
"the",
"widget"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L133-L151 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.width_max | def width_max(self, width_max):
"""Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded
"""
if width_max is None:
self._width_limits[1] ... | python | def width_max(self, width_max):
"""Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded
"""
if width_max is None:
self._width_limits[1] ... | [
"def",
"width_max",
"(",
"self",
",",
"width_max",
")",
":",
"if",
"width_max",
"is",
"None",
":",
"self",
".",
"_width_limits",
"[",
"1",
"]",
"=",
"None",
"return",
"width_max",
"=",
"float",
"(",
"width_max",
")",
"assert",
"(",
"self",
".",
"width_... | Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded | [
"Set",
"the",
"maximum",
"width",
"of",
"the",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L159-L176 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.height_min | def height_min(self, height_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if height_min is None:
self._height_limits[0] = 0
return
height_min = floa... | python | def height_min(self, height_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if height_min is None:
self._height_limits[0] = 0
return
height_min = floa... | [
"def",
"height_min",
"(",
"self",
",",
"height_min",
")",
":",
"if",
"height_min",
"is",
"None",
":",
"self",
".",
"_height_limits",
"[",
"0",
"]",
"=",
"0",
"return",
"height_min",
"=",
"float",
"(",
"height_min",
")",
"assert",
"(",
"height_min",
">=",... | Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget | [
"Set",
"the",
"minimum",
"height",
"of",
"the",
"widget"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L189-L206 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.height_max | def height_max(self, height_max):
"""Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded
"""
if height_max is None:
self._height_li... | python | def height_max(self, height_max):
"""Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded
"""
if height_max is None:
self._height_li... | [
"def",
"height_max",
"(",
"self",
",",
"height_max",
")",
":",
"if",
"height_max",
"is",
"None",
":",
"self",
".",
"_height_limits",
"[",
"1",
"]",
"=",
"None",
"return",
"height_max",
"=",
"float",
"(",
"height_max",
")",
"assert",
"(",
"0",
"<=",
"se... | Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded | [
"Set",
"the",
"maximum",
"height",
"of",
"the",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L214-L230 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.inner_rect | def inner_rect(self):
"""The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle.
"""
m = self.margin + self._border_width + self.padding
if not self.border_color.is_blank:
... | python | def inner_rect(self):
"""The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle.
"""
m = self.margin + self._border_width + self.padding
if not self.border_color.is_blank:
... | [
"def",
"inner_rect",
"(",
"self",
")",
":",
"m",
"=",
"self",
".",
"margin",
"+",
"self",
".",
"_border_width",
"+",
"self",
".",
"padding",
"if",
"not",
"self",
".",
"border_color",
".",
"is_blank",
":",
"m",
"+=",
"1",
"return",
"Rect",
"(",
"(",
... | The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle. | [
"The",
"rectangular",
"area",
"inside",
"the",
"margin",
"border",
"and",
"padding",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L245-L254 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget._update_clipper | def _update_clipper(self):
"""Called whenever the clipper for this widget may need to be updated.
"""
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
... | python | def _update_clipper(self):
"""Called whenever the clipper for this widget may need to be updated.
"""
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
... | [
"def",
"_update_clipper",
"(",
"self",
")",
":",
"if",
"self",
".",
"clip_children",
"and",
"self",
".",
"_clipper",
"is",
"None",
":",
"self",
".",
"_clipper",
"=",
"Clipper",
"(",
")",
"elif",
"not",
"self",
".",
"clip_children",
":",
"self",
".",
"_... | Called whenever the clipper for this widget may need to be updated. | [
"Called",
"whenever",
"the",
"clipper",
"for",
"this",
"widget",
"may",
"need",
"to",
"be",
"updated",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L283-L294 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget._update_line | def _update_line(self):
""" Update border line to match new shape """
w = self._border_width
m = self.margin
# border is drawn within the boundaries of the widget:
#
# size = (8, 7) margin=2
# internal rect = (3, 3, 2, 1)
# ........
# ........... | python | def _update_line(self):
""" Update border line to match new shape """
w = self._border_width
m = self.margin
# border is drawn within the boundaries of the widget:
#
# size = (8, 7) margin=2
# internal rect = (3, 3, 2, 1)
# ........
# ........... | [
"def",
"_update_line",
"(",
"self",
")",
":",
"w",
"=",
"self",
".",
"_border_width",
"m",
"=",
"self",
".",
"margin",
"# border is drawn within the boundaries of the widget:",
"#",
"# size = (8, 7) margin=2",
"# internal rect = (3, 3, 2, 1)",
"# ........",
"# ........... | Update border line to match new shape | [
"Update",
"border",
"line",
"to",
"match",
"new",
"shape"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L344-L390 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.add_widget | def add_widget(self, widget):
"""
Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget :... | python | def add_widget(self, widget):
"""
Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget :... | [
"def",
"add_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_widgets",
".",
"append",
"(",
"widget",
")",
"widget",
".",
"parent",
"=",
"self",
"self",
".",
"_update_child_widgets",
"(",
")",
"return",
"widget"
] | Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget : instance of Widget
The widget to add.... | [
"Add",
"a",
"Widget",
"as",
"a",
"managed",
"child",
"of",
"this",
"Widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L419-L440 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.add_grid | def add_grid(self, *args, **kwargs):
"""
Create a new Grid and add it as a child widget.
All arguments are given to Grid().
"""
from .grid import Grid
grid = Grid(*args, **kwargs)
return self.add_widget(grid) | python | def add_grid(self, *args, **kwargs):
"""
Create a new Grid and add it as a child widget.
All arguments are given to Grid().
"""
from .grid import Grid
grid = Grid(*args, **kwargs)
return self.add_widget(grid) | [
"def",
"add_grid",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"grid",
"import",
"Grid",
"grid",
"=",
"Grid",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"add_widget",
"(",
"grid",
")"... | Create a new Grid and add it as a child widget.
All arguments are given to Grid(). | [
"Create",
"a",
"new",
"Grid",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L442-L450 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.add_view | def add_view(self, *args, **kwargs):
"""
Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox().
"""
from .viewbox import ViewBox
view = ViewBox(*args, **kwargs)
return self.add_widget(view) | python | def add_view(self, *args, **kwargs):
"""
Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox().
"""
from .viewbox import ViewBox
view = ViewBox(*args, **kwargs)
return self.add_widget(view) | [
"def",
"add_view",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"viewbox",
"import",
"ViewBox",
"view",
"=",
"ViewBox",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"add_widget",
"(",
"vie... | Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox(). | [
"Create",
"a",
"new",
"ViewBox",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L452-L460 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | Widget.remove_widget | def remove_widget(self, widget):
"""
Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove.
"""
self._widgets.remove(widget)
widget.parent = None
self._update_child_wi... | python | def remove_widget(self, widget):
"""
Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove.
"""
self._widgets.remove(widget)
widget.parent = None
self._update_child_wi... | [
"def",
"remove_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_widgets",
".",
"remove",
"(",
"widget",
")",
"widget",
".",
"parent",
"=",
"None",
"self",
".",
"_update_child_widgets",
"(",
")"
] | Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove. | [
"Remove",
"a",
"Widget",
"as",
"a",
"managed",
"child",
"of",
"this",
"Widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L462-L473 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/datasets.py | pack_unit | def pack_unit(value):
"""Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
pack = np.zeros(value.shape + (4,), dtype=np.ubyte)
for i in range(4):
value, pack[..., i] = np.modf(value * 256.)
return pack | python | def pack_unit(value):
"""Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
pack = np.zeros(value.shape + (4,), dtype=np.ubyte)
for i in range(4):
value, pack[..., i] = np.modf(value * 256.)
return pack | [
"def",
"pack_unit",
"(",
"value",
")",
":",
"pack",
"=",
"np",
".",
"zeros",
"(",
"value",
".",
"shape",
"+",
"(",
"4",
",",
")",
",",
"dtype",
"=",
"np",
".",
"ubyte",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"value",
",",
"pack",... | Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel | [
"Packs",
"float",
"values",
"between",
"[",
"0",
"1",
"]",
"into",
"4",
"unsigned",
"int8"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L38-L49 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/datasets.py | pack_ieee | def pack_ieee(value):
"""Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
return np.fromstring(value.tostring(),
np.ubyte).reshape((value.shape + (4,))) | python | def pack_ieee(value):
"""Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
return np.fromstring(value.tostring(),
np.ubyte).reshape((value.shape + (4,))) | [
"def",
"pack_ieee",
"(",
"value",
")",
":",
"return",
"np",
".",
"fromstring",
"(",
"value",
".",
"tostring",
"(",
")",
",",
"np",
".",
"ubyte",
")",
".",
"reshape",
"(",
"(",
"value",
".",
"shape",
"+",
"(",
"4",
",",
")",
")",
")"
] | Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel | [
"Packs",
"float",
"ieee",
"binary",
"representation",
"into",
"4",
"unsigned",
"int8"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L52-L61 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/datasets.py | load_spatial_filters | def load_spatial_filters(packed=True):
"""Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16... | python | def load_spatial_filters(packed=True):
"""Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16... | [
"def",
"load_spatial_filters",
"(",
"packed",
"=",
"True",
")",
":",
"names",
"=",
"(",
"\"Bilinear\"",
",",
"\"Hanning\"",
",",
"\"Hamming\"",
",",
"\"Hermite\"",
",",
"\"Kaiser\"",
",",
"\"Quadric\"",
",",
"\"Bicubic\"",
",",
"\"CatRom\"",
",",
"\"Mitchell\"",... | Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16x1024 (unpacked float)
16 interpolatio... | [
"Load",
"spatial",
"-",
"filters",
"kernel"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L64-L94 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fonts/_triage.py | list_fonts | def list_fonts():
"""List system fonts
Returns
-------
fonts : list of str
List of system fonts.
"""
vals = _list_fonts()
for font in _vispy_fonts:
vals += [font] if font not in vals else []
vals = sorted(vals, key=lambda s: s.lower())
return vals | python | def list_fonts():
"""List system fonts
Returns
-------
fonts : list of str
List of system fonts.
"""
vals = _list_fonts()
for font in _vispy_fonts:
vals += [font] if font not in vals else []
vals = sorted(vals, key=lambda s: s.lower())
return vals | [
"def",
"list_fonts",
"(",
")",
":",
"vals",
"=",
"_list_fonts",
"(",
")",
"for",
"font",
"in",
"_vispy_fonts",
":",
"vals",
"+=",
"[",
"font",
"]",
"if",
"font",
"not",
"in",
"vals",
"else",
"[",
"]",
"vals",
"=",
"sorted",
"(",
"vals",
",",
"key",... | List system fonts
Returns
-------
fonts : list of str
List of system fonts. | [
"List",
"system",
"fonts"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fonts/_triage.py#L24-L36 | train |
brouberol/contexttimer | contexttimer/timeout.py | timeout | def timeout(limit, handler):
"""A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example... | python | def timeout(limit, handler):
"""A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example... | [
"def",
"timeout",
"(",
"limit",
",",
"handler",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"def",
"wrapped_f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"old_handler",
"=",
"signal",
".",
"getsignal",
"(",
"signal",
".",
"SIGALRM",
... | A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example:
>>>def timeout_handler(limit, ... | [
"A",
"decorator",
"ensuring",
"that",
"the",
"decorated",
"function",
"tun",
"time",
"does",
"not",
"exceeds",
"the",
"argument",
"limit",
"."
] | a866f420ed4c10f29abf252c58b11f9db6706100 | https://github.com/brouberol/contexttimer/blob/a866f420ed4c10f29abf252c58b11f9db6706100/contexttimer/timeout.py#L39-L80 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/base.py | BaseCanvasBackend._process_backend_kwargs | def _process_backend_kwargs(self, kwargs):
""" Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities.
"""
# Verify given argument with capability of the backend
app = self.... | python | def _process_backend_kwargs(self, kwargs):
""" Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities.
"""
# Verify given argument with capability of the backend
app = self.... | [
"def",
"_process_backend_kwargs",
"(",
"self",
",",
"kwargs",
")",
":",
"# Verify given argument with capability of the backend",
"app",
"=",
"self",
".",
"_vispy_canvas",
".",
"app",
"capability",
"=",
"app",
".",
"backend_module",
".",
"capability",
"if",
"kwargs",
... | Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities. | [
"Simple",
"utility",
"to",
"retrieve",
"kwargs",
"in",
"predetermined",
"order",
".",
"Also",
"checks",
"whether",
"the",
"values",
"of",
"the",
"backend",
"arguments",
"do",
"not",
"violate",
"the",
"backend",
"capabilities",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/base.py#L80-L106 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | FlyCamera._set_range | def _set_range(self, init):
""" Reset the view.
"""
#PerspectiveCamera._set_range(self, init)
# Stop moving
self._speed *= 0.0
# Get window size (and store factor now to sync with resizing)
w, h = self._viewbox.size
w, h = float(w), float(h)
# ... | python | def _set_range(self, init):
""" Reset the view.
"""
#PerspectiveCamera._set_range(self, init)
# Stop moving
self._speed *= 0.0
# Get window size (and store factor now to sync with resizing)
w, h = self._viewbox.size
w, h = float(w), float(h)
# ... | [
"def",
"_set_range",
"(",
"self",
",",
"init",
")",
":",
"#PerspectiveCamera._set_range(self, init)",
"# Stop moving",
"self",
".",
"_speed",
"*=",
"0.0",
"# Get window size (and store factor now to sync with resizing)",
"w",
",",
"h",
"=",
"self",
".",
"_viewbox",
".",... | Reset the view. | [
"Reset",
"the",
"view",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L146-L200 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | FlyCamera.on_timer | def on_timer(self, event):
"""Timer event handler
Parameters
----------
event : instance of Event
The event.
"""
# Set relative speed and acceleration
rel_speed = event.dt
rel_acc = 0.1
# Get what's forward
pf, pr, pl, pu = s... | python | def on_timer(self, event):
"""Timer event handler
Parameters
----------
event : instance of Event
The event.
"""
# Set relative speed and acceleration
rel_speed = event.dt
rel_acc = 0.1
# Get what's forward
pf, pr, pl, pu = s... | [
"def",
"on_timer",
"(",
"self",
",",
"event",
")",
":",
"# Set relative speed and acceleration",
"rel_speed",
"=",
"event",
".",
"dt",
"rel_acc",
"=",
"0.1",
"# Get what's forward",
"pf",
",",
"pr",
",",
"pl",
",",
"pu",
"=",
"self",
".",
"_get_directions",
... | Timer event handler
Parameters
----------
event : instance of Event
The event. | [
"Timer",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L231-L324 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | FlyCamera.viewbox_key_event | def viewbox_key_event(self, event):
"""ViewBox key event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_key_event(self, event)
if event.handled or not self.interactive:
return
# E... | python | def viewbox_key_event(self, event):
"""ViewBox key event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_key_event(self, event)
if event.handled or not self.interactive:
return
# E... | [
"def",
"viewbox_key_event",
"(",
"self",
",",
"event",
")",
":",
"PerspectiveCamera",
".",
"viewbox_key_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"# Ensure the timer runs",
"i... | ViewBox key event handler
Parameters
----------
event : instance of Event
The event. | [
"ViewBox",
"key",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L326-L357 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | FlyCamera.viewbox_mouse_event | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_mouse_event(self, event)
if event.handled or not self.interactive:
return
... | python | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_mouse_event(self, event)
if event.handled or not self.interactive:
return
... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"PerspectiveCamera",
".",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"if",
"event",
".",
"... | ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event. | [
"ViewBox",
"mouse",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L359-L439 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | _stdin_ready_posix | def _stdin_ready_posix():
"""Return True if there's something to read on stdin (posix version)."""
infds, outfds, erfds = select.select([sys.stdin],[],[],0)
return bool(infds) | python | def _stdin_ready_posix():
"""Return True if there's something to read on stdin (posix version)."""
infds, outfds, erfds = select.select([sys.stdin],[],[],0)
return bool(infds) | [
"def",
"_stdin_ready_posix",
"(",
")",
":",
"infds",
",",
"outfds",
",",
"erfds",
"=",
"select",
".",
"select",
"(",
"[",
"sys",
".",
"stdin",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"0",
")",
"return",
"bool",
"(",
"infds",
")"
] | Return True if there's something to read on stdin (posix version). | [
"Return",
"True",
"if",
"there",
"s",
"something",
"to",
"read",
"on",
"stdin",
"(",
"posix",
"version",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L55-L58 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.set_inputhook | def set_inputhook(self, callback):
"""Set PyOS_InputHook to callback and return the previous one."""
# On platforms with 'readline' support, it's all too likely to
# have a KeyboardInterrupt signal delivered *even before* an
# initial ``try:`` clause in the callback can be executed, so
... | python | def set_inputhook(self, callback):
"""Set PyOS_InputHook to callback and return the previous one."""
# On platforms with 'readline' support, it's all too likely to
# have a KeyboardInterrupt signal delivered *even before* an
# initial ``try:`` clause in the callback can be executed, so
... | [
"def",
"set_inputhook",
"(",
"self",
",",
"callback",
")",
":",
"# On platforms with 'readline' support, it's all too likely to",
"# have a KeyboardInterrupt signal delivered *even before* an",
"# initial ``try:`` clause in the callback can be executed, so",
"# we need to disable CTRL+C in thi... | Set PyOS_InputHook to callback and return the previous one. | [
"Set",
"PyOS_InputHook",
"to",
"callback",
"and",
"return",
"the",
"previous",
"one",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L138-L152 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.clear_inputhook | def clear_inputhook(self, app=None):
"""Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` metho... | python | def clear_inputhook(self, app=None):
"""Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` metho... | [
"def",
"clear_inputhook",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"pyos_inputhook_ptr",
"=",
"self",
".",
"get_pyos_inputhook",
"(",
")",
"original",
"=",
"self",
".",
"get_pyos_inputhook_as_func",
"(",
")",
"pyos_inputhook_ptr",
".",
"value",
"=",
"ct... | Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` methods. But
the actual value of the param... | [
"Set",
"PyOS_InputHook",
"to",
"NULL",
"and",
"return",
"the",
"previous",
"one",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L154-L170 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.clear_app_refs | def clear_app_refs(self, gui=None):
"""Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themsel... | python | def clear_app_refs(self, gui=None):
"""Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themsel... | [
"def",
"clear_app_refs",
"(",
"self",
",",
"gui",
"=",
"None",
")",
":",
"if",
"gui",
"is",
"None",
":",
"self",
".",
"apps",
"=",
"{",
"}",
"elif",
"gui",
"in",
"self",
".",
"apps",
":",
"del",
"self",
".",
"apps",
"[",
"gui",
"]"
] | Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themselves. This
method is provided to clear ... | [
"Clear",
"IPython",
"s",
"internal",
"reference",
"to",
"an",
"application",
"instance",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L172-L190 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.register | def register(self, toolkitname, *aliases):
"""Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`I... | python | def register(self, toolkitname, *aliases):
"""Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`I... | [
"def",
"register",
"(",
"self",
",",
"toolkitname",
",",
"*",
"aliases",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"inst",
"=",
"cls",
"(",
"self",
")",
"self",
".",
"guihooks",
"[",
"toolkitname",
"]",
"=",
"inst",
"for",
"a",
"in",
"ali... | Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`InputHookBase`.
::
... | [
"Register",
"a",
"class",
"to",
"provide",
"the",
"event",
"loop",
"for",
"a",
"given",
"GUI",
".",
"This",
"is",
"intended",
"to",
"be",
"used",
"as",
"a",
"class",
"decorator",
".",
"It",
"should",
"be",
"passed",
"the",
"names",
"with",
"which",
"to... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L192-L212 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.enable_gui | def enable_gui(self, gui=None, app=None):
"""Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
g... | python | def enable_gui(self, gui=None, app=None):
"""Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
g... | [
"def",
"enable_gui",
"(",
"self",
",",
"gui",
"=",
"None",
",",
"app",
"=",
"None",
")",
":",
"if",
"gui",
"in",
"(",
"None",
",",
"GUI_NONE",
")",
":",
"return",
"self",
".",
"disable_gui",
"(",
")",
"if",
"gui",
"in",
"self",
".",
"aliases",
":... | Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
gui : optional, string or None
If None (or '... | [
"Switch",
"amongst",
"GUI",
"input",
"hooks",
"by",
"name",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L218-L260 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | InputHookManager.disable_gui | def disable_gui(self):
"""Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`.
"""
gui = self._current_gui
if gui in self.apps:
self.apps[gui]... | python | def disable_gui(self):
"""Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`.
"""
gui = self._current_gui
if gui in self.apps:
self.apps[gui]... | [
"def",
"disable_gui",
"(",
"self",
")",
":",
"gui",
"=",
"self",
".",
"_current_gui",
"if",
"gui",
"in",
"self",
".",
"apps",
":",
"self",
".",
"apps",
"[",
"gui",
"]",
".",
"_in_event_loop",
"=",
"False",
"return",
"self",
".",
"clear_inputhook",
"(",... | Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`. | [
"Disable",
"GUI",
"event",
"loop",
"integration",
".",
"If",
"an",
"application",
"was",
"registered",
"this",
"sets",
"its",
"_in_event_loop",
"attribute",
"to",
"False",
".",
"It",
"then",
"calls",
":",
"meth",
":",
"clear_inputhook",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L262-L271 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | set_current_canvas | def set_current_canvas(canvas):
""" Make a canvas active. Used primarily by the canvas itself.
"""
# Notify glir
canvas.context._do_CURRENT_command = True
# Try to be quick
if canvasses and canvasses[-1]() is canvas:
return
# Make this the current
cc = [c() for c in canvasses if... | python | def set_current_canvas(canvas):
""" Make a canvas active. Used primarily by the canvas itself.
"""
# Notify glir
canvas.context._do_CURRENT_command = True
# Try to be quick
if canvasses and canvasses[-1]() is canvas:
return
# Make this the current
cc = [c() for c in canvasses if... | [
"def",
"set_current_canvas",
"(",
"canvas",
")",
":",
"# Notify glir ",
"canvas",
".",
"context",
".",
"_do_CURRENT_command",
"=",
"True",
"# Try to be quick",
"if",
"canvasses",
"and",
"canvasses",
"[",
"-",
"1",
"]",
"(",
")",
"is",
"canvas",
":",
"return",
... | Make a canvas active. Used primarily by the canvas itself. | [
"Make",
"a",
"canvas",
"active",
".",
"Used",
"primarily",
"by",
"the",
"canvas",
"itself",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L63-L76 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | forget_canvas | def forget_canvas(canvas):
""" Forget about the given canvas. Used by the canvas when closed.
"""
cc = [c() for c in canvasses if c() is not None]
while canvas in cc:
cc.remove(canvas)
canvasses[:] = [weakref.ref(c) for c in cc] | python | def forget_canvas(canvas):
""" Forget about the given canvas. Used by the canvas when closed.
"""
cc = [c() for c in canvasses if c() is not None]
while canvas in cc:
cc.remove(canvas)
canvasses[:] = [weakref.ref(c) for c in cc] | [
"def",
"forget_canvas",
"(",
"canvas",
")",
":",
"cc",
"=",
"[",
"c",
"(",
")",
"for",
"c",
"in",
"canvasses",
"if",
"c",
"(",
")",
"is",
"not",
"None",
"]",
"while",
"canvas",
"in",
"cc",
":",
"cc",
".",
"remove",
"(",
"canvas",
")",
"canvasses"... | Forget about the given canvas. Used by the canvas when closed. | [
"Forget",
"about",
"the",
"given",
"canvas",
".",
"Used",
"by",
"the",
"canvas",
"when",
"closed",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L79-L85 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | GLContext.create_shared | def create_shared(self, name, ref):
""" For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference.
"""
if self._shared is not None:
raise RuntimeError('Can only se... | python | def create_shared(self, name, ref):
""" For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference.
"""
if self._shared is not None:
raise RuntimeError('Can only se... | [
"def",
"create_shared",
"(",
"self",
",",
"name",
",",
"ref",
")",
":",
"if",
"self",
".",
"_shared",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Can only set_shared once.'",
")",
"self",
".",
"_shared",
"=",
"GLShared",
"(",
"name",
",",
"... | For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference. | [
"For",
"the",
"app",
"backends",
"to",
"create",
"the",
"GLShared",
"object",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L120-L132 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | GLContext.flush_commands | def flush_commands(self, event=None):
""" Flush
Parameters
----------
event : instance of Event
The event.
"""
if self._do_CURRENT_command:
self._do_CURRENT_command = False
canvas = get_current_canvas()
if canvas and hasatt... | python | def flush_commands(self, event=None):
""" Flush
Parameters
----------
event : instance of Event
The event.
"""
if self._do_CURRENT_command:
self._do_CURRENT_command = False
canvas = get_current_canvas()
if canvas and hasatt... | [
"def",
"flush_commands",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"_do_CURRENT_command",
":",
"self",
".",
"_do_CURRENT_command",
"=",
"False",
"canvas",
"=",
"get_current_canvas",
"(",
")",
"if",
"canvas",
"and",
"hasattr",
"(",
... | Flush
Parameters
----------
event : instance of Event
The event. | [
"Flush"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L160-L176 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | GLShared.add_ref | def add_ref(self, name, ref):
""" Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references.
"""
if self._name is None:
self._name = ... | python | def add_ref(self, name, ref):
""" Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references.
"""
if self._name is None:
self._name = ... | [
"def",
"add_ref",
"(",
"self",
",",
"name",
",",
"ref",
")",
":",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"name",
"elif",
"name",
"!=",
"self",
".",
"_name",
":",
"raise",
"RuntimeError",
"(",
"'Contexts can only share... | Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references. | [
"Add",
"a",
"reference",
"for",
"the",
"backend",
"object",
"that",
"gives",
"access",
"to",
"the",
"low",
"level",
"context",
".",
"Used",
"in",
"vispy",
".",
"app",
".",
"canvas",
".",
"backends",
".",
"The",
"given",
"name",
"must",
"match",
"with",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L225-L236 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/context.py | GLShared.ref | def ref(self):
""" A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object.
"""
# Clean
self._refs = [r for ... | python | def ref(self):
""" A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object.
"""
# Clean
self._refs = [r for ... | [
"def",
"ref",
"(",
"self",
")",
":",
"# Clean",
"self",
".",
"_refs",
"=",
"[",
"r",
"for",
"r",
"in",
"self",
".",
"_refs",
"if",
"(",
"r",
"(",
")",
"is",
"not",
"None",
")",
"]",
"# Get ref",
"ref",
"=",
"self",
".",
"_refs",
"[",
"0",
"]"... | A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object. | [
"A",
"reference",
"(",
"stored",
"internally",
"via",
"a",
"weakref",
")",
"to",
"an",
"object",
"that",
"the",
"backend",
"system",
"can",
"use",
"to",
"obtain",
"the",
"low",
"-",
"level",
"information",
"of",
"the",
"reference",
"context",
".",
"In",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L246-L259 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/dpi/_quartz.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.
"""
display = quartz.CGMainDisplayID()
... | 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.
"""
display = quartz.CGMainDisplayID()
... | [
"def",
"get_dpi",
"(",
"raise_error",
"=",
"True",
")",
":",
"display",
"=",
"quartz",
".",
"CGMainDisplayID",
"(",
")",
"mm",
"=",
"quartz",
".",
"CGDisplayScreenSize",
"(",
"display",
")",
"px",
"=",
"quartz",
".",
"CGDisplayBounds",
"(",
"display",
")",... | 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"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/dpi/_quartz.py#L10-L26 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py | Varying.link | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
... | python | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
... | [
"def",
"link",
"(",
"self",
",",
"var",
")",
":",
"assert",
"self",
".",
"_dtype",
"is",
"not",
"None",
"or",
"hasattr",
"(",
"var",
",",
"'dtype'",
")",
"self",
".",
"_link",
"=",
"var",
"self",
".",
"changed",
"(",
")"
] | Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``. | [
"Link",
"this",
"Varying",
"to",
"another",
"object",
"from",
"which",
"it",
"will",
"derive",
"its",
"dtype",
".",
"This",
"method",
"is",
"used",
"internally",
"when",
"assigning",
"an",
"attribute",
"to",
"a",
"varying",
"using",
"syntax",
"Function",
"["... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py#L207-L214 | train |
andim/scipydirect | examples/SH.py | obj | def obj(x):
"""Two Dimensional Shubert Function"""
j = np.arange(1, 6)
tmp1 = np.dot(j, np.cos((j+1)*x[0] + j))
tmp2 = np.dot(j, np.cos((j+1)*x[1] + j))
return tmp1 * tmp2 | python | def obj(x):
"""Two Dimensional Shubert Function"""
j = np.arange(1, 6)
tmp1 = np.dot(j, np.cos((j+1)*x[0] + j))
tmp2 = np.dot(j, np.cos((j+1)*x[1] + j))
return tmp1 * tmp2 | [
"def",
"obj",
"(",
"x",
")",
":",
"j",
"=",
"np",
".",
"arange",
"(",
"1",
",",
"6",
")",
"tmp1",
"=",
"np",
".",
"dot",
"(",
"j",
",",
"np",
".",
"cos",
"(",
"(",
"j",
"+",
"1",
")",
"*",
"x",
"[",
"0",
"]",
"+",
"j",
")",
")",
"tm... | Two Dimensional Shubert Function | [
"Two",
"Dimensional",
"Shubert",
"Function"
] | ad36ab19e6ad64054a1d2abd22f1c993fc4b87be | https://github.com/andim/scipydirect/blob/ad36ab19e6ad64054a1d2abd22f1c993fc4b87be/examples/SH.py#L13-L19 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/glsl/build-spatial-filters.py | Bessel.besj | def besj(self, x, n):
'''
Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from e... | python | def besj(self, x, n):
'''
Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from e... | [
"def",
"besj",
"(",
"self",
",",
"x",
",",
"n",
")",
":",
"if",
"n",
"<",
"0",
":",
"return",
"0.0",
"d",
"=",
"1e-6",
"b",
"=",
"0",
"if",
"math",
".",
"fabs",
"(",
"x",
")",
"<=",
"d",
":",
"if",
"n",
"!=",
"0",
":",
"return",
"0",
"r... | Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from equivalent FORTRAN library
Converte... | [
"Function",
"BESJ",
"calculates",
"Bessel",
"function",
"of",
"first",
"kind",
"of",
"order",
"n",
"Arguments",
":",
"n",
"-",
"an",
"integer",
"(",
">",
"=",
"0",
")",
"the",
"order",
"x",
"-",
"value",
"at",
"which",
"the",
"Bessel",
"function",
"is"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/build-spatial-filters.py#L493-L568 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.copy | def copy(self):
""" Create an exact copy of this quaternion.
"""
return Quaternion(self.w, self.x, self.y, self.z, False) | python | def copy(self):
""" Create an exact copy of this quaternion.
"""
return Quaternion(self.w, self.x, self.y, self.z, False) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Quaternion",
"(",
"self",
".",
"w",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"z",
",",
"False",
")"
] | Create an exact copy of this quaternion. | [
"Create",
"an",
"exact",
"copy",
"of",
"this",
"quaternion",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L28-L31 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.norm | def norm(self):
""" Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2
"""
tmp = self.w**2 + self.x**2 + self.y**2 + self.z**2
return tmp**0.5 | python | def norm(self):
""" Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2
"""
tmp = self.w**2 + self.x**2 + self.y**2 + self.z**2
return tmp**0.5 | [
"def",
"norm",
"(",
"self",
")",
":",
"tmp",
"=",
"self",
".",
"w",
"**",
"2",
"+",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"return",
"tmp",
"**",
"0.5"
] | Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2 | [
"Returns",
"the",
"norm",
"of",
"the",
"quaternion",
"norm",
"=",
"w",
"**",
"2",
"+",
"x",
"**",
"2",
"+",
"y",
"**",
"2",
"+",
"z",
"**",
"2"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L33-L39 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion._normalize | def _normalize(self):
""" Make the quaternion unit length.
"""
# Get length
L = self.norm()
if not L:
raise ValueError('Quaternion cannot have 0-length.')
# Correct
self.w /= L
self.x /= L
self.y /= L
self.z /= L | python | def _normalize(self):
""" Make the quaternion unit length.
"""
# Get length
L = self.norm()
if not L:
raise ValueError('Quaternion cannot have 0-length.')
# Correct
self.w /= L
self.x /= L
self.y /= L
self.z /= L | [
"def",
"_normalize",
"(",
"self",
")",
":",
"# Get length",
"L",
"=",
"self",
".",
"norm",
"(",
")",
"if",
"not",
"L",
":",
"raise",
"ValueError",
"(",
"'Quaternion cannot have 0-length.'",
")",
"# Correct",
"self",
".",
"w",
"/=",
"L",
"self",
".",
"x",... | Make the quaternion unit length. | [
"Make",
"the",
"quaternion",
"unit",
"length",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L41-L52 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.conjugate | def conjugate(self):
""" Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed.
"""
new = self.copy()
new.x *= -1
new.y *= -1
new.z *= -1
return new | python | def conjugate(self):
""" Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed.
"""
new = self.copy()
new.x *= -1
new.y *= -1
new.z *= -1
return new | [
"def",
"conjugate",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"copy",
"(",
")",
"new",
".",
"x",
"*=",
"-",
"1",
"new",
".",
"y",
"*=",
"-",
"1",
"new",
".",
"z",
"*=",
"-",
"1",
"return",
"new"
] | Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed. | [
"Obtain",
"the",
"conjugate",
"of",
"the",
"quaternion",
".",
"This",
"is",
"simply",
"the",
"same",
"quaternion",
"but",
"with",
"the",
"sign",
"of",
"the",
"imaginary",
"(",
"vector",
")",
"parts",
"reversed",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L61-L71 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.inverse | def inverse(self):
""" returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate.
"""
new = self.conjugate()
tmp = self.norm()**2
new.w /= tmp
new.x /= tmp
new.y /= tmp
new.z /= tmp
... | python | def inverse(self):
""" returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate.
"""
new = self.conjugate()
tmp = self.norm()**2
new.w /= tmp
new.x /= tmp
new.y /= tmp
new.z /= tmp
... | [
"def",
"inverse",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"conjugate",
"(",
")",
"tmp",
"=",
"self",
".",
"norm",
"(",
")",
"**",
"2",
"new",
".",
"w",
"/=",
"tmp",
"new",
".",
"x",
"/=",
"tmp",
"new",
".",
"y",
"/=",
"tmp",
"new",
... | returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate. | [
"returns",
"q",
".",
"conjugate",
"()",
"/",
"q",
".",
"norm",
"()",
"**",
"2",
"So",
"if",
"the",
"quaternion",
"is",
"unit",
"length",
"it",
"is",
"the",
"same",
"as",
"the",
"conjugate",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L73-L85 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.exp | def exp(self):
""" Returns the exponent of the quaternion.
(not tested)
"""
# Init
vecNorm = self.x**2 + self.y**2 + self.z**2
wPart = np.exp(self.w)
q = Quaternion()
# Calculate
q.w = wPart * np.cos(vecNorm)
q.x ... | python | def exp(self):
""" Returns the exponent of the quaternion.
(not tested)
"""
# Init
vecNorm = self.x**2 + self.y**2 + self.z**2
wPart = np.exp(self.w)
q = Quaternion()
# Calculate
q.w = wPart * np.cos(vecNorm)
q.x ... | [
"def",
"exp",
"(",
"self",
")",
":",
"# Init",
"vecNorm",
"=",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"wPart",
"=",
"np",
".",
"exp",
"(",
"self",
".",
"w",
")",
"q",
"=",
"Quaternio... | Returns the exponent of the quaternion.
(not tested) | [
"Returns",
"the",
"exponent",
"of",
"the",
"quaternion",
".",
"(",
"not",
"tested",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L87-L103 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.log | def log(self):
""" Returns the natural logarithm of the quaternion.
(not tested)
"""
# Init
norm = self.norm()
vecNorm = self.x**2 + self.y**2 + self.z**2
tmp = self.w / norm
q = Quaternion()
# Calculate
q.w = np.log(norm... | python | def log(self):
""" Returns the natural logarithm of the quaternion.
(not tested)
"""
# Init
norm = self.norm()
vecNorm = self.x**2 + self.y**2 + self.z**2
tmp = self.w / norm
q = Quaternion()
# Calculate
q.w = np.log(norm... | [
"def",
"log",
"(",
"self",
")",
":",
"# Init",
"norm",
"=",
"self",
".",
"norm",
"(",
")",
"vecNorm",
"=",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"tmp",
"=",
"self",
".",
"w",
"/",
... | Returns the natural logarithm of the quaternion.
(not tested) | [
"Returns",
"the",
"natural",
"logarithm",
"of",
"the",
"quaternion",
".",
"(",
"not",
"tested",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L105-L122 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.rotate_point | def rotate_point(self, p):
""" Rotate a Point instance using this quaternion.
"""
# Prepare
p = Quaternion(0, p[0], p[1], p[2], False) # Do not normalize!
q1 = self.normalize()
q2 = self.inverse()
# Apply rotation
r = (q1*p)*q2
# Make point and r... | python | def rotate_point(self, p):
""" Rotate a Point instance using this quaternion.
"""
# Prepare
p = Quaternion(0, p[0], p[1], p[2], False) # Do not normalize!
q1 = self.normalize()
q2 = self.inverse()
# Apply rotation
r = (q1*p)*q2
# Make point and r... | [
"def",
"rotate_point",
"(",
"self",
",",
"p",
")",
":",
"# Prepare ",
"p",
"=",
"Quaternion",
"(",
"0",
",",
"p",
"[",
"0",
"]",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
",",
"False",
")",
"# Do not normalize!",
"q1",
"=",
"self",
".",... | Rotate a Point instance using this quaternion. | [
"Rotate",
"a",
"Point",
"instance",
"using",
"this",
"quaternion",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L152-L162 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.get_matrix | def get_matrix(self):
""" Create a 4x4 homography matrix that represents the rotation
of the quaternion.
"""
# Init matrix (remember, a matrix, not an array)
a = np.zeros((4, 4), dtype=np.float32)
w, x, y, z = self.w, self.x, self.y, self.z
# First row
a[0... | python | def get_matrix(self):
""" Create a 4x4 homography matrix that represents the rotation
of the quaternion.
"""
# Init matrix (remember, a matrix, not an array)
a = np.zeros((4, 4), dtype=np.float32)
w, x, y, z = self.w, self.x, self.y, self.z
# First row
a[0... | [
"def",
"get_matrix",
"(",
"self",
")",
":",
"# Init matrix (remember, a matrix, not an array)",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
"4",
",",
"4",
")",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"w",
",",
"x",
",",
"y",
",",
"z",
"=",
"self",
... | Create a 4x4 homography matrix that represents the rotation
of the quaternion. | [
"Create",
"a",
"4x4",
"homography",
"matrix",
"that",
"represents",
"the",
"rotation",
"of",
"the",
"quaternion",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L164-L191 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.get_axis_angle | def get_axis_angle(self):
""" Get the axis-angle representation of the quaternion.
(The angle is in radians)
"""
# Init
angle = 2 * np.arccos(max(min(self.w, 1.), -1.))
scale = (self.x**2 + self.y**2 + self.z**2)**0.5
# Calc axis
if scale:
... | python | def get_axis_angle(self):
""" Get the axis-angle representation of the quaternion.
(The angle is in radians)
"""
# Init
angle = 2 * np.arccos(max(min(self.w, 1.), -1.))
scale = (self.x**2 + self.y**2 + self.z**2)**0.5
# Calc axis
if scale:
... | [
"def",
"get_axis_angle",
"(",
"self",
")",
":",
"# Init",
"angle",
"=",
"2",
"*",
"np",
".",
"arccos",
"(",
"max",
"(",
"min",
"(",
"self",
".",
"w",
",",
"1.",
")",
",",
"-",
"1.",
")",
")",
"scale",
"=",
"(",
"self",
".",
"x",
"**",
"2",
... | Get the axis-angle representation of the quaternion.
(The angle is in radians) | [
"Get",
"the",
"axis",
"-",
"angle",
"representation",
"of",
"the",
"quaternion",
".",
"(",
"The",
"angle",
"is",
"in",
"radians",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L193-L210 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | Quaternion.create_from_axis_angle | def create_from_axis_angle(cls, angle, ax, ay, az, degrees=False):
""" Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians).
"""
if degrees:
angle = np.radians(angle)
while angle < 0:
angle += np.pi*2
... | python | def create_from_axis_angle(cls, angle, ax, ay, az, degrees=False):
""" Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians).
"""
if degrees:
angle = np.radians(angle)
while angle < 0:
angle += np.pi*2
... | [
"def",
"create_from_axis_angle",
"(",
"cls",
",",
"angle",
",",
"ax",
",",
"ay",
",",
"az",
",",
"degrees",
"=",
"False",
")",
":",
"if",
"degrees",
":",
"angle",
"=",
"np",
".",
"radians",
"(",
"angle",
")",
"while",
"angle",
"<",
"0",
":",
"angle... | Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians). | [
"Classmethod",
"to",
"create",
"a",
"quaternion",
"from",
"an",
"axis",
"-",
"angle",
"representation",
".",
"(",
"angle",
"should",
"be",
"in",
"radians",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L213-L223 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.