repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L367-L391 |
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",
"*",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L393-L423 |
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",
... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L425-L450 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L452-L463 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L465-L479 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L481-L492 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L495-L520 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L522-L533 |
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",
... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L535-L563 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L565-L576 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/canvas.py#L587-L603 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L156-L159 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L202-L224 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L226-L277 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L279-L298 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L300-L324 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L726-L748 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L750-L775 |
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"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L839-L900 |
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",
"]"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/texture.py#L902-L917 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L20-L28 |
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",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L31-L40 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _normalize | def _normalize(x, cmin=None, cmax=None, clip=True):
"""Normalize an array from the range [cmin, cmax] to [0,1],
with optional clipping."""
if not isinstance(x, np.ndarray):
x = np.array(x)
if cmin is None:
cmin = x.min()
if cmax is None:
cmax = x.max()
if cmin == cmax:
... | python | def _normalize(x, cmin=None, cmax=None, clip=True):
"""Normalize an array from the range [cmin, cmax] to [0,1],
with optional clipping."""
if not isinstance(x, np.ndarray):
x = np.array(x)
if cmin is None:
cmin = x.min()
if cmax is None:
cmax = x.max()
if cmin == cmax:
... | [
"def",
"_normalize",
"(",
"x",
",",
"cmin",
"=",
"None",
",",
"cmax",
"=",
"None",
",",
"clip",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"if"... | Normalize an array from the range [cmin, cmax] to [0,1],
with optional clipping. | [
"Normalize",
"an",
"array",
"from",
"the",
"range",
"[",
"cmin",
"cmax",
"]",
"to",
"[",
"0",
"1",
"]",
"with",
"optional",
"clipping",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L49-L65 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _mix_simple | def _mix_simple(a, b, x):
"""Mix b (with proportion x) with a."""
x = np.clip(x, 0.0, 1.0)
return (1.0 - x)*a + x*b | python | def _mix_simple(a, b, x):
"""Mix b (with proportion x) with a."""
x = np.clip(x, 0.0, 1.0)
return (1.0 - x)*a + x*b | [
"def",
"_mix_simple",
"(",
"a",
",",
"b",
",",
"x",
")",
":",
"x",
"=",
"np",
".",
"clip",
"(",
"x",
",",
"0.0",
",",
"1.0",
")",
"return",
"(",
"1.0",
"-",
"x",
")",
"*",
"a",
"+",
"x",
"*",
"b"
] | Mix b (with proportion x) with a. | [
"Mix",
"b",
"(",
"with",
"proportion",
"x",
")",
"with",
"a",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L69-L72 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | smoothstep | def smoothstep(edge0, edge1, x):
""" performs smooth Hermite interpolation
between 0 and 1 when edge0 < x < edge1. """
# Scale, bias and saturate x to 0..1 range
x = np.clip((x - edge0)/(edge1 - edge0), 0.0, 1.0)
# Evaluate polynomial
return x*x*(3 - 2*x) | python | def smoothstep(edge0, edge1, x):
""" performs smooth Hermite interpolation
between 0 and 1 when edge0 < x < edge1. """
# Scale, bias and saturate x to 0..1 range
x = np.clip((x - edge0)/(edge1 - edge0), 0.0, 1.0)
# Evaluate polynomial
return x*x*(3 - 2*x) | [
"def",
"smoothstep",
"(",
"edge0",
",",
"edge1",
",",
"x",
")",
":",
"# Scale, bias and saturate x to 0..1 range",
"x",
"=",
"np",
".",
"clip",
"(",
"(",
"x",
"-",
"edge0",
")",
"/",
"(",
"edge1",
"-",
"edge0",
")",
",",
"0.0",
",",
"1.0",
")",
"# Ev... | performs smooth Hermite interpolation
between 0 and 1 when edge0 < x < edge1. | [
"performs",
"smooth",
"Hermite",
"interpolation",
"between",
"0",
"and",
"1",
"when",
"edge0",
"<",
"x",
"<",
"edge1",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L98-L104 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | step | def step(colors, x, controls=None):
x = x.ravel()
"""Step interpolation from a set of colors. x belongs in [0, 1]."""
assert (controls[0], controls[-1]) == (0., 1.)
ncolors = len(colors)
assert ncolors == len(controls) - 1
assert ncolors >= 2
x_step = _find_controls(x, controls, ncolors-1)
... | python | def step(colors, x, controls=None):
x = x.ravel()
"""Step interpolation from a set of colors. x belongs in [0, 1]."""
assert (controls[0], controls[-1]) == (0., 1.)
ncolors = len(colors)
assert ncolors == len(controls) - 1
assert ncolors >= 2
x_step = _find_controls(x, controls, ncolors-1)
... | [
"def",
"step",
"(",
"colors",
",",
"x",
",",
"controls",
"=",
"None",
")",
":",
"x",
"=",
"x",
".",
"ravel",
"(",
")",
"assert",
"(",
"controls",
"[",
"0",
"]",
",",
"controls",
"[",
"-",
"1",
"]",
")",
"==",
"(",
"0.",
",",
"1.",
")",
"nco... | Step interpolation from a set of colors. x belongs in [0, 1]. | [
"Step",
"interpolation",
"from",
"a",
"set",
"of",
"colors",
".",
"x",
"belongs",
"in",
"[",
"0",
"1",
"]",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L107-L115 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _glsl_mix | def _glsl_mix(controls=None):
"""Generate a GLSL template function from a given interpolation patterns
and control points."""
assert (controls[0], controls[-1]) == (0., 1.)
ncolors = len(controls)
assert ncolors >= 2
if ncolors == 2:
s = " return mix($color_0, $color_1, t);\n"
els... | python | def _glsl_mix(controls=None):
"""Generate a GLSL template function from a given interpolation patterns
and control points."""
assert (controls[0], controls[-1]) == (0., 1.)
ncolors = len(controls)
assert ncolors >= 2
if ncolors == 2:
s = " return mix($color_0, $color_1, t);\n"
els... | [
"def",
"_glsl_mix",
"(",
"controls",
"=",
"None",
")",
":",
"assert",
"(",
"controls",
"[",
"0",
"]",
",",
"controls",
"[",
"-",
"1",
"]",
")",
"==",
"(",
"0.",
",",
"1.",
")",
"ncolors",
"=",
"len",
"(",
"controls",
")",
"assert",
"ncolors",
">=... | Generate a GLSL template function from a given interpolation patterns
and control points. | [
"Generate",
"a",
"GLSL",
"template",
"function",
"from",
"a",
"given",
"interpolation",
"patterns",
"and",
"control",
"points",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L119-L140 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | _process_glsl_template | def _process_glsl_template(template, colors):
"""Replace $color_i by color #i in the GLSL template."""
for i in range(len(colors) - 1, -1, -1):
color = colors[i]
assert len(color) == 4
vec4_color = 'vec4(%.3f, %.3f, %.3f, %.3f)' % tuple(color)
template = template.replace('$color_... | python | def _process_glsl_template(template, colors):
"""Replace $color_i by color #i in the GLSL template."""
for i in range(len(colors) - 1, -1, -1):
color = colors[i]
assert len(color) == 4
vec4_color = 'vec4(%.3f, %.3f, %.3f, %.3f)' % tuple(color)
template = template.replace('$color_... | [
"def",
"_process_glsl_template",
"(",
"template",
",",
"colors",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"colors",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
")",
":",
"color",
"=",
"colors",
"[",
"i",
"]",
"assert",
"len",
"(",
... | Replace $color_i by color #i in the GLSL template. | [
"Replace",
"$color_i",
"by",
"color",
"#i",
"in",
"the",
"GLSL",
"template",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L160-L167 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | get_colormap | def get_colormap(name, *args, **kwargs):
"""Obtain a colormap
Some colormaps can have additional configuration parameters. Refer to
their corresponding documentation for more information.
Parameters
----------
name : str | Colormap
Colormap name. Can also be a Colormap for pass-through... | python | def get_colormap(name, *args, **kwargs):
"""Obtain a colormap
Some colormaps can have additional configuration parameters. Refer to
their corresponding documentation for more information.
Parameters
----------
name : str | Colormap
Colormap name. Can also be a Colormap for pass-through... | [
"def",
"get_colormap",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"BaseColormap",
")",
":",
"cmap",
"=",
"name",
"else",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"string_types",
")... | Obtain a colormap
Some colormaps can have additional configuration parameters. Refer to
their corresponding documentation for more information.
Parameters
----------
name : str | Colormap
Colormap name. Can also be a Colormap for pass-through.
Examples
--------
>>> get_co... | [
"Obtain",
"a",
"colormap"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L980-L1009 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/colormap.py | Colormap.map | def map(self, x):
"""The Python mapping function from the [0,1] interval to a
list of rgba colors
Parameters
----------
x : array-like
The values to map.
Returns
-------
colors : list
List of rgba colors.
"""
retur... | python | def map(self, x):
"""The Python mapping function from the [0,1] interval to a
list of rgba colors
Parameters
----------
x : array-like
The values to map.
Returns
-------
colors : list
List of rgba colors.
"""
retur... | [
"def",
"map",
"(",
"self",
",",
"x",
")",
":",
"return",
"self",
".",
"_map_function",
"(",
"self",
".",
"colors",
".",
"rgba",
",",
"x",
",",
"self",
".",
"_controls",
")"
] | The Python mapping function from the [0,1] interval to a
list of rgba colors
Parameters
----------
x : array-like
The values to map.
Returns
-------
colors : list
List of rgba colors. | [
"The",
"Python",
"mapping",
"function",
"from",
"the",
"[",
"0",
"1",
"]",
"interval",
"to",
"a",
"list",
"of",
"rgba",
"colors"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/colormap.py#L363-L377 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/border.py | _BorderVisual.visual_border_width | def visual_border_width(self):
""" The border width in visual coordinates
"""
render_to_doc = \
self.transforms.get_transform('document', 'visual')
vec = render_to_doc.map([self.border_width, self.border_width, 0])
origin = render_to_doc.map([0, 0, 0])
visu... | python | def visual_border_width(self):
""" The border width in visual coordinates
"""
render_to_doc = \
self.transforms.get_transform('document', 'visual')
vec = render_to_doc.map([self.border_width, self.border_width, 0])
origin = render_to_doc.map([0, 0, 0])
visu... | [
"def",
"visual_border_width",
"(",
"self",
")",
":",
"render_to_doc",
"=",
"self",
".",
"transforms",
".",
"get_transform",
"(",
"'document'",
",",
"'visual'",
")",
"vec",
"=",
"render_to_doc",
".",
"map",
"(",
"[",
"self",
".",
"border_width",
",",
"self",
... | The border width in visual coordinates | [
"The",
"border",
"width",
"in",
"visual",
"coordinates"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/border.py#L110-L124 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.run | def run(self, fig):
"""
Run the exporter on the given figure
Parmeters
---------
fig : matplotlib.Figure instance
The figure to export
"""
# Calling savefig executes the draw() command, putting elements
# in the correct place.
fig.save... | python | def run(self, fig):
"""
Run the exporter on the given figure
Parmeters
---------
fig : matplotlib.Figure instance
The figure to export
"""
# Calling savefig executes the draw() command, putting elements
# in the correct place.
fig.save... | [
"def",
"run",
"(",
"self",
",",
"fig",
")",
":",
"# Calling savefig executes the draw() command, putting elements",
"# in the correct place.",
"fig",
".",
"savefig",
"(",
"io",
".",
"BytesIO",
"(",
")",
",",
"format",
"=",
"'png'",
",",
"dpi",
"=",
"fig",
".",
... | Run the exporter on the given figure
Parmeters
---------
fig : matplotlib.Figure instance
The figure to export | [
"Run",
"the",
"exporter",
"on",
"the",
"given",
"figure"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L63-L78 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.process_transform | def process_transform(transform, ax=None, data=None, return_trans=False,
force_trans=None):
"""Process the transform and convert data to figure or data coordinates
Parameters
----------
transform : matplotlib Transform object
The transform applied t... | python | def process_transform(transform, ax=None, data=None, return_trans=False,
force_trans=None):
"""Process the transform and convert data to figure or data coordinates
Parameters
----------
transform : matplotlib Transform object
The transform applied t... | [
"def",
"process_transform",
"(",
"transform",
",",
"ax",
"=",
"None",
",",
"data",
"=",
"None",
",",
"return_trans",
"=",
"False",
",",
"force_trans",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"transform",
",",
"transforms",
".",
"BlendedGenericTransfo... | Process the transform and convert data to figure or data coordinates
Parameters
----------
transform : matplotlib Transform object
The transform applied to the data
ax : matplotlib Axes object (optional)
The axes the data is associated with
data : ndarray... | [
"Process",
"the",
"transform",
"and",
"convert",
"data",
"to",
"figure",
"or",
"data",
"coordinates"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L81-L138 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.crawl_fig | def crawl_fig(self, fig):
"""Crawl the figure and process all axes"""
with self.renderer.draw_figure(fig=fig,
props=utils.get_figure_properties(fig)):
for ax in fig.axes:
self.crawl_ax(ax) | python | def crawl_fig(self, fig):
"""Crawl the figure and process all axes"""
with self.renderer.draw_figure(fig=fig,
props=utils.get_figure_properties(fig)):
for ax in fig.axes:
self.crawl_ax(ax) | [
"def",
"crawl_fig",
"(",
"self",
",",
"fig",
")",
":",
"with",
"self",
".",
"renderer",
".",
"draw_figure",
"(",
"fig",
"=",
"fig",
",",
"props",
"=",
"utils",
".",
"get_figure_properties",
"(",
"fig",
")",
")",
":",
"for",
"ax",
"in",
"fig",
".",
... | Crawl the figure and process all axes | [
"Crawl",
"the",
"figure",
"and",
"process",
"all",
"axes"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L140-L145 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.crawl_ax | def crawl_ax(self, ax):
"""Crawl the axes and process all elements within"""
with self.renderer.draw_axes(ax=ax,
props=utils.get_axes_properties(ax)):
for line in ax.lines:
self.draw_line(ax, line)
for text in ax.texts:
... | python | def crawl_ax(self, ax):
"""Crawl the axes and process all elements within"""
with self.renderer.draw_axes(ax=ax,
props=utils.get_axes_properties(ax)):
for line in ax.lines:
self.draw_line(ax, line)
for text in ax.texts:
... | [
"def",
"crawl_ax",
"(",
"self",
",",
"ax",
")",
":",
"with",
"self",
".",
"renderer",
".",
"draw_axes",
"(",
"ax",
"=",
"ax",
",",
"props",
"=",
"utils",
".",
"get_axes_properties",
"(",
"ax",
")",
")",
":",
"for",
"line",
"in",
"ax",
".",
"lines",... | Crawl the axes and process all elements within | [
"Crawl",
"the",
"axes",
"and",
"process",
"all",
"elements",
"within"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L147-L176 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.crawl_legend | def crawl_legend(self, ax, legend):
"""
Recursively look through objects in legend children
"""
legendElements = list(utils.iter_all_children(legend._legend_box,
skipContainers=True))
legendElements.append(legend.legendPatch)
... | python | def crawl_legend(self, ax, legend):
"""
Recursively look through objects in legend children
"""
legendElements = list(utils.iter_all_children(legend._legend_box,
skipContainers=True))
legendElements.append(legend.legendPatch)
... | [
"def",
"crawl_legend",
"(",
"self",
",",
"ax",
",",
"legend",
")",
":",
"legendElements",
"=",
"list",
"(",
"utils",
".",
"iter_all_children",
"(",
"legend",
".",
"_legend_box",
",",
"skipContainers",
"=",
"True",
")",
")",
"legendElements",
".",
"append",
... | Recursively look through objects in legend children | [
"Recursively",
"look",
"through",
"objects",
"in",
"legend",
"children"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L178-L205 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.draw_line | def draw_line(self, ax, line, force_trans=None):
"""Process a matplotlib line and call renderer.draw_line"""
coordinates, data = self.process_transform(line.get_transform(),
ax, line.get_xydata(),
force... | python | def draw_line(self, ax, line, force_trans=None):
"""Process a matplotlib line and call renderer.draw_line"""
coordinates, data = self.process_transform(line.get_transform(),
ax, line.get_xydata(),
force... | [
"def",
"draw_line",
"(",
"self",
",",
"ax",
",",
"line",
",",
"force_trans",
"=",
"None",
")",
":",
"coordinates",
",",
"data",
"=",
"self",
".",
"process_transform",
"(",
"line",
".",
"get_transform",
"(",
")",
",",
"ax",
",",
"line",
".",
"get_xydata... | Process a matplotlib line and call renderer.draw_line | [
"Process",
"a",
"matplotlib",
"line",
"and",
"call",
"renderer",
".",
"draw_line"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L207-L225 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.draw_text | def draw_text(self, ax, text, force_trans=None, text_type=None):
"""Process a matplotlib text object and call renderer.draw_text"""
content = text.get_text()
if content:
transform = text.get_transform()
position = text.get_position()
coords, position = self.pr... | python | def draw_text(self, ax, text, force_trans=None, text_type=None):
"""Process a matplotlib text object and call renderer.draw_text"""
content = text.get_text()
if content:
transform = text.get_transform()
position = text.get_position()
coords, position = self.pr... | [
"def",
"draw_text",
"(",
"self",
",",
"ax",
",",
"text",
",",
"force_trans",
"=",
"None",
",",
"text_type",
"=",
"None",
")",
":",
"content",
"=",
"text",
".",
"get_text",
"(",
")",
"if",
"content",
":",
"transform",
"=",
"text",
".",
"get_transform",
... | Process a matplotlib text object and call renderer.draw_text | [
"Process",
"a",
"matplotlib",
"text",
"object",
"and",
"call",
"renderer",
".",
"draw_text"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L227-L240 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.draw_patch | def draw_patch(self, ax, patch, force_trans=None):
"""Process a matplotlib patch object and call renderer.draw_path"""
vertices, pathcodes = utils.SVG_path(patch.get_path())
transform = patch.get_transform()
coordinates, vertices = self.process_transform(transform,
... | python | def draw_patch(self, ax, patch, force_trans=None):
"""Process a matplotlib patch object and call renderer.draw_path"""
vertices, pathcodes = utils.SVG_path(patch.get_path())
transform = patch.get_transform()
coordinates, vertices = self.process_transform(transform,
... | [
"def",
"draw_patch",
"(",
"self",
",",
"ax",
",",
"patch",
",",
"force_trans",
"=",
"None",
")",
":",
"vertices",
",",
"pathcodes",
"=",
"utils",
".",
"SVG_path",
"(",
"patch",
".",
"get_path",
"(",
")",
")",
"transform",
"=",
"patch",
".",
"get_transf... | Process a matplotlib patch object and call renderer.draw_path | [
"Process",
"a",
"matplotlib",
"patch",
"object",
"and",
"call",
"renderer",
".",
"draw_path"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L242-L254 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.draw_collection | def draw_collection(self, ax, collection,
force_pathtrans=None,
force_offsettrans=None):
"""Process a matplotlib collection and call renderer.draw_collection"""
(transform, transOffset,
offsets, paths) = collection._prepare_points()
offse... | python | def draw_collection(self, ax, collection,
force_pathtrans=None,
force_offsettrans=None):
"""Process a matplotlib collection and call renderer.draw_collection"""
(transform, transOffset,
offsets, paths) = collection._prepare_points()
offse... | [
"def",
"draw_collection",
"(",
"self",
",",
"ax",
",",
"collection",
",",
"force_pathtrans",
"=",
"None",
",",
"force_offsettrans",
"=",
"None",
")",
":",
"(",
"transform",
",",
"transOffset",
",",
"offsets",
",",
"paths",
")",
"=",
"collection",
".",
"_pr... | Process a matplotlib collection and call renderer.draw_collection | [
"Process",
"a",
"matplotlib",
"collection",
"and",
"call",
"renderer",
".",
"draw_collection"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L256-L299 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Exporter.draw_image | def draw_image(self, ax, image):
"""Process a matplotlib image object and call renderer.draw_image"""
self.renderer.draw_image(imdata=utils.image_to_base64(image),
extent=image.get_extent(),
coordinates="data",
... | python | def draw_image(self, ax, image):
"""Process a matplotlib image object and call renderer.draw_image"""
self.renderer.draw_image(imdata=utils.image_to_base64(image),
extent=image.get_extent(),
coordinates="data",
... | [
"def",
"draw_image",
"(",
"self",
",",
"ax",
",",
"image",
")",
":",
"self",
".",
"renderer",
".",
"draw_image",
"(",
"imdata",
"=",
"utils",
".",
"image_to_base64",
"(",
"image",
")",
",",
"extent",
"=",
"image",
".",
"get_extent",
"(",
")",
",",
"c... | Process a matplotlib image object and call renderer.draw_image | [
"Process",
"a",
"matplotlib",
"image",
"object",
"and",
"call",
"renderer",
".",
"draw_image"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L301-L308 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer.draw_marked_line | def draw_marked_line(self, data, coordinates, linestyle, markerstyle,
label, mplobj=None):
"""Draw a line that also has markers.
If this isn't reimplemented by a renderer object, by default, it will
make a call to BOTH draw_line and draw_markers when both markerstyle
... | python | def draw_marked_line(self, data, coordinates, linestyle, markerstyle,
label, mplobj=None):
"""Draw a line that also has markers.
If this isn't reimplemented by a renderer object, by default, it will
make a call to BOTH draw_line and draw_markers when both markerstyle
... | [
"def",
"draw_marked_line",
"(",
"self",
",",
"data",
",",
"coordinates",
",",
"linestyle",
",",
"markerstyle",
",",
"label",
",",
"mplobj",
"=",
"None",
")",
":",
"if",
"linestyle",
"is",
"not",
"None",
":",
"self",
".",
"draw_line",
"(",
"data",
",",
... | Draw a line that also has markers.
If this isn't reimplemented by a renderer object, by default, it will
make a call to BOTH draw_line and draw_markers when both markerstyle
and linestyle are not None in the same Line2D object. | [
"Draw",
"a",
"line",
"that",
"also",
"has",
"markers",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L455-L467 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer.draw_line | def draw_line(self, data, coordinates, style, label, mplobj=None):
"""
Draw a line. By default, draw the line via the draw_path() command.
Some renderers might wish to override this and provide more
fine-grained behavior.
In matplotlib, lines are generally created via the plt.pl... | python | def draw_line(self, data, coordinates, style, label, mplobj=None):
"""
Draw a line. By default, draw the line via the draw_path() command.
Some renderers might wish to override this and provide more
fine-grained behavior.
In matplotlib, lines are generally created via the plt.pl... | [
"def",
"draw_line",
"(",
"self",
",",
"data",
",",
"coordinates",
",",
"style",
",",
"label",
",",
"mplobj",
"=",
"None",
")",
":",
"pathcodes",
"=",
"[",
"'M'",
"]",
"+",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
")",
"*",
"[",
"'L'"... | Draw a line. By default, draw the line via the draw_path() command.
Some renderers might wish to override this and provide more
fine-grained behavior.
In matplotlib, lines are generally created via the plt.plot() command,
though this command also can create marker collections.
... | [
"Draw",
"a",
"line",
".",
"By",
"default",
"draw",
"the",
"line",
"via",
"the",
"draw_path",
"()",
"command",
".",
"Some",
"renderers",
"might",
"wish",
"to",
"override",
"this",
"and",
"provide",
"more",
"fine",
"-",
"grained",
"behavior",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L469-L495 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer._iter_path_collection | def _iter_path_collection(paths, path_transforms, offsets, styles):
"""Build an iterator over the elements of the path collection"""
N = max(len(paths), len(offsets))
if not path_transforms:
path_transforms = [np.eye(3)]
edgecolor = styles['edgecolor']
if np.size(ed... | python | def _iter_path_collection(paths, path_transforms, offsets, styles):
"""Build an iterator over the elements of the path collection"""
N = max(len(paths), len(offsets))
if not path_transforms:
path_transforms = [np.eye(3)]
edgecolor = styles['edgecolor']
if np.size(ed... | [
"def",
"_iter_path_collection",
"(",
"paths",
",",
"path_transforms",
",",
"offsets",
",",
"styles",
")",
":",
"N",
"=",
"max",
"(",
"len",
"(",
"paths",
")",
",",
"len",
"(",
"offsets",
")",
")",
"if",
"not",
"path_transforms",
":",
"path_transforms",
"... | Build an iterator over the elements of the path collection | [
"Build",
"an",
"iterator",
"over",
"the",
"elements",
"of",
"the",
"path",
"collection"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L498-L516 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer.draw_path_collection | def draw_path_collection(self, paths, path_coordinates, path_transforms,
offsets, offset_coordinates, offset_order,
styles, mplobj=None):
"""
Draw a collection of paths. The paths, offsets, and styles are all
iterables, and the number of ... | python | def draw_path_collection(self, paths, path_coordinates, path_transforms,
offsets, offset_coordinates, offset_order,
styles, mplobj=None):
"""
Draw a collection of paths. The paths, offsets, and styles are all
iterables, and the number of ... | [
"def",
"draw_path_collection",
"(",
"self",
",",
"paths",
",",
"path_coordinates",
",",
"path_transforms",
",",
"offsets",
",",
"offset_coordinates",
",",
"offset_order",
",",
"styles",
",",
"mplobj",
"=",
"None",
")",
":",
"if",
"offset_order",
"==",
"\"before\... | Draw a collection of paths. The paths, offsets, and styles are all
iterables, and the number of paths is max(len(paths), len(offsets)).
By default, this is implemented via multiple calls to the draw_path()
function. For efficiency, Renderers may choose to customize this
implementation.
... | [
"Draw",
"a",
"collection",
"of",
"paths",
".",
"The",
"paths",
"offsets",
"and",
"styles",
"are",
"all",
"iterables",
"and",
"the",
"number",
"of",
"paths",
"is",
"max",
"(",
"len",
"(",
"paths",
")",
"len",
"(",
"offsets",
"))",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L518-L582 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer.draw_markers | def draw_markers(self, data, coordinates, style, label, mplobj=None):
"""
Draw a set of markers. By default, this is done by repeatedly
calling draw_path(), but renderers should generally overload
this method to provide a more efficient implementation.
In matplotlib, markers are... | python | def draw_markers(self, data, coordinates, style, label, mplobj=None):
"""
Draw a set of markers. By default, this is done by repeatedly
calling draw_path(), but renderers should generally overload
this method to provide a more efficient implementation.
In matplotlib, markers are... | [
"def",
"draw_markers",
"(",
"self",
",",
"data",
",",
"coordinates",
",",
"style",
",",
"label",
",",
"mplobj",
"=",
"None",
")",
":",
"vertices",
",",
"pathcodes",
"=",
"style",
"[",
"'markerpath'",
"]",
"pathstyle",
"=",
"dict",
"(",
"(",
"key",
",",... | Draw a set of markers. By default, this is done by repeatedly
calling draw_path(), but renderers should generally overload
this method to provide a more efficient implementation.
In matplotlib, markers are created using the plt.plot() command.
Parameters
----------
data... | [
"Draw",
"a",
"set",
"of",
"markers",
".",
"By",
"default",
"this",
"is",
"done",
"by",
"repeatedly",
"calling",
"draw_path",
"()",
"but",
"renderers",
"should",
"generally",
"overload",
"this",
"method",
"to",
"provide",
"a",
"more",
"efficient",
"implementati... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L584-L613 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | Renderer.draw_path | def draw_path(self, data, coordinates, pathcodes, style,
offset=None, offset_coordinates="data", mplobj=None):
"""
Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
d... | python | def draw_path(self, data, coordinates, pathcodes, style,
offset=None, offset_coordinates="data", mplobj=None):
"""
Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
d... | [
"def",
"draw_path",
"(",
"self",
",",
"data",
",",
"coordinates",
",",
"pathcodes",
",",
"style",
",",
"offset",
"=",
"None",
",",
"offset_coordinates",
"=",
"\"data\"",
",",
"mplobj",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
data : array_like
A shape (N, 2) array of datapoints.
coordinates : string
A string code, which should be either 'data... | [
"Draw",
"a",
"path",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L638-L673 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.from_times | def from_times(cls, times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of ... | python | def from_times(cls, times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of ... | [
"def",
"from_times",
"(",
"cls",
",",
"times",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"times_arr",
"=",
"np",
".",
"asarray",
"(",
"times",
".",
"jd",
"*",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"dtype",
"=",
"int",
")",
"intervals_arr",... | Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of one observation. It is set to 30 min by default. This data is used to compute the
... | [
"Create",
"a",
"TimeMOC",
"from",
"a",
"astropy",
".",
"time",
".",
"Time"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L31-L53 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.from_time_ranges | def from_time_ranges(cls, min_times, max_times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
... | python | def from_time_ranges(cls, min_times, max_times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
... | [
"def",
"from_time_ranges",
"(",
"cls",
",",
"min_times",
",",
"max_times",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"min_times_arr",
"=",
"np",
".",
"asarray",
"(",
"min_times",
".",
"jd",
"*",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"dtype",
... | Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
max_times : `astropy.time.Time`
astropy times defining the right part of the intervals
... | [
"Create",
"a",
"TimeMOC",
"from",
"a",
"range",
"defined",
"by",
"two",
"astropy",
".",
"time",
".",
"Time"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L56-L82 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.add_neighbours | def add_neighbours(self):
"""
Add all the pixels at max order in the neighbourhood of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.maximum(intervals_arr[:, 0] - time... | python | def add_neighbours(self):
"""
Add all the pixels at max order in the neighbourhood of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.maximum(intervals_arr[:, 0] - time... | [
"def",
"add_neighbours",
"(",
"self",
")",
":",
"time_delta",
"=",
"1",
"<<",
"(",
"2",
"*",
"(",
"IntervalSet",
".",
"HPY_MAX_ORDER",
"-",
"self",
".",
"max_order",
")",
")",
"intervals_arr",
"=",
"self",
".",
"_interval_set",
".",
"_intervals",
"interval... | Add all the pixels at max order in the neighbourhood of the moc | [
"Add",
"all",
"the",
"pixels",
"at",
"max",
"order",
"in",
"the",
"neighbourhood",
"of",
"the",
"moc"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L84-L95 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.remove_neighbours | def remove_neighbours(self):
"""
Remove all the pixels at max order located at the bound of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.minimum(intervals_arr[:, 0] ... | python | def remove_neighbours(self):
"""
Remove all the pixels at max order located at the bound of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.minimum(intervals_arr[:, 0] ... | [
"def",
"remove_neighbours",
"(",
"self",
")",
":",
"time_delta",
"=",
"1",
"<<",
"(",
"2",
"*",
"(",
"IntervalSet",
".",
"HPY_MAX_ORDER",
"-",
"self",
".",
"max_order",
")",
")",
"intervals_arr",
"=",
"self",
".",
"_interval_set",
".",
"_intervals",
"inter... | Remove all the pixels at max order located at the bound of the moc | [
"Remove",
"all",
"the",
"pixels",
"at",
"max",
"order",
"located",
"at",
"the",
"bound",
"of",
"the",
"moc"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L97-L110 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC._process_degradation | def _process_degradation(self, another_moc, order_op):
"""
Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down... | python | def _process_degradation(self, another_moc, order_op):
"""
Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down... | [
"def",
"_process_degradation",
"(",
"self",
",",
"another_moc",
",",
"order_op",
")",
":",
"max_order",
"=",
"max",
"(",
"self",
".",
"max_order",
",",
"another_moc",
".",
"max_order",
")",
"if",
"order_op",
">",
"max_order",
":",
"message",
"=",
"'Requested... | Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down-sampled to.
Returns
-------
result : (`~mocpy.tmo... | [
"Degrade",
"(",
"down",
"-",
"sampling",
")",
"self",
"and",
"another_moc",
"to",
"order_op",
"order"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L123-L150 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.intersection | def intersection(self, another_moc, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_... | python | def intersection(self, another_moc, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_... | [
"def",
"intersection",
"(",
"self",
",",
"another_moc",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"order_op",
"=",
"TimeMOC",
".",
"time_resolution_to_order",
"(",
"delta_t",
")",
"self_degraded",
",",
"moc_degraded",
"=",
"self",
".",
"_process_d... | Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_moc.AbstractMOC`
the MOC/TimeMOC used for performing the intersection with self... | [
"Intersection",
"between",
"self",
"and",
"moc",
".",
"delta_t",
"gives",
"the",
"possibility",
"to",
"the",
"user",
"to",
"set",
"a",
"time",
"resolution",
"for",
"performing",
"the",
"tmoc",
"intersection"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L152-L176 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.total_duration | def total_duration(self):
"""
Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc
... | python | def total_duration(self):
"""
Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc
... | [
"def",
"total_duration",
"(",
"self",
")",
":",
"if",
"self",
".",
"_interval_set",
".",
"empty",
"(",
")",
":",
"return",
"0",
"total_time_us",
"=",
"0",
"# The interval set is checked for consistency before looping over all the intervals",
"for",
"(",
"start_time",
... | Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc | [
"Get",
"the",
"total",
"duration",
"covered",
"by",
"the",
"temporal",
"moc"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L230-L251 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.consistency | def consistency(self):
"""
Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time withou... | python | def consistency(self):
"""
Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time withou... | [
"def",
"consistency",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"total_duration",
".",
"jd",
"/",
"(",
"self",
".",
"max_time",
"-",
"self",
".",
"min_time",
")",
".",
"jd",
"return",
"result"
] | Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time without big pauses.
Returns
----... | [
"Get",
"a",
"percentage",
"of",
"fill",
"between",
"the",
"min",
"and",
"max",
"time",
"the",
"moc",
"is",
"defined",
"."
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L254-L270 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.min_time | def min_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation
"""
min_time = Time(self._interval_set.min / TimeMOC.DAY_MICRO_SEC, format='jd', sca... | python | def min_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation
"""
min_time = Time(self._interval_set.min / TimeMOC.DAY_MICRO_SEC, format='jd', sca... | [
"def",
"min_time",
"(",
"self",
")",
":",
"min_time",
"=",
"Time",
"(",
"self",
".",
"_interval_set",
".",
"min",
"/",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"format",
"=",
"'jd'",
",",
"scale",
"=",
"'tdb'",
")",
"return",
"min_time"
] | Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation | [
"Get",
"the",
"~astropy",
".",
"time",
".",
"Time",
"time",
"of",
"the",
"tmoc",
"first",
"observation"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L273-L285 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.max_time | def max_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation
"""
max_time = Time(self._interval_set.max / TimeMOC.DAY_MICRO_SEC, format='jd', scal... | python | def max_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation
"""
max_time = Time(self._interval_set.max / TimeMOC.DAY_MICRO_SEC, format='jd', scal... | [
"def",
"max_time",
"(",
"self",
")",
":",
"max_time",
"=",
"Time",
"(",
"self",
".",
"_interval_set",
".",
"max",
"/",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"format",
"=",
"'jd'",
",",
"scale",
"=",
"'tdb'",
")",
"return",
"max_time"
] | Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation | [
"Get",
"the",
"~astropy",
".",
"time",
".",
"Time",
"time",
"of",
"the",
"tmoc",
"last",
"observation"
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L288-L300 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.contains | def contains(self, times, keep_inside=True, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whe... | python | def contains(self, times, keep_inside=True, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whe... | [
"def",
"contains",
"(",
"self",
",",
"times",
",",
"keep_inside",
"=",
"True",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"# the requested order for filtering the astropy observations table is more precise than the order",
"# of the TimeMoc object",
"current_max_o... | Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whether they are contained in the TMOC or not.
keep_inside : bool, optional
True b... | [
"Get",
"a",
"mask",
"array",
"(",
"e",
".",
"g",
".",
"a",
"numpy",
"boolean",
"array",
")",
"of",
"times",
"being",
"inside",
"(",
"or",
"outside",
")",
"the",
"TMOC",
"instance",
"."
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L302-L350 |
cds-astro/mocpy | mocpy/tmoc/tmoc.py | TimeMOC.plot | def plot(self, title='TimeMoc', view=(None, None)):
"""
Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
... | python | def plot(self, title='TimeMoc', view=(None, None)):
"""
Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
... | [
"def",
"plot",
"(",
"self",
",",
"title",
"=",
"'TimeMoc'",
",",
"view",
"=",
"(",
"None",
",",
"None",
")",
")",
":",
"from",
"matplotlib",
".",
"colors",
"import",
"LinearSegmentedColormap",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"if",
"se... | Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
The title of the plot. Set to 'TimeMoc' by default.
... | [
"Plot",
"the",
"TimeMoc",
"in",
"a",
"time",
"window",
"."
] | train | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L391-L474 |
rbarrois/mpdlcd | mpdlcd/mpdhooks.py | MPDHook.handle | def handle(self, client, subhooks=()):
"""Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value.
"""
new_data = self.fetch(client)
# Hol... | python | def handle(self, client, subhooks=()):
"""Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value.
"""
new_data = self.fetch(client)
# Hol... | [
"def",
"handle",
"(",
"self",
",",
"client",
",",
"subhooks",
"=",
"(",
")",
")",
":",
"new_data",
"=",
"self",
".",
"fetch",
"(",
"client",
")",
"# Holds the list of updated fields.",
"updated",
"=",
"{",
"}",
"if",
"not",
"subhooks",
":",
"# We always wa... | Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value. | [
"Handle",
"a",
"new",
"update",
"."
] | train | https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/mpdhooks.py#L68-L96 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/text/text.py | _text_to_vbo | def _text_to_vbo(text, font, anchor_x, anchor_y, lowres_size):
"""Convert text characters to VBO"""
# Necessary to flush commands before requesting current viewport because
# There may be a set_viewport command waiting in the queue.
# TODO: would be nicer if each canvas just remembers and manages its ow... | python | def _text_to_vbo(text, font, anchor_x, anchor_y, lowres_size):
"""Convert text characters to VBO"""
# Necessary to flush commands before requesting current viewport because
# There may be a set_viewport command waiting in the queue.
# TODO: would be nicer if each canvas just remembers and manages its ow... | [
"def",
"_text_to_vbo",
"(",
"text",
",",
"font",
",",
"anchor_x",
",",
"anchor_y",
",",
"lowres_size",
")",
":",
"# Necessary to flush commands before requesting current viewport because",
"# There may be a set_viewport command waiting in the queue.",
"# TODO: would be nicer if each ... | Convert text characters to VBO | [
"Convert",
"text",
"characters",
"to",
"VBO"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L132-L207 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/text/text.py | TextureFont._load_char | def _load_char(self, char):
"""Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented.
"""
assert isinstance(char, string_types) and len(char) == 1
assert char not in self... | python | def _load_char(self, char):
"""Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented.
"""
assert isinstance(char, string_types) and len(char) == 1
assert char not in self... | [
"def",
"_load_char",
"(",
"self",
",",
"char",
")",
":",
"assert",
"isinstance",
"(",
"char",
",",
"string_types",
")",
"and",
"len",
"(",
"char",
")",
"==",
"1",
"assert",
"char",
"not",
"in",
"self",
".",
"_glyphs",
"# load new glyph data from font",
"_l... | Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented. | [
"Build",
"and",
"store",
"a",
"glyph",
"corresponding",
"to",
"an",
"individual",
"character"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L72-L108 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/text/text.py | FontManager.get_font | def get_font(self, face, bold=False, italic=False):
"""Get a font described by face and size"""
key = '%s-%s-%s' % (face, bold, italic)
if key not in self._fonts:
font = dict(face=face, bold=bold, italic=italic)
self._fonts[key] = TextureFont(font, self._renderer)
... | python | def get_font(self, face, bold=False, italic=False):
"""Get a font described by face and size"""
key = '%s-%s-%s' % (face, bold, italic)
if key not in self._fonts:
font = dict(face=face, bold=bold, italic=italic)
self._fonts[key] = TextureFont(font, self._renderer)
... | [
"def",
"get_font",
"(",
"self",
",",
"face",
",",
"bold",
"=",
"False",
",",
"italic",
"=",
"False",
")",
":",
"key",
"=",
"'%s-%s-%s'",
"%",
"(",
"face",
",",
"bold",
",",
"italic",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_fonts",
":",
"fon... | Get a font described by face and size | [
"Get",
"a",
"font",
"described",
"by",
"face",
"and",
"size"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L119-L125 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fourier.py | stft | def stft(x, n_fft=1024, step=512, fs=2*np.pi, window='hann'):
"""Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
... | python | def stft(x, n_fft=1024, step=512, fs=2*np.pi, window='hann'):
"""Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
... | [
"def",
"stft",
"(",
"x",
",",
"n_fft",
"=",
"1024",
",",
"step",
"=",
"512",
",",
"fs",
"=",
"2",
"*",
"np",
".",
"pi",
",",
"window",
"=",
"'hann'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
",",
"float",
")",
"if",
"x",
".",
"... | Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
step : int | None
Step size between calculations. If None... | [
"Compute",
"the",
"STFT"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fourier.py#L8-L56 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/fourier.py | fft_freqs | def fft_freqs(n_fft, fs):
"""Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate.
"""
return np.arange(0, (n_fft // 2 + 1)) / float(n_fft) * float(fs) | python | def fft_freqs(n_fft, fs):
"""Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate.
"""
return np.arange(0, (n_fft // 2 + 1)) / float(n_fft) * float(fs) | [
"def",
"fft_freqs",
"(",
"n_fft",
",",
"fs",
")",
":",
"return",
"np",
".",
"arange",
"(",
"0",
",",
"(",
"n_fft",
"//",
"2",
"+",
"1",
")",
")",
"/",
"float",
"(",
"n_fft",
")",
"*",
"float",
"(",
"fs",
")"
] | Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate. | [
"Return",
"frequencies",
"for",
"DFT"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fourier.py#L59-L69 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/line/arrow.py | ArrowVisual.set_data | def set_data(self, pos=None, color=None, width=None, connect=None,
arrows=None):
"""Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
... | python | def set_data(self, pos=None, color=None, width=None, connect=None,
arrows=None):
"""Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
... | [
"def",
"set_data",
"(",
"self",
",",
"pos",
"=",
"None",
",",
"color",
"=",
"None",
",",
"width",
"=",
"None",
",",
"connect",
"=",
"None",
",",
"arrows",
"=",
"None",
")",
":",
"if",
"arrows",
"is",
"not",
"None",
":",
"self",
".",
"_arrows",
"=... | Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
The color to use when drawing the line. If an array is given, it
must be of shape (..... | [
"Set",
"the",
"data",
"used",
"for",
"this",
"visual"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/line/arrow.py#L191-L227 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | strip_html | def strip_html(text):
""" Get rid of ugly twitter html """
def reply_to(text):
replying_to = []
split_text = text.split()
for index, token in enumerate(split_text):
if token.startswith('@'): replying_to.append(token[1:])
else:
message = split_text[... | python | def strip_html(text):
""" Get rid of ugly twitter html """
def reply_to(text):
replying_to = []
split_text = text.split()
for index, token in enumerate(split_text):
if token.startswith('@'): replying_to.append(token[1:])
else:
message = split_text[... | [
"def",
"strip_html",
"(",
"text",
")",
":",
"def",
"reply_to",
"(",
"text",
")",
":",
"replying_to",
"=",
"[",
"]",
"split_text",
"=",
"text",
".",
"split",
"(",
")",
"for",
"index",
",",
"token",
"in",
"enumerate",
"(",
"split_text",
")",
":",
"if",... | Get rid of ugly twitter html | [
"Get",
"rid",
"of",
"ugly",
"twitter",
"html"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L169-L190 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | post_tweet | def post_tweet(user_id, message, additional_params={}):
"""
Helper function to post a tweet
"""
url = "https://api.twitter.com/1.1/statuses/update.json"
params = { "status" : message }
params.update(additional_params)
r = make_twitter_request(url, user_id, params, request_type='POST')
... | python | def post_tweet(user_id, message, additional_params={}):
"""
Helper function to post a tweet
"""
url = "https://api.twitter.com/1.1/statuses/update.json"
params = { "status" : message }
params.update(additional_params)
r = make_twitter_request(url, user_id, params, request_type='POST')
... | [
"def",
"post_tweet",
"(",
"user_id",
",",
"message",
",",
"additional_params",
"=",
"{",
"}",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/statuses/update.json\"",
"params",
"=",
"{",
"\"status\"",
":",
"message",
"}",
"params",
".",
"update",
"(",
"addi... | Helper function to post a tweet | [
"Helper",
"function",
"to",
"post",
"a",
"tweet"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L274-L283 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | make_twitter_request | def make_twitter_request(url, user_id, params={}, request_type='GET'):
""" Generically make a request to twitter API using a particular user's authorization """
if request_type == "GET":
return requests.get(url, auth=get_twitter_auth(user_id), params=params)
elif request_type == "POST":
retu... | python | def make_twitter_request(url, user_id, params={}, request_type='GET'):
""" Generically make a request to twitter API using a particular user's authorization """
if request_type == "GET":
return requests.get(url, auth=get_twitter_auth(user_id), params=params)
elif request_type == "POST":
retu... | [
"def",
"make_twitter_request",
"(",
"url",
",",
"user_id",
",",
"params",
"=",
"{",
"}",
",",
"request_type",
"=",
"'GET'",
")",
":",
"if",
"request_type",
"==",
"\"GET\"",
":",
"return",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"get_twitter... | Generically make a request to twitter API using a particular user's authorization | [
"Generically",
"make",
"a",
"request",
"to",
"twitter",
"API",
"using",
"a",
"particular",
"user",
"s",
"authorization"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L333-L338 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | geo_search | def geo_search(user_id, search_location):
"""
Search for a location - free form
"""
url = "https://api.twitter.com/1.1/geo/search.json"
params = {"query" : search_location }
response = make_twitter_request(url, user_id, params).json()
return response | python | def geo_search(user_id, search_location):
"""
Search for a location - free form
"""
url = "https://api.twitter.com/1.1/geo/search.json"
params = {"query" : search_location }
response = make_twitter_request(url, user_id, params).json()
return response | [
"def",
"geo_search",
"(",
"user_id",
",",
"search_location",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/geo/search.json\"",
"params",
"=",
"{",
"\"query\"",
":",
"search_location",
"}",
"response",
"=",
"make_twitter_request",
"(",
"url",
",",
"user_id",
"... | Search for a location - free form | [
"Search",
"for",
"a",
"location",
"-",
"free",
"form"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L350-L357 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | read_out_tweets | def read_out_tweets(processed_tweets, speech_convertor=None):
"""
Input - list of processed 'Tweets'
output - list of spoken responses
"""
return ["tweet number {num} by {user}. {text}.".format(num=index+1, user=user, text=text)
for index, (user, text) in enumerate(processed_tweets)] | python | def read_out_tweets(processed_tweets, speech_convertor=None):
"""
Input - list of processed 'Tweets'
output - list of spoken responses
"""
return ["tweet number {num} by {user}. {text}.".format(num=index+1, user=user, text=text)
for index, (user, text) in enumerate(processed_tweets)] | [
"def",
"read_out_tweets",
"(",
"processed_tweets",
",",
"speech_convertor",
"=",
"None",
")",
":",
"return",
"[",
"\"tweet number {num} by {user}. {text}.\"",
".",
"format",
"(",
"num",
"=",
"index",
"+",
"1",
",",
"user",
"=",
"user",
",",
"text",
"=",
"text"... | Input - list of processed 'Tweets'
output - list of spoken responses | [
"Input",
"-",
"list",
"of",
"processed",
"Tweets",
"output",
"-",
"list",
"of",
"spoken",
"responses"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L374-L380 |
anjishnu/ask-alexa-pykit | examples/twitter/twitter.py | search_for_tweets_about | def search_for_tweets_about(user_id, params):
""" Search twitter API """
url = "https://api.twitter.com/1.1/search/tweets.json"
response = make_twitter_request(url, user_id, params)
return process_tweets(response.json()["statuses"]) | python | def search_for_tweets_about(user_id, params):
""" Search twitter API """
url = "https://api.twitter.com/1.1/search/tweets.json"
response = make_twitter_request(url, user_id, params)
return process_tweets(response.json()["statuses"]) | [
"def",
"search_for_tweets_about",
"(",
"user_id",
",",
"params",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/search/tweets.json\"",
"response",
"=",
"make_twitter_request",
"(",
"url",
",",
"user_id",
",",
"params",
")",
"return",
"process_tweets",
"(",
"resp... | Search twitter API | [
"Search",
"twitter",
"API"
] | train | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L417-L421 |
federico123579/Trading212-API | tradingAPI/saver.py | Saver.add_val | def add_val(self, val):
"""add value in form of dict"""
if not isinstance(val, type({})):
raise ValueError(type({}))
self.read()
self.config.update(val)
self.save() | python | def add_val(self, val):
"""add value in form of dict"""
if not isinstance(val, type({})):
raise ValueError(type({}))
self.read()
self.config.update(val)
self.save() | [
"def",
"add_val",
"(",
"self",
",",
"val",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"type",
"(",
"{",
"}",
")",
")",
":",
"raise",
"ValueError",
"(",
"type",
"(",
"{",
"}",
")",
")",
"self",
".",
"read",
"(",
")",
"self",
".",
"c... | add value in form of dict | [
"add",
"value",
"in",
"form",
"of",
"dict"
] | train | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/saver.py#L55-L61 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/mesh.py | read_mesh | def read_mesh(fname):
"""Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
... | python | def read_mesh(fname):
"""Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
... | [
"def",
"read_mesh",
"(",
"fname",
")",
":",
"# Check format",
"fmt",
"=",
"op",
".",
"splitext",
"(",
"fname",
")",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"if",
"fmt",
"==",
"'.gz'",
":",
"fmt",
"=",
"op",
".",
"splitext",
"(",
"op",
".",
"splite... | Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
Triangle face definit... | [
"Read",
"mesh",
"data",
"from",
"file",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/mesh.py#L13-L43 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/mesh.py | write_mesh | def write_mesh(fname, vertices, faces, normals, texcoords, name='',
format='obj', overwrite=False, reshape_faces=True):
""" Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
face... | python | def write_mesh(fname, vertices, faces, normals, texcoords, name='',
format='obj', overwrite=False, reshape_faces=True):
""" Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
face... | [
"def",
"write_mesh",
"(",
"fname",
",",
"vertices",
",",
"faces",
",",
"normals",
",",
"texcoords",
",",
"name",
"=",
"''",
",",
"format",
"=",
"'obj'",
",",
"overwrite",
"=",
"False",
",",
"reshape_faces",
"=",
"True",
")",
":",
"# Check file",
"if",
... | Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
faces : array | None
Triangle face definitions.
normals : array
Normals for the mesh.
texcoords : array | None
Text... | [
"Write",
"mesh",
"data",
"to",
"file",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/mesh.py#L46-L80 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/backends/_pyglet.py | _set_config | def _set_config(config):
"""Set gl configuration"""
pyglet_config = pyglet.gl.Config()
pyglet_config.red_size = config['red_size']
pyglet_config.green_size = config['green_size']
pyglet_config.blue_size = config['blue_size']
pyglet_config.alpha_size = config['alpha_size']
pyglet_config.acc... | python | def _set_config(config):
"""Set gl configuration"""
pyglet_config = pyglet.gl.Config()
pyglet_config.red_size = config['red_size']
pyglet_config.green_size = config['green_size']
pyglet_config.blue_size = config['blue_size']
pyglet_config.alpha_size = config['alpha_size']
pyglet_config.acc... | [
"def",
"_set_config",
"(",
"config",
")",
":",
"pyglet_config",
"=",
"pyglet",
".",
"gl",
".",
"Config",
"(",
")",
"pyglet_config",
".",
"red_size",
"=",
"config",
"[",
"'red_size'",
"]",
"pyglet_config",
".",
"green_size",
"=",
"config",
"[",
"'green_size'"... | Set gl configuration | [
"Set",
"gl",
"configuration"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/backends/_pyglet.py#L118-L137 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/program.py | Program.set_shaders | def set_shaders(self, vert, frag):
""" Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders.
"""
if not vert or not frag:
raise... | python | def set_shaders(self, vert, frag):
""" Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders.
"""
if not vert or not frag:
raise... | [
"def",
"set_shaders",
"(",
"self",
",",
"vert",
",",
"frag",
")",
":",
"if",
"not",
"vert",
"or",
"not",
"frag",
":",
"raise",
"ValueError",
"(",
"'Vertex and fragment code must both be non-empty'",
")",
"# pre-process shader code for #include directives",
"vert",
","... | Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders. | [
"Set",
"the",
"vertex",
"and",
"fragment",
"shaders",
".",
"Parameters",
"----------",
"vert",
":",
"str",
"Source",
"code",
"for",
"vertex",
"shader",
".",
"frag",
":",
"str",
"Source",
"code",
"for",
"fragment",
"shaders",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L134-L159 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/program.py | Program._parse_variables_from_code | def _parse_variables_from_code(self):
""" Parse uniforms, attributes and varyings from the source code.
"""
# Get one string of code with comments removed
code = '\n\n'.join(self._shaders)
code = re.sub(r'(.*)(//.*)', r'\1', code, re.M)
# Regexp to look ... | python | def _parse_variables_from_code(self):
""" Parse uniforms, attributes and varyings from the source code.
"""
# Get one string of code with comments removed
code = '\n\n'.join(self._shaders)
code = re.sub(r'(.*)(//.*)', r'\1', code, re.M)
# Regexp to look ... | [
"def",
"_parse_variables_from_code",
"(",
"self",
")",
":",
"# Get one string of code with comments removed",
"code",
"=",
"'\\n\\n'",
".",
"join",
"(",
"self",
".",
"_shaders",
")",
"code",
"=",
"re",
".",
"sub",
"(",
"r'(.*)(//.*)'",
",",
"r'\\1'",
",",
"code"... | Parse uniforms, attributes and varyings from the source code. | [
"Parse",
"uniforms",
"attributes",
"and",
"varyings",
"from",
"the",
"source",
"code",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L184-L222 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/program.py | Program.bind | def bind(self, data):
""" Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL.
"""
# Check
if not isin... | python | def bind(self, data):
""" Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL.
"""
# Check
if not isin... | [
"def",
"bind",
"(",
"self",
",",
"data",
")",
":",
"# Check",
"if",
"not",
"isinstance",
"(",
"data",
",",
"VertexBuffer",
")",
":",
"raise",
"ValueError",
"(",
"'Program.bind() requires a VertexBuffer.'",
")",
"# Apply",
"for",
"name",
"in",
"data",
".",
"d... | Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL. | [
"Bind",
"a",
"VertexBuffer",
"that",
"has",
"structured",
"data",
"Parameters",
"----------",
"data",
":",
"VertexBuffer",
"The",
"vertex",
"buffer",
"to",
"bind",
".",
"The",
"field",
"names",
"of",
"the",
"array",
"are",
"mapped",
"to",
"attribute",
"names",... | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L224-L238 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/program.py | Program._process_pending_variables | def _process_pending_variables(self):
""" Try to apply the variables that were set but not known yet.
"""
# Clear our list of pending variables
self._pending_variables, pending = {}, self._pending_variables
# Try to apply it. On failure, it will be added again
for name, d... | python | def _process_pending_variables(self):
""" Try to apply the variables that were set but not known yet.
"""
# Clear our list of pending variables
self._pending_variables, pending = {}, self._pending_variables
# Try to apply it. On failure, it will be added again
for name, d... | [
"def",
"_process_pending_variables",
"(",
"self",
")",
":",
"# Clear our list of pending variables",
"self",
".",
"_pending_variables",
",",
"pending",
"=",
"{",
"}",
",",
"self",
".",
"_pending_variables",
"# Try to apply it. On failure, it will be added again",
"for",
"na... | Try to apply the variables that were set but not known yet. | [
"Try",
"to",
"apply",
"the",
"variables",
"that",
"were",
"set",
"but",
"not",
"known",
"yet",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L240-L247 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/program.py | Program.draw | def draw(self, mode='triangles', indices=None, check_error=True):
""" Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
... | python | def draw(self, mode='triangles', indices=None, check_error=True):
""" Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
... | [
"def",
"draw",
"(",
"self",
",",
"mode",
"=",
"'triangles'",
",",
"indices",
"=",
"None",
",",
"check_error",
"=",
"True",
")",
":",
"# Invalidate buffer (data has already been sent)",
"self",
".",
"_buffer",
"=",
"None",
"# Check if mode is valid",
"mode",
"=",
... | Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
indices : array
Array of indices to draw.
check_error:
... | [
"Draw",
"the",
"attribute",
"arrays",
"in",
"the",
"specified",
"mode",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L404-L470 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/surface_plot.py | SurfacePlotVisual.set_data | def set_data(self, x=None, y=None, z=None, colors=None):
"""Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
... | python | def set_data(self, x=None, y=None, z=None, colors=None):
"""Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
... | [
"def",
"set_data",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"z",
"=",
"None",
",",
"colors",
"=",
"None",
")",
":",
"if",
"x",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_x",
"is",
"None",
"or",
"len",
"(",
"x",
")... | Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
y : ndarray | None
1D array of values specifying the ... | [
"Update",
"the",
"data",
"in",
"this",
"surface",
"plot",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/surface_plot.py#L52-L135 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | ChainTransform.simplified | def simplified(self):
"""A simplified representation of the same transformation.
"""
if self._simplified is None:
self._simplified = SimplifiedChainTransform(self)
return self._simplified | python | def simplified(self):
"""A simplified representation of the same transformation.
"""
if self._simplified is None:
self._simplified = SimplifiedChainTransform(self)
return self._simplified | [
"def",
"simplified",
"(",
"self",
")",
":",
"if",
"self",
".",
"_simplified",
"is",
"None",
":",
"self",
".",
"_simplified",
"=",
"SimplifiedChainTransform",
"(",
"self",
")",
"return",
"self",
".",
"_simplified"
] | A simplified representation of the same transformation. | [
"A",
"simplified",
"representation",
"of",
"the",
"same",
"transformation",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L99-L104 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | ChainTransform.map | def map(self, coords):
"""Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in reversed(self.transforms):
coords = tr.map(coo... | python | def map(self, coords):
"""Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in reversed(self.transforms):
coords = tr.map(coo... | [
"def",
"map",
"(",
"self",
",",
"coords",
")",
":",
"for",
"tr",
"in",
"reversed",
"(",
"self",
".",
"transforms",
")",
":",
"coords",
"=",
"tr",
".",
"map",
"(",
"coords",
")",
"return",
"coords"
] | Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates. | [
"Map",
"coordinates"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L134-L149 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | ChainTransform.imap | def imap(self, coords):
"""Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in self.transforms:
coords = tr.... | python | def imap(self, coords):
"""Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in self.transforms:
coords = tr.... | [
"def",
"imap",
"(",
"self",
",",
"coords",
")",
":",
"for",
"tr",
"in",
"self",
".",
"transforms",
":",
"coords",
"=",
"tr",
".",
"imap",
"(",
"coords",
")",
"return",
"coords"
] | Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates. | [
"Inverse",
"map",
"coordinates"
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L151-L166 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | ChainTransform.append | def append(self, tr):
"""
Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.append(tr)
tr.changed.connect(self._subtr_changed)
self._rebuild_shaders... | python | def append(self, tr):
"""
Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.append(tr)
tr.changed.connect(self._subtr_changed)
self._rebuild_shaders... | [
"def",
"append",
"(",
"self",
",",
"tr",
")",
":",
"self",
".",
"transforms",
".",
"append",
"(",
"tr",
")",
"tr",
".",
"changed",
".",
"connect",
"(",
"self",
".",
"_subtr_changed",
")",
"self",
".",
"_rebuild_shaders",
"(",
")",
"self",
".",
"updat... | Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use. | [
"Add",
"a",
"new",
"transform",
"to",
"the",
"end",
"of",
"this",
"chain",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L181-L193 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | ChainTransform.prepend | def prepend(self, tr):
"""
Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.insert(0, tr)
tr.changed.connect(self._subtr_changed)
self._rebui... | python | def prepend(self, tr):
"""
Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.insert(0, tr)
tr.changed.connect(self._subtr_changed)
self._rebui... | [
"def",
"prepend",
"(",
"self",
",",
"tr",
")",
":",
"self",
".",
"transforms",
".",
"insert",
"(",
"0",
",",
"tr",
")",
"tr",
".",
"changed",
".",
"connect",
"(",
"self",
".",
"_subtr_changed",
")",
"self",
".",
"_rebuild_shaders",
"(",
")",
"self",
... | Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use. | [
"Add",
"a",
"new",
"transform",
"to",
"the",
"beginning",
"of",
"this",
"chain",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L195-L207 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | SimplifiedChainTransform.source_changed | def source_changed(self, event):
"""Generate a simplified chain by joining adjacent transforms.
"""
# bail out early if the chain is empty
transforms = self._chain.transforms[:]
if len(transforms) == 0:
self.transforms = []
return
# If the... | python | def source_changed(self, event):
"""Generate a simplified chain by joining adjacent transforms.
"""
# bail out early if the chain is empty
transforms = self._chain.transforms[:]
if len(transforms) == 0:
self.transforms = []
return
# If the... | [
"def",
"source_changed",
"(",
"self",
",",
"event",
")",
":",
"# bail out early if the chain is empty",
"transforms",
"=",
"self",
".",
"_chain",
".",
"transforms",
"[",
":",
"]",
"if",
"len",
"(",
"transforms",
")",
"==",
"0",
":",
"self",
".",
"transforms"... | Generate a simplified chain by joining adjacent transforms. | [
"Generate",
"a",
"simplified",
"chain",
"by",
"joining",
"adjacent",
"transforms",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L251-L295 |
dlecocq/nsq-py | nsq/util.py | pack_iterable | def pack_iterable(messages):
'''Pack an iterable of messages in the TCP protocol format'''
# [ 4-byte body size ]
# [ 4-byte num messages ]
# [ 4-byte message #1 size ][ N-byte binary data ]
# ... (repeated <num_messages> times)
return pack_string(
struct.pack('>l', len(messages)) +... | python | def pack_iterable(messages):
'''Pack an iterable of messages in the TCP protocol format'''
# [ 4-byte body size ]
# [ 4-byte num messages ]
# [ 4-byte message #1 size ][ N-byte binary data ]
# ... (repeated <num_messages> times)
return pack_string(
struct.pack('>l', len(messages)) +... | [
"def",
"pack_iterable",
"(",
"messages",
")",
":",
"# [ 4-byte body size ]",
"# [ 4-byte num messages ]",
"# [ 4-byte message #1 size ][ N-byte binary data ]",
"# ... (repeated <num_messages> times)",
"return",
"pack_string",
"(",
"struct",
".",
"pack",
"(",
"'>l'",
",",
"... | Pack an iterable of messages in the TCP protocol format | [
"Pack",
"an",
"iterable",
"of",
"messages",
"in",
"the",
"TCP",
"protocol",
"format"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L12-L20 |
dlecocq/nsq-py | nsq/util.py | hexify | def hexify(message):
'''Print out printable characters, but others in hex'''
import string
hexified = []
for char in message:
if (char in '\n\r \t') or (char not in string.printable):
hexified.append('\\x%02x' % ord(char))
else:
hexified.append(char)
return ''... | python | def hexify(message):
'''Print out printable characters, but others in hex'''
import string
hexified = []
for char in message:
if (char in '\n\r \t') or (char not in string.printable):
hexified.append('\\x%02x' % ord(char))
else:
hexified.append(char)
return ''... | [
"def",
"hexify",
"(",
"message",
")",
":",
"import",
"string",
"hexified",
"=",
"[",
"]",
"for",
"char",
"in",
"message",
":",
"if",
"(",
"char",
"in",
"'\\n\\r \\t'",
")",
"or",
"(",
"char",
"not",
"in",
"string",
".",
"printable",
")",
":",
"hexifi... | Print out printable characters, but others in hex | [
"Print",
"out",
"printable",
"characters",
"but",
"others",
"in",
"hex"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L31-L40 |
dlecocq/nsq-py | nsq/util.py | distribute | def distribute(total, objects):
'''Generator for (count, object) tuples that distributes count evenly among
the provided objects'''
for index, obj in enumerate(objects):
start = (index * total) / len(objects)
stop = ((index + 1) * total) / len(objects)
yield (stop - start, obj) | python | def distribute(total, objects):
'''Generator for (count, object) tuples that distributes count evenly among
the provided objects'''
for index, obj in enumerate(objects):
start = (index * total) / len(objects)
stop = ((index + 1) * total) / len(objects)
yield (stop - start, obj) | [
"def",
"distribute",
"(",
"total",
",",
"objects",
")",
":",
"for",
"index",
",",
"obj",
"in",
"enumerate",
"(",
"objects",
")",
":",
"start",
"=",
"(",
"index",
"*",
"total",
")",
"/",
"len",
"(",
"objects",
")",
"stop",
"=",
"(",
"(",
"index",
... | Generator for (count, object) tuples that distributes count evenly among
the provided objects | [
"Generator",
"for",
"(",
"count",
"object",
")",
"tuples",
"that",
"distributes",
"count",
"evenly",
"among",
"the",
"provided",
"objects"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L43-L49 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.clean | def clean(self):
"""Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again.
"""
for _, item in self.queue.items():
... | python | def clean(self):
"""Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again.
"""
for _, item in self.queue.items():
... | [
"def",
"clean",
"(",
"self",
")",
":",
"for",
"_",
",",
"item",
"in",
"self",
".",
"queue",
".",
"items",
"(",
")",
":",
"if",
"item",
"[",
"'status'",
"]",
"in",
"[",
"'paused'",
",",
"'running'",
",",
"'stopping'",
",",
"'killing'",
"]",
":",
"... | Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again. | [
"Clean",
"queue",
"items",
"from",
"a",
"previous",
"session",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L56-L67 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.clear | def clear(self):
"""Remove all completed tasks from the queue."""
for key in list(self.queue.keys()):
if self.queue[key]['status'] in ['done', 'failed']:
del self.queue[key]
self.write() | python | def clear(self):
"""Remove all completed tasks from the queue."""
for key in list(self.queue.keys()):
if self.queue[key]['status'] in ['done', 'failed']:
del self.queue[key]
self.write() | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"queue",
".",
"keys",
"(",
")",
")",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"in",
"[",
"'done'",
",",
"'failed'",
"]",
":",
... | Remove all completed tasks from the queue. | [
"Remove",
"all",
"completed",
"tasks",
"from",
"the",
"queue",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L69-L74 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.next | def next(self):
"""Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found.
"""
smallest = None
for key in self.queue.keys():
... | python | def next(self):
"""Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found.
"""
smallest = None
for key in self.queue.keys():
... | [
"def",
"next",
"(",
"self",
")",
":",
"smallest",
"=",
"None",
"for",
"key",
"in",
"self",
".",
"queue",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"==",
"'queued'",
":",
"if",
"smallest",
"is",... | Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found. | [
"Get",
"the",
"next",
"processable",
"item",
"of",
"the",
"queue",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L76-L91 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.read | def read(self):
"""Read the queue of the last pueue session or set `self.queue = {}`."""
queue_path = os.path.join(self.config_dir, 'queue')
if os.path.exists(queue_path):
queue_file = open(queue_path, 'rb')
try:
self.queue = pickle.load(queue_file)
... | python | def read(self):
"""Read the queue of the last pueue session or set `self.queue = {}`."""
queue_path = os.path.join(self.config_dir, 'queue')
if os.path.exists(queue_path):
queue_file = open(queue_path, 'rb')
try:
self.queue = pickle.load(queue_file)
... | [
"def",
"read",
"(",
"self",
")",
":",
"queue_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'queue'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"queue_path",
")",
":",
"queue_file",
"=",
"open",
"(",
"queu... | Read the queue of the last pueue session or set `self.queue = {}`. | [
"Read",
"the",
"queue",
"of",
"the",
"last",
"pueue",
"session",
"or",
"set",
"self",
".",
"queue",
"=",
"{}",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L93-L106 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.write | def write(self):
"""Write the current queue to a file. We need this to continue an earlier session."""
queue_path = os.path.join(self.config_dir, 'queue')
queue_file = open(queue_path, 'wb+')
try:
pickle.dump(self.queue, queue_file, -1)
except Exception:
p... | python | def write(self):
"""Write the current queue to a file. We need this to continue an earlier session."""
queue_path = os.path.join(self.config_dir, 'queue')
queue_file = open(queue_path, 'wb+')
try:
pickle.dump(self.queue, queue_file, -1)
except Exception:
p... | [
"def",
"write",
"(",
"self",
")",
":",
"queue_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'queue'",
")",
"queue_file",
"=",
"open",
"(",
"queue_path",
",",
"'wb+'",
")",
"try",
":",
"pickle",
".",
"dump",
"(",
... | Write the current queue to a file. We need this to continue an earlier session. | [
"Write",
"the",
"current",
"queue",
"to",
"a",
"file",
".",
"We",
"need",
"this",
"to",
"continue",
"an",
"earlier",
"session",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L108-L116 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.add_new | def add_new(self, command):
"""Add a new entry to the queue."""
self.queue[self.next_key] = command
self.queue[self.next_key]['status'] = 'queued'
self.queue[self.next_key]['returncode'] = ''
self.queue[self.next_key]['stdout'] = ''
self.queue[self.next_key]['stderr'] = '... | python | def add_new(self, command):
"""Add a new entry to the queue."""
self.queue[self.next_key] = command
self.queue[self.next_key]['status'] = 'queued'
self.queue[self.next_key]['returncode'] = ''
self.queue[self.next_key]['stdout'] = ''
self.queue[self.next_key]['stderr'] = '... | [
"def",
"add_new",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"queue",
"[",
"self",
".",
"next_key",
"]",
"=",
"command",
"self",
".",
"queue",
"[",
"self",
".",
"next_key",
"]",
"[",
"'status'",
"]",
"=",
"'queued'",
"self",
".",
"queue",
... | Add a new entry to the queue. | [
"Add",
"a",
"new",
"entry",
"to",
"the",
"queue",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L118-L129 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.remove | def remove(self, key):
"""Remove a key from the queue, return `False` if no such key exists."""
if key in self.queue:
del self.queue[key]
self.write()
return True
return False | python | def remove(self, key):
"""Remove a key from the queue, return `False` if no such key exists."""
if key in self.queue:
del self.queue[key]
self.write()
return True
return False | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"queue",
":",
"del",
"self",
".",
"queue",
"[",
"key",
"]",
"self",
".",
"write",
"(",
")",
"return",
"True",
"return",
"False"
] | Remove a key from the queue, return `False` if no such key exists. | [
"Remove",
"a",
"key",
"from",
"the",
"queue",
"return",
"False",
"if",
"no",
"such",
"key",
"exists",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L131-L137 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.restart | def restart(self, key):
"""Restart a previously finished entry."""
if key in self.queue:
if self.queue[key]['status'] in ['failed', 'done']:
new_entry = {'command': self.queue[key]['command'],
'path': self.queue[key]['path']}
self.... | python | def restart(self, key):
"""Restart a previously finished entry."""
if key in self.queue:
if self.queue[key]['status'] in ['failed', 'done']:
new_entry = {'command': self.queue[key]['command'],
'path': self.queue[key]['path']}
self.... | [
"def",
"restart",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"queue",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"in",
"[",
"'failed'",
",",
"'done'",
"]",
":",
"new_entry",
"=",
"{",
"'command... | Restart a previously finished entry. | [
"Restart",
"a",
"previously",
"finished",
"entry",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L139-L148 |
Nukesor/pueue | pueue/daemon/queue.py | Queue.switch | def switch(self, first, second):
"""Switch two entries in the queue. Return False if an entry doesn't exist."""
allowed_states = ['queued', 'stashed']
if first in self.queue and second in self.queue \
and self.queue[first]['status'] in allowed_states\
and self.que... | python | def switch(self, first, second):
"""Switch two entries in the queue. Return False if an entry doesn't exist."""
allowed_states = ['queued', 'stashed']
if first in self.queue and second in self.queue \
and self.queue[first]['status'] in allowed_states\
and self.que... | [
"def",
"switch",
"(",
"self",
",",
"first",
",",
"second",
")",
":",
"allowed_states",
"=",
"[",
"'queued'",
",",
"'stashed'",
"]",
"if",
"first",
"in",
"self",
".",
"queue",
"and",
"second",
"in",
"self",
".",
"queue",
"and",
"self",
".",
"queue",
"... | Switch two entries in the queue. Return False if an entry doesn't exist. | [
"Switch",
"two",
"entries",
"in",
"the",
"queue",
".",
"Return",
"False",
"if",
"an",
"entry",
"doesn",
"t",
"exist",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L150-L162 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.