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/extern/vispy/visuals/shaders/compiler.py | Compiler._rename_objects_pretty | def _rename_objects_pretty(self):
""" Rename all objects like "name_1" to avoid conflicts. Objects are
only renamed if necessary.
This method produces more readable GLSL, but is rather slow.
"""
#
# 1. For each object, add its static names to the global namespace
... | python | def _rename_objects_pretty(self):
""" Rename all objects like "name_1" to avoid conflicts. Objects are
only renamed if necessary.
This method produces more readable GLSL, but is rather slow.
"""
#
# 1. For each object, add its static names to the global namespace
... | [
"def",
"_rename_objects_pretty",
"(",
"self",
")",
":",
"#",
"# 1. For each object, add its static names to the global namespace",
"# and make a list of the shaders used by the object.",
"#",
"# {name: obj} mapping for finding unique names",
"# initialize with reserved keywords.",
"self",... | Rename all objects like "name_1" to avoid conflicts. Objects are
only renamed if necessary.
This method produces more readable GLSL, but is rather slow. | [
"Rename",
"all",
"objects",
"like",
"name_1",
"to",
"avoid",
"conflicts",
".",
"Objects",
"are",
"only",
"renamed",
"if",
"necessary",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py#L135-L181 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py | Compiler._name_available | def _name_available(self, obj, name, shaders):
""" Return True if *name* is available for *obj* in *shaders*.
"""
if name in self._global_ns:
return False
shaders = self.shaders if self._is_global(obj) else shaders
for shader in shaders:
if name in self._s... | python | def _name_available(self, obj, name, shaders):
""" Return True if *name* is available for *obj* in *shaders*.
"""
if name in self._global_ns:
return False
shaders = self.shaders if self._is_global(obj) else shaders
for shader in shaders:
if name in self._s... | [
"def",
"_name_available",
"(",
"self",
",",
"obj",
",",
"name",
",",
"shaders",
")",
":",
"if",
"name",
"in",
"self",
".",
"_global_ns",
":",
"return",
"False",
"shaders",
"=",
"self",
".",
"shaders",
"if",
"self",
".",
"_is_global",
"(",
"obj",
")",
... | Return True if *name* is available for *obj* in *shaders*. | [
"Return",
"True",
"if",
"*",
"name",
"*",
"is",
"available",
"for",
"*",
"obj",
"*",
"in",
"*",
"shaders",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py#L196-L205 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py | Compiler._assign_name | def _assign_name(self, obj, name, shaders):
""" Assign *name* to *obj* in *shaders*.
"""
if self._is_global(obj):
assert name not in self._global_ns
self._global_ns[name] = obj
else:
for shader in shaders:
ns = self._shader_ns[shader]
... | python | def _assign_name(self, obj, name, shaders):
""" Assign *name* to *obj* in *shaders*.
"""
if self._is_global(obj):
assert name not in self._global_ns
self._global_ns[name] = obj
else:
for shader in shaders:
ns = self._shader_ns[shader]
... | [
"def",
"_assign_name",
"(",
"self",
",",
"obj",
",",
"name",
",",
"shaders",
")",
":",
"if",
"self",
".",
"_is_global",
"(",
"obj",
")",
":",
"assert",
"name",
"not",
"in",
"self",
".",
"_global_ns",
"self",
".",
"_global_ns",
"[",
"name",
"]",
"=",
... | Assign *name* to *obj* in *shaders*. | [
"Assign",
"*",
"name",
"*",
"to",
"*",
"obj",
"*",
"in",
"*",
"shaders",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py#L207-L218 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/colorbar.py | _CoreColorBarVisual._update | def _update(self):
"""Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual
"""
x, y = self._pos
halfw, halfh = self._halfdim
# test that width and height are non-zero
if halfw <= 0:
raise ValueError("hal... | python | def _update(self):
"""Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual
"""
x, y = self._pos
halfw, halfh = self._halfdim
# test that width and height are non-zero
if halfw <= 0:
raise ValueError("hal... | [
"def",
"_update",
"(",
"self",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"_pos",
"halfw",
",",
"halfh",
"=",
"self",
".",
"_halfdim",
"# test that width and height are non-zero",
"if",
"halfw",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"half-width must ... | Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual | [
"Rebuilds",
"the",
"shaders",
"and",
"repositions",
"the",
"objects",
"that",
"are",
"used",
"internally",
"by",
"the",
"ColorBarVisual"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/colorbar.py#L117-L158 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/colorbar.py | ColorBarVisual._update | def _update(self):
"""Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual
"""
self._colorbar.halfdim = self._halfdim
self._border.halfdim = self._halfdim
self._label.text = self._label_str
self._ticks[0].text = str(... | python | def _update(self):
"""Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual
"""
self._colorbar.halfdim = self._halfdim
self._border.halfdim = self._halfdim
self._label.text = self._label_str
self._ticks[0].text = str(... | [
"def",
"_update",
"(",
"self",
")",
":",
"self",
".",
"_colorbar",
".",
"halfdim",
"=",
"self",
".",
"_halfdim",
"self",
".",
"_border",
".",
"halfdim",
"=",
"self",
".",
"_halfdim",
"self",
".",
"_label",
".",
"text",
"=",
"self",
".",
"_label_str",
... | Rebuilds the shaders, and repositions the objects
that are used internally by the ColorBarVisual | [
"Rebuilds",
"the",
"shaders",
"and",
"repositions",
"the",
"objects",
"that",
"are",
"used",
"internally",
"by",
"the",
"ColorBarVisual"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/colorbar.py#L319-L333 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/colorbar.py | ColorBarVisual._update_positions | def _update_positions(self):
"""
updates the positions of the colorbars and labels
"""
self._colorbar.pos = self._pos
self._border.pos = self._pos
if self._orientation == "right" or self._orientation == "left":
self._label.rotation = -90
x, y = self... | python | def _update_positions(self):
"""
updates the positions of the colorbars and labels
"""
self._colorbar.pos = self._pos
self._border.pos = self._pos
if self._orientation == "right" or self._orientation == "left":
self._label.rotation = -90
x, y = self... | [
"def",
"_update_positions",
"(",
"self",
")",
":",
"self",
".",
"_colorbar",
".",
"pos",
"=",
"self",
".",
"_pos",
"self",
".",
"_border",
".",
"pos",
"=",
"self",
".",
"_pos",
"if",
"self",
".",
"_orientation",
"==",
"\"right\"",
"or",
"self",
".",
... | updates the positions of the colorbars and labels | [
"updates",
"the",
"positions",
"of",
"the",
"colorbars",
"and",
"labels"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/colorbar.py#L335-L374 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/colorbar.py | ColorBarVisual._calc_positions | def _calc_positions(center, halfdim, border_width,
orientation, transforms):
"""
Calculate the text centeritions given the ColorBar
parameters.
Note
----
This is static because in principle, this
function does not need access to the state ... | python | def _calc_positions(center, halfdim, border_width,
orientation, transforms):
"""
Calculate the text centeritions given the ColorBar
parameters.
Note
----
This is static because in principle, this
function does not need access to the state ... | [
"def",
"_calc_positions",
"(",
"center",
",",
"halfdim",
",",
"border_width",
",",
"orientation",
",",
"transforms",
")",
":",
"(",
"x",
",",
"y",
")",
"=",
"center",
"(",
"halfw",
",",
"halfh",
")",
"=",
"halfdim",
"visual_to_doc",
"=",
"transforms",
".... | Calculate the text centeritions given the ColorBar
parameters.
Note
----
This is static because in principle, this
function does not need access to the state of the ColorBar
at all. It's a computation function that computes coordinate
transforms
Paramete... | [
"Calculate",
"the",
"text",
"centeritions",
"given",
"the",
"ColorBar",
"parameters",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/colorbar.py#L471-L551 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/colorbar.py | ColorBarVisual.size | def size(self):
""" The size of the ColorBar
Returns
-------
size: (major_axis_length, minor_axis_length)
major and minor axis are defined by the
orientation of the ColorBar
"""
(halfw, halfh) = self._halfdim
if self.orientation in ["top",... | python | def size(self):
""" The size of the ColorBar
Returns
-------
size: (major_axis_length, minor_axis_length)
major and minor axis are defined by the
orientation of the ColorBar
"""
(halfw, halfh) = self._halfdim
if self.orientation in ["top",... | [
"def",
"size",
"(",
"self",
")",
":",
"(",
"halfw",
",",
"halfh",
")",
"=",
"self",
".",
"_halfdim",
"if",
"self",
".",
"orientation",
"in",
"[",
"\"top\"",
",",
"\"bottom\"",
"]",
":",
"return",
"(",
"halfw",
"*",
"2.",
",",
"halfh",
"*",
"2.",
... | The size of the ColorBar
Returns
-------
size: (major_axis_length, minor_axis_length)
major and minor axis are defined by the
orientation of the ColorBar | [
"The",
"size",
"of",
"the",
"ColorBar"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/colorbar.py#L645-L658 | train |
rbarrois/mpdlcd | mpdlcd/lcdrunner.py | MpdRunner.add_pseudo_fields | def add_pseudo_fields(self):
"""Add 'pseudo' fields (e.g non-displayed fields) to the display."""
fields = []
if self.backlight_on != enums.BACKLIGHT_ON_NEVER:
fields.append(
display_fields.BacklightPseudoField(ref='0', backlight_rule=self.backlight_on)
)
... | python | def add_pseudo_fields(self):
"""Add 'pseudo' fields (e.g non-displayed fields) to the display."""
fields = []
if self.backlight_on != enums.BACKLIGHT_ON_NEVER:
fields.append(
display_fields.BacklightPseudoField(ref='0', backlight_rule=self.backlight_on)
)
... | [
"def",
"add_pseudo_fields",
"(",
"self",
")",
":",
"fields",
"=",
"[",
"]",
"if",
"self",
".",
"backlight_on",
"!=",
"enums",
".",
"BACKLIGHT_ON_NEVER",
":",
"fields",
".",
"append",
"(",
"display_fields",
".",
"BacklightPseudoField",
"(",
"ref",
"=",
"'0'",... | Add 'pseudo' fields (e.g non-displayed fields) to the display. | [
"Add",
"pseudo",
"fields",
"(",
"e",
".",
"g",
"non",
"-",
"displayed",
"fields",
")",
"to",
"the",
"display",
"."
] | 85f16c8cc0883f8abb4c2cc7f69729c3e2f857da | https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/lcdrunner.py#L63-L79 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/rect.py | Rect.padded | def padded(self, padding):
"""Return a new Rect padded (smaller) by padding on all sides
Parameters
----------
padding : float
The padding.
Returns
-------
rect : instance of Rect
The padded rectangle.
"""
return Rect(pos=... | python | def padded(self, padding):
"""Return a new Rect padded (smaller) by padding on all sides
Parameters
----------
padding : float
The padding.
Returns
-------
rect : instance of Rect
The padded rectangle.
"""
return Rect(pos=... | [
"def",
"padded",
"(",
"self",
",",
"padding",
")",
":",
"return",
"Rect",
"(",
"pos",
"=",
"(",
"self",
".",
"pos",
"[",
"0",
"]",
"+",
"padding",
",",
"self",
".",
"pos",
"[",
"1",
"]",
"+",
"padding",
")",
",",
"size",
"=",
"(",
"self",
"."... | Return a new Rect padded (smaller) by padding on all sides
Parameters
----------
padding : float
The padding.
Returns
-------
rect : instance of Rect
The padded rectangle. | [
"Return",
"a",
"new",
"Rect",
"padded",
"(",
"smaller",
")",
"by",
"padding",
"on",
"all",
"sides"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/rect.py#L115-L129 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/rect.py | Rect.normalized | def normalized(self):
"""Return a Rect covering the same area, but with height and width
guaranteed to be positive."""
return Rect(pos=(min(self.left, self.right),
min(self.top, self.bottom)),
size=(abs(self.width), abs(self.height))) | python | def normalized(self):
"""Return a Rect covering the same area, but with height and width
guaranteed to be positive."""
return Rect(pos=(min(self.left, self.right),
min(self.top, self.bottom)),
size=(abs(self.width), abs(self.height))) | [
"def",
"normalized",
"(",
"self",
")",
":",
"return",
"Rect",
"(",
"pos",
"=",
"(",
"min",
"(",
"self",
".",
"left",
",",
"self",
".",
"right",
")",
",",
"min",
"(",
"self",
".",
"top",
",",
"self",
".",
"bottom",
")",
")",
",",
"size",
"=",
... | Return a Rect covering the same area, but with height and width
guaranteed to be positive. | [
"Return",
"a",
"Rect",
"covering",
"the",
"same",
"area",
"but",
"with",
"height",
"and",
"width",
"guaranteed",
"to",
"be",
"positive",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/rect.py#L131-L136 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/rect.py | Rect.flipped | def flipped(self, x=False, y=True):
"""Return a Rect with the same bounds but with axes inverted
Parameters
----------
x : bool
Flip the X axis.
y : bool
Flip the Y axis.
Returns
-------
rect : instance of Rect
The fli... | python | def flipped(self, x=False, y=True):
"""Return a Rect with the same bounds but with axes inverted
Parameters
----------
x : bool
Flip the X axis.
y : bool
Flip the Y axis.
Returns
-------
rect : instance of Rect
The fli... | [
"def",
"flipped",
"(",
"self",
",",
"x",
"=",
"False",
",",
"y",
"=",
"True",
")",
":",
"pos",
"=",
"list",
"(",
"self",
".",
"pos",
")",
"size",
"=",
"list",
"(",
"self",
".",
"size",
")",
"for",
"i",
",",
"flip",
"in",
"enumerate",
"(",
"("... | Return a Rect with the same bounds but with axes inverted
Parameters
----------
x : bool
Flip the X axis.
y : bool
Flip the Y axis.
Returns
-------
rect : instance of Rect
The flipped rectangle. | [
"Return",
"a",
"Rect",
"with",
"the",
"same",
"bounds",
"but",
"with",
"axes",
"inverted"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/rect.py#L138-L159 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/rect.py | Rect._transform_in | def _transform_in(self):
"""Return array of coordinates that can be mapped by Transform
classes."""
return np.array([
[self.left, self.bottom, 0, 1],
[self.right, self.top, 0, 1]]) | python | def _transform_in(self):
"""Return array of coordinates that can be mapped by Transform
classes."""
return np.array([
[self.left, self.bottom, 0, 1],
[self.right, self.top, 0, 1]]) | [
"def",
"_transform_in",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"[",
"self",
".",
"left",
",",
"self",
".",
"bottom",
",",
"0",
",",
"1",
"]",
",",
"[",
"self",
".",
"right",
",",
"self",
".",
"top",
",",
"0",
",",
"1",... | Return array of coordinates that can be mapped by Transform
classes. | [
"Return",
"array",
"of",
"coordinates",
"that",
"can",
"be",
"mapped",
"by",
"Transform",
"classes",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/rect.py#L193-L198 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py | TransformSystem.configure | def configure(self, viewport=None, fbo_size=None, fbo_rect=None,
canvas=None):
"""Automatically configure the TransformSystem:
* canvas_transform maps from the Canvas logical pixel
coordinate system to the framebuffer coordinate system, taking into
account the log... | python | def configure(self, viewport=None, fbo_size=None, fbo_rect=None,
canvas=None):
"""Automatically configure the TransformSystem:
* canvas_transform maps from the Canvas logical pixel
coordinate system to the framebuffer coordinate system, taking into
account the log... | [
"def",
"configure",
"(",
"self",
",",
"viewport",
"=",
"None",
",",
"fbo_size",
"=",
"None",
",",
"fbo_rect",
"=",
"None",
",",
"canvas",
"=",
"None",
")",
":",
"# TODO: check that d2f and f2r transforms still contain a single",
"# STTransform (if the user has modified ... | Automatically configure the TransformSystem:
* canvas_transform maps from the Canvas logical pixel
coordinate system to the framebuffer coordinate system, taking into
account the logical/physical pixel scale factor, current FBO
position, and y-axis inversion.
* framebuff... | [
"Automatically",
"configure",
"the",
"TransformSystem",
":"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py#L164-L228 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py | TransformSystem.dpi | def dpi(self):
""" Physical resolution of the document coordinate system (dots per
inch).
"""
if self._dpi is None:
if self._canvas is None:
return None
else:
return self.canvas.dpi
else:
return self._dpi | python | def dpi(self):
""" Physical resolution of the document coordinate system (dots per
inch).
"""
if self._dpi is None:
if self._canvas is None:
return None
else:
return self.canvas.dpi
else:
return self._dpi | [
"def",
"dpi",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dpi",
"is",
"None",
":",
"if",
"self",
".",
"_canvas",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",
"self",
".",
"canvas",
".",
"dpi",
"else",
":",
"return",
"self",
".",
"_... | Physical resolution of the document coordinate system (dots per
inch). | [
"Physical",
"resolution",
"of",
"the",
"document",
"coordinate",
"system",
"(",
"dots",
"per",
"inch",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py#L241-L251 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py | TransformSystem.get_transform | def get_transform(self, map_from='visual', map_to='render'):
"""Return a transform mapping between any two coordinate systems.
Parameters
----------
map_from : str
The starting coordinate system to map from. Must be one of: visual,
scene, document, canvas... | python | def get_transform(self, map_from='visual', map_to='render'):
"""Return a transform mapping between any two coordinate systems.
Parameters
----------
map_from : str
The starting coordinate system to map from. Must be one of: visual,
scene, document, canvas... | [
"def",
"get_transform",
"(",
"self",
",",
"map_from",
"=",
"'visual'",
",",
"map_to",
"=",
"'render'",
")",
":",
"tr",
"=",
"[",
"'visual'",
",",
"'scene'",
",",
"'document'",
",",
"'canvas'",
",",
"'framebuffer'",
",",
"'render'",
"]",
"ifrom",
"=",
"tr... | Return a transform mapping between any two coordinate systems.
Parameters
----------
map_from : str
The starting coordinate system to map from. Must be one of: visual,
scene, document, canvas, framebuffer, or render.
map_to : str
The ending co... | [
"Return",
"a",
"transform",
"mapping",
"between",
"any",
"two",
"coordinate",
"systems",
".",
"Parameters",
"----------",
"map_from",
":",
"str",
"The",
"starting",
"coordinate",
"system",
"to",
"map",
"from",
".",
"Must",
"be",
"one",
"of",
":",
"visual",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py#L313-L335 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/force_directed.py | _calculate_delta_pos | def _calculate_delta_pos(adjacency_arr, pos, t, optimal):
"""Helper to calculate the delta position"""
# XXX eventually this should be refactored for the sparse case to only
# do the necessary pairwise distances
delta = pos[:, np.newaxis, :] - pos
# Distance between points
distance2 = (delta*de... | python | def _calculate_delta_pos(adjacency_arr, pos, t, optimal):
"""Helper to calculate the delta position"""
# XXX eventually this should be refactored for the sparse case to only
# do the necessary pairwise distances
delta = pos[:, np.newaxis, :] - pos
# Distance between points
distance2 = (delta*de... | [
"def",
"_calculate_delta_pos",
"(",
"adjacency_arr",
",",
"pos",
",",
"t",
",",
"optimal",
")",
":",
"# XXX eventually this should be refactored for the sparse case to only",
"# do the necessary pairwise distances",
"delta",
"=",
"pos",
"[",
":",
",",
"np",
".",
"newaxis"... | Helper to calculate the delta position | [
"Helper",
"to",
"calculate",
"the",
"delta",
"position"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/force_directed.py#L190-L212 | train |
anjishnu/ask-alexa-pykit | lambda_function.py | get_recipe_intent_handler | def get_recipe_intent_handler(request):
"""
You can insert arbitrary business logic code here
"""
# Get variables like userId, slots, intent name etc from the 'Request' object
ingredient = request.slots["Ingredient"] # Gets an Ingredient Slot from the Request object.
if ingredient == ... | python | def get_recipe_intent_handler(request):
"""
You can insert arbitrary business logic code here
"""
# Get variables like userId, slots, intent name etc from the 'Request' object
ingredient = request.slots["Ingredient"] # Gets an Ingredient Slot from the Request object.
if ingredient == ... | [
"def",
"get_recipe_intent_handler",
"(",
"request",
")",
":",
"# Get variables like userId, slots, intent name etc from the 'Request' object",
"ingredient",
"=",
"request",
".",
"slots",
"[",
"\"Ingredient\"",
"]",
"# Gets an Ingredient Slot from the Request object.",
"if",
"ingred... | You can insert arbitrary business logic code here | [
"You",
"can",
"insert",
"arbitrary",
"business",
"logic",
"code",
"here"
] | a47c278ca7a60532bbe1a9b789f6c37e609fea8b | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/lambda_function.py#L47-L71 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/wrappers.py | use | def use(app=None, gl=None):
""" Set the usage options for vispy
Specify what app backend and GL backend to use.
Parameters
----------
app : str
The app backend to use (case insensitive). Standard backends:
* 'PyQt4': use Qt widget toolkit via PyQt4.
* 'PyQt5': use Q... | python | def use(app=None, gl=None):
""" Set the usage options for vispy
Specify what app backend and GL backend to use.
Parameters
----------
app : str
The app backend to use (case insensitive). Standard backends:
* 'PyQt4': use Qt widget toolkit via PyQt4.
* 'PyQt5': use Q... | [
"def",
"use",
"(",
"app",
"=",
"None",
",",
"gl",
"=",
"None",
")",
":",
"if",
"app",
"is",
"None",
"and",
"gl",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'Must specify at least one of \"app\" or \"gl\".'",
")",
"# Example for future. This wont work (yet).",
... | Set the usage options for vispy
Specify what app backend and GL backend to use.
Parameters
----------
app : str
The app backend to use (case insensitive). Standard backends:
* 'PyQt4': use Qt widget toolkit via PyQt4.
* 'PyQt5': use Qt widget toolkit via PyQt5.
... | [
"Set",
"the",
"usage",
"options",
"for",
"vispy"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/wrappers.py#L23-L94 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/wrappers.py | run_subprocess | def run_subprocess(command, return_code=False, **kwargs):
"""Run command using subprocess.Popen
Run command and wait for command to complete. If the return code was zero
then return, otherwise raise CalledProcessError.
By default, this will also add stdout= and stderr=subproces.PIPE
to the call to ... | python | def run_subprocess(command, return_code=False, **kwargs):
"""Run command using subprocess.Popen
Run command and wait for command to complete. If the return code was zero
then return, otherwise raise CalledProcessError.
By default, this will also add stdout= and stderr=subproces.PIPE
to the call to ... | [
"def",
"run_subprocess",
"(",
"command",
",",
"return_code",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# code adapted with permission from mne-python",
"use_kwargs",
"=",
"dict",
"(",
"stderr",
"=",
"subprocess",
".",
"PIPE",
",",
"stdout",
"=",
"subproc... | Run command using subprocess.Popen
Run command and wait for command to complete. If the return code was zero
then return, otherwise raise CalledProcessError.
By default, this will also add stdout= and stderr=subproces.PIPE
to the call to Popen to suppress printing to the terminal.
Parameters
-... | [
"Run",
"command",
"using",
"subprocess",
".",
"Popen"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/wrappers.py#L97-L148 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/timer.py | Timer.start | def start(self, interval=None, iterations=None):
"""Start the timer.
A timeout event will be generated every *interval* seconds.
If *interval* is None, then self.interval will be used.
If *iterations* is specified, the timer will stop after
emitting that number of events. If un... | python | def start(self, interval=None, iterations=None):
"""Start the timer.
A timeout event will be generated every *interval* seconds.
If *interval* is None, then self.interval will be used.
If *iterations* is specified, the timer will stop after
emitting that number of events. If un... | [
"def",
"start",
"(",
"self",
",",
"interval",
"=",
"None",
",",
"iterations",
"=",
"None",
")",
":",
"if",
"self",
".",
"running",
":",
"return",
"# don't do anything if already running",
"self",
".",
"iter_count",
"=",
"0",
"if",
"interval",
"is",
"not",
... | Start the timer.
A timeout event will be generated every *interval* seconds.
If *interval* is None, then self.interval will be used.
If *iterations* is specified, the timer will stop after
emitting that number of events. If unspecified, then
the previous value of self.iteration... | [
"Start",
"the",
"timer",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/timer.py#L97-L124 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/timer.py | Timer.stop | def stop(self):
"""Stop the timer."""
self._backend._vispy_stop()
self._running = False
self.events.stop(type='timer_stop') | python | def stop(self):
"""Stop the timer."""
self._backend._vispy_stop()
self._running = False
self.events.stop(type='timer_stop') | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_backend",
".",
"_vispy_stop",
"(",
")",
"self",
".",
"_running",
"=",
"False",
"self",
".",
"events",
".",
"stop",
"(",
"type",
"=",
"'timer_stop'",
")"
] | Stop the timer. | [
"Stop",
"the",
"timer",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/timer.py#L126-L130 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC._best_res_pixels | def _best_res_pixels(self):
"""
Returns a numpy array of all the HEALPix indexes contained in the MOC at its max order.
Returns
-------
result : `~numpy.ndarray`
The array of HEALPix at ``max_order``
"""
factor = 2 * (AbstractMOC.HPY_MAX_NORDER - self... | python | def _best_res_pixels(self):
"""
Returns a numpy array of all the HEALPix indexes contained in the MOC at its max order.
Returns
-------
result : `~numpy.ndarray`
The array of HEALPix at ``max_order``
"""
factor = 2 * (AbstractMOC.HPY_MAX_NORDER - self... | [
"def",
"_best_res_pixels",
"(",
"self",
")",
":",
"factor",
"=",
"2",
"*",
"(",
"AbstractMOC",
".",
"HPY_MAX_NORDER",
"-",
"self",
".",
"max_order",
")",
"pix_l",
"=",
"[",
"]",
"for",
"iv",
"in",
"self",
".",
"_interval_set",
".",
"_intervals",
":",
"... | Returns a numpy array of all the HEALPix indexes contained in the MOC at its max order.
Returns
-------
result : `~numpy.ndarray`
The array of HEALPix at ``max_order`` | [
"Returns",
"a",
"numpy",
"array",
"of",
"all",
"the",
"HEALPix",
"indexes",
"contained",
"in",
"the",
"MOC",
"at",
"its",
"max",
"order",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L71-L86 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.contains | def contains(self, ra, dec, keep_inside=True):
"""
Returns a boolean mask array of the positions lying inside (or outside) the MOC instance.
Parameters
----------
ra : `astropy.units.Quantity`
Right ascension array
dec : `astropy.units.Quantity`
D... | python | def contains(self, ra, dec, keep_inside=True):
"""
Returns a boolean mask array of the positions lying inside (or outside) the MOC instance.
Parameters
----------
ra : `astropy.units.Quantity`
Right ascension array
dec : `astropy.units.Quantity`
D... | [
"def",
"contains",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"keep_inside",
"=",
"True",
")",
":",
"depth",
"=",
"self",
".",
"max_order",
"m",
"=",
"np",
".",
"zeros",
"(",
"nside2npix",
"(",
"1",
"<<",
"depth",
")",
",",
"dtype",
"=",
"bool",
")... | Returns a boolean mask array of the positions lying inside (or outside) the MOC instance.
Parameters
----------
ra : `astropy.units.Quantity`
Right ascension array
dec : `astropy.units.Quantity`
Declination array
keep_inside : bool, optional
T... | [
"Returns",
"a",
"boolean",
"mask",
"array",
"of",
"the",
"positions",
"lying",
"inside",
"(",
"or",
"outside",
")",
"the",
"MOC",
"instance",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L88-L119 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.add_neighbours | def add_neighbours(self):
"""
Extends the MOC instance so that it includes the HEALPix cells touching its border.
The depth of the HEALPix cells added at the border is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
sel... | python | def add_neighbours(self):
"""
Extends the MOC instance so that it includes the HEALPix cells touching its border.
The depth of the HEALPix cells added at the border is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
sel... | [
"def",
"add_neighbours",
"(",
"self",
")",
":",
"# Get the pixels array of the MOC at the its max order.",
"ipix",
"=",
"self",
".",
"_best_res_pixels",
"(",
")",
"hp",
"=",
"HEALPix",
"(",
"nside",
"=",
"(",
"1",
"<<",
"self",
".",
"max_order",
")",
",",
"ord... | Extends the MOC instance so that it includes the HEALPix cells touching its border.
The depth of the HEALPix cells added at the border is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
self extended by one degree of neighbours. | [
"Extends",
"the",
"MOC",
"instance",
"so",
"that",
"it",
"includes",
"the",
"HEALPix",
"cells",
"touching",
"its",
"border",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L124-L151 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.remove_neighbours | def remove_neighbours(self):
"""
Removes from the MOC instance the HEALPix cells located at its border.
The depth of the HEALPix cells removed is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
self minus its HEALPix ce... | python | def remove_neighbours(self):
"""
Removes from the MOC instance the HEALPix cells located at its border.
The depth of the HEALPix cells removed is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
self minus its HEALPix ce... | [
"def",
"remove_neighbours",
"(",
"self",
")",
":",
"# Get the HEALPix cells of the MOC at its max depth",
"ipix",
"=",
"self",
".",
"_best_res_pixels",
"(",
")",
"hp",
"=",
"HEALPix",
"(",
"nside",
"=",
"(",
"1",
"<<",
"self",
".",
"max_order",
")",
",",
"orde... | Removes from the MOC instance the HEALPix cells located at its border.
The depth of the HEALPix cells removed is equal to the maximum depth of the MOC instance.
Returns
-------
moc : `~mocpy.moc.MOC`
self minus its HEALPix cells located at its border. | [
"Removes",
"from",
"the",
"MOC",
"instance",
"the",
"HEALPix",
"cells",
"located",
"at",
"its",
"border",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L153-L182 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.fill | def fill(self, ax, wcs, **kw_mpl_pathpatch):
"""
Draws the MOC on a matplotlib axis.
This performs the projection of the cells from the world coordinate system to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.patches.PathPatch`
... | python | def fill(self, ax, wcs, **kw_mpl_pathpatch):
"""
Draws the MOC on a matplotlib axis.
This performs the projection of the cells from the world coordinate system to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.patches.PathPatch`
... | [
"def",
"fill",
"(",
"self",
",",
"ax",
",",
"wcs",
",",
"*",
"*",
"kw_mpl_pathpatch",
")",
":",
"fill",
".",
"fill",
"(",
"self",
",",
"ax",
",",
"wcs",
",",
"*",
"*",
"kw_mpl_pathpatch",
")"
] | Draws the MOC on a matplotlib axis.
This performs the projection of the cells from the world coordinate system to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.patches.PathPatch`
(see the `list of valid keywords <https://matplotlib.org/api/_as... | [
"Draws",
"the",
"MOC",
"on",
"a",
"matplotlib",
"axis",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L184-L229 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.border | def border(self, ax, wcs, **kw_mpl_pathpatch):
"""
Draws the MOC border(s) on a matplotlib axis.
This performs the projection of the sky coordinates defining the perimeter of the MOC to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.pat... | python | def border(self, ax, wcs, **kw_mpl_pathpatch):
"""
Draws the MOC border(s) on a matplotlib axis.
This performs the projection of the sky coordinates defining the perimeter of the MOC to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.pat... | [
"def",
"border",
"(",
"self",
",",
"ax",
",",
"wcs",
",",
"*",
"*",
"kw_mpl_pathpatch",
")",
":",
"border",
".",
"border",
"(",
"self",
",",
"ax",
",",
"wcs",
",",
"*",
"*",
"kw_mpl_pathpatch",
")"
] | Draws the MOC border(s) on a matplotlib axis.
This performs the projection of the sky coordinates defining the perimeter of the MOC to the pixel image coordinate system.
You are able to specify various styling kwargs for `matplotlib.patches.PathPatch`
(see the `list of valid keywords <https://... | [
"Draws",
"the",
"MOC",
"border",
"(",
"s",
")",
"on",
"a",
"matplotlib",
"axis",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L231-L273 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_image | def from_image(cls, header, max_norder, mask=None):
"""
Creates a `~mocpy.moc.MOC` from an image stored as a FITS file.
Parameters
----------
header : `astropy.io.fits.Header`
FITS header containing all the info of where the image is located (position, size, etc...)
... | python | def from_image(cls, header, max_norder, mask=None):
"""
Creates a `~mocpy.moc.MOC` from an image stored as a FITS file.
Parameters
----------
header : `astropy.io.fits.Header`
FITS header containing all the info of where the image is located (position, size, etc...)
... | [
"def",
"from_image",
"(",
"cls",
",",
"header",
",",
"max_norder",
",",
"mask",
"=",
"None",
")",
":",
"# load the image data",
"height",
"=",
"header",
"[",
"'NAXIS2'",
"]",
"width",
"=",
"header",
"[",
"'NAXIS1'",
"]",
"# use wcs from astropy to locate the ima... | Creates a `~mocpy.moc.MOC` from an image stored as a FITS file.
Parameters
----------
header : `astropy.io.fits.Header`
FITS header containing all the info of where the image is located (position, size, etc...)
max_norder : int
The moc resolution.
mask : ... | [
"Creates",
"a",
"~mocpy",
".",
"moc",
".",
"MOC",
"from",
"an",
"image",
"stored",
"as",
"a",
"FITS",
"file",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L299-L359 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_fits_images | def from_fits_images(cls, path_l, max_norder):
"""
Loads a MOC from a set of FITS file images.
Parameters
----------
path_l : [str]
A list of path where the fits image are located.
max_norder : int
The MOC resolution.
Returns
----... | python | def from_fits_images(cls, path_l, max_norder):
"""
Loads a MOC from a set of FITS file images.
Parameters
----------
path_l : [str]
A list of path where the fits image are located.
max_norder : int
The MOC resolution.
Returns
----... | [
"def",
"from_fits_images",
"(",
"cls",
",",
"path_l",
",",
"max_norder",
")",
":",
"moc",
"=",
"MOC",
"(",
")",
"for",
"path",
"in",
"path_l",
":",
"header",
"=",
"fits",
".",
"getheader",
"(",
"path",
")",
"current_moc",
"=",
"MOC",
".",
"from_image",... | Loads a MOC from a set of FITS file images.
Parameters
----------
path_l : [str]
A list of path where the fits image are located.
max_norder : int
The MOC resolution.
Returns
-------
moc : `~mocpy.moc.MOC`
The union of all the... | [
"Loads",
"a",
"MOC",
"from",
"a",
"set",
"of",
"FITS",
"file",
"images",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L362-L384 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_vizier_table | def from_vizier_table(cls, table_id, nside=256):
"""
Creates a `~mocpy.moc.MOC` object from a VizieR table.
**Info**: This method is already implemented in `astroquery.cds <https://astroquery.readthedocs.io/en/latest/cds/cds.html>`__. You can ask to get a `mocpy.moc.MOC` object
from a v... | python | def from_vizier_table(cls, table_id, nside=256):
"""
Creates a `~mocpy.moc.MOC` object from a VizieR table.
**Info**: This method is already implemented in `astroquery.cds <https://astroquery.readthedocs.io/en/latest/cds/cds.html>`__. You can ask to get a `mocpy.moc.MOC` object
from a v... | [
"def",
"from_vizier_table",
"(",
"cls",
",",
"table_id",
",",
"nside",
"=",
"256",
")",
":",
"nside_possible_values",
"=",
"(",
"8",
",",
"16",
",",
"32",
",",
"64",
",",
"128",
",",
"256",
",",
"512",
")",
"if",
"nside",
"not",
"in",
"nside_possible... | Creates a `~mocpy.moc.MOC` object from a VizieR table.
**Info**: This method is already implemented in `astroquery.cds <https://astroquery.readthedocs.io/en/latest/cds/cds.html>`__. You can ask to get a `mocpy.moc.MOC` object
from a vizier catalog ID.
Parameters
----------
tabl... | [
"Creates",
"a",
"~mocpy",
".",
"moc",
".",
"MOC",
"object",
"from",
"a",
"VizieR",
"table",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L387-L411 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_ivorn | def from_ivorn(cls, ivorn, nside=256):
"""
Creates a `~mocpy.moc.MOC` object from a given ivorn.
Parameters
----------
ivorn : str
nside : int, optional
256 by default
Returns
-------
result : `~mocpy.moc.MOC`
The resultin... | python | def from_ivorn(cls, ivorn, nside=256):
"""
Creates a `~mocpy.moc.MOC` object from a given ivorn.
Parameters
----------
ivorn : str
nside : int, optional
256 by default
Returns
-------
result : `~mocpy.moc.MOC`
The resultin... | [
"def",
"from_ivorn",
"(",
"cls",
",",
"ivorn",
",",
"nside",
"=",
"256",
")",
":",
"return",
"cls",
".",
"from_url",
"(",
"'%s?%s'",
"%",
"(",
"MOC",
".",
"MOC_SERVER_ROOT_URL",
",",
"urlencode",
"(",
"{",
"'ivorn'",
":",
"ivorn",
",",
"'get'",
":",
... | Creates a `~mocpy.moc.MOC` object from a given ivorn.
Parameters
----------
ivorn : str
nside : int, optional
256 by default
Returns
-------
result : `~mocpy.moc.MOC`
The resulting MOC. | [
"Creates",
"a",
"~mocpy",
".",
"moc",
".",
"MOC",
"object",
"from",
"a",
"given",
"ivorn",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L416-L436 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_url | def from_url(cls, url):
"""
Creates a `~mocpy.moc.MOC` object from a given url.
Parameters
----------
url : str
The url of a FITS file storing a MOC.
Returns
-------
result : `~mocpy.moc.MOC`
The resulting MOC.
"""
... | python | def from_url(cls, url):
"""
Creates a `~mocpy.moc.MOC` object from a given url.
Parameters
----------
url : str
The url of a FITS file storing a MOC.
Returns
-------
result : `~mocpy.moc.MOC`
The resulting MOC.
"""
... | [
"def",
"from_url",
"(",
"cls",
",",
"url",
")",
":",
"path",
"=",
"download_file",
"(",
"url",
",",
"show_progress",
"=",
"False",
",",
"timeout",
"=",
"60",
")",
"return",
"cls",
".",
"from_fits",
"(",
"path",
")"
] | Creates a `~mocpy.moc.MOC` object from a given url.
Parameters
----------
url : str
The url of a FITS file storing a MOC.
Returns
-------
result : `~mocpy.moc.MOC`
The resulting MOC. | [
"Creates",
"a",
"~mocpy",
".",
"moc",
".",
"MOC",
"object",
"from",
"a",
"given",
"url",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L439-L454 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_skycoords | def from_skycoords(cls, skycoords, max_norder):
"""
Creates a MOC from an `astropy.coordinates.SkyCoord`.
Parameters
----------
skycoords : `astropy.coordinates.SkyCoord`
The sky coordinates that will belong to the MOC.
max_norder : int
The depth ... | python | def from_skycoords(cls, skycoords, max_norder):
"""
Creates a MOC from an `astropy.coordinates.SkyCoord`.
Parameters
----------
skycoords : `astropy.coordinates.SkyCoord`
The sky coordinates that will belong to the MOC.
max_norder : int
The depth ... | [
"def",
"from_skycoords",
"(",
"cls",
",",
"skycoords",
",",
"max_norder",
")",
":",
"hp",
"=",
"HEALPix",
"(",
"nside",
"=",
"(",
"1",
"<<",
"max_norder",
")",
",",
"order",
"=",
"'nested'",
")",
"ipix",
"=",
"hp",
".",
"lonlat_to_healpix",
"(",
"skyco... | Creates a MOC from an `astropy.coordinates.SkyCoord`.
Parameters
----------
skycoords : `astropy.coordinates.SkyCoord`
The sky coordinates that will belong to the MOC.
max_norder : int
The depth of the smallest HEALPix cells contained in the MOC.
... | [
"Creates",
"a",
"MOC",
"from",
"an",
"astropy",
".",
"coordinates",
".",
"SkyCoord",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L457-L480 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_lonlat | def from_lonlat(cls, lon, lat, max_norder):
"""
Creates a MOC from astropy lon, lat `astropy.units.Quantity`.
Parameters
----------
lon : `astropy.units.Quantity`
The longitudes of the sky coordinates belonging to the MOC.
lat : `astropy.units.Quantit... | python | def from_lonlat(cls, lon, lat, max_norder):
"""
Creates a MOC from astropy lon, lat `astropy.units.Quantity`.
Parameters
----------
lon : `astropy.units.Quantity`
The longitudes of the sky coordinates belonging to the MOC.
lat : `astropy.units.Quantit... | [
"def",
"from_lonlat",
"(",
"cls",
",",
"lon",
",",
"lat",
",",
"max_norder",
")",
":",
"hp",
"=",
"HEALPix",
"(",
"nside",
"=",
"(",
"1",
"<<",
"max_norder",
")",
",",
"order",
"=",
"'nested'",
")",
"ipix",
"=",
"hp",
".",
"lonlat_to_healpix",
"(",
... | Creates a MOC from astropy lon, lat `astropy.units.Quantity`.
Parameters
----------
lon : `astropy.units.Quantity`
The longitudes of the sky coordinates belonging to the MOC.
lat : `astropy.units.Quantity`
The latitudes of the sky coordinates belonging to... | [
"Creates",
"a",
"MOC",
"from",
"astropy",
"lon",
"lat",
"astropy",
".",
"units",
".",
"Quantity",
".",
"Parameters",
"----------",
"lon",
":",
"astropy",
".",
"units",
".",
"Quantity",
"The",
"longitudes",
"of",
"the",
"sky",
"coordinates",
"belonging",
"to"... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L483-L508 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_polygon_skycoord | def from_polygon_skycoord(cls, skycoord, inside=None, max_depth=10):
"""
Creates a MOC from a polygon.
The polygon is given as an `astropy.coordinates.SkyCoord` that contains the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are cu... | python | def from_polygon_skycoord(cls, skycoord, inside=None, max_depth=10):
"""
Creates a MOC from a polygon.
The polygon is given as an `astropy.coordinates.SkyCoord` that contains the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are cu... | [
"def",
"from_polygon_skycoord",
"(",
"cls",
",",
"skycoord",
",",
"inside",
"=",
"None",
",",
"max_depth",
"=",
"10",
")",
":",
"return",
"MOC",
".",
"from_polygon",
"(",
"lon",
"=",
"skycoord",
".",
"icrs",
".",
"ra",
",",
"lat",
"=",
"skycoord",
".",... | Creates a MOC from a polygon.
The polygon is given as an `astropy.coordinates.SkyCoord` that contains the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are currently not properly handled.
Parameters
----------
skycoord : `... | [
"Creates",
"a",
"MOC",
"from",
"a",
"polygon",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L511-L541 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.from_polygon | def from_polygon(cls, lon, lat, inside=None, max_depth=10):
"""
Creates a MOC from a polygon
The polygon is given as lon and lat `astropy.units.Quantity` that define the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are currently n... | python | def from_polygon(cls, lon, lat, inside=None, max_depth=10):
"""
Creates a MOC from a polygon
The polygon is given as lon and lat `astropy.units.Quantity` that define the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are currently n... | [
"def",
"from_polygon",
"(",
"cls",
",",
"lon",
",",
"lat",
",",
"inside",
"=",
"None",
",",
"max_depth",
"=",
"10",
")",
":",
"from",
".",
"polygon",
"import",
"PolygonComputer",
"polygon_computer",
"=",
"PolygonComputer",
"(",
"lon",
",",
"lat",
",",
"i... | Creates a MOC from a polygon
The polygon is given as lon and lat `astropy.units.Quantity` that define the
vertices of the polygon. Concave and convex polygons are accepted but
self-intersecting ones are currently not properly handled.
Parameters
----------
lon : `astro... | [
"Creates",
"a",
"MOC",
"from",
"a",
"polygon"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L544-L586 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.sky_fraction | def sky_fraction(self):
"""
Sky fraction covered by the MOC
"""
pix_id = self._best_res_pixels()
nb_pix_filled = pix_id.size
return nb_pix_filled / float(3 << (2*(self.max_order + 1))) | python | def sky_fraction(self):
"""
Sky fraction covered by the MOC
"""
pix_id = self._best_res_pixels()
nb_pix_filled = pix_id.size
return nb_pix_filled / float(3 << (2*(self.max_order + 1))) | [
"def",
"sky_fraction",
"(",
"self",
")",
":",
"pix_id",
"=",
"self",
".",
"_best_res_pixels",
"(",
")",
"nb_pix_filled",
"=",
"pix_id",
".",
"size",
"return",
"nb_pix_filled",
"/",
"float",
"(",
"3",
"<<",
"(",
"2",
"*",
"(",
"self",
".",
"max_order",
... | Sky fraction covered by the MOC | [
"Sky",
"fraction",
"covered",
"by",
"the",
"MOC"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L589-L595 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC._query | def _query(self, resource_id, max_rows):
"""
Internal method to query Simbad or a VizieR table
for sources in the coverage of the MOC instance
"""
from astropy.io.votable import parse_single_table
if max_rows is not None and max_rows >= 0:
max_rows_str = str(... | python | def _query(self, resource_id, max_rows):
"""
Internal method to query Simbad or a VizieR table
for sources in the coverage of the MOC instance
"""
from astropy.io.votable import parse_single_table
if max_rows is not None and max_rows >= 0:
max_rows_str = str(... | [
"def",
"_query",
"(",
"self",
",",
"resource_id",
",",
"max_rows",
")",
":",
"from",
"astropy",
".",
"io",
".",
"votable",
"import",
"parse_single_table",
"if",
"max_rows",
"is",
"not",
"None",
"and",
"max_rows",
">=",
"0",
":",
"max_rows_str",
"=",
"str",... | Internal method to query Simbad or a VizieR table
for sources in the coverage of the MOC instance | [
"Internal",
"method",
"to",
"query",
"Simbad",
"or",
"a",
"VizieR",
"table",
"for",
"sources",
"in",
"the",
"coverage",
"of",
"the",
"MOC",
"instance"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L612-L644 | train |
cds-astro/mocpy | mocpy/moc/moc.py | MOC.plot | def plot(self, title='MOC', frame=None):
"""
Plot the MOC object using a mollweide projection.
**Deprecated**: New `fill` and `border` methods produce more reliable results and allow you to specify additional
matplotlib style parameters.
Parameters
----------
t... | python | def plot(self, title='MOC', frame=None):
"""
Plot the MOC object using a mollweide projection.
**Deprecated**: New `fill` and `border` methods produce more reliable results and allow you to specify additional
matplotlib style parameters.
Parameters
----------
t... | [
"def",
"plot",
"(",
"self",
",",
"title",
"=",
"'MOC'",
",",
"frame",
"=",
"None",
")",
":",
"frame",
"=",
"ICRS",
"(",
")",
"if",
"frame",
"is",
"None",
"else",
"frame",
"from",
"matplotlib",
".",
"colors",
"import",
"LinearSegmentedColormap",
"import",... | Plot the MOC object using a mollweide projection.
**Deprecated**: New `fill` and `border` methods produce more reliable results and allow you to specify additional
matplotlib style parameters.
Parameters
----------
title : str
The title of the plot
frame : ... | [
"Plot",
"the",
"MOC",
"object",
"using",
"a",
"mollweide",
"projection",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L646-L712 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/base_transform.py | BaseTransform.inverse | def inverse(self):
""" The inverse of this transform.
"""
if self._inverse is None:
self._inverse = InverseTransform(self)
return self._inverse | python | def inverse(self):
""" The inverse of this transform.
"""
if self._inverse is None:
self._inverse = InverseTransform(self)
return self._inverse | [
"def",
"inverse",
"(",
"self",
")",
":",
"if",
"self",
".",
"_inverse",
"is",
"None",
":",
"self",
".",
"_inverse",
"=",
"InverseTransform",
"(",
"self",
")",
"return",
"self",
".",
"_inverse"
] | The inverse of this transform. | [
"The",
"inverse",
"of",
"this",
"transform",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/base_transform.py#L99-L104 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/axis.py | Ticker._tile_ticks | def _tile_ticks(self, frac, tickvec):
"""Tiles tick marks along the axis."""
origins = np.tile(self.axis._vec, (len(frac), 1))
origins = self.axis.pos[0].T + (origins.T*frac).T
endpoints = tickvec + origins
return origins, endpoints | python | def _tile_ticks(self, frac, tickvec):
"""Tiles tick marks along the axis."""
origins = np.tile(self.axis._vec, (len(frac), 1))
origins = self.axis.pos[0].T + (origins.T*frac).T
endpoints = tickvec + origins
return origins, endpoints | [
"def",
"_tile_ticks",
"(",
"self",
",",
"frac",
",",
"tickvec",
")",
":",
"origins",
"=",
"np",
".",
"tile",
"(",
"self",
".",
"axis",
".",
"_vec",
",",
"(",
"len",
"(",
"frac",
")",
",",
"1",
")",
")",
"origins",
"=",
"self",
".",
"axis",
".",... | Tiles tick marks along the axis. | [
"Tiles",
"tick",
"marks",
"along",
"the",
"axis",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/axis.py#L345-L350 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/axis.py | Ticker._get_tick_frac_labels | def _get_tick_frac_labels(self):
"""Get the major ticks, minor ticks, and major labels"""
minor_num = 4 # number of minor ticks per major division
if (self.axis.scale_type == 'linear'):
domain = self.axis.domain
if domain[1] < domain[0]:
flip = True
... | python | def _get_tick_frac_labels(self):
"""Get the major ticks, minor ticks, and major labels"""
minor_num = 4 # number of minor ticks per major division
if (self.axis.scale_type == 'linear'):
domain = self.axis.domain
if domain[1] < domain[0]:
flip = True
... | [
"def",
"_get_tick_frac_labels",
"(",
"self",
")",
":",
"minor_num",
"=",
"4",
"# number of minor ticks per major division",
"if",
"(",
"self",
".",
"axis",
".",
"scale_type",
"==",
"'linear'",
")",
":",
"domain",
"=",
"self",
".",
"axis",
".",
"domain",
"if",
... | Get the major ticks, minor ticks, and major labels | [
"Get",
"the",
"major",
"ticks",
"minor",
"ticks",
"and",
"major",
"labels"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/axis.py#L352-L396 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | interleave_planes | def interleave_planes(ipixels, apixels, ipsize, apsize):
"""
Interleave (colour) planes, e.g. RGB + A = RGBA.
Return an array of pixels consisting of the `ipsize` elements of
data from each pixel in `ipixels` followed by the `apsize` elements
of data from each pixel in `apixels`. Conventionally `i... | python | def interleave_planes(ipixels, apixels, ipsize, apsize):
"""
Interleave (colour) planes, e.g. RGB + A = RGBA.
Return an array of pixels consisting of the `ipsize` elements of
data from each pixel in `ipixels` followed by the `apsize` elements
of data from each pixel in `apixels`. Conventionally `i... | [
"def",
"interleave_planes",
"(",
"ipixels",
",",
"apixels",
",",
"ipsize",
",",
"apsize",
")",
":",
"itotal",
"=",
"len",
"(",
"ipixels",
")",
"atotal",
"=",
"len",
"(",
"apixels",
")",
"newtotal",
"=",
"itotal",
"+",
"atotal",
"newpsize",
"=",
"ipsize",... | Interleave (colour) planes, e.g. RGB + A = RGBA.
Return an array of pixels consisting of the `ipsize` elements of
data from each pixel in `ipixels` followed by the `apsize` elements
of data from each pixel in `apixels`. Conventionally `ipixels`
and `apixels` are byte arrays so the sizes are bytes, but... | [
"Interleave",
"(",
"colour",
")",
"planes",
"e",
".",
"g",
".",
"RGB",
"+",
"A",
"=",
"RGBA",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L101-L129 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | write_chunks | def write_chunks(out, chunks):
"""Create a PNG file by writing out the chunks."""
out.write(_signature)
for chunk in chunks:
write_chunk(out, *chunk) | python | def write_chunks(out, chunks):
"""Create a PNG file by writing out the chunks."""
out.write(_signature)
for chunk in chunks:
write_chunk(out, *chunk) | [
"def",
"write_chunks",
"(",
"out",
",",
"chunks",
")",
":",
"out",
".",
"write",
"(",
"_signature",
")",
"for",
"chunk",
"in",
"chunks",
":",
"write_chunk",
"(",
"out",
",",
"*",
"chunk",
")"
] | Create a PNG file by writing out the chunks. | [
"Create",
"a",
"PNG",
"file",
"by",
"writing",
"out",
"the",
"chunks",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L838-L843 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | filter_scanline | def filter_scanline(type, line, fo, prev=None):
"""Apply a scanline filter to a scanline. `type` specifies the
filter type (0 to 4); `line` specifies the current (unfiltered)
scanline as a sequence of bytes; `prev` specifies the previous
(unfiltered) scanline as a sequence of bytes. `fo` specifies the
... | python | def filter_scanline(type, line, fo, prev=None):
"""Apply a scanline filter to a scanline. `type` specifies the
filter type (0 to 4); `line` specifies the current (unfiltered)
scanline as a sequence of bytes; `prev` specifies the previous
(unfiltered) scanline as a sequence of bytes. `fo` specifies the
... | [
"def",
"filter_scanline",
"(",
"type",
",",
"line",
",",
"fo",
",",
"prev",
"=",
"None",
")",
":",
"assert",
"0",
"<=",
"type",
"<",
"5",
"# The output array. Which, pathetically, we extend one-byte at a",
"# time (fortunately this is linear).",
"out",
"=",
"array",
... | Apply a scanline filter to a scanline. `type` specifies the
filter type (0 to 4); `line` specifies the current (unfiltered)
scanline as a sequence of bytes; `prev` specifies the previous
(unfiltered) scanline as a sequence of bytes. `fo` specifies the
filter offset; normally this is size of a pixel in ... | [
"Apply",
"a",
"scanline",
"filter",
"to",
"a",
"scanline",
".",
"type",
"specifies",
"the",
"filter",
"type",
"(",
"0",
"to",
"4",
")",
";",
"line",
"specifies",
"the",
"current",
"(",
"unfiltered",
")",
"scanline",
"as",
"a",
"sequence",
"of",
"bytes",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L845-L929 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | from_array | def from_array(a, mode=None, info={}):
"""Create a PNG :class:`Image` object from a 2- or 3-dimensional
array. One application of this function is easy PIL-style saving:
``png.from_array(pixels, 'L').save('foo.png')``.
.. note :
The use of the term *3-dimensional* is for marketing purposes
... | python | def from_array(a, mode=None, info={}):
"""Create a PNG :class:`Image` object from a 2- or 3-dimensional
array. One application of this function is easy PIL-style saving:
``png.from_array(pixels, 'L').save('foo.png')``.
.. note :
The use of the term *3-dimensional* is for marketing purposes
... | [
"def",
"from_array",
"(",
"a",
",",
"mode",
"=",
"None",
",",
"info",
"=",
"{",
"}",
")",
":",
"# We abuse the *info* parameter by modifying it. Take a copy here.",
"# (Also typechecks *info* to some extent).",
"info",
"=",
"dict",
"(",
"info",
")",
"# Syntax check mod... | Create a PNG :class:`Image` object from a 2- or 3-dimensional
array. One application of this function is easy PIL-style saving:
``png.from_array(pixels, 'L').save('foo.png')``.
.. note :
The use of the term *3-dimensional* is for marketing purposes
only. It doesn't actually work. Please bea... | [
"Create",
"a",
"PNG",
":",
"class",
":",
"Image",
"object",
"from",
"a",
"2",
"-",
"or",
"3",
"-",
"dimensional",
"array",
".",
"One",
"application",
"of",
"this",
"function",
"is",
"easy",
"PIL",
"-",
"style",
"saving",
":",
"png",
".",
"from_array",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L932-L1136 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.make_palette | def make_palette(self):
"""Create the byte sequences for a ``PLTE`` and if necessary a
``tRNS`` chunk. Returned as a pair (*p*, *t*). *t* will be
``None`` if no ``tRNS`` chunk is necessary.
"""
p = array('B')
t = array('B')
for x in self.palette:
p... | python | def make_palette(self):
"""Create the byte sequences for a ``PLTE`` and if necessary a
``tRNS`` chunk. Returned as a pair (*p*, *t*). *t* will be
``None`` if no ``tRNS`` chunk is necessary.
"""
p = array('B')
t = array('B')
for x in self.palette:
p... | [
"def",
"make_palette",
"(",
"self",
")",
":",
"p",
"=",
"array",
"(",
"'B'",
")",
"t",
"=",
"array",
"(",
"'B'",
")",
"for",
"x",
"in",
"self",
".",
"palette",
":",
"p",
".",
"extend",
"(",
"x",
"[",
"0",
":",
"3",
"]",
")",
"if",
"len",
"(... | Create the byte sequences for a ``PLTE`` and if necessary a
``tRNS`` chunk. Returned as a pair (*p*, *t*). *t* will be
``None`` if no ``tRNS`` chunk is necessary. | [
"Create",
"the",
"byte",
"sequences",
"for",
"a",
"PLTE",
"and",
"if",
"necessary",
"a",
"tRNS",
"chunk",
".",
"Returned",
"as",
"a",
"pair",
"(",
"*",
"p",
"*",
"*",
"t",
"*",
")",
".",
"*",
"t",
"*",
"will",
"be",
"None",
"if",
"no",
"tRNS",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L464-L481 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.write | def write(self, outfile, rows):
"""Write a PNG image to the output file. `rows` should be
an iterable that yields each row in boxed row flat pixel
format. The rows should be the rows of the original image,
so there should be ``self.height`` rows of ``self.width *
self.planes`` ... | python | def write(self, outfile, rows):
"""Write a PNG image to the output file. `rows` should be
an iterable that yields each row in boxed row flat pixel
format. The rows should be the rows of the original image,
so there should be ``self.height`` rows of ``self.width *
self.planes`` ... | [
"def",
"write",
"(",
"self",
",",
"outfile",
",",
"rows",
")",
":",
"if",
"self",
".",
"interlace",
":",
"fmt",
"=",
"'BH'",
"[",
"self",
".",
"bitdepth",
">",
"8",
"]",
"a",
"=",
"array",
"(",
"fmt",
",",
"itertools",
".",
"chain",
"(",
"*",
"... | Write a PNG image to the output file. `rows` should be
an iterable that yields each row in boxed row flat pixel
format. The rows should be the rows of the original image,
so there should be ``self.height`` rows of ``self.width *
self.planes`` values. If `interlace` is specified (when
... | [
"Write",
"a",
"PNG",
"image",
"to",
"the",
"output",
"file",
".",
"rows",
"should",
"be",
"an",
"iterable",
"that",
"yields",
"each",
"row",
"in",
"boxed",
"row",
"flat",
"pixel",
"format",
".",
"The",
"rows",
"should",
"be",
"the",
"rows",
"of",
"the"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L483-L508 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.write_passes | def write_passes(self, outfile, rows, packed=False):
"""
Write a PNG image to the output file.
Most users are expected to find the :meth:`write` or
:meth:`write_array` method more convenient.
The rows should be given to this method in the order that
they appear ... | python | def write_passes(self, outfile, rows, packed=False):
"""
Write a PNG image to the output file.
Most users are expected to find the :meth:`write` or
:meth:`write_array` method more convenient.
The rows should be given to this method in the order that
they appear ... | [
"def",
"write_passes",
"(",
"self",
",",
"outfile",
",",
"rows",
",",
"packed",
"=",
"False",
")",
":",
"# http://www.w3.org/TR/PNG/#5PNG-file-signature",
"outfile",
".",
"write",
"(",
"_signature",
")",
"# http://www.w3.org/TR/PNG/#11IHDR",
"write_chunk",
"(",
"outfi... | Write a PNG image to the output file.
Most users are expected to find the :meth:`write` or
:meth:`write_array` method more convenient.
The rows should be given to this method in the order that
they appear in the output file. For straightlaced images,
this is the usual ... | [
"Write",
"a",
"PNG",
"image",
"to",
"the",
"output",
"file",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L510-L676 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.write_packed | def write_packed(self, outfile, rows):
"""
Write PNG file to `outfile`. The pixel data comes from `rows`
which should be in boxed row packed format. Each row should be
a sequence of packed bytes.
Technically, this method does work for interlaced images but it
is best a... | python | def write_packed(self, outfile, rows):
"""
Write PNG file to `outfile`. The pixel data comes from `rows`
which should be in boxed row packed format. Each row should be
a sequence of packed bytes.
Technically, this method does work for interlaced images but it
is best a... | [
"def",
"write_packed",
"(",
"self",
",",
"outfile",
",",
"rows",
")",
":",
"if",
"self",
".",
"rescale",
":",
"raise",
"Error",
"(",
"\"write_packed method not suitable for bit depth %d\"",
"%",
"self",
".",
"rescale",
"[",
"0",
"]",
")",
"return",
"self",
"... | Write PNG file to `outfile`. The pixel data comes from `rows`
which should be in boxed row packed format. Each row should be
a sequence of packed bytes.
Technically, this method does work for interlaced images but it
is best avoided. For interlaced images, the rows should be
... | [
"Write",
"PNG",
"file",
"to",
"outfile",
".",
"The",
"pixel",
"data",
"comes",
"from",
"rows",
"which",
"should",
"be",
"in",
"boxed",
"row",
"packed",
"format",
".",
"Each",
"row",
"should",
"be",
"a",
"sequence",
"of",
"packed",
"bytes",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L689-L707 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.convert_pnm | def convert_pnm(self, infile, outfile):
"""
Convert a PNM file containing raw pixel data into a PNG file
with the parameters set in the writer object. Works for
(binary) PGM, PPM, and PAM formats.
"""
if self.interlace:
pixels = array('B')
pixels... | python | def convert_pnm(self, infile, outfile):
"""
Convert a PNM file containing raw pixel data into a PNG file
with the parameters set in the writer object. Works for
(binary) PGM, PPM, and PAM formats.
"""
if self.interlace:
pixels = array('B')
pixels... | [
"def",
"convert_pnm",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"if",
"self",
".",
"interlace",
":",
"pixels",
"=",
"array",
"(",
"'B'",
")",
"pixels",
".",
"fromfile",
"(",
"infile",
",",
"(",
"self",
".",
"bitdepth",
"/",
"8",
")",
"*... | Convert a PNM file containing raw pixel data into a PNG file
with the parameters set in the writer object. Works for
(binary) PGM, PPM, and PAM formats. | [
"Convert",
"a",
"PNM",
"file",
"containing",
"raw",
"pixel",
"data",
"into",
"a",
"PNG",
"file",
"with",
"the",
"parameters",
"set",
"in",
"the",
"writer",
"object",
".",
"Works",
"for",
"(",
"binary",
")",
"PGM",
"PPM",
"and",
"PAM",
"formats",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L709-L723 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.convert_ppm_and_pgm | def convert_ppm_and_pgm(self, ppmfile, pgmfile, outfile):
"""
Convert a PPM and PGM file containing raw pixel data into a
PNG outfile with the parameters set in the writer object.
"""
pixels = array('B')
pixels.fromfile(ppmfile,
(self.bitdepth/8) *... | python | def convert_ppm_and_pgm(self, ppmfile, pgmfile, outfile):
"""
Convert a PPM and PGM file containing raw pixel data into a
PNG outfile with the parameters set in the writer object.
"""
pixels = array('B')
pixels.fromfile(ppmfile,
(self.bitdepth/8) *... | [
"def",
"convert_ppm_and_pgm",
"(",
"self",
",",
"ppmfile",
",",
"pgmfile",
",",
"outfile",
")",
":",
"pixels",
"=",
"array",
"(",
"'B'",
")",
"pixels",
".",
"fromfile",
"(",
"ppmfile",
",",
"(",
"self",
".",
"bitdepth",
"/",
"8",
")",
"*",
"self",
".... | Convert a PPM and PGM file containing raw pixel data into a
PNG outfile with the parameters set in the writer object. | [
"Convert",
"a",
"PPM",
"and",
"PGM",
"file",
"containing",
"raw",
"pixel",
"data",
"into",
"a",
"PNG",
"outfile",
"with",
"the",
"parameters",
"set",
"in",
"the",
"writer",
"object",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L725-L744 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.file_scanlines | def file_scanlines(self, infile):
"""
Generates boxed rows in flat pixel format, from the input file
`infile`. It assumes that the input file is in a "Netpbm-like"
binary format, and is positioned at the beginning of the first
pixel. The number of pixels to read is taken from t... | python | def file_scanlines(self, infile):
"""
Generates boxed rows in flat pixel format, from the input file
`infile`. It assumes that the input file is in a "Netpbm-like"
binary format, and is positioned at the beginning of the first
pixel. The number of pixels to read is taken from t... | [
"def",
"file_scanlines",
"(",
"self",
",",
"infile",
")",
":",
"# Values per row",
"vpr",
"=",
"self",
".",
"width",
"*",
"self",
".",
"planes",
"row_bytes",
"=",
"vpr",
"if",
"self",
".",
"bitdepth",
">",
"8",
":",
"assert",
"self",
".",
"bitdepth",
"... | Generates boxed rows in flat pixel format, from the input file
`infile`. It assumes that the input file is in a "Netpbm-like"
binary format, and is positioned at the beginning of the first
pixel. The number of pixels to read is taken from the image
dimensions (`width`, `height`, `plane... | [
"Generates",
"boxed",
"rows",
"in",
"flat",
"pixel",
"format",
"from",
"the",
"input",
"file",
"infile",
".",
"It",
"assumes",
"that",
"the",
"input",
"file",
"is",
"in",
"a",
"Netpbm",
"-",
"like",
"binary",
"format",
"and",
"is",
"positioned",
"at",
"t... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L746-L770 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Writer.array_scanlines_interlace | def array_scanlines_interlace(self, pixels):
"""
Generator for interlaced scanlines from an array. `pixels` is
the full source image in flat row flat pixel format. The
generator yields each scanline of the reduced passes in turn, in
boxed row flat pixel format.
"""
... | python | def array_scanlines_interlace(self, pixels):
"""
Generator for interlaced scanlines from an array. `pixels` is
the full source image in flat row flat pixel format. The
generator yields each scanline of the reduced passes in turn, in
boxed row flat pixel format.
"""
... | [
"def",
"array_scanlines_interlace",
"(",
"self",
",",
"pixels",
")",
":",
"# http://www.w3.org/TR/PNG/#8InterlaceMethods",
"# Array type.",
"fmt",
"=",
"'BH'",
"[",
"self",
".",
"bitdepth",
">",
"8",
"]",
"# Value per row",
"vpr",
"=",
"self",
".",
"width",
"*",
... | Generator for interlaced scanlines from an array. `pixels` is
the full source image in flat row flat pixel format. The
generator yields each scanline of the reduced passes in turn, in
boxed row flat pixel format. | [
"Generator",
"for",
"interlaced",
"scanlines",
"from",
"an",
"array",
".",
"pixels",
"is",
"the",
"full",
"source",
"image",
"in",
"flat",
"row",
"flat",
"pixel",
"format",
".",
"The",
"generator",
"yields",
"each",
"scanline",
"of",
"the",
"reduced",
"passe... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L786-L820 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.undo_filter | def undo_filter(self, filter_type, scanline, previous):
"""Undo the filter for a scanline. `scanline` is a sequence of
bytes that does not include the initial filter type byte.
`previous` is decoded previous scanline (for straightlaced
images this is the previous pixel row, but for inte... | python | def undo_filter(self, filter_type, scanline, previous):
"""Undo the filter for a scanline. `scanline` is a sequence of
bytes that does not include the initial filter type byte.
`previous` is decoded previous scanline (for straightlaced
images this is the previous pixel row, but for inte... | [
"def",
"undo_filter",
"(",
"self",
",",
"filter_type",
",",
"scanline",
",",
"previous",
")",
":",
"# :todo: Would it be better to update scanline in place?",
"# Yes, with the Cython extension making the undo_filter fast,",
"# updating scanline inplace makes the code 3 times faster",
"... | Undo the filter for a scanline. `scanline` is a sequence of
bytes that does not include the initial filter type byte.
`previous` is decoded previous scanline (for straightlaced
images this is the previous pixel row, but for interlaced
images, it is the previous scanline in the reduced i... | [
"Undo",
"the",
"filter",
"for",
"a",
"scanline",
".",
"scanline",
"is",
"a",
"sequence",
"of",
"bytes",
"that",
"does",
"not",
"include",
"the",
"initial",
"filter",
"type",
"byte",
".",
"previous",
"is",
"decoded",
"previous",
"scanline",
"(",
"for",
"str... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1315-L1424 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.deinterlace | def deinterlace(self, raw):
"""
Read raw pixel data, undo filters, deinterlace, and flatten.
Return in flat row flat pixel format.
"""
# Values per row (of the target image)
vpr = self.width * self.planes
# Make a result array, and make it big enough. Interleav... | python | def deinterlace(self, raw):
"""
Read raw pixel data, undo filters, deinterlace, and flatten.
Return in flat row flat pixel format.
"""
# Values per row (of the target image)
vpr = self.width * self.planes
# Make a result array, and make it big enough. Interleav... | [
"def",
"deinterlace",
"(",
"self",
",",
"raw",
")",
":",
"# Values per row (of the target image)",
"vpr",
"=",
"self",
".",
"width",
"*",
"self",
".",
"planes",
"# Make a result array, and make it big enough. Interleaving",
"# writes to the output array randomly (well, not qui... | Read raw pixel data, undo filters, deinterlace, and flatten.
Return in flat row flat pixel format. | [
"Read",
"raw",
"pixel",
"data",
"undo",
"filters",
"deinterlace",
"and",
"flatten",
".",
"Return",
"in",
"flat",
"row",
"flat",
"pixel",
"format",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1426-L1472 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.iterboxed | def iterboxed(self, rows):
"""Iterator that yields each scanline in boxed row flat pixel
format. `rows` should be an iterator that yields the bytes of
each row in turn.
"""
def asvalues(raw):
"""Convert a row of raw bytes into a flat row. Result will
be... | python | def iterboxed(self, rows):
"""Iterator that yields each scanline in boxed row flat pixel
format. `rows` should be an iterator that yields the bytes of
each row in turn.
"""
def asvalues(raw):
"""Convert a row of raw bytes into a flat row. Result will
be... | [
"def",
"iterboxed",
"(",
"self",
",",
"rows",
")",
":",
"def",
"asvalues",
"(",
"raw",
")",
":",
"\"\"\"Convert a row of raw bytes into a flat row. Result will\n be a freshly allocated object, not shared with\n argument.\n \"\"\"",
"if",
"self",
".... | Iterator that yields each scanline in boxed row flat pixel
format. `rows` should be an iterator that yields the bytes of
each row in turn. | [
"Iterator",
"that",
"yields",
"each",
"scanline",
"in",
"boxed",
"row",
"flat",
"pixel",
"format",
".",
"rows",
"should",
"be",
"an",
"iterator",
"that",
"yields",
"the",
"bytes",
"of",
"each",
"row",
"in",
"turn",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1474-L1502 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.serialtoflat | def serialtoflat(self, bytes, width=None):
"""Convert serial format (byte stream) pixel data to flat row
flat pixel.
"""
if self.bitdepth == 8:
return bytes
if self.bitdepth == 16:
bytes = tostring(bytes)
return array('H',
struct... | python | def serialtoflat(self, bytes, width=None):
"""Convert serial format (byte stream) pixel data to flat row
flat pixel.
"""
if self.bitdepth == 8:
return bytes
if self.bitdepth == 16:
bytes = tostring(bytes)
return array('H',
struct... | [
"def",
"serialtoflat",
"(",
"self",
",",
"bytes",
",",
"width",
"=",
"None",
")",
":",
"if",
"self",
".",
"bitdepth",
"==",
"8",
":",
"return",
"bytes",
"if",
"self",
".",
"bitdepth",
"==",
"16",
":",
"bytes",
"=",
"tostring",
"(",
"bytes",
")",
"r... | Convert serial format (byte stream) pixel data to flat row
flat pixel. | [
"Convert",
"serial",
"format",
"(",
"byte",
"stream",
")",
"pixel",
"data",
"to",
"flat",
"row",
"flat",
"pixel",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1504-L1529 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.iterstraight | def iterstraight(self, raw):
"""Iterator that undoes the effect of filtering, and yields
each row in serialised format (as a sequence of bytes).
Assumes input is straightlaced. `raw` should be an iterable
that yields the raw bytes in chunks of arbitrary size.
"""
# leng... | python | def iterstraight(self, raw):
"""Iterator that undoes the effect of filtering, and yields
each row in serialised format (as a sequence of bytes).
Assumes input is straightlaced. `raw` should be an iterable
that yields the raw bytes in chunks of arbitrary size.
"""
# leng... | [
"def",
"iterstraight",
"(",
"self",
",",
"raw",
")",
":",
"# length of row, in bytes",
"rb",
"=",
"self",
".",
"row_bytes",
"a",
"=",
"array",
"(",
"'B'",
")",
"# The previous (reconstructed) scanline. None indicates first",
"# line of image.",
"recon",
"=",
"None",
... | Iterator that undoes the effect of filtering, and yields
each row in serialised format (as a sequence of bytes).
Assumes input is straightlaced. `raw` should be an iterable
that yields the raw bytes in chunks of arbitrary size. | [
"Iterator",
"that",
"undoes",
"the",
"effect",
"of",
"filtering",
"and",
"yields",
"each",
"row",
"in",
"serialised",
"format",
"(",
"as",
"a",
"sequence",
"of",
"bytes",
")",
".",
"Assumes",
"input",
"is",
"straightlaced",
".",
"raw",
"should",
"be",
"an"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1531-L1558 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.chunklentype | def chunklentype(self):
"""Reads just enough of the input to determine the next
chunk's length and type, returned as a (*length*, *type*) pair
where *type* is a string. If there are no more chunks, ``None``
is returned.
"""
x = self.file.read(8)
if not x:
... | python | def chunklentype(self):
"""Reads just enough of the input to determine the next
chunk's length and type, returned as a (*length*, *type*) pair
where *type* is a string. If there are no more chunks, ``None``
is returned.
"""
x = self.file.read(8)
if not x:
... | [
"def",
"chunklentype",
"(",
"self",
")",
":",
"x",
"=",
"self",
".",
"file",
".",
"read",
"(",
"8",
")",
"if",
"not",
"x",
":",
"return",
"None",
"if",
"len",
"(",
"x",
")",
"!=",
"8",
":",
"raise",
"FormatError",
"(",
"'End of file whilst reading ch... | Reads just enough of the input to determine the next
chunk's length and type, returned as a (*length*, *type*) pair
where *type* is a string. If there are no more chunks, ``None``
is returned. | [
"Reads",
"just",
"enough",
"of",
"the",
"input",
"to",
"determine",
"the",
"next",
"chunk",
"s",
"length",
"and",
"type",
"returned",
"as",
"a",
"(",
"*",
"length",
"*",
"*",
"type",
"*",
")",
"pair",
"where",
"*",
"type",
"*",
"is",
"a",
"string",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1594-L1611 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.read | def read(self, lenient=False):
"""
Read the PNG file and decode it. Returns (`width`, `height`,
`pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksu... | python | def read(self, lenient=False):
"""
Read the PNG file and decode it. Returns (`width`, `height`,
`pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksu... | [
"def",
"read",
"(",
"self",
",",
"lenient",
"=",
"False",
")",
":",
"def",
"iteridat",
"(",
")",
":",
"\"\"\"Iterator that yields all the ``IDAT`` chunks as strings.\"\"\"",
"while",
"True",
":",
"try",
":",
"type",
",",
"data",
"=",
"self",
".",
"chunk",
"(",... | Read the PNG file and decode it. Returns (`width`, `height`,
`pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksum failures will raise warnings rather than exceptio... | [
"Read",
"the",
"PNG",
"file",
"and",
"decode",
"it",
".",
"Returns",
"(",
"width",
"height",
"pixels",
"metadata",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1735-L1805 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.palette | def palette(self, alpha='natural'):
"""Returns a palette that is a sequence of 3-tuples or 4-tuples,
synthesizing it from the ``PLTE`` and ``tRNS`` chunks. These
chunks should have already been processed (for example, by
calling the :meth:`preamble` method). All the tuples are the
... | python | def palette(self, alpha='natural'):
"""Returns a palette that is a sequence of 3-tuples or 4-tuples,
synthesizing it from the ``PLTE`` and ``tRNS`` chunks. These
chunks should have already been processed (for example, by
calling the :meth:`preamble` method). All the tuples are the
... | [
"def",
"palette",
"(",
"self",
",",
"alpha",
"=",
"'natural'",
")",
":",
"if",
"not",
"self",
".",
"plte",
":",
"raise",
"FormatError",
"(",
"\"Required PLTE chunk is missing in colour type 3 image.\"",
")",
"plte",
"=",
"group",
"(",
"array",
"(",
"'B'",
",",... | Returns a palette that is a sequence of 3-tuples or 4-tuples,
synthesizing it from the ``PLTE`` and ``tRNS`` chunks. These
chunks should have already been processed (for example, by
calling the :meth:`preamble` method). All the tuples are the
same size: 3-tuples if there is no ``tRNS``... | [
"Returns",
"a",
"palette",
"that",
"is",
"a",
"sequence",
"of",
"3",
"-",
"tuples",
"or",
"4",
"-",
"tuples",
"synthesizing",
"it",
"from",
"the",
"PLTE",
"and",
"tRNS",
"chunks",
".",
"These",
"chunks",
"should",
"have",
"already",
"been",
"processed",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1826-L1847 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.asDirect | def asDirect(self):
"""Returns the image data as a direct representation of an
``x * y * planes`` array. This method is intended to remove the
need for callers to deal with palettes and transparency
themselves. Images with a palette (colour type 3)
are converted to RGB or RGBA;... | python | def asDirect(self):
"""Returns the image data as a direct representation of an
``x * y * planes`` array. This method is intended to remove the
need for callers to deal with palettes and transparency
themselves. Images with a palette (colour type 3)
are converted to RGB or RGBA;... | [
"def",
"asDirect",
"(",
"self",
")",
":",
"self",
".",
"preamble",
"(",
")",
"# Simple case, no conversion necessary.",
"if",
"not",
"self",
".",
"colormap",
"and",
"not",
"self",
".",
"trns",
"and",
"not",
"self",
".",
"sbit",
":",
"return",
"self",
".",
... | Returns the image data as a direct representation of an
``x * y * planes`` array. This method is intended to remove the
need for callers to deal with palettes and transparency
themselves. Images with a palette (colour type 3)
are converted to RGB or RGBA; images with transparency (a
... | [
"Returns",
"the",
"image",
"data",
"as",
"a",
"direct",
"representation",
"of",
"an",
"x",
"*",
"y",
"*",
"planes",
"array",
".",
"This",
"method",
"is",
"intended",
"to",
"remove",
"the",
"need",
"for",
"callers",
"to",
"deal",
"with",
"palettes",
"and"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1849-L1952 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.asFloat | def asFloat(self, maxval=1.0):
"""Return image pixels as per :meth:`asDirect` method, but scale
all pixel values to be floating point values between 0.0 and
*maxval*.
"""
x,y,pixels,info = self.asDirect()
sourcemaxval = 2**info['bitdepth']-1
del info['bitdepth']
... | python | def asFloat(self, maxval=1.0):
"""Return image pixels as per :meth:`asDirect` method, but scale
all pixel values to be floating point values between 0.0 and
*maxval*.
"""
x,y,pixels,info = self.asDirect()
sourcemaxval = 2**info['bitdepth']-1
del info['bitdepth']
... | [
"def",
"asFloat",
"(",
"self",
",",
"maxval",
"=",
"1.0",
")",
":",
"x",
",",
"y",
",",
"pixels",
",",
"info",
"=",
"self",
".",
"asDirect",
"(",
")",
"sourcemaxval",
"=",
"2",
"**",
"info",
"[",
"'bitdepth'",
"]",
"-",
"1",
"del",
"info",
"[",
... | Return image pixels as per :meth:`asDirect` method, but scale
all pixel values to be floating point values between 0.0 and
*maxval*. | [
"Return",
"image",
"pixels",
"as",
"per",
":",
"meth",
":",
"asDirect",
"method",
"but",
"scale",
"all",
"pixel",
"values",
"to",
"be",
"floating",
"point",
"values",
"between",
"0",
".",
"0",
"and",
"*",
"maxval",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1954-L1968 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader._as_rescale | def _as_rescale(self, get, targetbitdepth):
"""Helper used by :meth:`asRGB8` and :meth:`asRGBA8`."""
width,height,pixels,meta = get()
maxval = 2**meta['bitdepth'] - 1
targetmaxval = 2**targetbitdepth - 1
factor = float(targetmaxval) / float(maxval)
meta['bitdepth'] = tar... | python | def _as_rescale(self, get, targetbitdepth):
"""Helper used by :meth:`asRGB8` and :meth:`asRGBA8`."""
width,height,pixels,meta = get()
maxval = 2**meta['bitdepth'] - 1
targetmaxval = 2**targetbitdepth - 1
factor = float(targetmaxval) / float(maxval)
meta['bitdepth'] = tar... | [
"def",
"_as_rescale",
"(",
"self",
",",
"get",
",",
"targetbitdepth",
")",
":",
"width",
",",
"height",
",",
"pixels",
",",
"meta",
"=",
"get",
"(",
")",
"maxval",
"=",
"2",
"**",
"meta",
"[",
"'bitdepth'",
"]",
"-",
"1",
"targetmaxval",
"=",
"2",
... | Helper used by :meth:`asRGB8` and :meth:`asRGBA8`. | [
"Helper",
"used",
"by",
":",
"meth",
":",
"asRGB8",
"and",
":",
"meth",
":",
"asRGBA8",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L1970-L1984 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.asRGB | def asRGB(self):
"""Return image as RGB pixels. RGB colour images are passed
through unchanged; greyscales are expanded into RGB
triplets (there is a small speed overhead for doing this).
An alpha channel in the source image will raise an
exception.
The return values a... | python | def asRGB(self):
"""Return image as RGB pixels. RGB colour images are passed
through unchanged; greyscales are expanded into RGB
triplets (there is a small speed overhead for doing this).
An alpha channel in the source image will raise an
exception.
The return values a... | [
"def",
"asRGB",
"(",
"self",
")",
":",
"width",
",",
"height",
",",
"pixels",
",",
"meta",
"=",
"self",
".",
"asDirect",
"(",
")",
"if",
"meta",
"[",
"'alpha'",
"]",
":",
"raise",
"Error",
"(",
"\"will not convert image with alpha channel to RGB\"",
")",
"... | Return image as RGB pixels. RGB colour images are passed
through unchanged; greyscales are expanded into RGB
triplets (there is a small speed overhead for doing this).
An alpha channel in the source image will raise an
exception.
The return values are as for the :meth:`read` m... | [
"Return",
"image",
"as",
"RGB",
"pixels",
".",
"RGB",
"colour",
"images",
"are",
"passed",
"through",
"unchanged",
";",
"greyscales",
"are",
"expanded",
"into",
"RGB",
"triplets",
"(",
"there",
"is",
"a",
"small",
"speed",
"overhead",
"for",
"doing",
"this",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L2017-L2044 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/png.py | Reader.asRGBA | def asRGBA(self):
"""Return image as RGBA pixels. Greyscales are expanded into
RGB triplets; an alpha channel is synthesized if necessary.
The return values are as for the :meth:`read` method
except that the *metadata* reflect the returned pixels, not the
source image. In parti... | python | def asRGBA(self):
"""Return image as RGBA pixels. Greyscales are expanded into
RGB triplets; an alpha channel is synthesized if necessary.
The return values are as for the :meth:`read` method
except that the *metadata* reflect the returned pixels, not the
source image. In parti... | [
"def",
"asRGBA",
"(",
"self",
")",
":",
"width",
",",
"height",
",",
"pixels",
",",
"meta",
"=",
"self",
".",
"asDirect",
"(",
")",
"if",
"meta",
"[",
"'alpha'",
"]",
"and",
"not",
"meta",
"[",
"'greyscale'",
"]",
":",
"return",
"width",
",",
"heig... | Return image as RGBA pixels. Greyscales are expanded into
RGB triplets; an alpha channel is synthesized if necessary.
The return values are as for the :meth:`read` method
except that the *metadata* reflect the returned pixels, not the
source image. In particular, for this method
... | [
"Return",
"image",
"as",
"RGBA",
"pixels",
".",
"Greyscales",
"are",
"expanded",
"into",
"RGB",
"triplets",
";",
"an",
"alpha",
"channel",
"is",
"synthesized",
"if",
"necessary",
".",
"The",
"return",
"values",
"are",
"as",
"for",
"the",
":",
"meth",
":",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/png.py#L2046-L2092 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | load_data_file | def load_data_file(fname, directory=None, force_download=False):
"""Get a standard vispy demo data file
Parameters
----------
fname : str
The filename on the remote ``demo-data`` repository to download,
e.g. ``'molecular_viewer/micelle.npy'``. These correspond to paths
on ``http... | python | def load_data_file(fname, directory=None, force_download=False):
"""Get a standard vispy demo data file
Parameters
----------
fname : str
The filename on the remote ``demo-data`` repository to download,
e.g. ``'molecular_viewer/micelle.npy'``. These correspond to paths
on ``http... | [
"def",
"load_data_file",
"(",
"fname",
",",
"directory",
"=",
"None",
",",
"force_download",
"=",
"False",
")",
":",
"_url_root",
"=",
"'http://github.com/vispy/demo-data/raw/master/'",
"url",
"=",
"_url_root",
"+",
"fname",
"if",
"directory",
"is",
"None",
":",
... | Get a standard vispy demo data file
Parameters
----------
fname : str
The filename on the remote ``demo-data`` repository to download,
e.g. ``'molecular_viewer/micelle.npy'``. These correspond to paths
on ``https://github.com/vispy/demo-data/``.
directory : str | None
Di... | [
"Get",
"a",
"standard",
"vispy",
"demo",
"data",
"file"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L23-L69 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | _chunk_read | def _chunk_read(response, local_file, chunk_size=65536, initial_size=0):
"""Download a file chunk by chunk and show advancement
Can also be used when resuming downloads over http.
Parameters
----------
response: urllib.response.addinfourl
Response to the download request in order to get fi... | python | def _chunk_read(response, local_file, chunk_size=65536, initial_size=0):
"""Download a file chunk by chunk and show advancement
Can also be used when resuming downloads over http.
Parameters
----------
response: urllib.response.addinfourl
Response to the download request in order to get fi... | [
"def",
"_chunk_read",
"(",
"response",
",",
"local_file",
",",
"chunk_size",
"=",
"65536",
",",
"initial_size",
"=",
"0",
")",
":",
"# Adapted from NISL:",
"# https://github.com/nisl/tutorial/blob/master/nisl/datasets.py",
"bytes_so_far",
"=",
"initial_size",
"# Returns onl... | Download a file chunk by chunk and show advancement
Can also be used when resuming downloads over http.
Parameters
----------
response: urllib.response.addinfourl
Response to the download request in order to get file size.
local_file: file
Hard disk file where data should be writte... | [
"Download",
"a",
"file",
"chunk",
"by",
"chunk",
"and",
"show",
"advancement"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L174-L207 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | _chunk_write | def _chunk_write(chunk, local_file, progress):
"""Write a chunk to file and update the progress bar"""
local_file.write(chunk)
progress.update_with_increment_value(len(chunk)) | python | def _chunk_write(chunk, local_file, progress):
"""Write a chunk to file and update the progress bar"""
local_file.write(chunk)
progress.update_with_increment_value(len(chunk)) | [
"def",
"_chunk_write",
"(",
"chunk",
",",
"local_file",
",",
"progress",
")",
":",
"local_file",
".",
"write",
"(",
"chunk",
")",
"progress",
".",
"update_with_increment_value",
"(",
"len",
"(",
"chunk",
")",
")"
] | Write a chunk to file and update the progress bar | [
"Write",
"a",
"chunk",
"to",
"file",
"and",
"update",
"the",
"progress",
"bar"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L210-L213 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | _fetch_file | def _fetch_file(url, file_name, print_destination=True):
"""Load requested file, downloading it if needed or requested
Parameters
----------
url: string
The url of file to be downloaded.
file_name: string
Name, along with the path, of where downloaded file will be saved.
print_d... | python | def _fetch_file(url, file_name, print_destination=True):
"""Load requested file, downloading it if needed or requested
Parameters
----------
url: string
The url of file to be downloaded.
file_name: string
Name, along with the path, of where downloaded file will be saved.
print_d... | [
"def",
"_fetch_file",
"(",
"url",
",",
"file_name",
",",
"print_destination",
"=",
"True",
")",
":",
"# Adapted from NISL:",
"# https://github.com/nisl/tutorial/blob/master/nisl/datasets.py",
"temp_file_name",
"=",
"file_name",
"+",
"\".part\"",
"local_file",
"=",
"None",
... | Load requested file, downloading it if needed or requested
Parameters
----------
url: string
The url of file to be downloaded.
file_name: string
Name, along with the path, of where downloaded file will be saved.
print_destination: bool, optional
If true, destination of where... | [
"Load",
"requested",
"file",
"downloading",
"it",
"if",
"needed",
"or",
"requested"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L216-L261 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | ProgressBar.update | def update(self, cur_value, mesg=None):
"""Update progressbar with current value of process
Parameters
----------
cur_value : number
Current value of process. Should be <= max_value (but this is not
enforced). The percent of the progressbar will be computed as
... | python | def update(self, cur_value, mesg=None):
"""Update progressbar with current value of process
Parameters
----------
cur_value : number
Current value of process. Should be <= max_value (but this is not
enforced). The percent of the progressbar will be computed as
... | [
"def",
"update",
"(",
"self",
",",
"cur_value",
",",
"mesg",
"=",
"None",
")",
":",
"# Ensure floating-point division so we can get fractions of a percent",
"# for the progressbar.",
"self",
".",
"cur_value",
"=",
"cur_value",
"progress",
"=",
"float",
"(",
"self",
".... | Update progressbar with current value of process
Parameters
----------
cur_value : number
Current value of process. Should be <= max_value (but this is not
enforced). The percent of the progressbar will be computed as
(cur_value / max_value) * 100
m... | [
"Update",
"progressbar",
"with",
"current",
"value",
"of",
"process"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L113-L153 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fetching.py | ProgressBar.update_with_increment_value | def update_with_increment_value(self, increment_value, mesg=None):
"""Update progressbar with the value of the increment instead of the
current value of process as in update()
Parameters
----------
increment_value : int
Value of the increment of process. The percent... | python | def update_with_increment_value(self, increment_value, mesg=None):
"""Update progressbar with the value of the increment instead of the
current value of process as in update()
Parameters
----------
increment_value : int
Value of the increment of process. The percent... | [
"def",
"update_with_increment_value",
"(",
"self",
",",
"increment_value",
",",
"mesg",
"=",
"None",
")",
":",
"self",
".",
"cur_value",
"+=",
"increment_value",
"self",
".",
"update",
"(",
"self",
".",
"cur_value",
",",
"mesg",
")"
] | Update progressbar with the value of the increment instead of the
current value of process as in update()
Parameters
----------
increment_value : int
Value of the increment of process. The percent of the progressbar
will be computed as
(self.cur_valu... | [
"Update",
"progressbar",
"with",
"the",
"value",
"of",
"the",
"increment",
"instead",
"of",
"the",
"current",
"value",
"of",
"process",
"as",
"in",
"update",
"()"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L155-L171 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.central_widget | def central_widget(self):
""" Returns the default widget that occupies the entire area of the
canvas.
"""
if self._central_widget is None:
self._central_widget = Widget(size=self.size, parent=self.scene)
return self._central_widget | python | def central_widget(self):
""" Returns the default widget that occupies the entire area of the
canvas.
"""
if self._central_widget is None:
self._central_widget = Widget(size=self.size, parent=self.scene)
return self._central_widget | [
"def",
"central_widget",
"(",
"self",
")",
":",
"if",
"self",
".",
"_central_widget",
"is",
"None",
":",
"self",
".",
"_central_widget",
"=",
"Widget",
"(",
"size",
"=",
"self",
".",
"size",
",",
"parent",
"=",
"self",
".",
"scene",
")",
"return",
"sel... | Returns the default widget that occupies the entire area of the
canvas. | [
"Returns",
"the",
"default",
"widget",
"that",
"occupies",
"the",
"entire",
"area",
"of",
"the",
"canvas",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L164-L170 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.render | def render(self, region=None, size=None, bgcolor=None):
"""Render the scene to an offscreen buffer and return the image array.
Parameters
----------
region : tuple | None
Specifies the region of the canvas to render. Format is
(x, y, w, h). By default, t... | python | def render(self, region=None, size=None, bgcolor=None):
"""Render the scene to an offscreen buffer and return the image array.
Parameters
----------
region : tuple | None
Specifies the region of the canvas to render. Format is
(x, y, w, h). By default, t... | [
"def",
"render",
"(",
"self",
",",
"region",
"=",
"None",
",",
"size",
"=",
"None",
",",
"bgcolor",
"=",
"None",
")",
":",
"self",
".",
"set_current",
"(",
")",
"# Set up a framebuffer to render to",
"offset",
"=",
"(",
"0",
",",
"0",
")",
"if",
"regio... | Render the scene to an offscreen buffer and return the image array.
Parameters
----------
region : tuple | None
Specifies the region of the canvas to render. Format is
(x, y, w, h). By default, the entire canvas is rendered.
size : tuple | None
... | [
"Render",
"the",
"scene",
"to",
"an",
"offscreen",
"buffer",
"and",
"return",
"the",
"image",
"array",
".",
"Parameters",
"----------",
"region",
":",
"tuple",
"|",
"None",
"Specifies",
"the",
"region",
"of",
"the",
"canvas",
"to",
"render",
".",
"Format",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L209-L247 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.draw_visual | def draw_visual(self, visual, event=None):
""" Draw a visual and its children to the canvas or currently active
framebuffer.
Parameters
----------
visual : Visual
The visual to draw
event : None or DrawEvent
Optionally specifies the origin... | python | def draw_visual(self, visual, event=None):
""" Draw a visual and its children to the canvas or currently active
framebuffer.
Parameters
----------
visual : Visual
The visual to draw
event : None or DrawEvent
Optionally specifies the origin... | [
"def",
"draw_visual",
"(",
"self",
",",
"visual",
",",
"event",
"=",
"None",
")",
":",
"prof",
"=",
"Profiler",
"(",
")",
"# make sure this canvas's context is active",
"self",
".",
"set_current",
"(",
")",
"try",
":",
"self",
".",
"_drawing",
"=",
"True",
... | Draw a visual and its children to the canvas or currently active
framebuffer.
Parameters
----------
visual : Visual
The visual to draw
event : None or DrawEvent
Optionally specifies the original canvas draw event that initiated
this dr... | [
"Draw",
"a",
"visual",
"and",
"its",
"children",
"to",
"the",
"canvas",
"or",
"currently",
"active",
"framebuffer",
".",
"Parameters",
"----------",
"visual",
":",
"Visual",
"The",
"visual",
"to",
"draw",
"event",
":",
"None",
"or",
"DrawEvent",
"Optionally",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L255-L298 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas._generate_draw_order | def _generate_draw_order(self, node=None):
"""Return a list giving the order to draw visuals.
Each node appears twice in the list--(node, True) appears before the
node's children are drawn, and (node, False) appears after.
"""
if node is None:
node = self._sc... | python | def _generate_draw_order(self, node=None):
"""Return a list giving the order to draw visuals.
Each node appears twice in the list--(node, True) appears before the
node's children are drawn, and (node, False) appears after.
"""
if node is None:
node = self._sc... | [
"def",
"_generate_draw_order",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"_scene",
"order",
"=",
"[",
"(",
"node",
",",
"True",
")",
"]",
"children",
"=",
"node",
".",
"children",
"c... | Return a list giving the order to draw visuals.
Each node appears twice in the list--(node, True) appears before the
node's children are drawn, and (node, False) appears after. | [
"Return",
"a",
"list",
"giving",
"the",
"order",
"to",
"draw",
"visuals",
".",
"Each",
"node",
"appears",
"twice",
"in",
"the",
"list",
"--",
"(",
"node",
"True",
")",
"appears",
"before",
"the",
"node",
"s",
"children",
"are",
"drawn",
"and",
"(",
"no... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L300-L314 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.visual_at | def visual_at(self, pos):
"""Return the visual at a given position
Parameters
----------
pos : tuple
The position in logical coordinates to query.
Returns
-------
visual : instance of Visual | None
The visual at the position, if it exists... | python | def visual_at(self, pos):
"""Return the visual at a given position
Parameters
----------
pos : tuple
The position in logical coordinates to query.
Returns
-------
visual : instance of Visual | None
The visual at the position, if it exists... | [
"def",
"visual_at",
"(",
"self",
",",
"pos",
")",
":",
"tr",
"=",
"self",
".",
"transforms",
".",
"get_transform",
"(",
"'canvas'",
",",
"'framebuffer'",
")",
"fbpos",
"=",
"tr",
".",
"map",
"(",
"pos",
")",
"[",
":",
"2",
"]",
"try",
":",
"id_",
... | Return the visual at a given position
Parameters
----------
pos : tuple
The position in logical coordinates to query.
Returns
-------
visual : instance of Visual | None
The visual at the position, if it exists. | [
"Return",
"the",
"visual",
"at",
"a",
"given",
"position"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L367-L391 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas._visual_bounds_at | def _visual_bounds_at(self, pos, node=None):
"""Find a visual whose bounding rect encompasses *pos*.
"""
if node is None:
node = self.scene
for ch in node.children:
hit = self._visual_bounds_at(pos, ch)
if hit is not None:
... | python | def _visual_bounds_at(self, pos, node=None):
"""Find a visual whose bounding rect encompasses *pos*.
"""
if node is None:
node = self.scene
for ch in node.children:
hit = self._visual_bounds_at(pos, ch)
if hit is not None:
... | [
"def",
"_visual_bounds_at",
"(",
"self",
",",
"pos",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"scene",
"for",
"ch",
"in",
"node",
".",
"children",
":",
"hit",
"=",
"self",
".",
"_visual_bounds_at"... | Find a visual whose bounding rect encompasses *pos*. | [
"Find",
"a",
"visual",
"whose",
"bounding",
"rect",
"encompasses",
"*",
"pos",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L393-L423 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.visuals_at | def visuals_at(self, pos, radius=10):
"""Return a list of visuals within *radius* pixels of *pos*.
Visuals are sorted by their proximity to *pos*.
Parameters
----------
pos : tuple
(x, y) position at which to find visuals.
radius : int
... | python | def visuals_at(self, pos, radius=10):
"""Return a list of visuals within *radius* pixels of *pos*.
Visuals are sorted by their proximity to *pos*.
Parameters
----------
pos : tuple
(x, y) position at which to find visuals.
radius : int
... | [
"def",
"visuals_at",
"(",
"self",
",",
"pos",
",",
"radius",
"=",
"10",
")",
":",
"tr",
"=",
"self",
".",
"transforms",
".",
"get_transform",
"(",
"'canvas'",
",",
"'framebuffer'",
")",
"pos",
"=",
"tr",
".",
"map",
"(",
"pos",
")",
"[",
":",
"2",
... | Return a list of visuals within *radius* pixels of *pos*.
Visuals are sorted by their proximity to *pos*.
Parameters
----------
pos : tuple
(x, y) position at which to find visuals.
radius : int
Distance away from *pos* to search for visu... | [
"Return",
"a",
"list",
"of",
"visuals",
"within",
"*",
"radius",
"*",
"pixels",
"of",
"*",
"pos",
"*",
".",
"Visuals",
"are",
"sorted",
"by",
"their",
"proximity",
"to",
"*",
"pos",
"*",
".",
"Parameters",
"----------",
"pos",
":",
"tuple",
"(",
"x",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L425-L450 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas._render_picking | def _render_picking(self, **kwargs):
"""Render the scene in picking mode, returning a 2D array of visual
IDs.
"""
try:
self._scene.picking = True
img = self.render(bgcolor=(0, 0, 0, 0), **kwargs)
finally:
self._scene.picking = False
im... | python | def _render_picking(self, **kwargs):
"""Render the scene in picking mode, returning a 2D array of visual
IDs.
"""
try:
self._scene.picking = True
img = self.render(bgcolor=(0, 0, 0, 0), **kwargs)
finally:
self._scene.picking = False
im... | [
"def",
"_render_picking",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_scene",
".",
"picking",
"=",
"True",
"img",
"=",
"self",
".",
"render",
"(",
"bgcolor",
"=",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
",",
... | Render the scene in picking mode, returning a 2D array of visual
IDs. | [
"Render",
"the",
"scene",
"in",
"picking",
"mode",
"returning",
"a",
"2D",
"array",
"of",
"visual",
"IDs",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L452-L463 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.on_resize | def on_resize(self, event):
"""Resize handler
Parameters
----------
event : instance of Event
The resize event.
"""
self._update_transforms()
if self._central_widget is not None:
self._central_widget.size = self.size
... | python | def on_resize(self, event):
"""Resize handler
Parameters
----------
event : instance of Event
The resize event.
"""
self._update_transforms()
if self._central_widget is not None:
self._central_widget.size = self.size
... | [
"def",
"on_resize",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_update_transforms",
"(",
")",
"if",
"self",
".",
"_central_widget",
"is",
"not",
"None",
":",
"self",
".",
"_central_widget",
".",
"size",
"=",
"self",
".",
"size",
"if",
"len",
"(... | Resize handler
Parameters
----------
event : instance of Event
The resize event. | [
"Resize",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L465-L479 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.on_close | def on_close(self, event):
"""Close event handler
Parameters
----------
event : instance of Event
The event.
"""
self.events.mouse_press.disconnect(self._process_mouse_event)
self.events.mouse_move.disconnect(self._process_mouse_event)
self.ev... | python | def on_close(self, event):
"""Close event handler
Parameters
----------
event : instance of Event
The event.
"""
self.events.mouse_press.disconnect(self._process_mouse_event)
self.events.mouse_move.disconnect(self._process_mouse_event)
self.ev... | [
"def",
"on_close",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"events",
".",
"mouse_press",
".",
"disconnect",
"(",
"self",
".",
"_process_mouse_event",
")",
"self",
".",
"events",
".",
"mouse_move",
".",
"disconnect",
"(",
"self",
".",
"_process_mo... | Close event handler
Parameters
----------
event : instance of Event
The event. | [
"Close",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L481-L492 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.push_viewport | def push_viewport(self, viewport):
""" Push a viewport (x, y, w, h) on the stack. Values must be integers
relative to the active framebuffer.
Parameters
----------
viewport : tuple
The viewport as (x, y, w, h).
"""
vp = list(viewport)
# Normal... | python | def push_viewport(self, viewport):
""" Push a viewport (x, y, w, h) on the stack. Values must be integers
relative to the active framebuffer.
Parameters
----------
viewport : tuple
The viewport as (x, y, w, h).
"""
vp = list(viewport)
# Normal... | [
"def",
"push_viewport",
"(",
"self",
",",
"viewport",
")",
":",
"vp",
"=",
"list",
"(",
"viewport",
")",
"# Normalize viewport before setting;",
"if",
"vp",
"[",
"2",
"]",
"<",
"0",
":",
"vp",
"[",
"0",
"]",
"+=",
"vp",
"[",
"2",
"]",
"vp",
"[",
"2... | Push a viewport (x, y, w, h) on the stack. Values must be integers
relative to the active framebuffer.
Parameters
----------
viewport : tuple
The viewport as (x, y, w, h). | [
"Push",
"a",
"viewport",
"(",
"x",
"y",
"w",
"h",
")",
"on",
"the",
"stack",
".",
"Values",
"must",
"be",
"integers",
"relative",
"to",
"the",
"active",
"framebuffer",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L495-L520 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.pop_viewport | def pop_viewport(self):
""" Pop a viewport from the stack.
"""
vp = self._vp_stack.pop()
# Activate latest
if len(self._vp_stack) > 0:
self.context.set_viewport(*self._vp_stack[-1])
else:
self.context.set_viewport(0, 0, *self.physical_size)
... | python | def pop_viewport(self):
""" Pop a viewport from the stack.
"""
vp = self._vp_stack.pop()
# Activate latest
if len(self._vp_stack) > 0:
self.context.set_viewport(*self._vp_stack[-1])
else:
self.context.set_viewport(0, 0, *self.physical_size)
... | [
"def",
"pop_viewport",
"(",
"self",
")",
":",
"vp",
"=",
"self",
".",
"_vp_stack",
".",
"pop",
"(",
")",
"# Activate latest",
"if",
"len",
"(",
"self",
".",
"_vp_stack",
")",
">",
"0",
":",
"self",
".",
"context",
".",
"set_viewport",
"(",
"*",
"self... | Pop a viewport from the stack. | [
"Pop",
"a",
"viewport",
"from",
"the",
"stack",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L522-L533 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.push_fbo | def push_fbo(self, fbo, offset, csize):
""" Push an FBO on the stack.
This activates the framebuffer and causes subsequent rendering to be
written to the framebuffer rather than the canvas's back buffer. This
will also set the canvas viewport to cover the boundaries of the
... | python | def push_fbo(self, fbo, offset, csize):
""" Push an FBO on the stack.
This activates the framebuffer and causes subsequent rendering to be
written to the framebuffer rather than the canvas's back buffer. This
will also set the canvas viewport to cover the boundaries of the
... | [
"def",
"push_fbo",
"(",
"self",
",",
"fbo",
",",
"offset",
",",
"csize",
")",
":",
"self",
".",
"_fb_stack",
".",
"append",
"(",
"(",
"fbo",
",",
"offset",
",",
"csize",
")",
")",
"try",
":",
"fbo",
".",
"activate",
"(",
")",
"h",
",",
"w",
"="... | Push an FBO on the stack.
This activates the framebuffer and causes subsequent rendering to be
written to the framebuffer rather than the canvas's back buffer. This
will also set the canvas viewport to cover the boundaries of the
framebuffer.
Parameters
-------... | [
"Push",
"an",
"FBO",
"on",
"the",
"stack",
".",
"This",
"activates",
"the",
"framebuffer",
"and",
"causes",
"subsequent",
"rendering",
"to",
"be",
"written",
"to",
"the",
"framebuffer",
"rather",
"than",
"the",
"canvas",
"s",
"back",
"buffer",
".",
"This",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L535-L563 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas.pop_fbo | def pop_fbo(self):
""" Pop an FBO from the stack.
"""
fbo = self._fb_stack.pop()
fbo[0].deactivate()
self.pop_viewport()
if len(self._fb_stack) > 0:
old_fbo = self._fb_stack[-1]
old_fbo[0].activate()
self._update_transforms()
... | python | def pop_fbo(self):
""" Pop an FBO from the stack.
"""
fbo = self._fb_stack.pop()
fbo[0].deactivate()
self.pop_viewport()
if len(self._fb_stack) > 0:
old_fbo = self._fb_stack[-1]
old_fbo[0].activate()
self._update_transforms()
... | [
"def",
"pop_fbo",
"(",
"self",
")",
":",
"fbo",
"=",
"self",
".",
"_fb_stack",
".",
"pop",
"(",
")",
"fbo",
"[",
"0",
"]",
".",
"deactivate",
"(",
")",
"self",
".",
"pop_viewport",
"(",
")",
"if",
"len",
"(",
"self",
".",
"_fb_stack",
")",
">",
... | Pop an FBO from the stack. | [
"Pop",
"an",
"FBO",
"from",
"the",
"stack",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L565-L576 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/canvas.py | SceneCanvas._update_transforms | def _update_transforms(self):
"""Update the canvas's TransformSystem to correct for the current
canvas size, framebuffer, and viewport.
"""
if len(self._fb_stack) == 0:
fb_size = fb_rect = None
else:
fb, origin, fb_size = self._fb_stack[-1]
fb... | python | def _update_transforms(self):
"""Update the canvas's TransformSystem to correct for the current
canvas size, framebuffer, and viewport.
"""
if len(self._fb_stack) == 0:
fb_size = fb_rect = None
else:
fb, origin, fb_size = self._fb_stack[-1]
fb... | [
"def",
"_update_transforms",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_fb_stack",
")",
"==",
"0",
":",
"fb_size",
"=",
"fb_rect",
"=",
"None",
"else",
":",
"fb",
",",
"origin",
",",
"fb_size",
"=",
"self",
".",
"_fb_stack",
"[",
"-",
... | Update the canvas's TransformSystem to correct for the current
canvas size, framebuffer, and viewport. | [
"Update",
"the",
"canvas",
"s",
"TransformSystem",
"to",
"correct",
"for",
"the",
"current",
"canvas",
"size",
"framebuffer",
"and",
"viewport",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L587-L603 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | BaseTexture.wrapping | def wrapping(self):
""" Texture wrapping mode """
value = self._wrapping
return value[0] if all([v == value[0] for v in value]) else value | python | def wrapping(self):
""" Texture wrapping mode """
value = self._wrapping
return value[0] if all([v == value[0] for v in value]) else value | [
"def",
"wrapping",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_wrapping",
"return",
"value",
"[",
"0",
"]",
"if",
"all",
"(",
"[",
"v",
"==",
"value",
"[",
"0",
"]",
"for",
"v",
"in",
"value",
"]",
")",
"else",
"value"
] | Texture wrapping mode | [
"Texture",
"wrapping",
"mode"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L156-L159 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | BaseTexture.resize | def resize(self, shape, format=None, internalformat=None):
"""Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.... | python | def resize(self, shape, format=None, internalformat=None):
"""Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.... | [
"def",
"resize",
"(",
"self",
",",
"shape",
",",
"format",
"=",
"None",
",",
"internalformat",
"=",
"None",
")",
":",
"return",
"self",
".",
"_resize",
"(",
"shape",
",",
"format",
",",
"internalformat",
")"
] | Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.
format : str | enum | None
The format of the text... | [
"Set",
"the",
"texture",
"size",
"and",
"format"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L202-L224 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | BaseTexture._resize | def _resize(self, shape, format=None, internalformat=None):
"""Internal method for resize.
"""
shape = self._normalize_shape(shape)
# Check
if not self._resizable:
raise RuntimeError("Texture is not resizable")
# Determine format
if format is None:
... | python | def _resize(self, shape, format=None, internalformat=None):
"""Internal method for resize.
"""
shape = self._normalize_shape(shape)
# Check
if not self._resizable:
raise RuntimeError("Texture is not resizable")
# Determine format
if format is None:
... | [
"def",
"_resize",
"(",
"self",
",",
"shape",
",",
"format",
"=",
"None",
",",
"internalformat",
"=",
"None",
")",
":",
"shape",
"=",
"self",
".",
"_normalize_shape",
"(",
"shape",
")",
"# Check",
"if",
"not",
"self",
".",
"_resizable",
":",
"raise",
"R... | Internal method for resize. | [
"Internal",
"method",
"for",
"resize",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L226-L277 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | BaseTexture.set_data | def set_data(self, data, offset=None, copy=False):
"""Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is... | python | def set_data(self, data, offset=None, copy=False):
"""Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is... | [
"def",
"set_data",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"return",
"self",
".",
"_set_data",
"(",
"data",
",",
"offset",
",",
"copy",
")"
] | Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is deferred, data may change before
data is actually... | [
"Set",
"texture",
"data"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L279-L298 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | BaseTexture._set_data | def _set_data(self, data, offset=None, copy=False):
"""Internal method for set_data.
"""
# Copy if needed, check/normalize shape
data = np.array(data, copy=copy)
data = self._normalize_shape(data)
# Maybe resize to purge DATA commands?
if offset ... | python | def _set_data(self, data, offset=None, copy=False):
"""Internal method for set_data.
"""
# Copy if needed, check/normalize shape
data = np.array(data, copy=copy)
data = self._normalize_shape(data)
# Maybe resize to purge DATA commands?
if offset ... | [
"def",
"_set_data",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"# Copy if needed, check/normalize shape",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"copy",
"=",
"copy",
")",
"data",
"=",
"self",
... | Internal method for set_data. | [
"Internal",
"method",
"for",
"set_data",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L300-L324 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | TextureEmulated3D.set_data | def set_data(self, data, offset=None, copy=False):
"""Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is... | python | def set_data(self, data, offset=None, copy=False):
"""Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is... | [
"def",
"set_data",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"self",
".",
"_set_emulated_shape",
"(",
"data",
")",
"Texture2D",
".",
"set_data",
"(",
"self",
",",
"self",
".",
"_normalize_emulated_shape",
... | Set texture data
Parameters
----------
data : ndarray
Data to be uploaded
offset: int | tuple of ints
Offset in texture where to start copying data
copy: bool
Since the operation is deferred, data may change before
data is actually... | [
"Set",
"texture",
"data"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L726-L748 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | TextureEmulated3D.resize | def resize(self, shape, format=None, internalformat=None):
"""Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.... | python | def resize(self, shape, format=None, internalformat=None):
"""Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.... | [
"def",
"resize",
"(",
"self",
",",
"shape",
",",
"format",
"=",
"None",
",",
"internalformat",
"=",
"None",
")",
":",
"self",
".",
"_set_emulated_shape",
"(",
"shape",
")",
"Texture2D",
".",
"resize",
"(",
"self",
",",
"self",
".",
"_normalize_emulated_sha... | Set the texture size and format
Parameters
----------
shape : tuple of integers
New texture shape in zyx order. Optionally, an extra dimention
may be specified to indicate the number of color channels.
format : str | enum | None
The format of the text... | [
"Set",
"the",
"texture",
"size",
"and",
"format"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L750-L775 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | TextureAtlas.get_free_region | def get_free_region(self, width, height):
"""Get a free region of given size and allocate it
Parameters
----------
width : int
Width of region to allocate
height : int
Height of region to allocate
Returns
-------
bounds : tuple | ... | python | def get_free_region(self, width, height):
"""Get a free region of given size and allocate it
Parameters
----------
width : int
Width of region to allocate
height : int
Height of region to allocate
Returns
-------
bounds : tuple | ... | [
"def",
"get_free_region",
"(",
"self",
",",
"width",
",",
"height",
")",
":",
"best_height",
"=",
"best_width",
"=",
"np",
".",
"inf",
"best_index",
"=",
"-",
"1",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_atlas_nodes",
")",
")",
":"... | Get a free region of given size and allocate it
Parameters
----------
width : int
Width of region to allocate
height : int
Height of region to allocate
Returns
-------
bounds : tuple | None
A newly allocated region as (x, y, w... | [
"Get",
"a",
"free",
"region",
"of",
"given",
"size",
"and",
"allocate",
"it"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L839-L900 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/texture.py | TextureAtlas._fit | def _fit(self, index, width, height):
"""Test if region (width, height) fit into self._atlas_nodes[index]"""
node = self._atlas_nodes[index]
x, y = node[0], node[1]
width_left = width
if x+width > self._shape[1]:
return -1
i = index
while width_left > ... | python | def _fit(self, index, width, height):
"""Test if region (width, height) fit into self._atlas_nodes[index]"""
node = self._atlas_nodes[index]
x, y = node[0], node[1]
width_left = width
if x+width > self._shape[1]:
return -1
i = index
while width_left > ... | [
"def",
"_fit",
"(",
"self",
",",
"index",
",",
"width",
",",
"height",
")",
":",
"node",
"=",
"self",
".",
"_atlas_nodes",
"[",
"index",
"]",
"x",
",",
"y",
"=",
"node",
"[",
"0",
"]",
",",
"node",
"[",
"1",
"]",
"width_left",
"=",
"width",
"if... | Test if region (width, height) fit into self._atlas_nodes[index] | [
"Test",
"if",
"region",
"(",
"width",
"height",
")",
"fit",
"into",
"self",
".",
"_atlas_nodes",
"[",
"index",
"]"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L902-L917 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _vector_or_scalar | def _vector_or_scalar(x, type='row'):
"""Convert an object to either a scalar or a row or column vector."""
if isinstance(x, (list, tuple)):
x = np.array(x)
if isinstance(x, np.ndarray):
assert x.ndim == 1
if type == 'column':
x = x[:, None]
return x | python | def _vector_or_scalar(x, type='row'):
"""Convert an object to either a scalar or a row or column vector."""
if isinstance(x, (list, tuple)):
x = np.array(x)
if isinstance(x, np.ndarray):
assert x.ndim == 1
if type == 'column':
x = x[:, None]
return x | [
"def",
"_vector_or_scalar",
"(",
"x",
",",
"type",
"=",
"'row'",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"if",
"isinstance",
"(",
"x",
",",
"np",
".",
... | Convert an object to either a scalar or a row or column vector. | [
"Convert",
"an",
"object",
"to",
"either",
"a",
"scalar",
"or",
"a",
"row",
"or",
"column",
"vector",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L20-L28 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _vector | def _vector(x, type='row'):
"""Convert an object to a row or column vector."""
if isinstance(x, (list, tuple)):
x = np.array(x, dtype=np.float32)
elif not isinstance(x, np.ndarray):
x = np.array([x], dtype=np.float32)
assert x.ndim == 1
if type == 'column':
x = x[:, None]
... | python | def _vector(x, type='row'):
"""Convert an object to a row or column vector."""
if isinstance(x, (list, tuple)):
x = np.array(x, dtype=np.float32)
elif not isinstance(x, np.ndarray):
x = np.array([x], dtype=np.float32)
assert x.ndim == 1
if type == 'column':
x = x[:, None]
... | [
"def",
"_vector",
"(",
"x",
",",
"type",
"=",
"'row'",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"elif",
"not",... | Convert an object to a row or column vector. | [
"Convert",
"an",
"object",
"to",
"a",
"row",
"or",
"column",
"vector",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L31-L40 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.