repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py | image_to_base64 | def image_to_base64(image):
"""
Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png imag... | python | def image_to_base64(image):
"""
Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png imag... | [
"def",
"image_to_base64",
"(",
"image",
")",
":",
"ax",
"=",
"image",
".",
"axes",
"binary_buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"# image is saved in axes coordinates: we need to temporarily",
"# set the correct limits to get the correct image",
"lim",
"=",
"ax",
... | Convert a matplotlib image to a base64 png representation
Parameters
----------
image : matplotlib image object
The image to be converted.
Returns
-------
image_base64 : string
The UTF8-encoded base64 string representation of the png image. | [
"Convert",
"a",
"matplotlib",
"image",
"to",
"a",
"base64",
"png",
"representation"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplutils.py#L328-L353 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/inputhook.py | set_interactive | def set_interactive(enabled=True, app=None):
"""Activate the IPython hook for VisPy. If the app is not specified, the
default is used.
"""
if enabled:
inputhook_manager.enable_gui('vispy', app)
else:
inputhook_manager.disable_gui() | python | def set_interactive(enabled=True, app=None):
"""Activate the IPython hook for VisPy. If the app is not specified, the
default is used.
"""
if enabled:
inputhook_manager.enable_gui('vispy', app)
else:
inputhook_manager.disable_gui() | [
"def",
"set_interactive",
"(",
"enabled",
"=",
"True",
",",
"app",
"=",
"None",
")",
":",
"if",
"enabled",
":",
"inputhook_manager",
".",
"enable_gui",
"(",
"'vispy'",
",",
"app",
")",
"else",
":",
"inputhook_manager",
".",
"disable_gui",
"(",
")"
] | Activate the IPython hook for VisPy. If the app is not specified, the
default is used. | [
"Activate",
"the",
"IPython",
"hook",
"for",
"VisPy",
".",
"If",
"the",
"app",
"is",
"not",
"specified",
"the",
"default",
"is",
"used",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/inputhook.py#L17-L24 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._resize_buffers | def _resize_buffers(self, font_scale):
"""Resize buffers only if necessary"""
new_sizes = (font_scale,) + self.size
if new_sizes == self._current_sizes: # don't need resize
return
self._n_rows = int(max(self.size[1] /
(self._char_height * font_... | python | def _resize_buffers(self, font_scale):
"""Resize buffers only if necessary"""
new_sizes = (font_scale,) + self.size
if new_sizes == self._current_sizes: # don't need resize
return
self._n_rows = int(max(self.size[1] /
(self._char_height * font_... | [
"def",
"_resize_buffers",
"(",
"self",
",",
"font_scale",
")",
":",
"new_sizes",
"=",
"(",
"font_scale",
",",
")",
"+",
"self",
".",
"size",
"if",
"new_sizes",
"==",
"self",
".",
"_current_sizes",
":",
"# don't need resize",
"return",
"self",
".",
"_n_rows",... | Resize buffers only if necessary | [
"Resize",
"buffers",
"only",
"if",
"necessary"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L245-L268 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual.clear | def clear(self):
"""Clear the console"""
if hasattr(self, '_bytes_012'):
self._bytes_012.fill(0)
self._bytes_345.fill(0)
self._text_lines = [] * self._n_rows
self._pending_writes = [] | python | def clear(self):
"""Clear the console"""
if hasattr(self, '_bytes_012'):
self._bytes_012.fill(0)
self._bytes_345.fill(0)
self._text_lines = [] * self._n_rows
self._pending_writes = [] | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_bytes_012'",
")",
":",
"self",
".",
"_bytes_012",
".",
"fill",
"(",
"0",
")",
"self",
".",
"_bytes_345",
".",
"fill",
"(",
"0",
")",
"self",
".",
"_text_lines",
"=",
"[",
... | Clear the console | [
"Clear",
"the",
"console"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L292-L298 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual.write | def write(self, text='', wrap=True):
"""Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages w... | python | def write(self, text='', wrap=True):
"""Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages w... | [
"def",
"write",
"(",
"self",
",",
"text",
"=",
"''",
",",
"wrap",
"=",
"True",
")",
":",
"# Clear line",
"if",
"not",
"isinstance",
"(",
"text",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'text must be a string'",
")",
"# ensure we only have ... | Write text and scroll
Parameters
----------
text : str
Text to write. ``''`` can be used for a blank line, as a newline
is automatically added to the end of each line.
wrap : str
If True, long messages will be wrapped to span multiple lines. | [
"Write",
"text",
"and",
"scroll"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L300-L317 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._do_pending_writes | def _do_pending_writes(self):
"""Do any pending text writes"""
for text, wrap in self._pending_writes:
# truncate in case of *really* long messages
text = text[-self._n_cols*self._n_rows:]
text = text.split('\n')
text = [t if len(t) > 0 else '' for t in te... | python | def _do_pending_writes(self):
"""Do any pending text writes"""
for text, wrap in self._pending_writes:
# truncate in case of *really* long messages
text = text[-self._n_cols*self._n_rows:]
text = text.split('\n')
text = [t if len(t) > 0 else '' for t in te... | [
"def",
"_do_pending_writes",
"(",
"self",
")",
":",
"for",
"text",
",",
"wrap",
"in",
"self",
".",
"_pending_writes",
":",
"# truncate in case of *really* long messages",
"text",
"=",
"text",
"[",
"-",
"self",
".",
"_n_cols",
"*",
"self",
".",
"_n_rows",
":",
... | Do any pending text writes | [
"Do",
"any",
"pending",
"text",
"writes"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L319-L338 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/console.py | ConsoleVisual._insert_text_buf | def _insert_text_buf(self, line, idx):
"""Insert text into bytes buffers"""
self._bytes_012[idx] = 0
self._bytes_345[idx] = 0
# Crop text if necessary
I = np.array([ord(c) - 32 for c in line[:self._n_cols]])
I = np.clip(I, 0, len(__font_6x8__)-1)
if len(I) > 0:
... | python | def _insert_text_buf(self, line, idx):
"""Insert text into bytes buffers"""
self._bytes_012[idx] = 0
self._bytes_345[idx] = 0
# Crop text if necessary
I = np.array([ord(c) - 32 for c in line[:self._n_cols]])
I = np.clip(I, 0, len(__font_6x8__)-1)
if len(I) > 0:
... | [
"def",
"_insert_text_buf",
"(",
"self",
",",
"line",
",",
"idx",
")",
":",
"self",
".",
"_bytes_012",
"[",
"idx",
"]",
"=",
"0",
"self",
".",
"_bytes_345",
"[",
"idx",
"]",
"=",
"0",
"# Crop text if necessary",
"I",
"=",
"np",
".",
"array",
"(",
"[",... | Insert text into bytes buffers | [
"Insert",
"text",
"into",
"bytes",
"buffers"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L340-L350 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function.replace | def replace(self, str1, str2):
""" Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
... | python | def replace(self, str1, str2):
""" Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
... | [
"def",
"replace",
"(",
"self",
",",
"str1",
",",
"str2",
")",
":",
"if",
"str2",
"!=",
"self",
".",
"_replacements",
".",
"get",
"(",
"str1",
",",
"None",
")",
":",
"self",
".",
"_replacements",
"[",
"str1",
"]",
"=",
"str2",
"self",
".",
"changed"... | Set verbatim code replacement
It is strongly recommended to use function['$foo'] = 'bar' where
possible because template variables are less likely to changed
than the code itself in future versions of vispy.
Parameters
----------
str1 : str
S... | [
"Set",
"verbatim",
"code",
"replacement",
"It",
"is",
"strongly",
"recommended",
"to",
"use",
"function",
"[",
"$foo",
"]",
"=",
"bar",
"where",
"possible",
"because",
"template",
"variables",
"are",
"less",
"likely",
"to",
"changed",
"than",
"the",
"code",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L378-L394 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._parse_template_vars | def _parse_template_vars(self):
""" find all template variables in self._code, excluding the
function name.
"""
template_vars = set()
for var in parsing.find_template_variables(self._code):
var = var.lstrip('$')
if var == self.name:
contin... | python | def _parse_template_vars(self):
""" find all template variables in self._code, excluding the
function name.
"""
template_vars = set()
for var in parsing.find_template_variables(self._code):
var = var.lstrip('$')
if var == self.name:
contin... | [
"def",
"_parse_template_vars",
"(",
"self",
")",
":",
"template_vars",
"=",
"set",
"(",
")",
"for",
"var",
"in",
"parsing",
".",
"find_template_variables",
"(",
"self",
".",
"_code",
")",
":",
"var",
"=",
"var",
".",
"lstrip",
"(",
"'$'",
")",
"if",
"v... | find all template variables in self._code, excluding the
function name. | [
"find",
"all",
"template",
"variables",
"in",
"self",
".",
"_code",
"excluding",
"the",
"function",
"name",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L399-L412 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._get_replaced_code | def _get_replaced_code(self, names):
""" Return code, with new name, expressions, and replacements applied.
"""
code = self._code
# Modify name
fname = names[self]
code = code.replace(" " + self.name + "(", " " + fname + "(")
# Apply string replacements ... | python | def _get_replaced_code(self, names):
""" Return code, with new name, expressions, and replacements applied.
"""
code = self._code
# Modify name
fname = names[self]
code = code.replace(" " + self.name + "(", " " + fname + "(")
# Apply string replacements ... | [
"def",
"_get_replaced_code",
"(",
"self",
",",
"names",
")",
":",
"code",
"=",
"self",
".",
"_code",
"# Modify name",
"fname",
"=",
"names",
"[",
"self",
"]",
"code",
"=",
"code",
".",
"replace",
"(",
"\" \"",
"+",
"self",
".",
"name",
"+",
"\"(\"",
... | Return code, with new name, expressions, and replacements applied. | [
"Return",
"code",
"with",
"new",
"name",
"expressions",
"and",
"replacements",
"applied",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L414-L472 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | Function._clean_code | def _clean_code(self, code):
""" Return *code* with indentation and leading/trailing blank lines
removed.
"""
lines = code.split("\n")
min_indent = 100
for line in lines:
if line.strip() != "":
indent = len(line) - len(line.lstrip())
... | python | def _clean_code(self, code):
""" Return *code* with indentation and leading/trailing blank lines
removed.
"""
lines = code.split("\n")
min_indent = 100
for line in lines:
if line.strip() != "":
indent = len(line) - len(line.lstrip())
... | [
"def",
"_clean_code",
"(",
"self",
",",
"code",
")",
":",
"lines",
"=",
"code",
".",
"split",
"(",
"\"\\n\"",
")",
"min_indent",
"=",
"100",
"for",
"line",
"in",
"lines",
":",
"if",
"line",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"indent",
"=",
... | Return *code* with indentation and leading/trailing blank lines
removed. | [
"Return",
"*",
"code",
"*",
"with",
"indentation",
"and",
"leading",
"/",
"trailing",
"blank",
"lines",
"removed",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L480-L493 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | MainFunction.add_chain | def add_chain(self, var):
"""
Create a new ChainFunction and attach to $var.
"""
chain = FunctionChain(var, [])
self._chains[var] = chain
self[var] = chain | python | def add_chain(self, var):
"""
Create a new ChainFunction and attach to $var.
"""
chain = FunctionChain(var, [])
self._chains[var] = chain
self[var] = chain | [
"def",
"add_chain",
"(",
"self",
",",
"var",
")",
":",
"chain",
"=",
"FunctionChain",
"(",
"var",
",",
"[",
"]",
")",
"self",
".",
"_chains",
"[",
"var",
"]",
"=",
"chain",
"self",
"[",
"var",
"]",
"=",
"chain"
] | Create a new ChainFunction and attach to $var. | [
"Create",
"a",
"new",
"ChainFunction",
"and",
"attach",
"to",
"$var",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L540-L546 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.append | def append(self, function, update=True):
""" Append a new function to the end of this chain.
"""
self._funcs.append(function)
self._add_dep(function)
if update:
self._update() | python | def append(self, function, update=True):
""" Append a new function to the end of this chain.
"""
self._funcs.append(function)
self._add_dep(function)
if update:
self._update() | [
"def",
"append",
"(",
"self",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"append",
"(",
"function",
")",
"self",
".",
"_add_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
".",
"_update",
"(",
")"
] | Append a new function to the end of this chain. | [
"Append",
"a",
"new",
"function",
"to",
"the",
"end",
"of",
"this",
"chain",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L655-L661 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.insert | def insert(self, index, function, update=True):
""" Insert a new function into the chain at *index*.
"""
self._funcs.insert(index, function)
self._add_dep(function)
if update:
self._update() | python | def insert(self, index, function, update=True):
""" Insert a new function into the chain at *index*.
"""
self._funcs.insert(index, function)
self._add_dep(function)
if update:
self._update() | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"insert",
"(",
"index",
",",
"function",
")",
"self",
".",
"_add_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
... | Insert a new function into the chain at *index*. | [
"Insert",
"a",
"new",
"function",
"into",
"the",
"chain",
"at",
"*",
"index",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L673-L679 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | FunctionChain.remove | def remove(self, function, update=True):
""" Remove a function from the chain.
"""
self._funcs.remove(function)
self._remove_dep(function)
if update:
self._update() | python | def remove(self, function, update=True):
""" Remove a function from the chain.
"""
self._funcs.remove(function)
self._remove_dep(function)
if update:
self._update() | [
"def",
"remove",
"(",
"self",
",",
"function",
",",
"update",
"=",
"True",
")",
":",
"self",
".",
"_funcs",
".",
"remove",
"(",
"function",
")",
"self",
".",
"_remove_dep",
"(",
"function",
")",
"if",
"update",
":",
"self",
".",
"_update",
"(",
")"
] | Remove a function from the chain. | [
"Remove",
"a",
"function",
"from",
"the",
"chain",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L681-L687 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | StatementList.add | def add(self, item, position=5):
"""Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code.
"""
if item in self.items:
return
self.items[item] = position
... | python | def add(self, item, position=5):
"""Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code.
"""
if item in self.items:
return
self.items[item] = position
... | [
"def",
"add",
"(",
"self",
",",
"item",
",",
"position",
"=",
"5",
")",
":",
"if",
"item",
"in",
"self",
".",
"items",
":",
"return",
"self",
".",
"items",
"[",
"item",
"]",
"=",
"position",
"self",
".",
"_add_dep",
"(",
"item",
")",
"self",
".",... | Add an item to the list unless it is already present.
If the item is an expression, then a semicolon will be appended to it
in the final compiled code. | [
"Add",
"an",
"item",
"to",
"the",
"list",
"unless",
"it",
"is",
"already",
"present",
".",
"If",
"the",
"item",
"is",
"an",
"expression",
"then",
"a",
"semicolon",
"will",
"be",
"appended",
"to",
"it",
"in",
"the",
"final",
"compiled",
"code",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L748-L759 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/function.py | StatementList.remove | def remove(self, item):
"""Remove an item from the list.
"""
self.items.pop(item)
self._remove_dep(item)
self.order = None
self.changed(code_changed=True) | python | def remove(self, item):
"""Remove an item from the list.
"""
self.items.pop(item)
self._remove_dep(item)
self.order = None
self.changed(code_changed=True) | [
"def",
"remove",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"items",
".",
"pop",
"(",
"item",
")",
"self",
".",
"_remove_dep",
"(",
"item",
")",
"self",
".",
"order",
"=",
"None",
"self",
".",
"changed",
"(",
"code_changed",
"=",
"True",
")"
... | Remove an item from the list. | [
"Remove",
"an",
"item",
"from",
"the",
"list",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/function.py#L761-L767 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.faces | def faces(self):
"""Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces ... | python | def faces(self):
"""Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces ... | [
"def",
"faces",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_faces"
] | Return an array (Nf, 3) of vertex indexes, three per triangular
face in the mesh.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"(",
"Nf",
"3",
")",
"of",
"vertex",
"indexes",
"three",
"per",
"triangular",
"face",
"in",
"the",
"mesh",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L36-L49 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.vertices | def vertices(self):
"""Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
if self._vertices is None:
... | python | def vertices(self):
"""Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
if self._vertices is None:
... | [
"def",
"vertices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_vertices"
] | Return an array (Nf, 3) of vertices.
If only faces exist, the function computes the vertices and
returns them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"(",
"Nf",
"3",
")",
"of",
"vertices",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L60-L72 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.convex_hull | def convex_hull(self):
"""Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
... | python | def convex_hull(self):
"""Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None.
"""
if self._faces is None:
... | [
"def",
"convex_hull",
"(",
"self",
")",
":",
"if",
"self",
".",
"_faces",
"is",
"None",
":",
"if",
"self",
".",
"_vertices",
"is",
"None",
":",
"return",
"None",
"self",
".",
"triangulate",
"(",
")",
"return",
"self",
".",
"_convex_hull"
] | Return an array of vertex indexes representing the convex hull.
If faces have not been computed for this mesh, the function
computes them.
If no vertices or faces are specified, the function returns None. | [
"Return",
"an",
"array",
"of",
"vertex",
"indexes",
"representing",
"the",
"convex",
"hull",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L98-L109 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/polygon.py | PolygonData.triangulate | def triangulate(self):
"""
Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull.
"""
npts = self._vertices.shape[0]
if np.any(self._vertices[0] != self._vertices[1]):
# start != end, so edges must wrap around to... | python | def triangulate(self):
"""
Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull.
"""
npts = self._vertices.shape[0]
if np.any(self._vertices[0] != self._vertices[1]):
# start != end, so edges must wrap around to... | [
"def",
"triangulate",
"(",
"self",
")",
":",
"npts",
"=",
"self",
".",
"_vertices",
".",
"shape",
"[",
"0",
"]",
"if",
"np",
".",
"any",
"(",
"self",
".",
"_vertices",
"[",
"0",
"]",
"!=",
"self",
".",
"_vertices",
"[",
"1",
"]",
")",
":",
"# s... | Triangulates the set of vertices and stores the triangles in faces and
the convex hull in convex_hull. | [
"Triangulates",
"the",
"set",
"of",
"vertices",
"and",
"stores",
"the",
"triangles",
"in",
"faces",
"and",
"the",
"convex",
"hull",
"in",
"convex_hull",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/polygon.py#L111-L131 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/glsl/__init__.py | find | def find(name):
"""Locate a filename into the shader library."""
if op.exists(name):
return name
path = op.dirname(__file__) or '.'
paths = [path] + config['include_path']
for path in paths:
filename = op.abspath(op.join(path, name))
if op.exists(filename):
re... | python | def find(name):
"""Locate a filename into the shader library."""
if op.exists(name):
return name
path = op.dirname(__file__) or '.'
paths = [path] + config['include_path']
for path in paths:
filename = op.abspath(op.join(path, name))
if op.exists(filename):
re... | [
"def",
"find",
"(",
"name",
")",
":",
"if",
"op",
".",
"exists",
"(",
"name",
")",
":",
"return",
"name",
"path",
"=",
"op",
".",
"dirname",
"(",
"__file__",
")",
"or",
"'.'",
"paths",
"=",
"[",
"path",
"]",
"+",
"config",
"[",
"'include_path'",
... | Locate a filename into the shader library. | [
"Locate",
"a",
"filename",
"into",
"the",
"shader",
"library",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/__init__.py#L12-L34 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/glsl/__init__.py | get | def get(name):
"""Retrieve code from the given filename."""
filename = find(name)
if filename is None:
raise RuntimeError('Could not find %s' % name)
with open(filename) as fid:
return fid.read() | python | def get(name):
"""Retrieve code from the given filename."""
filename = find(name)
if filename is None:
raise RuntimeError('Could not find %s' % name)
with open(filename) as fid:
return fid.read() | [
"def",
"get",
"(",
"name",
")",
":",
"filename",
"=",
"find",
"(",
"name",
")",
"if",
"filename",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Could not find %s'",
"%",
"name",
")",
"with",
"open",
"(",
"filename",
")",
"as",
"fid",
":",
"return"... | Retrieve code from the given filename. | [
"Retrieve",
"code",
"from",
"the",
"given",
"filename",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/__init__.py#L37-L44 | train |
federico123579/Trading212-API | tradingAPI/utils.py | expect | def expect(func, args, times=7, sleep_t=0.5):
"""try many times as in times with sleep time"""
while times > 0:
try:
return func(*args)
except Exception as e:
times -= 1
logger.debug("expect failed - attempts left: %d" % times)
time.sleep(sleep_t)
... | python | def expect(func, args, times=7, sleep_t=0.5):
"""try many times as in times with sleep time"""
while times > 0:
try:
return func(*args)
except Exception as e:
times -= 1
logger.debug("expect failed - attempts left: %d" % times)
time.sleep(sleep_t)
... | [
"def",
"expect",
"(",
"func",
",",
"args",
",",
"times",
"=",
"7",
",",
"sleep_t",
"=",
"0.5",
")",
":",
"while",
"times",
">",
"0",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
")",
"except",
"Exception",
"as",
"e",
":",
"times",
"-=",
... | try many times as in times with sleep time | [
"try",
"many",
"times",
"as",
"in",
"times",
"with",
"sleep",
"time"
] | 0fab20b71a2348e72bbe76071b81f3692128851f | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L20-L30 | train |
federico123579/Trading212-API | tradingAPI/utils.py | num | def num(string):
"""convert a string to float"""
if not isinstance(string, type('')):
raise ValueError(type(''))
try:
string = re.sub('[^a-zA-Z0-9\.\-]', '', string)
number = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", string)
return float(number[0])
except Exception as e:
... | python | def num(string):
"""convert a string to float"""
if not isinstance(string, type('')):
raise ValueError(type(''))
try:
string = re.sub('[^a-zA-Z0-9\.\-]', '', string)
number = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", string)
return float(number[0])
except Exception as e:
... | [
"def",
"num",
"(",
"string",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"type",
"(",
"''",
")",
")",
":",
"raise",
"ValueError",
"(",
"type",
"(",
"''",
")",
")",
"try",
":",
"string",
"=",
"re",
".",
"sub",
"(",
"'[^a-zA-Z0-9\\.\\-]'... | convert a string to float | [
"convert",
"a",
"string",
"to",
"float"
] | 0fab20b71a2348e72bbe76071b81f3692128851f | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L33-L45 | train |
federico123579/Trading212-API | tradingAPI/utils.py | get_number_unit | def get_number_unit(number):
"""get the unit of number"""
n = str(float(number))
mult, submult = n.split('.')
if float(submult) != 0:
unit = '0.' + (len(submult)-1)*'0' + '1'
return float(unit)
else:
return float(1) | python | def get_number_unit(number):
"""get the unit of number"""
n = str(float(number))
mult, submult = n.split('.')
if float(submult) != 0:
unit = '0.' + (len(submult)-1)*'0' + '1'
return float(unit)
else:
return float(1) | [
"def",
"get_number_unit",
"(",
"number",
")",
":",
"n",
"=",
"str",
"(",
"float",
"(",
"number",
")",
")",
"mult",
",",
"submult",
"=",
"n",
".",
"split",
"(",
"'.'",
")",
"if",
"float",
"(",
"submult",
")",
"!=",
"0",
":",
"unit",
"=",
"'0.'",
... | get the unit of number | [
"get",
"the",
"unit",
"of",
"number"
] | 0fab20b71a2348e72bbe76071b81f3692128851f | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L48-L56 | train |
federico123579/Trading212-API | tradingAPI/utils.py | get_pip | def get_pip(mov=None, api=None, name=None):
"""get value of pip"""
# ~ check args
if mov is None and api is None:
logger.error("need at least one of those")
raise ValueError()
elif mov is not None and api is not None:
logger.error("mov and api are exclusive")
raise ValueE... | python | def get_pip(mov=None, api=None, name=None):
"""get value of pip"""
# ~ check args
if mov is None and api is None:
logger.error("need at least one of those")
raise ValueError()
elif mov is not None and api is not None:
logger.error("mov and api are exclusive")
raise ValueE... | [
"def",
"get_pip",
"(",
"mov",
"=",
"None",
",",
"api",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# ~ check args",
"if",
"mov",
"is",
"None",
"and",
"api",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"need at least one of those\"",
")",
"r... | get value of pip | [
"get",
"value",
"of",
"pip"
] | 0fab20b71a2348e72bbe76071b81f3692128851f | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/utils.py#L59-L117 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.itemsize | def itemsize(self):
""" Individual item sizes """
return self._items[:self._count, 1] - self._items[:self._count, 0] | python | def itemsize(self):
""" Individual item sizes """
return self._items[:self._count, 1] - self._items[:self._count, 0] | [
"def",
"itemsize",
"(",
"self",
")",
":",
"return",
"self",
".",
"_items",
"[",
":",
"self",
".",
"_count",
",",
"1",
"]",
"-",
"self",
".",
"_items",
"[",
":",
"self",
".",
"_count",
",",
"0",
"]"
] | Individual item sizes | [
"Individual",
"item",
"sizes"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L126-L128 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.reserve | def reserve(self, capacity):
""" Set current capacity of the underlying array"""
if capacity >= self._data.size:
capacity = int(2 ** np.ceil(np.log2(capacity)))
self._data = np.resize(self._data, capacity) | python | def reserve(self, capacity):
""" Set current capacity of the underlying array"""
if capacity >= self._data.size:
capacity = int(2 ** np.ceil(np.log2(capacity)))
self._data = np.resize(self._data, capacity) | [
"def",
"reserve",
"(",
"self",
",",
"capacity",
")",
":",
"if",
"capacity",
">=",
"self",
".",
"_data",
".",
"size",
":",
"capacity",
"=",
"int",
"(",
"2",
"**",
"np",
".",
"ceil",
"(",
"np",
".",
"log2",
"(",
"capacity",
")",
")",
")",
"self",
... | Set current capacity of the underlying array | [
"Set",
"current",
"capacity",
"of",
"the",
"underlying",
"array"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L135-L140 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.insert | def insert(self, index, data, itemsize=None):
""" Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __arr... | python | def insert(self, index, data, itemsize=None):
""" Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __arr... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"data",
",",
"itemsize",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_sizeable",
":",
"raise",
"AttributeError",
"(",
"\"List is not sizeable\"",
")",
"if",
"isinstance",
"(",
"data",
",",
"(",
"list... | Insert data before index
Parameters
----------
index : int
Index before which data will be inserted.
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
... | [
"Insert",
"data",
"before",
"index"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L285-L391 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py | ArrayList.append | def append(self, data, itemsize=None):
"""
Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: ... | python | def append(self, data, itemsize=None):
"""
Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: ... | [
"def",
"append",
"(",
"self",
",",
"data",
",",
"itemsize",
"=",
"None",
")",
":",
"self",
".",
"insert",
"(",
"len",
"(",
"self",
")",
",",
"data",
",",
"itemsize",
")"
] | Append data to the end.
Parameters
----------
data : array_like
An array, any object exposing the array interface, an object
whose __array__ method returns an array, or any (nested) sequence.
itemsize: int or 1-D array
If `itemsize is an integer, N... | [
"Append",
"data",
"to",
"the",
"end",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/array_list.py#L393-L415 | train |
andim/scipydirect | scipydirect/__init__.py | minimize | def minimize(func, bounds=None, nvar=None, args=(), disp=False,
eps=1e-4,
maxf=20000,
maxT=6000,
algmethod=0,
fglobal=-1e100,
fglper=0.01,
volper=-1.0,
sigmaper=-1.0,
**kwargs
):
... | python | def minimize(func, bounds=None, nvar=None, args=(), disp=False,
eps=1e-4,
maxf=20000,
maxT=6000,
algmethod=0,
fglobal=-1e100,
fglper=0.01,
volper=-1.0,
sigmaper=-1.0,
**kwargs
):
... | [
"def",
"minimize",
"(",
"func",
",",
"bounds",
"=",
"None",
",",
"nvar",
"=",
"None",
",",
"args",
"=",
"(",
")",
",",
"disp",
"=",
"False",
",",
"eps",
"=",
"1e-4",
",",
"maxf",
"=",
"20000",
",",
"maxT",
"=",
"6000",
",",
"algmethod",
"=",
"0... | Solve an optimization problem using the DIRECT (Dividing Rectangles) algorithm.
It can be used to solve general nonlinear programming problems of the form:
.. math::
\min_ {x \in R^n} f(x)
subject to
.. math::
x_L \leq x \leq x_U
Where :math:`x` are the... | [
"Solve",
"an",
"optimization",
"problem",
"using",
"the",
"DIRECT",
"(",
"Dividing",
"Rectangles",
")",
"algorithm",
".",
"It",
"can",
"be",
"used",
"to",
"solve",
"general",
"nonlinear",
"programming",
"problems",
"of",
"the",
"form",
":",
"..",
"math",
"::... | ad36ab19e6ad64054a1d2abd22f1c993fc4b87be | https://github.com/andim/scipydirect/blob/ad36ab19e6ad64054a1d2abd22f1c993fc4b87be/scipydirect/__init__.py#L111-L258 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/dpi/_win32.py | get_dpi | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
try:
user32.SetProcessDPIAware(... | python | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
try:
user32.SetProcessDPIAware(... | [
"def",
"get_dpi",
"(",
"raise_error",
"=",
"True",
")",
":",
"try",
":",
"user32",
".",
"SetProcessDPIAware",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"# not present on XP",
"dc",
"=",
"user32",
".",
"GetDC",
"(",
"0",
")",
"h_size",
"=",
"gdi32"... | Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen. | [
"Get",
"screen",
"DPI",
"from",
"the",
"OS"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/dpi/_win32.py#L11-L34 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/program.py | ModularProgram.build_if_needed | def build_if_needed(self):
""" Reset shader source if necesssary.
"""
if self._need_build:
self._build()
self._need_build = False
self.update_variables() | python | def build_if_needed(self):
""" Reset shader source if necesssary.
"""
if self._need_build:
self._build()
self._need_build = False
self.update_variables() | [
"def",
"build_if_needed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_need_build",
":",
"self",
".",
"_build",
"(",
")",
"self",
".",
"_need_build",
"=",
"False",
"self",
".",
"update_variables",
"(",
")"
] | Reset shader source if necesssary. | [
"Reset",
"shader",
"source",
"if",
"necesssary",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/program.py#L79-L85 | train |
antonagestam/nmap | nmap/nmap.py | nmap | def nmap(a, b, c, d, curvefn=None, normfn=None):
"""
Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output.
"""
if not curvefn:
cur... | python | def nmap(a, b, c, d, curvefn=None, normfn=None):
"""
Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output.
"""
if not curvefn:
cur... | [
"def",
"nmap",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"curvefn",
"=",
"None",
",",
"normfn",
"=",
"None",
")",
":",
"if",
"not",
"curvefn",
":",
"curvefn",
"=",
"lambda",
"x",
":",
"x",
"def",
"map",
"(",
"n",
")",
":",
"r",
"=",
"1.0... | Returns a function that maps a number n from range (a, b) onto a range
(c, d). If no curvefn is given, linear mapping will be used. Optionally a
normalisation function normfn can be provided to transform output. | [
"Returns",
"a",
"function",
"that",
"maps",
"a",
"number",
"n",
"from",
"range",
"(",
"a",
"b",
")",
"onto",
"a",
"range",
"(",
"c",
"d",
")",
".",
"If",
"no",
"curvefn",
"is",
"given",
"linear",
"mapping",
"will",
"be",
"used",
".",
"Optionally",
... | dd6d90d6a04b4cfc39687af1c081c5d6c4602dea | https://github.com/antonagestam/nmap/blob/dd6d90d6a04b4cfc39687af1c081c5d6c4602dea/nmap/nmap.py#L1-L16 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/axis.py | AxisWidget.link_view | def link_view(self, view):
"""Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link.
"""
if view is self._link... | python | def link_view(self, view):
"""Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link.
"""
if view is self._link... | [
"def",
"link_view",
"(",
"self",
",",
"view",
")",
":",
"if",
"view",
"is",
"self",
".",
"_linked_view",
":",
"return",
"if",
"self",
".",
"_linked_view",
"is",
"not",
"None",
":",
"self",
".",
"_linked_view",
".",
"scene",
".",
"transform",
".",
"chan... | Link this axis to a ViewBox
This makes it so that the axis's domain always matches the
visible range in the ViewBox.
Parameters
----------
view : instance of ViewBox
The ViewBox to link. | [
"Link",
"this",
"axis",
"to",
"a",
"ViewBox"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/axis.py#L61-L79 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/axis.py | AxisWidget._view_changed | def _view_changed(self, event=None):
"""Linked view transform has changed; update ticks.
"""
tr = self.node_transform(self._linked_view.scene)
p1, p2 = tr.map(self._axis_ends())
if self.orientation in ('left', 'right'):
self.axis.domain = (p1[1], p2[1])
else:
... | python | def _view_changed(self, event=None):
"""Linked view transform has changed; update ticks.
"""
tr = self.node_transform(self._linked_view.scene)
p1, p2 = tr.map(self._axis_ends())
if self.orientation in ('left', 'right'):
self.axis.domain = (p1[1], p2[1])
else:
... | [
"def",
"_view_changed",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"tr",
"=",
"self",
".",
"node_transform",
"(",
"self",
".",
"_linked_view",
".",
"scene",
")",
"p1",
",",
"p2",
"=",
"tr",
".",
"map",
"(",
"self",
".",
"_axis_ends",
"(",
")... | Linked view transform has changed; update ticks. | [
"Linked",
"view",
"transform",
"has",
"changed",
";",
"update",
"ticks",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/axis.py#L81-L89 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py | MagnifyCamera.viewbox_mouse_event | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event.
"""
# When the attached ViewBox reseives a mouse event, it is sent to the
# camera here.
self.mouse_... | python | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event.
"""
# When the attached ViewBox reseives a mouse event, it is sent to the
# camera here.
self.mouse_... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"# When the attached ViewBox reseives a mouse event, it is sent to the",
"# camera here.",
"self",
".",
"mouse_pos",
"=",
"event",
".",
"pos",
"[",
":",
"2",
"]",
"if",
"event",
".",
"type",
"==",
... | ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event. | [
"ViewBox",
"mouse",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py#L83-L110 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py | MagnifyCamera.on_timer | def on_timer(self, event=None):
"""Timer event handler
Parameters
----------
event : instance of Event
The timer event.
"""
# Smoothly update center and magnification properties of the transform
k = np.clip(100. / self.mag.mag, 10, 100)
s = 10... | python | def on_timer(self, event=None):
"""Timer event handler
Parameters
----------
event : instance of Event
The timer event.
"""
# Smoothly update center and magnification properties of the transform
k = np.clip(100. / self.mag.mag, 10, 100)
s = 10... | [
"def",
"on_timer",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Smoothly update center and magnification properties of the transform",
"k",
"=",
"np",
".",
"clip",
"(",
"100.",
"/",
"self",
".",
"mag",
".",
"mag",
",",
"10",
",",
"100",
")",
"s",
"... | Timer event handler
Parameters
----------
event : instance of Event
The timer event. | [
"Timer",
"event",
"handler"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py#L112-L137 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/gl/_gl2.py | glBufferData | def glBufferData(target, data, usage):
""" Data can be numpy array or the size of data to allocate.
"""
if isinstance(data, int):
size = data
data = ctypes.c_voidp(0)
else:
if not data.flags['C_CONTIGUOUS'] or not data.flags['ALIGNED']:
data = data.copy('C')
d... | python | def glBufferData(target, data, usage):
""" Data can be numpy array or the size of data to allocate.
"""
if isinstance(data, int):
size = data
data = ctypes.c_voidp(0)
else:
if not data.flags['C_CONTIGUOUS'] or not data.flags['ALIGNED']:
data = data.copy('C')
d... | [
"def",
"glBufferData",
"(",
"target",
",",
"data",
",",
"usage",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"int",
")",
":",
"size",
"=",
"data",
"data",
"=",
"ctypes",
".",
"c_voidp",
"(",
"0",
")",
"else",
":",
"if",
"not",
"data",
".",
"f... | Data can be numpy array or the size of data to allocate. | [
"Data",
"can",
"be",
"numpy",
"array",
"or",
"the",
"size",
"of",
"data",
"to",
"allocate",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/gl/_gl2.py#L123-L139 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | next_power_of_2 | def next_power_of_2(n):
""" Return next power of 2 greater than or equal to n """
n -= 1 # greater than OR EQUAL TO n
shift = 1
while (n + 1) & n: # n+1 is not a power of 2 yet
n |= n >> shift
shift *= 2
return max(4, n + 1) | python | def next_power_of_2(n):
""" Return next power of 2 greater than or equal to n """
n -= 1 # greater than OR EQUAL TO n
shift = 1
while (n + 1) & n: # n+1 is not a power of 2 yet
n |= n >> shift
shift *= 2
return max(4, n + 1) | [
"def",
"next_power_of_2",
"(",
"n",
")",
":",
"n",
"-=",
"1",
"# greater than OR EQUAL TO n",
"shift",
"=",
"1",
"while",
"(",
"n",
"+",
"1",
")",
"&",
"n",
":",
"# n+1 is not a power of 2 yet",
"n",
"|=",
"n",
">>",
"shift",
"shift",
"*=",
"2",
"return"... | Return next power of 2 greater than or equal to n | [
"Return",
"next",
"power",
"of",
"2",
"greater",
"than",
"or",
"equal",
"to",
"n"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L22-L29 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection.append | def append(self, vertices, uniforms=None, indices=None, itemsize=None):
"""
Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
... | python | def append(self, vertices, uniforms=None, indices=None, itemsize=None):
"""
Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
... | [
"def",
"append",
"(",
"self",
",",
"vertices",
",",
"uniforms",
"=",
"None",
",",
"indices",
"=",
"None",
",",
"itemsize",
"=",
"None",
")",
":",
"# Vertices",
"# -----------------------------",
"vertices",
"=",
"np",
".",
"array",
"(",
"vertices",
")",
".... | Parameters
----------
vertices : numpy array
An array whose dtype is compatible with self.vdtype
uniforms: numpy array
An array whose dtype is compatible with self.utype
indices : numpy array
An array whose dtype is compatible with self.idtype
... | [
"Parameters",
"----------"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L229-L313 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection._compute_texture_shape | def _compute_texture_shape(self, size=1):
""" Compute uniform texture shape """
# We should use this line but we may not have a GL context yet
# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)
linesize = 1024
count = self._uniforms_float_count
cols = 4 * linesize // i... | python | def _compute_texture_shape(self, size=1):
""" Compute uniform texture shape """
# We should use this line but we may not have a GL context yet
# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)
linesize = 1024
count = self._uniforms_float_count
cols = 4 * linesize // i... | [
"def",
"_compute_texture_shape",
"(",
"self",
",",
"size",
"=",
"1",
")",
":",
"# We should use this line but we may not have a GL context yet",
"# linesize = gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE)",
"linesize",
"=",
"1024",
"count",
"=",
"self",
".",
"_uniforms_float_count",
... | Compute uniform texture shape | [
"Compute",
"uniform",
"texture",
"shape"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L453-L464 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py | BaseCollection._update | def _update(self):
""" Update vertex buffers & texture """
if self._vertices_buffer is not None:
self._vertices_buffer.delete()
self._vertices_buffer = VertexBuffer(self._vertices_list.data)
if self.itype is not None:
if self._indices_buffer is not None:
... | python | def _update(self):
""" Update vertex buffers & texture """
if self._vertices_buffer is not None:
self._vertices_buffer.delete()
self._vertices_buffer = VertexBuffer(self._vertices_list.data)
if self.itype is not None:
if self._indices_buffer is not None:
... | [
"def",
"_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vertices_buffer",
"is",
"not",
"None",
":",
"self",
".",
"_vertices_buffer",
".",
"delete",
"(",
")",
"self",
".",
"_vertices_buffer",
"=",
"VertexBuffer",
"(",
"self",
".",
"_vertices_list",
".... | Update vertex buffers & texture | [
"Update",
"vertex",
"buffers",
"&",
"texture"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L466-L498 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/__init__.py | get_layout | def get_layout(name, *args, **kwargs):
"""
Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all av... | python | def get_layout(name, *args, **kwargs):
"""
Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all av... | [
"def",
"get_layout",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"not",
"in",
"_layout_map",
":",
"raise",
"KeyError",
"(",
"\"Graph layout '%s' not found. Should be one of %s\"",
"%",
"(",
"name",
",",
"AVAILABLE_LAYOUTS",
... | Retrieve a graph layout
Some graph layouts accept extra options. Please refer to their
documentation for more information.
Parameters
----------
name : string
The name of the layout. The variable `AVAILABLE_LAYOUTS`
contains all available layouts.
*args
Positional argum... | [
"Retrieve",
"a",
"graph",
"layout"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/__init__.py#L22-L53 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/common/compat.py | update_viewer_state | def update_viewer_state(rec, context):
"""
Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place.
"""
if '_protocol' not in rec:
rec.pop('properties')
rec['... | python | def update_viewer_state(rec, context):
"""
Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place.
"""
if '_protocol' not in rec:
rec.pop('properties')
rec['... | [
"def",
"update_viewer_state",
"(",
"rec",
",",
"context",
")",
":",
"if",
"'_protocol'",
"not",
"in",
"rec",
":",
"rec",
".",
"pop",
"(",
"'properties'",
")",
"rec",
"[",
"'state'",
"]",
"=",
"{",
"}",
"rec",
"[",
"'state'",
"]",
"[",
"'values'",
"]"... | Given viewer session information, make sure the session information is
compatible with the current version of the viewers, and if not, update
the session information in-place. | [
"Given",
"viewer",
"session",
"information",
"make",
"sure",
"the",
"session",
"information",
"is",
"compatible",
"with",
"the",
"current",
"version",
"of",
"the",
"viewers",
"and",
"if",
"not",
"update",
"the",
"session",
"information",
"in",
"-",
"place",
".... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/common/compat.py#L18-L55 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/preprocessor.py | remove_comments | def remove_comments(code):
"""Remove C-style comment from GLSL code string."""
pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*\n)"
# first group captures quoted strings (double or single)
# second group captures comments (//single-line or /* multi-line */)
regex = re.compile(pattern, re.MULTILI... | python | def remove_comments(code):
"""Remove C-style comment from GLSL code string."""
pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*\n)"
# first group captures quoted strings (double or single)
# second group captures comments (//single-line or /* multi-line */)
regex = re.compile(pattern, re.MULTILI... | [
"def",
"remove_comments",
"(",
"code",
")",
":",
"pattern",
"=",
"r\"(\\\".*?\\\"|\\'.*?\\')|(/\\*.*?\\*/|//[^\\r\\n]*\\n)\"",
"# first group captures quoted strings (double or single)",
"# second group captures comments (//single-line or /* multi-line */)",
"regex",
"=",
"re",
".",
"c... | Remove C-style comment from GLSL code string. | [
"Remove",
"C",
"-",
"style",
"comment",
"from",
"GLSL",
"code",
"string",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/preprocessor.py#L12-L28 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/preprocessor.py | merge_includes | def merge_includes(code):
"""Merge all includes recursively."""
pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
regex = re.compile(pattern)
includes = []
def replace(match):
filename = match.group("filename")
if filename not in includes:
includes.append... | python | def merge_includes(code):
"""Merge all includes recursively."""
pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
regex = re.compile(pattern)
includes = []
def replace(match):
filename = match.group("filename")
if filename not in includes:
includes.append... | [
"def",
"merge_includes",
"(",
"code",
")",
":",
"pattern",
"=",
"'\\#\\s*include\\s*\"(?P<filename>[a-zA-Z0-9\\_\\-\\.\\/]+)\"'",
"regex",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"includes",
"=",
"[",
"]",
"def",
"replace",
"(",
"match",
")",
":",
"filen... | Merge all includes recursively. | [
"Merge",
"all",
"includes",
"recursively",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/preprocessor.py#L31-L61 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_widget | def add_widget(self, widget=None, row=None, col=None, row_span=1,
col_span=1, **kwargs):
"""
Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Paramet... | python | def add_widget(self, widget=None, row=None, col=None, row_span=1,
col_span=1, **kwargs):
"""
Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Paramet... | [
"def",
"add_widget",
"(",
"self",
",",
"widget",
"=",
"None",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"row",
"is",
"None",
":",
"row",
"=",... | Add a new widget to this grid. This will cause other widgets in the
grid to be resized to make room for the new widget. Can be used
to replace a widget as well
Parameters
----------
widget : Widget | None
The Widget to add. New widget is constructed if widget is None... | [
"Add",
"a",
"new",
"widget",
"to",
"this",
"grid",
".",
"This",
"will",
"cause",
"other",
"widgets",
"in",
"the",
"grid",
"to",
"be",
"resized",
"to",
"make",
"room",
"for",
"the",
"new",
"widget",
".",
"Can",
"be",
"used",
"to",
"replace",
"a",
"wid... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L85-L148 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.remove_widget | def remove_widget(self, widget):
"""Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove
"""
self._grid_widgets = dict((key, val)
for (key, val) in self._grid_widgets.items()
... | python | def remove_widget(self, widget):
"""Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove
"""
self._grid_widgets = dict((key, val)
for (key, val) in self._grid_widgets.items()
... | [
"def",
"remove_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_grid_widgets",
"=",
"dict",
"(",
"(",
"key",
",",
"val",
")",
"for",
"(",
"key",
",",
"val",
")",
"in",
"self",
".",
"_grid_widgets",
".",
"items",
"(",
")",
"if",
"val",
... | Remove a widget from this grid
Parameters
----------
widget : Widget
The Widget to remove | [
"Remove",
"a",
"widget",
"from",
"this",
"grid"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L150-L163 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.resize_widget | def resize_widget(self, widget, row_span, col_span):
"""Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
... | python | def resize_widget(self, widget, row_span, col_span):
"""Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
... | [
"def",
"resize_widget",
"(",
"self",
",",
"widget",
",",
"row_span",
",",
"col_span",
")",
":",
"row",
"=",
"None",
"col",
"=",
"None",
"for",
"(",
"r",
",",
"c",
",",
"rspan",
",",
"cspan",
",",
"w",
")",
"in",
"self",
".",
"_grid_widgets",
".",
... | Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
The number of columns to be occupied by this widget. | [
"Resize",
"a",
"widget",
"in",
"the",
"grid",
"to",
"new",
"dimensions",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L165-L193 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_grid | def add_grid(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The ... | python | def add_grid(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The ... | [
"def",
"add_grid",
"(",
"self",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"grid",
"import",
"Grid",
"grid",
"=",
"Grid",
"(",
"*",
"*"... | Create a new Grid and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The column in which to add the widget (0 is the leftmost column)
row_span : int
The number of r... | [
"Create",
"a",
"new",
"Grid",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L198-L218 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | Grid.add_view | def add_view(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
T... | python | def add_view(self, row=None, col=None, row_span=1, col_span=1,
**kwargs):
"""
Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
T... | [
"def",
"add_view",
"(",
"self",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"row_span",
"=",
"1",
",",
"col_span",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"viewbox",
"import",
"ViewBox",
"view",
"=",
"ViewBox",
"(",
"... | Create a new ViewBox and add it as a child widget.
Parameters
----------
row : int
The row in which to add the widget (0 is the topmost row)
col : int
The column in which to add the widget (0 is the leftmost column)
row_span : int
The number o... | [
"Create",
"a",
"new",
"ViewBox",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L220-L240 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/fontconfig.py | find_font | def find_font(face, bold, italic):
"""Find font"""
bold = FC_WEIGHT_BOLD if bold else FC_WEIGHT_REGULAR
italic = FC_SLANT_ITALIC if italic else FC_SLANT_ROMAN
face = face.encode('utf8')
fontconfig.FcInit()
pattern = fontconfig.FcPatternCreate()
fontconfig.FcPatternAddInteger(pattern, FC_WEIG... | python | def find_font(face, bold, italic):
"""Find font"""
bold = FC_WEIGHT_BOLD if bold else FC_WEIGHT_REGULAR
italic = FC_SLANT_ITALIC if italic else FC_SLANT_ROMAN
face = face.encode('utf8')
fontconfig.FcInit()
pattern = fontconfig.FcPatternCreate()
fontconfig.FcPatternAddInteger(pattern, FC_WEIG... | [
"def",
"find_font",
"(",
"face",
",",
"bold",
",",
"italic",
")",
":",
"bold",
"=",
"FC_WEIGHT_BOLD",
"if",
"bold",
"else",
"FC_WEIGHT_REGULAR",
"italic",
"=",
"FC_SLANT_ITALIC",
"if",
"italic",
"else",
"FC_SLANT_ROMAN",
"face",
"=",
"face",
".",
"encode",
"... | Find font | [
"Find",
"font"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/fontconfig.py#L85-L111 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/fontconfig.py | _list_fonts | def _list_fonts():
"""List system fonts"""
stdout_, stderr = run_subprocess(['fc-list', ':scalable=true', 'family'])
vals = [v.split(',')[0] for v in stdout_.strip().splitlines(False)]
return vals | python | def _list_fonts():
"""List system fonts"""
stdout_, stderr = run_subprocess(['fc-list', ':scalable=true', 'family'])
vals = [v.split(',')[0] for v in stdout_.strip().splitlines(False)]
return vals | [
"def",
"_list_fonts",
"(",
")",
":",
"stdout_",
",",
"stderr",
"=",
"run_subprocess",
"(",
"[",
"'fc-list'",
",",
"':scalable=true'",
",",
"'family'",
"]",
")",
"vals",
"=",
"[",
"v",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
"for",
"v",
"in",
... | List system fonts | [
"List",
"system",
"fonts"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/fontconfig.py#L114-L118 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _get_vispy_caller | def _get_vispy_caller():
"""Helper to get vispy calling function from the stack"""
records = inspect.stack()
# first few records are vispy-based logging calls
for record in records[5:]:
module = record[0].f_globals['__name__']
if module.startswith('vispy'):
line = str(record[... | python | def _get_vispy_caller():
"""Helper to get vispy calling function from the stack"""
records = inspect.stack()
# first few records are vispy-based logging calls
for record in records[5:]:
module = record[0].f_globals['__name__']
if module.startswith('vispy'):
line = str(record[... | [
"def",
"_get_vispy_caller",
"(",
")",
":",
"records",
"=",
"inspect",
".",
"stack",
"(",
")",
"# first few records are vispy-based logging calls",
"for",
"record",
"in",
"records",
"[",
"5",
":",
"]",
":",
"module",
"=",
"record",
"[",
"0",
"]",
".",
"f_glob... | Helper to get vispy calling function from the stack | [
"Helper",
"to",
"get",
"vispy",
"calling",
"function",
"from",
"the",
"stack"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L22-L35 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | set_log_level | def set_log_level(verbose, match=None, return_old=False):
"""Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that thes... | python | def set_log_level(verbose, match=None, return_old=False):
"""Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that thes... | [
"def",
"set_log_level",
"(",
"verbose",
",",
"match",
"=",
"None",
",",
"return_old",
"=",
"False",
")",
":",
"# This method is responsible for setting properties of the handler and",
"# formatter such that proper messages (possibly with the vispy caller",
"# prepended) are displayed... | Convenience function for setting the logging level
Parameters
----------
verbose : bool, str, int, or None
The verbosity of messages to print. If a str, it can be either DEBUG,
INFO, WARNING, ERROR, or CRITICAL. Note that these are for
convenience and are equivalent to passing in lo... | [
"Convenience",
"function",
"for",
"setting",
"the",
"logging",
"level"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L129-L183 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | log_exception | def log_exception(level='warning', tb_skip=2):
"""
Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the... | python | def log_exception(level='warning', tb_skip=2):
"""
Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the... | [
"def",
"log_exception",
"(",
"level",
"=",
"'warning'",
",",
"tb_skip",
"=",
"2",
")",
":",
"stack",
"=",
"\"\"",
".",
"join",
"(",
"traceback",
".",
"format_stack",
"(",
")",
"[",
":",
"-",
"tb_skip",
"]",
")",
"tb",
"=",
"traceback",
".",
"format_e... | Send an exception and traceback to the logger.
This function is used in cases where an exception is handled safely but
nevertheless should generate a descriptive error message. An extra line
is inserted into the stack trace indicating where the exception was caught.
Parameters
----------
... | [
"Send",
"an",
"exception",
"and",
"traceback",
"to",
"the",
"logger",
".",
"This",
"function",
"is",
"used",
"in",
"cases",
"where",
"an",
"exception",
"is",
"handled",
"safely",
"but",
"nevertheless",
"should",
"generate",
"a",
"descriptive",
"error",
"messag... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L249-L271 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _handle_exception | def _handle_exception(ignore_callback_errors, print_callback_errors, obj,
cb_event=None, node=None):
"""Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example.
"""
if not hasattr(obj, '_vispy_err_registry'):
obj._vispy_err_registry = {}
... | python | def _handle_exception(ignore_callback_errors, print_callback_errors, obj,
cb_event=None, node=None):
"""Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example.
"""
if not hasattr(obj, '_vispy_err_registry'):
obj._vispy_err_registry = {}
... | [
"def",
"_handle_exception",
"(",
"ignore_callback_errors",
",",
"print_callback_errors",
",",
"obj",
",",
"cb_event",
"=",
"None",
",",
"node",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'_vispy_err_registry'",
")",
":",
"obj",
".",
"_v... | Helper for prining errors in callbacks
See EventEmitter._invoke_callback for a use example. | [
"Helper",
"for",
"prining",
"errors",
"in",
"callbacks"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L276-L334 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _serialize_buffer | def _serialize_buffer(buffer, array_serialization=None):
"""Serialize a NumPy array."""
if array_serialization == 'binary':
# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()
# but tostring() is still here for now for backward compatibility.
return buffer.ravel().tostring(... | python | def _serialize_buffer(buffer, array_serialization=None):
"""Serialize a NumPy array."""
if array_serialization == 'binary':
# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()
# but tostring() is still here for now for backward compatibility.
return buffer.ravel().tostring(... | [
"def",
"_serialize_buffer",
"(",
"buffer",
",",
"array_serialization",
"=",
"None",
")",
":",
"if",
"array_serialization",
"==",
"'binary'",
":",
"# WARNING: in NumPy 1.9, tostring() has been renamed to tobytes()",
"# but tostring() is still here for now for backward compatibility.",... | Serialize a NumPy array. | [
"Serialize",
"a",
"NumPy",
"array",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L337-L348 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/logs.py | _VispyStreamHandler._vispy_emit_match_andor_record | def _vispy_emit_match_andor_record(self, record):
"""Log message emitter that optionally matches and/or records"""
test = record.getMessage()
match = self._vispy_match
if (match is None or re.search(match, test) or
re.search(match, _get_vispy_caller())):
if se... | python | def _vispy_emit_match_andor_record(self, record):
"""Log message emitter that optionally matches and/or records"""
test = record.getMessage()
match = self._vispy_match
if (match is None or re.search(match, test) or
re.search(match, _get_vispy_caller())):
if se... | [
"def",
"_vispy_emit_match_andor_record",
"(",
"self",
",",
"record",
")",
":",
"test",
"=",
"record",
".",
"getMessage",
"(",
")",
"match",
"=",
"self",
".",
"_vispy_match",
"if",
"(",
"match",
"is",
"None",
"or",
"re",
".",
"search",
"(",
"match",
",",
... | Log message emitter that optionally matches and/or records | [
"Log",
"message",
"emitter",
"that",
"optionally",
"matches",
"and",
"/",
"or",
"records"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/logs.py#L82-L94 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.create | def create(self, obj, ref=None):
""" Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*.
"""
if isinstance(ref, Variable):
ref = ref.name
elif isinstance(ref, string_types) and ref.startswith('gl_'):
... | python | def create(self, obj, ref=None):
""" Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*.
"""
if isinstance(ref, Variable):
ref = ref.name
elif isinstance(ref, string_types) and ref.startswith('gl_'):
... | [
"def",
"create",
"(",
"self",
",",
"obj",
",",
"ref",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"ref",
",",
"Variable",
")",
":",
"ref",
"=",
"ref",
".",
"name",
"elif",
"isinstance",
"(",
"ref",
",",
"string_types",
")",
"and",
"ref",
".",
... | Convert *obj* to a new ShaderObject. If the output is a Variable
with no name, then set its name using *ref*. | [
"Convert",
"*",
"obj",
"*",
"to",
"a",
"new",
"ShaderObject",
".",
"If",
"the",
"output",
"is",
"a",
"Variable",
"with",
"no",
"name",
"then",
"set",
"its",
"name",
"using",
"*",
"ref",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L24-L50 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.dependencies | def dependencies(self, sort=False):
""" Return all dependencies required to use this object. The last item
in the list is *self*.
"""
alldeps = []
if sort:
def key(obj):
# sort deps such that we get functions, variables, self.
if not i... | python | def dependencies(self, sort=False):
""" Return all dependencies required to use this object. The last item
in the list is *self*.
"""
alldeps = []
if sort:
def key(obj):
# sort deps such that we get functions, variables, self.
if not i... | [
"def",
"dependencies",
"(",
"self",
",",
"sort",
"=",
"False",
")",
":",
"alldeps",
"=",
"[",
"]",
"if",
"sort",
":",
"def",
"key",
"(",
"obj",
")",
":",
"# sort deps such that we get functions, variables, self.",
"if",
"not",
"isinstance",
"(",
"obj",
",",
... | Return all dependencies required to use this object. The last item
in the list is *self*. | [
"Return",
"all",
"dependencies",
"required",
"to",
"use",
"this",
"object",
".",
"The",
"last",
"item",
"in",
"the",
"list",
"is",
"*",
"self",
"*",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L77-L97 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._add_dep | def _add_dep(self, dep):
""" Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event.
"""
if dep in self._deps:
self._deps[dep] += 1
else:
self._deps[dep] = 1
dep._dependents[self] = None | python | def _add_dep(self, dep):
""" Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event.
"""
if dep in self._deps:
self._deps[dep] += 1
else:
self._deps[dep] = 1
dep._dependents[self] = None | [
"def",
"_add_dep",
"(",
"self",
",",
"dep",
")",
":",
"if",
"dep",
"in",
"self",
".",
"_deps",
":",
"self",
".",
"_deps",
"[",
"dep",
"]",
"+=",
"1",
"else",
":",
"self",
".",
"_deps",
"[",
"dep",
"]",
"=",
"1",
"dep",
".",
"_dependents",
"[",
... | Increment the reference count for *dep*. If this is a new
dependency, then connect to its *changed* event. | [
"Increment",
"the",
"reference",
"count",
"for",
"*",
"dep",
"*",
".",
"If",
"this",
"is",
"a",
"new",
"dependency",
"then",
"connect",
"to",
"its",
"*",
"changed",
"*",
"event",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L108-L116 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._remove_dep | def _remove_dep(self, dep):
""" Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected.
"""
refcount = self._deps[dep]
if refcount == 1:
self._deps.pop(dep)
... | python | def _remove_dep(self, dep):
""" Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected.
"""
refcount = self._deps[dep]
if refcount == 1:
self._deps.pop(dep)
... | [
"def",
"_remove_dep",
"(",
"self",
",",
"dep",
")",
":",
"refcount",
"=",
"self",
".",
"_deps",
"[",
"dep",
"]",
"if",
"refcount",
"==",
"1",
":",
"self",
".",
"_deps",
".",
"pop",
"(",
"dep",
")",
"dep",
".",
"_dependents",
".",
"pop",
"(",
"sel... | Decrement the reference count for *dep*. If the reference count
reaches 0, then the dependency is removed and its *changed* event is
disconnected. | [
"Decrement",
"the",
"reference",
"count",
"for",
"*",
"dep",
"*",
".",
"If",
"the",
"reference",
"count",
"reaches",
"0",
"then",
"the",
"dependency",
"is",
"removed",
"and",
"its",
"*",
"changed",
"*",
"event",
"is",
"disconnected",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L118-L128 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject._dep_changed | def _dep_changed(self, dep, code_changed=False, value_changed=False):
""" Called when a dependency's expression has changed.
"""
self.changed(code_changed, value_changed) | python | def _dep_changed(self, dep, code_changed=False, value_changed=False):
""" Called when a dependency's expression has changed.
"""
self.changed(code_changed, value_changed) | [
"def",
"_dep_changed",
"(",
"self",
",",
"dep",
",",
"code_changed",
"=",
"False",
",",
"value_changed",
"=",
"False",
")",
":",
"self",
".",
"changed",
"(",
"code_changed",
",",
"value_changed",
")"
] | Called when a dependency's expression has changed. | [
"Called",
"when",
"a",
"dependency",
"s",
"expression",
"has",
"changed",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L130-L133 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py | ShaderObject.changed | def changed(self, code_changed=False, value_changed=False):
"""Inform dependents that this shaderobject has changed.
"""
for d in self._dependents:
d._dep_changed(self, code_changed=code_changed,
value_changed=value_changed) | python | def changed(self, code_changed=False, value_changed=False):
"""Inform dependents that this shaderobject has changed.
"""
for d in self._dependents:
d._dep_changed(self, code_changed=code_changed,
value_changed=value_changed) | [
"def",
"changed",
"(",
"self",
",",
"code_changed",
"=",
"False",
",",
"value_changed",
"=",
"False",
")",
":",
"for",
"d",
"in",
"self",
".",
"_dependents",
":",
"d",
".",
"_dep_changed",
"(",
"self",
",",
"code_changed",
"=",
"code_changed",
",",
"valu... | Inform dependents that this shaderobject has changed. | [
"Inform",
"dependents",
"that",
"this",
"shaderobject",
"has",
"changed",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/shader_object.py#L135-L140 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/eq.py | eq | def eq(a, b):
""" The great missing equivalence function: Guaranteed evaluation
to a single bool value.
"""
if a is b:
return True
if a is None or b is None:
return True if a is None and b is None else False
try:
e = a == b
except ValueError:
return False
... | python | def eq(a, b):
""" The great missing equivalence function: Guaranteed evaluation
to a single bool value.
"""
if a is b:
return True
if a is None or b is None:
return True if a is None and b is None else False
try:
e = a == b
except ValueError:
return False
... | [
"def",
"eq",
"(",
"a",
",",
"b",
")",
":",
"if",
"a",
"is",
"b",
":",
"return",
"True",
"if",
"a",
"is",
"None",
"or",
"b",
"is",
"None",
":",
"return",
"True",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
"else",
"False",
"try",
":",
... | The great missing equivalence function: Guaranteed evaluation
to a single bool value. | [
"The",
"great",
"missing",
"equivalence",
"function",
":",
"Guaranteed",
"evaluation",
"to",
"a",
"single",
"bool",
"value",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/eq.py#L5-L41 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.zoom | def zoom(self, factor, center=None):
""" Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 ... | python | def zoom(self, factor, center=None):
""" Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 ... | [
"def",
"zoom",
"(",
"self",
",",
"factor",
",",
"center",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"center",
")",
"in",
"(",
"2",
",",
"3",
",",
"4",
")",
"# Get scale factor, take scale ratio into account",
"if",
"np",
".",
"isscalar",
"(",
"factor"... | Zoom in (or out) at the given center
Parameters
----------
factor : float or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2
causes the scene to appear twice as large).
center : tuple of 2-4 elements
The center of the view. If n... | [
"Zoom",
"in",
"(",
"or",
"out",
")",
"at",
"the",
"given",
"center"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L76-L114 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.pan | def pan(self, *pan):
"""Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene.
"""
if len(pan) == 1:
pan = pan[0]
self.rect = self.rect + pan | python | def pan(self, *pan):
"""Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene.
"""
if len(pan) == 1:
pan = pan[0]
self.rect = self.rect + pan | [
"def",
"pan",
"(",
"self",
",",
"*",
"pan",
")",
":",
"if",
"len",
"(",
"pan",
")",
"==",
"1",
":",
"pan",
"=",
"pan",
"[",
"0",
"]",
"self",
".",
"rect",
"=",
"self",
".",
"rect",
"+",
"pan"
] | Pan the view.
Parameters
----------
*pan : length-2 sequence
The distance to pan the view, in the coordinate system of the
scene. | [
"Pan",
"the",
"view",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L116-L127 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py | PanZoomCamera.viewbox_mouse_event | def viewbox_mouse_event(self, event):
"""
The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event.
"""
if event.handled or not self.interactive:
return
#... | python | def viewbox_mouse_event(self, event):
"""
The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event.
"""
if event.handled or not self.interactive:
return
#... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"# Scrolling",
"BaseCamera",
".",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
... | The SubScene received a mouse event; update transform
accordingly.
Parameters
----------
event : instance of Event
The event. | [
"The",
"SubScene",
"received",
"a",
"mouse",
"event",
";",
"update",
"transform",
"accordingly",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/panzoom.py#L191-L244 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/volume.py | VolumeVisual.set_data | def set_data(self, vol, clim=None):
""" Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values.
"""
# Check volume
if not isinstance... | python | def set_data(self, vol, clim=None):
""" Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values.
"""
# Check volume
if not isinstance... | [
"def",
"set_data",
"(",
"self",
",",
"vol",
",",
"clim",
"=",
"None",
")",
":",
"# Check volume",
"if",
"not",
"isinstance",
"(",
"vol",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"'Volume visual needs a numpy array.'",
")",
"if",
"no... | Set the volume data.
Parameters
----------
vol : ndarray
The 3D volume.
clim : tuple | None
Colormap limits to use. None will use the min and max values. | [
"Set",
"the",
"volume",
"data",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/volume.py#L450-L496 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/volume.py | VolumeVisual._create_vertex_data | def _create_vertex_data(self):
""" Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total.
"""
shape = self._vol_shape
# Get corner coordinates. The -0.... | python | def _create_vertex_data(self):
""" Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total.
"""
shape = self._vol_shape
# Get corner coordinates. The -0.... | [
"def",
"_create_vertex_data",
"(",
"self",
")",
":",
"shape",
"=",
"self",
".",
"_vol_shape",
"# Get corner coordinates. The -0.5 offset is to center",
"# pixels/voxels. This works correctly for anisotropic data.",
"x0",
",",
"x1",
"=",
"-",
"0.5",
",",
"shape",
"[",
"2",... | Create and set positions and texture coords from the given shape
We have six faces with 1 quad (2 triangles) each, resulting in
6*2*3 = 36 vertices in total. | [
"Create",
"and",
"set",
"positions",
"and",
"texture",
"coords",
"from",
"the",
"given",
"shape",
"We",
"have",
"six",
"faces",
"with",
"1",
"quad",
"(",
"2",
"triangles",
")",
"each",
"resulting",
"in",
"6",
"*",
"2",
"*",
"3",
"=",
"36",
"vertices",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/volume.py#L583-L625 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/linear_region.py | LinearRegionVisual.set_data | def set_data(self, pos=None, color=None):
"""Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have ... | python | def set_data(self, pos=None, color=None):
"""Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have ... | [
"def",
"set_data",
"(",
"self",
",",
"pos",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"new_pos",
"=",
"self",
".",
"_pos",
"new_color",
"=",
"self",
".",
"_color",
"if",
"pos",
"is",
"not",
"None",
":",
"num_elements",
"=",
"len",
"(",
"pos... | Set the data
Parameters
----------
pos : list, tuple or numpy array
Bounds of the region along the axis. len(pos) must be >=2.
color : list, tuple, or array
The color to use when drawing the line. It must have a shape of
(1, 4) for a single color regi... | [
"Set",
"the",
"data"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/linear_region.py#L87-L142 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/linear_region.py | LinearRegionVisual._prepare_draw | def _prepare_draw(self, view=None):
"""This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn.
"""
if self._changed['pos']:
self.pos_buf.set_data(self._pos)
self._changed['pos'] = False
if self.... | python | def _prepare_draw(self, view=None):
"""This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn.
"""
if self._changed['pos']:
self.pos_buf.set_data(self._pos)
self._changed['pos'] = False
if self.... | [
"def",
"_prepare_draw",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"if",
"self",
".",
"_changed",
"[",
"'pos'",
"]",
":",
"self",
".",
"pos_buf",
".",
"set_data",
"(",
"self",
".",
"_pos",
")",
"self",
".",
"_changed",
"[",
"'pos'",
"]",
"=",... | This method is called immediately before each draw.
The *view* argument indicates which view is about to be drawn. | [
"This",
"method",
"is",
"called",
"immediately",
"before",
"each",
"draw",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/linear_region.py#L180-L195 | train |
anjishnu/ask-alexa-pykit | examples/useful_science/useful_science.py | SimplePostsCache.refresh_cache | def refresh_cache(self, cat_id):
'''
Repopulate cache
'''
self.cache[cat_id] = most_recent_25_posts_by_category(cat_id)
self.last_refresh[cat_id] = datetime.now()
print ('Cache refresh at...', str(self.last_refresh[cat_id])) | python | def refresh_cache(self, cat_id):
'''
Repopulate cache
'''
self.cache[cat_id] = most_recent_25_posts_by_category(cat_id)
self.last_refresh[cat_id] = datetime.now()
print ('Cache refresh at...', str(self.last_refresh[cat_id])) | [
"def",
"refresh_cache",
"(",
"self",
",",
"cat_id",
")",
":",
"self",
".",
"cache",
"[",
"cat_id",
"]",
"=",
"most_recent_25_posts_by_category",
"(",
"cat_id",
")",
"self",
".",
"last_refresh",
"[",
"cat_id",
"]",
"=",
"datetime",
".",
"now",
"(",
")",
"... | Repopulate cache | [
"Repopulate",
"cache"
] | a47c278ca7a60532bbe1a9b789f6c37e609fea8b | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/useful_science/useful_science.py#L57-L63 | train |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet._merge_intervals | def _merge_intervals(self, min_depth):
"""
Merge overlapping intervals.
This method is called only once in the constructor.
"""
def add_interval(ret, start, stop):
if min_depth is not None:
shift = 2 * (29 - min_depth)
mask = (int(1) <... | python | def _merge_intervals(self, min_depth):
"""
Merge overlapping intervals.
This method is called only once in the constructor.
"""
def add_interval(ret, start, stop):
if min_depth is not None:
shift = 2 * (29 - min_depth)
mask = (int(1) <... | [
"def",
"_merge_intervals",
"(",
"self",
",",
"min_depth",
")",
":",
"def",
"add_interval",
"(",
"ret",
",",
"start",
",",
"stop",
")",
":",
"if",
"min_depth",
"is",
"not",
"None",
":",
"shift",
"=",
"2",
"*",
"(",
"29",
"-",
"min_depth",
")",
"mask",... | Merge overlapping intervals.
This method is called only once in the constructor. | [
"Merge",
"overlapping",
"intervals",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L98-L147 | train |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet.union | def union(self, another_is):
"""
Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is... | python | def union(self, another_is):
"""
Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is... | [
"def",
"union",
"(",
"self",
",",
"another_is",
")",
":",
"result",
"=",
"IntervalSet",
"(",
")",
"if",
"another_is",
".",
"empty",
"(",
")",
":",
"result",
".",
"_intervals",
"=",
"self",
".",
"_intervals",
"elif",
"self",
".",
"empty",
"(",
")",
":... | Return the union between self and ``another_is``.
Parameters
----------
another_is : `IntervalSet`
an IntervalSet object.
Returns
-------
interval : `IntervalSet`
the union of self with ``another_is``. | [
"Return",
"the",
"union",
"between",
"self",
"and",
"another_is",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L149-L172 | train |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet.to_nuniq_interval_set | def to_nuniq_interval_set(cls, nested_is):
"""
Convert an IntervalSet using the NESTED numbering scheme to an IntervalSet containing UNIQ numbers for HEALPix
cells.
Parameters
----------
nested_is : `IntervalSet`
IntervalSet object storing HEALPix cells as [i... | python | def to_nuniq_interval_set(cls, nested_is):
"""
Convert an IntervalSet using the NESTED numbering scheme to an IntervalSet containing UNIQ numbers for HEALPix
cells.
Parameters
----------
nested_is : `IntervalSet`
IntervalSet object storing HEALPix cells as [i... | [
"def",
"to_nuniq_interval_set",
"(",
"cls",
",",
"nested_is",
")",
":",
"r2",
"=",
"nested_is",
".",
"copy",
"(",
")",
"res",
"=",
"[",
"]",
"if",
"r2",
".",
"empty",
"(",
")",
":",
"return",
"IntervalSet",
"(",
")",
"order",
"=",
"0",
"while",
"no... | Convert an IntervalSet using the NESTED numbering scheme to an IntervalSet containing UNIQ numbers for HEALPix
cells.
Parameters
----------
nested_is : `IntervalSet`
IntervalSet object storing HEALPix cells as [ipix*4^(29-order), (ipix+1)*4^(29-order)[ intervals.
Re... | [
"Convert",
"an",
"IntervalSet",
"using",
"the",
"NESTED",
"numbering",
"scheme",
"to",
"an",
"IntervalSet",
"containing",
"UNIQ",
"numbers",
"for",
"HEALPix",
"cells",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L217-L261 | train |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet.from_nuniq_interval_set | def from_nuniq_interval_set(cls, nuniq_is):
"""
Convert an IntervalSet containing NUNIQ intervals to an IntervalSet representing HEALPix
cells following the NESTED numbering scheme.
Parameters
----------
nuniq_is : `IntervalSet`
IntervalSet object storing HEA... | python | def from_nuniq_interval_set(cls, nuniq_is):
"""
Convert an IntervalSet containing NUNIQ intervals to an IntervalSet representing HEALPix
cells following the NESTED numbering scheme.
Parameters
----------
nuniq_is : `IntervalSet`
IntervalSet object storing HEA... | [
"def",
"from_nuniq_interval_set",
"(",
"cls",
",",
"nuniq_is",
")",
":",
"nested_is",
"=",
"IntervalSet",
"(",
")",
"# Appending a list is faster than appending a numpy array",
"# For these algorithms we append a list and create the interval set from the finished list",
"rtmp",
"=",
... | Convert an IntervalSet containing NUNIQ intervals to an IntervalSet representing HEALPix
cells following the NESTED numbering scheme.
Parameters
----------
nuniq_is : `IntervalSet`
IntervalSet object storing HEALPix cells as [ipix + 4*4^(order), ipix+1 + 4*4^(order)[ interva... | [
"Convert",
"an",
"IntervalSet",
"containing",
"NUNIQ",
"intervals",
"to",
"an",
"IntervalSet",
"representing",
"HEALPix",
"cells",
"following",
"the",
"NESTED",
"numbering",
"scheme",
"."
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L264-L301 | train |
cds-astro/mocpy | mocpy/interval_set.py | IntervalSet.merge | def merge(a_intervals, b_intervals, op):
"""
Merge two lists of intervals according to the boolean function op
``a_intervals`` and ``b_intervals`` need to be sorted and consistent (no overlapping intervals).
This operation keeps the resulting interval set consistent.
Parameters... | python | def merge(a_intervals, b_intervals, op):
"""
Merge two lists of intervals according to the boolean function op
``a_intervals`` and ``b_intervals`` need to be sorted and consistent (no overlapping intervals).
This operation keeps the resulting interval set consistent.
Parameters... | [
"def",
"merge",
"(",
"a_intervals",
",",
"b_intervals",
",",
"op",
")",
":",
"a_endpoints",
"=",
"a_intervals",
".",
"flatten",
"(",
")",
".",
"tolist",
"(",
")",
"b_endpoints",
"=",
"b_intervals",
".",
"flatten",
"(",
")",
".",
"tolist",
"(",
")",
"se... | Merge two lists of intervals according to the boolean function op
``a_intervals`` and ``b_intervals`` need to be sorted and consistent (no overlapping intervals).
This operation keeps the resulting interval set consistent.
Parameters
----------
a_intervals : `~numpy.ndarray`
... | [
"Merge",
"two",
"lists",
"of",
"intervals",
"according",
"to",
"the",
"boolean",
"function",
"op"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/interval_set.py#L304-L357 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/globject.py | GLObject.delete | def delete(self):
""" Delete the object from GPU memory.
Note that the GPU object will also be deleted when this gloo
object is about to be deleted. However, sometimes you want to
explicitly delete the GPU object explicitly.
"""
# We only allow the object from being del... | python | def delete(self):
""" Delete the object from GPU memory.
Note that the GPU object will also be deleted when this gloo
object is about to be deleted. However, sometimes you want to
explicitly delete the GPU object explicitly.
"""
# We only allow the object from being del... | [
"def",
"delete",
"(",
"self",
")",
":",
"# We only allow the object from being deleted once, otherwise",
"# we might be deleting another GPU object that got our gl-id",
"# after our GPU object was deleted. Also note that e.g.",
"# DataBufferView does not have the _glir attribute.",
"if",
"hasa... | Delete the object from GPU memory.
Note that the GPU object will also be deleted when this gloo
object is about to be deleted. However, sometimes you want to
explicitly delete the GPU object explicitly. | [
"Delete",
"the",
"object",
"from",
"GPU",
"memory",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/globject.py#L80-L97 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/image.py | ImageVisual.set_data | def set_data(self, image):
"""Set the data
Parameters
----------
image : array-like
The image data.
"""
data = np.asarray(image)
if self._data is None or self._data.shape != data.shape:
self._need_vertex_update = True
self._data = ... | python | def set_data(self, image):
"""Set the data
Parameters
----------
image : array-like
The image data.
"""
data = np.asarray(image)
if self._data is None or self._data.shape != data.shape:
self._need_vertex_update = True
self._data = ... | [
"def",
"set_data",
"(",
"self",
",",
"image",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"image",
")",
"if",
"self",
".",
"_data",
"is",
"None",
"or",
"self",
".",
"_data",
".",
"shape",
"!=",
"data",
".",
"shape",
":",
"self",
".",
"_need... | Set the data
Parameters
----------
image : array-like
The image data. | [
"Set",
"the",
"data"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/image.py#L219-L231 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/image.py | ImageVisual._build_interpolation | def _build_interpolation(self):
"""Rebuild the _data_lookup_fn using different interpolations within
the shader
"""
interpolation = self._interpolation
self._data_lookup_fn = self._interpolation_fun[interpolation]
self.shared_program.frag['get_data'] = self._data_lookup_f... | python | def _build_interpolation(self):
"""Rebuild the _data_lookup_fn using different interpolations within
the shader
"""
interpolation = self._interpolation
self._data_lookup_fn = self._interpolation_fun[interpolation]
self.shared_program.frag['get_data'] = self._data_lookup_f... | [
"def",
"_build_interpolation",
"(",
"self",
")",
":",
"interpolation",
"=",
"self",
".",
"_interpolation",
"self",
".",
"_data_lookup_fn",
"=",
"self",
".",
"_interpolation_fun",
"[",
"interpolation",
"]",
"self",
".",
"shared_program",
".",
"frag",
"[",
"'get_d... | Rebuild the _data_lookup_fn using different interpolations within
the shader | [
"Rebuild",
"the",
"_data_lookup_fn",
"using",
"different",
"interpolations",
"within",
"the",
"shader"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/image.py#L306-L330 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/image.py | ImageVisual._build_vertex_data | def _build_vertex_data(self):
"""Rebuild the vertex buffers used for rendering the image when using
the subdivide method.
"""
grid = self._grid
w = 1.0 / grid[1]
h = 1.0 / grid[0]
quad = np.array([[0, 0, 0], [w, 0, 0], [w, h, 0],
[0, 0, 0... | python | def _build_vertex_data(self):
"""Rebuild the vertex buffers used for rendering the image when using
the subdivide method.
"""
grid = self._grid
w = 1.0 / grid[1]
h = 1.0 / grid[0]
quad = np.array([[0, 0, 0], [w, 0, 0], [w, h, 0],
[0, 0, 0... | [
"def",
"_build_vertex_data",
"(",
"self",
")",
":",
"grid",
"=",
"self",
".",
"_grid",
"w",
"=",
"1.0",
"/",
"grid",
"[",
"1",
"]",
"h",
"=",
"1.0",
"/",
"grid",
"[",
"0",
"]",
"quad",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
... | Rebuild the vertex buffers used for rendering the image when using
the subdivide method. | [
"Rebuild",
"the",
"vertex",
"buffers",
"used",
"for",
"rendering",
"the",
"image",
"when",
"using",
"the",
"subdivide",
"method",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/image.py#L332-L357 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/image.py | ImageVisual._update_method | def _update_method(self, view):
"""Decide which method to use for *view* and configure it accordingly.
"""
method = self._method
if method == 'auto':
if view.transforms.get_transform().Linear:
method = 'subdivide'
else:
method = 'im... | python | def _update_method(self, view):
"""Decide which method to use for *view* and configure it accordingly.
"""
method = self._method
if method == 'auto':
if view.transforms.get_transform().Linear:
method = 'subdivide'
else:
method = 'im... | [
"def",
"_update_method",
"(",
"self",
",",
"view",
")",
":",
"method",
"=",
"self",
".",
"_method",
"if",
"method",
"==",
"'auto'",
":",
"if",
"view",
".",
"transforms",
".",
"get_transform",
"(",
")",
".",
"Linear",
":",
"method",
"=",
"'subdivide'",
... | Decide which method to use for *view* and configure it accordingly. | [
"Decide",
"which",
"method",
"to",
"use",
"for",
"*",
"view",
"*",
"and",
"configure",
"it",
"accordingly",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/image.py#L359-L383 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py | AggFastPathCollection.append | def append(self, P, closed=False, itemsize=None, **kwargs):
"""
Append a new set of vertices to the collection.
For kwargs argument, n is the number of vertices (local) or the number
of item (shared)
Parameters
----------
P : np.array
Vertices posit... | python | def append(self, P, closed=False, itemsize=None, **kwargs):
"""
Append a new set of vertices to the collection.
For kwargs argument, n is the number of vertices (local) or the number
of item (shared)
Parameters
----------
P : np.array
Vertices posit... | [
"def",
"append",
"(",
"self",
",",
"P",
",",
"closed",
"=",
"False",
",",
"itemsize",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"itemsize",
"=",
"itemsize",
"or",
"len",
"(",
"P",
")",
"itemcount",
"=",
"len",
"(",
"P",
")",
"/",
"itemsize"... | Append a new set of vertices to the collection.
For kwargs argument, n is the number of vertices (local) or the number
of item (shared)
Parameters
----------
P : np.array
Vertices positions of the path(s) to be added
closed: bool
Whether path(s... | [
"Append",
"a",
"new",
"set",
"of",
"vertices",
"to",
"the",
"collection",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py#L93-L177 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py | AggFastPathCollection.bake | def bake(self, P, key='curr', closed=False, itemsize=None):
"""
Given a path P, return the baked vertices as they should be copied in
the collection if the path has already been appended.
Example:
--------
paths.append(P)
P *= 2
paths['prev'][0] = bake(P... | python | def bake(self, P, key='curr', closed=False, itemsize=None):
"""
Given a path P, return the baked vertices as they should be copied in
the collection if the path has already been appended.
Example:
--------
paths.append(P)
P *= 2
paths['prev'][0] = bake(P... | [
"def",
"bake",
"(",
"self",
",",
"P",
",",
"key",
"=",
"'curr'",
",",
"closed",
"=",
"False",
",",
"itemsize",
"=",
"None",
")",
":",
"itemsize",
"=",
"itemsize",
"or",
"len",
"(",
"P",
")",
"itemcount",
"=",
"len",
"(",
"P",
")",
"/",
"itemsize"... | Given a path P, return the baked vertices as they should be copied in
the collection if the path has already been appended.
Example:
--------
paths.append(P)
P *= 2
paths['prev'][0] = bake(P,'prev')
paths['curr'][0] = bake(P,'curr')
paths['next'][0] = ba... | [
"Given",
"a",
"path",
"P",
"return",
"the",
"baked",
"vertices",
"as",
"they",
"should",
"be",
"copied",
"in",
"the",
"collection",
"if",
"the",
"path",
"has",
"already",
"been",
"appended",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py#L179-L219 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py | AggFastPathCollection.draw | def draw(self, mode="triangle_strip"):
""" Draw collection """
gl.glDepthMask(gl.GL_FALSE)
Collection.draw(self, mode)
gl.glDepthMask(gl.GL_TRUE) | python | def draw(self, mode="triangle_strip"):
""" Draw collection """
gl.glDepthMask(gl.GL_FALSE)
Collection.draw(self, mode)
gl.glDepthMask(gl.GL_TRUE) | [
"def",
"draw",
"(",
"self",
",",
"mode",
"=",
"\"triangle_strip\"",
")",
":",
"gl",
".",
"glDepthMask",
"(",
"gl",
".",
"GL_FALSE",
")",
"Collection",
".",
"draw",
"(",
"self",
",",
"mode",
")",
"gl",
".",
"glDepthMask",
"(",
"gl",
".",
"GL_TRUE",
")... | Draw collection | [
"Draw",
"collection"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/agg_fast_path_collection.py#L221-L226 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/backends/ipython/_widget.py | _stop_timers | def _stop_timers(canvas):
"""Stop all timers in a canvas."""
for attr in dir(canvas):
try:
attr_obj = getattr(canvas, attr)
except NotImplementedError:
# This try/except is needed because canvas.position raises
# an error (it is not implemented in this backend... | python | def _stop_timers(canvas):
"""Stop all timers in a canvas."""
for attr in dir(canvas):
try:
attr_obj = getattr(canvas, attr)
except NotImplementedError:
# This try/except is needed because canvas.position raises
# an error (it is not implemented in this backend... | [
"def",
"_stop_timers",
"(",
"canvas",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"canvas",
")",
":",
"try",
":",
"attr_obj",
"=",
"getattr",
"(",
"canvas",
",",
"attr",
")",
"except",
"NotImplementedError",
":",
"# This try/except is needed because canvas.positi... | Stop all timers in a canvas. | [
"Stop",
"all",
"timers",
"in",
"a",
"canvas",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/backends/ipython/_widget.py#L21-L31 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | _last_stack_str | def _last_stack_str():
"""Print stack trace from call that didn't originate from here"""
stack = extract_stack()
for s in stack[::-1]:
if op.join('vispy', 'gloo', 'buffer.py') not in __file__:
break
return format_list([s])[0] | python | def _last_stack_str():
"""Print stack trace from call that didn't originate from here"""
stack = extract_stack()
for s in stack[::-1]:
if op.join('vispy', 'gloo', 'buffer.py') not in __file__:
break
return format_list([s])[0] | [
"def",
"_last_stack_str",
"(",
")",
":",
"stack",
"=",
"extract_stack",
"(",
")",
"for",
"s",
"in",
"stack",
"[",
":",
":",
"-",
"1",
"]",
":",
"if",
"op",
".",
"join",
"(",
"'vispy'",
",",
"'gloo'",
",",
"'buffer.py'",
")",
"not",
"in",
"__file__"... | Print stack trace from call that didn't originate from here | [
"Print",
"stack",
"trace",
"from",
"call",
"that",
"didn",
"t",
"originate",
"from",
"here"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L457-L463 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | Buffer.set_subdata | def set_subdata(self, data, offset=0, copy=False):
""" Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
copy: bool
... | python | def set_subdata(self, data, offset=0, copy=False):
""" Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
copy: bool
... | [
"def",
"set_subdata",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"0",
",",
"copy",
"=",
"False",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"copy",
"=",
"copy",
")",
"nbytes",
"=",
"data",
".",
"nbytes",
"if",
"offset",
"<",
... | Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
copy: bool
Since the operation is deferred, data may change befo... | [
"Set",
"a",
"sub",
"-",
"region",
"of",
"the",
"buffer",
"(",
"deferred",
"operation",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L61-L88 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | Buffer.set_data | def set_data(self, data, copy=False):
""" Set data in the buffer (deferred operation).
This completely resets the size and contents of the buffer.
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred... | python | def set_data(self, data, copy=False):
""" Set data in the buffer (deferred operation).
This completely resets the size and contents of the buffer.
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred... | [
"def",
"set_data",
"(",
"self",
",",
"data",
",",
"copy",
"=",
"False",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"copy",
"=",
"copy",
")",
"nbytes",
"=",
"data",
".",
"nbytes",
"if",
"nbytes",
"!=",
"self",
".",
"_nbytes",
":"... | Set data in the buffer (deferred operation).
This completely resets the size and contents of the buffer.
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred, data may change before
data is actua... | [
"Set",
"data",
"in",
"the",
"buffer",
"(",
"deferred",
"operation",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L90-L114 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | Buffer.resize_bytes | def resize_bytes(self, size):
""" Resize this buffer (deferred operation).
Parameters
----------
size : int
New buffer size in bytes.
"""
self._nbytes = size
self._glir.command('SIZE', self._id, size)
# Invalidate any view on this buf... | python | def resize_bytes(self, size):
""" Resize this buffer (deferred operation).
Parameters
----------
size : int
New buffer size in bytes.
"""
self._nbytes = size
self._glir.command('SIZE', self._id, size)
# Invalidate any view on this buf... | [
"def",
"resize_bytes",
"(",
"self",
",",
"size",
")",
":",
"self",
".",
"_nbytes",
"=",
"size",
"self",
".",
"_glir",
".",
"command",
"(",
"'SIZE'",
",",
"self",
".",
"_id",
",",
"size",
")",
"# Invalidate any view on this buffer",
"for",
"view",
"in",
"... | Resize this buffer (deferred operation).
Parameters
----------
size : int
New buffer size in bytes. | [
"Resize",
"this",
"buffer",
"(",
"deferred",
"operation",
")",
".",
"Parameters",
"----------",
"size",
":",
"int",
"New",
"buffer",
"size",
"in",
"bytes",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L116-L130 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | DataBuffer.set_subdata | def set_subdata(self, data, offset=0, copy=False, **kwargs):
""" Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
cop... | python | def set_subdata(self, data, offset=0, copy=False, **kwargs):
""" Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
cop... | [
"def",
"set_subdata",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"0",
",",
"copy",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_prepare_data",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
"offset",
"=",
"offset",
... | Set a sub-region of the buffer (deferred operation).
Parameters
----------
data : ndarray
Data to be uploaded
offset: int
Offset in buffer where to start copying data (in bytes)
copy: bool
Since the operation is deferred, data may change befo... | [
"Set",
"a",
"sub",
"-",
"region",
"of",
"the",
"buffer",
"(",
"deferred",
"operation",
")",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L157-L176 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | DataBuffer.set_data | def set_data(self, data, copy=False, **kwargs):
""" Set data (deferred operation)
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred, data may change before
data is actually uploaded to GPU memo... | python | def set_data(self, data, copy=False, **kwargs):
""" Set data (deferred operation)
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred, data may change before
data is actually uploaded to GPU memo... | [
"def",
"set_data",
"(",
"self",
",",
"data",
",",
"copy",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_prepare_data",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_dtype",
"=",
"data",
".",
"dtype",
"se... | Set data (deferred operation)
Parameters
----------
data : ndarray
Data to be uploaded
copy: bool
Since the operation is deferred, data may change before
data is actually uploaded to GPU memory.
Asking explicitly for a copy will prevent th... | [
"Set",
"data",
"(",
"deferred",
"operation",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L178-L196 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | DataBuffer.glsl_type | def glsl_type(self):
""" GLSL declaration strings required for a variable to hold this data.
"""
if self.dtype is None:
return None
dtshape = self.dtype[0].shape
n = dtshape[0] if dtshape else 1
if n > 1:
dtype = 'vec%d' % n
else:
... | python | def glsl_type(self):
""" GLSL declaration strings required for a variable to hold this data.
"""
if self.dtype is None:
return None
dtshape = self.dtype[0].shape
n = dtshape[0] if dtshape else 1
if n > 1:
dtype = 'vec%d' % n
else:
... | [
"def",
"glsl_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"dtype",
"is",
"None",
":",
"return",
"None",
"dtshape",
"=",
"self",
".",
"dtype",
"[",
"0",
"]",
".",
"shape",
"n",
"=",
"dtshape",
"[",
"0",
"]",
"if",
"dtshape",
"else",
"1",
"if",... | GLSL declaration strings required for a variable to hold this data. | [
"GLSL",
"declaration",
"strings",
"required",
"for",
"a",
"variable",
"to",
"hold",
"this",
"data",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L228-L239 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/buffer.py | DataBuffer.resize_bytes | def resize_bytes(self, size):
""" Resize the buffer (in-place, deferred operation)
Parameters
----------
size : integer
New buffer size in bytes
Notes
-----
This clears any pending operations.
"""
Buffer.resize_bytes(self, size)
... | python | def resize_bytes(self, size):
""" Resize the buffer (in-place, deferred operation)
Parameters
----------
size : integer
New buffer size in bytes
Notes
-----
This clears any pending operations.
"""
Buffer.resize_bytes(self, size)
... | [
"def",
"resize_bytes",
"(",
"self",
",",
"size",
")",
":",
"Buffer",
".",
"resize_bytes",
"(",
"self",
",",
"size",
")",
"self",
".",
"_size",
"=",
"size",
"//",
"self",
".",
"itemsize"
] | Resize the buffer (in-place, deferred operation)
Parameters
----------
size : integer
New buffer size in bytes
Notes
-----
This clears any pending operations. | [
"Resize",
"the",
"buffer",
"(",
"in",
"-",
"place",
"deferred",
"operation",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/buffer.py#L241-L254 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py | Compiler.compile | def compile(self, pretty=True):
""" Compile all code and return a dict {name: code} where the keys
are determined by the keyword arguments passed to __init__().
Parameters
----------
pretty : bool
If True, use a slower method to mangle object names. This produces
... | python | def compile(self, pretty=True):
""" Compile all code and return a dict {name: code} where the keys
are determined by the keyword arguments passed to __init__().
Parameters
----------
pretty : bool
If True, use a slower method to mangle object names. This produces
... | [
"def",
"compile",
"(",
"self",
",",
"pretty",
"=",
"True",
")",
":",
"# Authoritative mapping of {obj: name}",
"self",
".",
"_object_names",
"=",
"{",
"}",
"#",
"# 1. collect list of dependencies for each shader",
"#",
"# maps {shader_name: [deps]}",
"self",
".",
"_shad... | Compile all code and return a dict {name: code} where the keys
are determined by the keyword arguments passed to __init__().
Parameters
----------
pretty : bool
If True, use a slower method to mangle object names. This produces
GLSL that is more readable.
... | [
"Compile",
"all",
"code",
"and",
"return",
"a",
"dict",
"{",
"name",
":",
"code",
"}",
"where",
"the",
"keys",
"are",
"determined",
"by",
"the",
"keyword",
"arguments",
"passed",
"to",
"__init__",
"()",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py#L49-L118 | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py | Compiler._rename_objects_fast | def _rename_objects_fast(self):
""" Rename all objects quickly to guaranteed-unique names using the
id() of each object.
This produces mostly unreadable GLSL, but is about 10x faster to
compile.
"""
for shader_name, deps in self._shader_deps.items():
for dep ... | python | def _rename_objects_fast(self):
""" Rename all objects quickly to guaranteed-unique names using the
id() of each object.
This produces mostly unreadable GLSL, but is about 10x faster to
compile.
"""
for shader_name, deps in self._shader_deps.items():
for dep ... | [
"def",
"_rename_objects_fast",
"(",
"self",
")",
":",
"for",
"shader_name",
",",
"deps",
"in",
"self",
".",
"_shader_deps",
".",
"items",
"(",
")",
":",
"for",
"dep",
"in",
"deps",
":",
"name",
"=",
"dep",
".",
"name",
"if",
"name",
"!=",
"'main'",
"... | Rename all objects quickly to guaranteed-unique names using the
id() of each object.
This produces mostly unreadable GLSL, but is about 10x faster to
compile. | [
"Rename",
"all",
"objects",
"quickly",
"to",
"guaranteed",
"-",
"unique",
"names",
"using",
"the",
"id",
"()",
"of",
"each",
"object",
"."
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/compiler.py#L120-L133 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.