partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | translate | Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing the translation. | glue_vispy_viewers/extern/vispy/util/transforms.py | def translate(offset, dtype=None):
"""Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix descr... | def translate(offset, dtype=None):
"""Translate by an offset (x, y, z) .
Parameters
----------
offset : array-like, shape (3,)
Translation in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix descr... | [
"Translate",
"by",
"an",
"offset",
"(",
"x",
"y",
"z",
")",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L15-L36 | [
"def",
"translate",
"(",
"offset",
",",
"dtype",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"offset",
")",
"==",
"3",
"x",
",",
"y",
",",
"z",
"=",
"offset",
"M",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1.",
",",
"0.",
",",
"0.",
",",
"0... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | scale | Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing the scaling. | glue_vispy_viewers/extern/vispy/util/transforms.py | def scale(s, dtype=None):
"""Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing ... | def scale(s, dtype=None):
"""Non-uniform scaling along the x, y, and z axes
Parameters
----------
s : array-like, shape (3,)
Scaling in x, y, z.
dtype : dtype | None
Output type (if None, don't cast).
Returns
-------
M : ndarray
Transformation matrix describing ... | [
"Non",
"-",
"uniform",
"scaling",
"along",
"the",
"x",
"y",
"and",
"z",
"axes"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L39-L55 | [
"def",
"scale",
"(",
"s",
",",
"dtype",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"s",
")",
"==",
"3",
"return",
"np",
".",
"array",
"(",
"np",
".",
"diag",
"(",
"np",
".",
"concatenate",
"(",
"[",
"s",
",",
"(",
"1.",
",",
")",
"]",
")"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | rotate | The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector. | glue_vispy_viewers/extern/vispy/util/transforms.py | def rotate(angle, axis, dtype=None):
"""The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector.
"""
angle = np.radians(angle)
assert l... | def rotate(angle, axis, dtype=None):
"""The 3x3 rotation matrix for rotation about a vector.
Parameters
----------
angle : float
The angle of rotation, in degrees.
axis : ndarray
The x, y, z coordinates of the axis direction vector.
"""
angle = np.radians(angle)
assert l... | [
"The",
"3x3",
"rotation",
"matrix",
"for",
"rotation",
"about",
"a",
"vector",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L58-L77 | [
"def",
"rotate",
"(",
"angle",
",",
"axis",
",",
"dtype",
"=",
"None",
")",
":",
"angle",
"=",
"np",
".",
"radians",
"(",
"angle",
")",
"assert",
"len",
"(",
"axis",
")",
"==",
"3",
"x",
",",
"y",
",",
"z",
"=",
"axis",
"/",
"np",
".",
"linal... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | perspective | Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
Far coordinate of the field of view.
Returns... | glue_vispy_viewers/extern/vispy/util/transforms.py | def perspective(fovy, aspect, znear, zfar):
"""Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
... | def perspective(fovy, aspect, znear, zfar):
"""Create perspective projection matrix
Parameters
----------
fovy : float
The field of view along the y axis.
aspect : float
Aspect ratio of the view.
znear : float
Near coordinate of the field of view.
zfar : float
... | [
"Create",
"perspective",
"projection",
"matrix"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L156-L178 | [
"def",
"perspective",
"(",
"fovy",
",",
"aspect",
",",
"znear",
",",
"zfar",
")",
":",
"assert",
"(",
"znear",
"!=",
"zfar",
")",
"h",
"=",
"math",
".",
"tan",
"(",
"fovy",
"/",
"360.0",
"*",
"math",
".",
"pi",
")",
"*",
"znear",
"w",
"=",
"h",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | affine_map | Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3). | glue_vispy_viewers/extern/vispy/util/transforms.py | def affine_map(points1, points2):
""" Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3).
"""
A = np.ones((4, 4))
A[:, :3] = points1
B = np.ones((4, 4))
B[:, :3] = points2
# solve 3 sets of linear equat... | def affine_map(points1, points2):
""" Find a 3D transformation matrix that maps points1 onto points2.
Arguments are specified as arrays of four 3D coordinates, shape (4, 3).
"""
A = np.ones((4, 4))
A[:, :3] = points1
B = np.ones((4, 4))
B[:, :3] = points2
# solve 3 sets of linear equat... | [
"Find",
"a",
"3D",
"transformation",
"matrix",
"that",
"maps",
"points1",
"onto",
"points2",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L181-L198 | [
"def",
"affine_map",
"(",
"points1",
",",
"points2",
")",
":",
"A",
"=",
"np",
".",
"ones",
"(",
"(",
"4",
",",
"4",
")",
")",
"A",
"[",
":",
",",
":",
"3",
"]",
"=",
"points1",
"B",
"=",
"np",
".",
"ones",
"(",
"(",
"4",
",",
"4",
")",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Profiler.finish | Add a final message; flush the message list if no parent profiler. | glue_vispy_viewers/extern/vispy/util/profiler.py | def finish(self, msg=None):
"""Add a final message; flush the message list if no parent profiler.
"""
if self._finished or self.disable:
return
self._finished = True
if msg is not None:
self(msg)
self._new_msg("< Exiting %s, total time: %0.... | def finish(self, msg=None):
"""Add a final message; flush the message list if no parent profiler.
"""
if self._finished or self.disable:
return
self._finished = True
if msg is not None:
self(msg)
self._new_msg("< Exiting %s, total time: %0.... | [
"Add",
"a",
"final",
"message",
";",
"flush",
"the",
"message",
"list",
"if",
"no",
"parent",
"profiler",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/profiler.py#L121-L133 | [
"def",
"finish",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"self",
".",
"_finished",
"or",
"self",
".",
"disable",
":",
"return",
"self",
".",
"_finished",
"=",
"True",
"if",
"msg",
"is",
"not",
"None",
":",
"self",
"(",
"msg",
")",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _init | Create global Config object, parse command flags | glue_vispy_viewers/extern/vispy/util/config.py | def _init():
""" Create global Config object, parse command flags
"""
global config, _data_path, _allowed_config_keys
app_dir = _get_vispy_app_dir()
if app_dir is not None:
_data_path = op.join(app_dir, 'data')
_test_data_path = op.join(app_dir, 'test_data')
else:
_data_... | def _init():
""" Create global Config object, parse command flags
"""
global config, _data_path, _allowed_config_keys
app_dir = _get_vispy_app_dir()
if app_dir is not None:
_data_path = op.join(app_dir, 'data')
_test_data_path = op.join(app_dir, 'test_data')
else:
_data_... | [
"Create",
"global",
"Config",
"object",
"parse",
"command",
"flags"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L35-L88 | [
"def",
"_init",
"(",
")",
":",
"global",
"config",
",",
"_data_path",
",",
"_allowed_config_keys",
"app_dir",
"=",
"_get_vispy_app_dir",
"(",
")",
"if",
"app_dir",
"is",
"not",
"None",
":",
"_data_path",
"=",
"op",
".",
"join",
"(",
"app_dir",
",",
"'data'... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _parse_command_line_arguments | Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace. | glue_vispy_viewers/extern/vispy/util/config.py | def _parse_command_line_arguments():
""" Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace.
"""
global config
# Get command line args for vispy
argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',... | def _parse_command_line_arguments():
""" Transform vispy specific command line args to vispy config.
Put into a function so that any variables dont leak in the vispy namespace.
"""
global config
# Get command line args for vispy
argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',... | [
"Transform",
"vispy",
"specific",
"command",
"line",
"args",
"to",
"vispy",
"config",
".",
"Put",
"into",
"a",
"function",
"so",
"that",
"any",
"variables",
"dont",
"leak",
"in",
"the",
"vispy",
"namespace",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L138-L180 | [
"def",
"_parse_command_line_arguments",
"(",
")",
":",
"global",
"config",
"# Get command line args for vispy",
"argnames",
"=",
"[",
"'vispy-backend='",
",",
"'vispy-gl-debug'",
",",
"'vispy-glir-file='",
",",
"'vispy-log='",
",",
"'vispy-help'",
",",
"'vispy-profile='",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _get_vispy_app_dir | Helper to get the default directory for storing vispy data | glue_vispy_viewers/extern/vispy/util/config.py | def _get_vispy_app_dir():
"""Helper to get the default directory for storing vispy data"""
# Define default user directory
user_dir = os.path.expanduser('~')
# Get system app data dir
path = None
if sys.platform.startswith('win'):
path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP... | def _get_vispy_app_dir():
"""Helper to get the default directory for storing vispy data"""
# Define default user directory
user_dir = os.path.expanduser('~')
# Get system app data dir
path = None
if sys.platform.startswith('win'):
path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP... | [
"Helper",
"to",
"get",
"the",
"default",
"directory",
"for",
"storing",
"vispy",
"data"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L188-L224 | [
"def",
"_get_vispy_app_dir",
"(",
")",
":",
"# Define default user directory",
"user_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"# Get system app data dir",
"path",
"=",
"None",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _get_config_fname | Helper for the vispy config file | glue_vispy_viewers/extern/vispy/util/config.py | def _get_config_fname():
"""Helper for the vispy config file"""
directory = _get_vispy_app_dir()
if directory is None:
return None
fname = op.join(directory, 'vispy.json')
if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None:
fname = op.join(_TempDir(), 'vispy.json')
retu... | def _get_config_fname():
"""Helper for the vispy config file"""
directory = _get_vispy_app_dir()
if directory is None:
return None
fname = op.join(directory, 'vispy.json')
if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None:
fname = op.join(_TempDir(), 'vispy.json')
retu... | [
"Helper",
"for",
"the",
"vispy",
"config",
"file"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L300-L308 | [
"def",
"_get_config_fname",
"(",
")",
":",
"directory",
"=",
"_get_vispy_app_dir",
"(",
")",
"if",
"directory",
"is",
"None",
":",
"return",
"None",
"fname",
"=",
"op",
".",
"join",
"(",
"directory",
",",
"'vispy.json'",
")",
"if",
"os",
".",
"environ",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _load_config | Helper to load prefs from ~/.vispy/vispy.json | glue_vispy_viewers/extern/vispy/util/config.py | def _load_config():
"""Helper to load prefs from ~/.vispy/vispy.json"""
fname = _get_config_fname()
if fname is None or not op.isfile(fname):
return dict()
with open(fname, 'r') as fid:
config = json.load(fid)
return config | def _load_config():
"""Helper to load prefs from ~/.vispy/vispy.json"""
fname = _get_config_fname()
if fname is None or not op.isfile(fname):
return dict()
with open(fname, 'r') as fid:
config = json.load(fid)
return config | [
"Helper",
"to",
"load",
"prefs",
"from",
"~",
"/",
".",
"vispy",
"/",
"vispy",
".",
"json"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L311-L318 | [
"def",
"_load_config",
"(",
")",
":",
"fname",
"=",
"_get_config_fname",
"(",
")",
"if",
"fname",
"is",
"None",
"or",
"not",
"op",
".",
"isfile",
"(",
"fname",
")",
":",
"return",
"dict",
"(",
")",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | save_config | Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file. | glue_vispy_viewers/extern/vispy/util/config.py | def save_config(**kwargs):
"""Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file.
"""
if kwargs == {}:
kwargs = config._config
current_config = _load_config()
current_config.update(**... | def save_config(**kwargs):
"""Save configuration keys to vispy config file
Parameters
----------
**kwargs : keyword arguments
Key/value pairs to save to the config file.
"""
if kwargs == {}:
kwargs = config._config
current_config = _load_config()
current_config.update(**... | [
"Save",
"configuration",
"keys",
"to",
"vispy",
"config",
"file"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L321-L340 | [
"def",
"save_config",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"==",
"{",
"}",
":",
"kwargs",
"=",
"config",
".",
"_config",
"current_config",
"=",
"_load_config",
"(",
")",
"current_config",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"# wr... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | set_data_dir | Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to the vispy config. | glue_vispy_viewers/extern/vispy/util/config.py | def set_data_dir(directory=None, create=False, save=False):
"""Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to... | def set_data_dir(directory=None, create=False, save=False):
"""Set vispy data download directory
Parameters
----------
directory : str | None
The directory to use.
create : bool
If True, create directory if it doesn't exist.
save : bool
If True, save the configuration to... | [
"Set",
"vispy",
"data",
"download",
"directory"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L343-L367 | [
"def",
"set_data_dir",
"(",
"directory",
"=",
"None",
",",
"create",
"=",
"False",
",",
"save",
"=",
"False",
")",
":",
"if",
"directory",
"is",
"None",
":",
"directory",
"=",
"_data_path",
"if",
"_data_path",
"is",
"None",
":",
"raise",
"IOError",
"(",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _enable_profiling | Start profiling and register callback to print stats when the program
exits. | glue_vispy_viewers/extern/vispy/util/config.py | def _enable_profiling():
""" Start profiling and register callback to print stats when the program
exits.
"""
import cProfile
import atexit
global _profiler
_profiler = cProfile.Profile()
_profiler.enable()
atexit.register(_profile_atexit) | def _enable_profiling():
""" Start profiling and register callback to print stats when the program
exits.
"""
import cProfile
import atexit
global _profiler
_profiler = cProfile.Profile()
_profiler.enable()
atexit.register(_profile_atexit) | [
"Start",
"profiling",
"and",
"register",
"callback",
"to",
"print",
"stats",
"when",
"the",
"program",
"exits",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L370-L379 | [
"def",
"_enable_profiling",
"(",
")",
":",
"import",
"cProfile",
"import",
"atexit",
"global",
"_profiler",
"_profiler",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"_profiler",
".",
"enable",
"(",
")",
"atexit",
".",
"register",
"(",
"_profile_atexit",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | sys_info | Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
The system information as a string. | glue_vispy_viewers/extern/vispy/util/config.py | def sys_info(fname=None, overwrite=False):
"""Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
... | def sys_info(fname=None, overwrite=False):
"""Get relevant system and debugging information
Parameters
----------
fname : str | None
Filename to dump info to. Use None to simply print.
overwrite : bool
If True, overwrite file (if it exists).
Returns
-------
out : str
... | [
"Get",
"relevant",
"system",
"and",
"debugging",
"information"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L390-L442 | [
"def",
"sys_info",
"(",
"fname",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"fname",
"is",
"not",
"None",
"and",
"op",
".",
"isfile",
"(",
"fname",
")",
"and",
"not",
"overwrite",
":",
"raise",
"IOError",
"(",
"'file exists, use overwri... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | compact | Compact vertices and indices within given tolerance | glue_vispy_viewers/extern/vispy/geometry/normals.py | def compact(vertices, indices, tolerance=1e-3):
""" Compact vertices and indices within given tolerance """
# Transform vertices into a structured array for np.unique to work
n = len(vertices)
V = np.zeros(n, dtype=[("pos", np.float32, 3)])
V["pos"][:, 0] = vertices[:, 0]
V["pos"][:, 1] = verti... | def compact(vertices, indices, tolerance=1e-3):
""" Compact vertices and indices within given tolerance """
# Transform vertices into a structured array for np.unique to work
n = len(vertices)
V = np.zeros(n, dtype=[("pos", np.float32, 3)])
V["pos"][:, 0] = vertices[:, 0]
V["pos"][:, 1] = verti... | [
"Compact",
"vertices",
"and",
"indices",
"within",
"given",
"tolerance"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L10-L49 | [
"def",
"compact",
"(",
"vertices",
",",
"indices",
",",
"tolerance",
"=",
"1e-3",
")",
":",
"# Transform vertices into a structured array for np.unique to work",
"n",
"=",
"len",
"(",
"vertices",
")",
"V",
"=",
"np",
".",
"zeros",
"(",
"n",
",",
"dtype",
"=",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | normals | Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices | glue_vispy_viewers/extern/vispy/geometry/normals.py | def normals(vertices, indices):
"""
Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices
"""
# Compact similar vertices
vertices, indices, mapping = compact(vertices... | def normals(vertices, indices):
"""
Compute normals over a triangulated surface
Parameters
----------
vertices : ndarray (n,3)
triangles vertices
indices : ndarray (p,3)
triangles indices
"""
# Compact similar vertices
vertices, indices, mapping = compact(vertices... | [
"Compute",
"normals",
"over",
"a",
"triangulated",
"surface"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L52-L82 | [
"def",
"normals",
"(",
"vertices",
",",
"indices",
")",
":",
"# Compact similar vertices",
"vertices",
",",
"indices",
",",
"mapping",
"=",
"compact",
"(",
"vertices",
",",
"indices",
")",
"T",
"=",
"vertices",
"[",
"indices",
"]",
"N",
"=",
"np",
".",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.create_native | Create the native widget if not already done so. If the widget
is already created, this function does nothing. | glue_vispy_viewers/extern/vispy/app/canvas.py | def create_native(self):
""" Create the native widget if not already done so. If the widget
is already created, this function does nothing.
"""
if self._backend is not None:
return
# Make sure that the app is active
assert self._app.native
# Instantiat... | def create_native(self):
""" Create the native widget if not already done so. If the widget
is already created, this function does nothing.
"""
if self._backend is not None:
return
# Make sure that the app is active
assert self._app.native
# Instantiat... | [
"Create",
"the",
"native",
"widget",
"if",
"not",
"already",
"done",
"so",
".",
"If",
"the",
"widget",
"is",
"already",
"created",
"this",
"function",
"does",
"nothing",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L213-L231 | [
"def",
"create_native",
"(",
"self",
")",
":",
"if",
"self",
".",
"_backend",
"is",
"not",
"None",
":",
"return",
"# Make sure that the app is active",
"assert",
"self",
".",
"_app",
".",
"native",
"# Instantiate the backend with the right class",
"self",
".",
"_app... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.connect | Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
fun : callable
T... | glue_vispy_viewers/extern/vispy/app/canvas.py | def connect(self, fun):
""" Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
... | def connect(self, fun):
""" Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
... | [
"Connect",
"a",
"function",
"to",
"an",
"event"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L302-L330 | [
"def",
"connect",
"(",
"self",
",",
"fun",
")",
":",
"# Get and check name",
"name",
"=",
"fun",
".",
"__name__",
"if",
"not",
"name",
".",
"startswith",
"(",
"'on_'",
")",
":",
"raise",
"ValueError",
"(",
"'When connecting a function based on its name, '",
"'th... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.size | The size of canvas/window | glue_vispy_viewers/extern/vispy/app/canvas.py | def size(self):
""" The size of canvas/window """
size = self._backend._vispy_get_size()
return (size[0] // self._px_scale, size[1] // self._px_scale) | def size(self):
""" The size of canvas/window """
size = self._backend._vispy_get_size()
return (size[0] // self._px_scale, size[1] // self._px_scale) | [
"The",
"size",
"of",
"canvas",
"/",
"window"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L334-L337 | [
"def",
"size",
"(",
"self",
")",
":",
"size",
"=",
"self",
".",
"_backend",
".",
"_vispy_get_size",
"(",
")",
"return",
"(",
"size",
"[",
"0",
"]",
"//",
"self",
".",
"_px_scale",
",",
"size",
"[",
"1",
"]",
"//",
"self",
".",
"_px_scale",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.show | Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop. | glue_vispy_viewers/extern/vispy/app/canvas.py | def show(self, visible=True, run=False):
"""Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop.
"""
self._backend._vispy_set_visible(visible)
if run:
... | def show(self, visible=True, run=False):
"""Show or hide the canvas
Parameters
----------
visible : bool
Make the canvas visible.
run : bool
Run the backend event loop.
"""
self._backend._vispy_set_visible(visible)
if run:
... | [
"Show",
"or",
"hide",
"the",
"canvas"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L419-L431 | [
"def",
"show",
"(",
"self",
",",
"visible",
"=",
"True",
",",
"run",
"=",
"False",
")",
":",
"self",
".",
"_backend",
".",
"_vispy_set_visible",
"(",
"visible",
")",
"if",
"run",
":",
"self",
".",
"app",
".",
"run",
"(",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.close | Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making the widget a sub-widget. | glue_vispy_viewers/extern/vispy/app/canvas.py | def close(self):
"""Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making t... | def close(self):
"""Close the canvas
Notes
-----
This will usually destroy the GL context. For Qt, the context
(and widget) will be destroyed only if the widget is top-level.
To avoid having the widget destroyed (more like standard Qt
behavior), consider making t... | [
"Close",
"the",
"canvas"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L444-L458 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_backend",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"self",
".",
"events",
".",
"close",
"(",
")",
"self",
".",
"_backend",
".",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas._update_fps | Update the fps after every window | glue_vispy_viewers/extern/vispy/app/canvas.py | def _update_fps(self, event):
"""Update the fps after every window"""
self._frame_count += 1
diff = time() - self._basetime
if (diff > self._fps_window):
self._fps = self._frame_count / diff
self._basetime = time()
self._frame_count = 0
sel... | def _update_fps(self, event):
"""Update the fps after every window"""
self._frame_count += 1
diff = time() - self._basetime
if (diff > self._fps_window):
self._fps = self._frame_count / diff
self._basetime = time()
self._frame_count = 0
sel... | [
"Update",
"the",
"fps",
"after",
"every",
"window"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L460-L468 | [
"def",
"_update_fps",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_frame_count",
"+=",
"1",
"diff",
"=",
"time",
"(",
")",
"-",
"self",
".",
"_basetime",
"if",
"(",
"diff",
">",
"self",
".",
"_fps_window",
")",
":",
"self",
".",
"_fps",
"=",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.measure_fps | Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS. Default 1.0.
callback : function | str
The f... | glue_vispy_viewers/extern/vispy/app/canvas.py | def measure_fps(self, window=1, callback='%1.1f FPS'):
"""Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS... | def measure_fps(self, window=1, callback='%1.1f FPS'):
"""Measure the current FPS
Sets the update window, connects the draw event to update_fps
and sets the callback function.
Parameters
----------
window : float
The time-window (in seconds) to calculate FPS... | [
"Measure",
"the",
"current",
"FPS"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L470-L499 | [
"def",
"measure_fps",
"(",
"self",
",",
"window",
"=",
"1",
",",
"callback",
"=",
"'%1.1f FPS'",
")",
":",
"# Connect update_fps function to draw",
"self",
".",
"events",
".",
"draw",
".",
"disconnect",
"(",
"self",
".",
"_update_fps",
")",
"if",
"callback",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Canvas.render | Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region. | glue_vispy_viewers/extern/vispy/app/canvas.py | def render(self):
""" Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region.
"""
... | def render(self):
""" Render the canvas to an offscreen buffer and return the image
array.
Returns
-------
image : array
Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the
upper-left corner of the rendered region.
"""
... | [
"Render",
"the",
"canvas",
"to",
"an",
"offscreen",
"buffer",
"and",
"return",
"the",
"image",
"array",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L520-L541 | [
"def",
"render",
"(",
"self",
")",
":",
"self",
".",
"set_current",
"(",
")",
"size",
"=",
"self",
".",
"physical_size",
"fbo",
"=",
"FrameBuffer",
"(",
"color",
"=",
"RenderBuffer",
"(",
"size",
"[",
":",
":",
"-",
"1",
"]",
")",
",",
"depth",
"="... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | MouseEvent.drag_events | Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation. | glue_vispy_viewers/extern/vispy/app/canvas.py | def drag_events(self):
""" Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation.
"""
if not self.is_dragging:
return None
event = self
events = []
while True:
# mouse_press ev... | def drag_events(self):
""" Return a list of all mouse events in the current drag operation.
Returns None if there is no current drag operation.
"""
if not self.is_dragging:
return None
event = self
events = []
while True:
# mouse_press ev... | [
"Return",
"a",
"list",
"of",
"all",
"mouse",
"events",
"in",
"the",
"current",
"drag",
"operation",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L639-L656 | [
"def",
"drag_events",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_dragging",
":",
"return",
"None",
"event",
"=",
"self",
"events",
"=",
"[",
"]",
"while",
"True",
":",
"# mouse_press events can only be the start of a trail",
"if",
"event",
"is",
"Non... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | MouseEvent.trail | Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation. | glue_vispy_viewers/extern/vispy/app/canvas.py | def trail(self):
""" Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation.
"""
events = self.drag_events()
if events is None:
return None
trail = np.empty(... | def trail(self):
""" Return an (N, 2) array of mouse coordinates for every event in the
current mouse drag operation.
Returns None if there is no current drag operation.
"""
events = self.drag_events()
if events is None:
return None
trail = np.empty(... | [
"Return",
"an",
"(",
"N",
"2",
")",
"array",
"of",
"mouse",
"coordinates",
"for",
"every",
"event",
"in",
"the",
"current",
"mouse",
"drag",
"operation",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L658-L672 | [
"def",
"trail",
"(",
"self",
")",
":",
"events",
"=",
"self",
".",
"drag_events",
"(",
")",
"if",
"events",
"is",
"None",
":",
"return",
"None",
"trail",
"=",
"np",
".",
"empty",
"(",
"(",
"len",
"(",
"events",
")",
",",
"2",
")",
",",
"dtype",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.width_min | Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def width_min(self, width_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if width_min is None:
self._width_limits[0] = 0
return
width_min = float(wi... | def width_min(self, width_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if width_min is None:
self._width_limits[0] = 0
return
width_min = float(wi... | [
"Set",
"the",
"minimum",
"height",
"of",
"the",
"widget"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L133-L151 | [
"def",
"width_min",
"(",
"self",
",",
"width_min",
")",
":",
"if",
"width_min",
"is",
"None",
":",
"self",
".",
"_width_limits",
"[",
"0",
"]",
"=",
"0",
"return",
"width_min",
"=",
"float",
"(",
"width_min",
")",
"assert",
"(",
"0",
"<=",
"width_min",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.width_max | Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def width_max(self, width_max):
"""Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded
"""
if width_max is None:
self._width_limits[1] ... | def width_max(self, width_max):
"""Set the maximum width of the widget.
Parameters
----------
width_max: None | float
the maximum width of the widget. if None, maximum width
is unbounded
"""
if width_max is None:
self._width_limits[1] ... | [
"Set",
"the",
"maximum",
"width",
"of",
"the",
"widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L159-L176 | [
"def",
"width_max",
"(",
"self",
",",
"width_max",
")",
":",
"if",
"width_max",
"is",
"None",
":",
"self",
".",
"_width_limits",
"[",
"1",
"]",
"=",
"None",
"return",
"width_max",
"=",
"float",
"(",
"width_max",
")",
"assert",
"(",
"self",
".",
"width_... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.height_min | Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def height_min(self, height_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if height_min is None:
self._height_limits[0] = 0
return
height_min = floa... | def height_min(self, height_min):
"""Set the minimum height of the widget
Parameters
----------
height_min: float
the minimum height of the widget
"""
if height_min is None:
self._height_limits[0] = 0
return
height_min = floa... | [
"Set",
"the",
"minimum",
"height",
"of",
"the",
"widget"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L189-L206 | [
"def",
"height_min",
"(",
"self",
",",
"height_min",
")",
":",
"if",
"height_min",
"is",
"None",
":",
"self",
".",
"_height_limits",
"[",
"0",
"]",
"=",
"0",
"return",
"height_min",
"=",
"float",
"(",
"height_min",
")",
"assert",
"(",
"height_min",
">=",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.height_max | Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def height_max(self, height_max):
"""Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded
"""
if height_max is None:
self._height_li... | def height_max(self, height_max):
"""Set the maximum height of the widget.
Parameters
----------
height_max: None | float
the maximum height of the widget. if None, maximum height
is unbounded
"""
if height_max is None:
self._height_li... | [
"Set",
"the",
"maximum",
"height",
"of",
"the",
"widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L214-L230 | [
"def",
"height_max",
"(",
"self",
",",
"height_max",
")",
":",
"if",
"height_max",
"is",
"None",
":",
"self",
".",
"_height_limits",
"[",
"1",
"]",
"=",
"None",
"return",
"height_max",
"=",
"float",
"(",
"height_max",
")",
"assert",
"(",
"0",
"<=",
"se... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.inner_rect | The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle. | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def inner_rect(self):
"""The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle.
"""
m = self.margin + self._border_width + self.padding
if not self.border_color.is_blank:
... | def inner_rect(self):
"""The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside
this rectangle.
"""
m = self.margin + self._border_width + self.padding
if not self.border_color.is_blank:
... | [
"The",
"rectangular",
"area",
"inside",
"the",
"margin",
"border",
"and",
"padding",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L245-L254 | [
"def",
"inner_rect",
"(",
"self",
")",
":",
"m",
"=",
"self",
".",
"margin",
"+",
"self",
".",
"_border_width",
"+",
"self",
".",
"padding",
"if",
"not",
"self",
".",
"border_color",
".",
"is_blank",
":",
"m",
"+=",
"1",
"return",
"Rect",
"(",
"(",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget._update_clipper | Called whenever the clipper for this widget may need to be updated. | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def _update_clipper(self):
"""Called whenever the clipper for this widget may need to be updated.
"""
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
... | def _update_clipper(self):
"""Called whenever the clipper for this widget may need to be updated.
"""
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
... | [
"Called",
"whenever",
"the",
"clipper",
"for",
"this",
"widget",
"may",
"need",
"to",
"be",
"updated",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L283-L294 | [
"def",
"_update_clipper",
"(",
"self",
")",
":",
"if",
"self",
".",
"clip_children",
"and",
"self",
".",
"_clipper",
"is",
"None",
":",
"self",
".",
"_clipper",
"=",
"Clipper",
"(",
")",
"elif",
"not",
"self",
".",
"clip_children",
":",
"self",
".",
"_... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget._update_line | Update border line to match new shape | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def _update_line(self):
""" Update border line to match new shape """
w = self._border_width
m = self.margin
# border is drawn within the boundaries of the widget:
#
# size = (8, 7) margin=2
# internal rect = (3, 3, 2, 1)
# ........
# ........... | def _update_line(self):
""" Update border line to match new shape """
w = self._border_width
m = self.margin
# border is drawn within the boundaries of the widget:
#
# size = (8, 7) margin=2
# internal rect = (3, 3, 2, 1)
# ........
# ........... | [
"Update",
"border",
"line",
"to",
"match",
"new",
"shape"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L344-L390 | [
"def",
"_update_line",
"(",
"self",
")",
":",
"w",
"=",
"self",
".",
"_border_width",
"m",
"=",
"self",
".",
"margin",
"# border is drawn within the boundaries of the widget:",
"#",
"# size = (8, 7) margin=2",
"# internal rect = (3, 3, 2, 1)",
"# ........",
"# ........... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.add_widget | Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget : instance of Widget
The widget to add.... | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def add_widget(self, widget):
"""
Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget :... | def add_widget(self, widget):
"""
Add a Widget as a managed child of this Widget.
The child will be
automatically positioned and sized to fill the entire space inside
this Widget (unless _update_child_widgets is redefined).
Parameters
----------
widget :... | [
"Add",
"a",
"Widget",
"as",
"a",
"managed",
"child",
"of",
"this",
"Widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L419-L440 | [
"def",
"add_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_widgets",
".",
"append",
"(",
"widget",
")",
"widget",
".",
"parent",
"=",
"self",
"self",
".",
"_update_child_widgets",
"(",
")",
"return",
"widget"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.add_grid | Create a new Grid and add it as a child widget.
All arguments are given to Grid(). | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def add_grid(self, *args, **kwargs):
"""
Create a new Grid and add it as a child widget.
All arguments are given to Grid().
"""
from .grid import Grid
grid = Grid(*args, **kwargs)
return self.add_widget(grid) | def add_grid(self, *args, **kwargs):
"""
Create a new Grid and add it as a child widget.
All arguments are given to Grid().
"""
from .grid import Grid
grid = Grid(*args, **kwargs)
return self.add_widget(grid) | [
"Create",
"a",
"new",
"Grid",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L442-L450 | [
"def",
"add_grid",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"grid",
"import",
"Grid",
"grid",
"=",
"Grid",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"add_widget",
"(",
"grid",
")"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.add_view | Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox(). | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def add_view(self, *args, **kwargs):
"""
Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox().
"""
from .viewbox import ViewBox
view = ViewBox(*args, **kwargs)
return self.add_widget(view) | def add_view(self, *args, **kwargs):
"""
Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox().
"""
from .viewbox import ViewBox
view = ViewBox(*args, **kwargs)
return self.add_widget(view) | [
"Create",
"a",
"new",
"ViewBox",
"and",
"add",
"it",
"as",
"a",
"child",
"widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L452-L460 | [
"def",
"add_view",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"viewbox",
"import",
"ViewBox",
"view",
"=",
"ViewBox",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"add_widget",
"(",
"vie... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Widget.remove_widget | Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove. | glue_vispy_viewers/extern/vispy/scene/widgets/widget.py | def remove_widget(self, widget):
"""
Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove.
"""
self._widgets.remove(widget)
widget.parent = None
self._update_child_wi... | def remove_widget(self, widget):
"""
Remove a Widget as a managed child of this Widget.
Parameters
----------
widget : instance of Widget
The widget to remove.
"""
self._widgets.remove(widget)
widget.parent = None
self._update_child_wi... | [
"Remove",
"a",
"Widget",
"as",
"a",
"managed",
"child",
"of",
"this",
"Widget",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L462-L473 | [
"def",
"remove_widget",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_widgets",
".",
"remove",
"(",
"widget",
")",
"widget",
".",
"parent",
"=",
"None",
"self",
".",
"_update_child_widgets",
"(",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | pack_unit | Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel | glue_vispy_viewers/extern/vispy/io/datasets.py | def pack_unit(value):
"""Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
pack = np.zeros(value.shape + (4,), dtype=np.ubyte)
for i in range(4):
value, pack[..., i] = np.modf(value * 256.)
return pack | def pack_unit(value):
"""Packs float values between [0,1] into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
pack = np.zeros(value.shape + (4,), dtype=np.ubyte)
for i in range(4):
value, pack[..., i] = np.modf(value * 256.)
return pack | [
"Packs",
"float",
"values",
"between",
"[",
"0",
"1",
"]",
"into",
"4",
"unsigned",
"int8"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L38-L49 | [
"def",
"pack_unit",
"(",
"value",
")",
":",
"pack",
"=",
"np",
".",
"zeros",
"(",
"value",
".",
"shape",
"+",
"(",
"4",
",",
")",
",",
"dtype",
"=",
"np",
".",
"ubyte",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"value",
",",
"pack",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | pack_ieee | Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel | glue_vispy_viewers/extern/vispy/io/datasets.py | def pack_ieee(value):
"""Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
return np.fromstring(value.tostring(),
np.ubyte).reshape((value.shape + (4,))) | def pack_ieee(value):
"""Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
return np.fromstring(value.tostring(),
np.ubyte).reshape((value.shape + (4,))) | [
"Packs",
"float",
"ieee",
"binary",
"representation",
"into",
"4",
"unsigned",
"int8"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L52-L61 | [
"def",
"pack_ieee",
"(",
"value",
")",
":",
"return",
"np",
".",
"fromstring",
"(",
"value",
".",
"tostring",
"(",
")",
",",
"np",
".",
"ubyte",
")",
".",
"reshape",
"(",
"(",
"value",
".",
"shape",
"+",
"(",
"4",
",",
")",
")",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | load_spatial_filters | Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16x1024 (unpacked float)
16 interpolatio... | glue_vispy_viewers/extern/vispy/io/datasets.py | def load_spatial_filters(packed=True):
"""Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16... | def load_spatial_filters(packed=True):
"""Load spatial-filters kernel
Parameters
----------
packed : bool
Whether or not the data should be in "packed" representation
for use in GLSL code.
Returns
-------
kernel : array
16x1024x4 (packed float in rgba) or
16... | [
"Load",
"spatial",
"-",
"filters",
"kernel"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L64-L94 | [
"def",
"load_spatial_filters",
"(",
"packed",
"=",
"True",
")",
":",
"names",
"=",
"(",
"\"Bilinear\"",
",",
"\"Hanning\"",
",",
"\"Hamming\"",
",",
"\"Hermite\"",
",",
"\"Kaiser\"",
",",
"\"Quadric\"",
",",
"\"Bicubic\"",
",",
"\"CatRom\"",
",",
"\"Mitchell\"",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | list_fonts | List system fonts
Returns
-------
fonts : list of str
List of system fonts. | glue_vispy_viewers/extern/vispy/util/fonts/_triage.py | def list_fonts():
"""List system fonts
Returns
-------
fonts : list of str
List of system fonts.
"""
vals = _list_fonts()
for font in _vispy_fonts:
vals += [font] if font not in vals else []
vals = sorted(vals, key=lambda s: s.lower())
return vals | def list_fonts():
"""List system fonts
Returns
-------
fonts : list of str
List of system fonts.
"""
vals = _list_fonts()
for font in _vispy_fonts:
vals += [font] if font not in vals else []
vals = sorted(vals, key=lambda s: s.lower())
return vals | [
"List",
"system",
"fonts"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fonts/_triage.py#L24-L36 | [
"def",
"list_fonts",
"(",
")",
":",
"vals",
"=",
"_list_fonts",
"(",
")",
"for",
"font",
"in",
"_vispy_fonts",
":",
"vals",
"+=",
"[",
"font",
"]",
"if",
"font",
"not",
"in",
"vals",
"else",
"[",
"]",
"vals",
"=",
"sorted",
"(",
"vals",
",",
"key",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | timeout | A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example:
>>>def timeout_handler(limit, ... | contexttimer/timeout.py | def timeout(limit, handler):
"""A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example... | def timeout(limit, handler):
"""A decorator ensuring that the decorated function tun time does not
exceeds the argument limit.
:args limit: the time limit
:type limit: int
:args handler: the handler function called when the decorated
function times out.
:type handler: callable
Example... | [
"A",
"decorator",
"ensuring",
"that",
"the",
"decorated",
"function",
"tun",
"time",
"does",
"not",
"exceeds",
"the",
"argument",
"limit",
"."
] | brouberol/contexttimer | python | https://github.com/brouberol/contexttimer/blob/a866f420ed4c10f29abf252c58b11f9db6706100/contexttimer/timeout.py#L39-L80 | [
"def",
"timeout",
"(",
"limit",
",",
"handler",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"def",
"wrapped_f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"old_handler",
"=",
"signal",
".",
"getsignal",
"(",
"signal",
".",
"SIGALRM",
... | a866f420ed4c10f29abf252c58b11f9db6706100 |
train | BaseCanvasBackend._process_backend_kwargs | Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities. | glue_vispy_viewers/extern/vispy/app/base.py | def _process_backend_kwargs(self, kwargs):
""" Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities.
"""
# Verify given argument with capability of the backend
app = self.... | def _process_backend_kwargs(self, kwargs):
""" Simple utility to retrieve kwargs in predetermined order.
Also checks whether the values of the backend arguments do not
violate the backend capabilities.
"""
# Verify given argument with capability of the backend
app = self.... | [
"Simple",
"utility",
"to",
"retrieve",
"kwargs",
"in",
"predetermined",
"order",
".",
"Also",
"checks",
"whether",
"the",
"values",
"of",
"the",
"backend",
"arguments",
"do",
"not",
"violate",
"the",
"backend",
"capabilities",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/base.py#L80-L106 | [
"def",
"_process_backend_kwargs",
"(",
"self",
",",
"kwargs",
")",
":",
"# Verify given argument with capability of the backend",
"app",
"=",
"self",
".",
"_vispy_canvas",
".",
"app",
"capability",
"=",
"app",
".",
"backend_module",
".",
"capability",
"if",
"kwargs",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | FlyCamera._set_range | Reset the view. | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | def _set_range(self, init):
""" Reset the view.
"""
#PerspectiveCamera._set_range(self, init)
# Stop moving
self._speed *= 0.0
# Get window size (and store factor now to sync with resizing)
w, h = self._viewbox.size
w, h = float(w), float(h)
# ... | def _set_range(self, init):
""" Reset the view.
"""
#PerspectiveCamera._set_range(self, init)
# Stop moving
self._speed *= 0.0
# Get window size (and store factor now to sync with resizing)
w, h = self._viewbox.size
w, h = float(w), float(h)
# ... | [
"Reset",
"the",
"view",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L146-L200 | [
"def",
"_set_range",
"(",
"self",
",",
"init",
")",
":",
"#PerspectiveCamera._set_range(self, init)",
"# Stop moving",
"self",
".",
"_speed",
"*=",
"0.0",
"# Get window size (and store factor now to sync with resizing)",
"w",
",",
"h",
"=",
"self",
".",
"_viewbox",
".",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | FlyCamera.on_timer | Timer event handler
Parameters
----------
event : instance of Event
The event. | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | def on_timer(self, event):
"""Timer event handler
Parameters
----------
event : instance of Event
The event.
"""
# Set relative speed and acceleration
rel_speed = event.dt
rel_acc = 0.1
# Get what's forward
pf, pr, pl, pu = s... | def on_timer(self, event):
"""Timer event handler
Parameters
----------
event : instance of Event
The event.
"""
# Set relative speed and acceleration
rel_speed = event.dt
rel_acc = 0.1
# Get what's forward
pf, pr, pl, pu = s... | [
"Timer",
"event",
"handler"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L231-L324 | [
"def",
"on_timer",
"(",
"self",
",",
"event",
")",
":",
"# Set relative speed and acceleration",
"rel_speed",
"=",
"event",
".",
"dt",
"rel_acc",
"=",
"0.1",
"# Get what's forward",
"pf",
",",
"pr",
",",
"pl",
",",
"pu",
"=",
"self",
".",
"_get_directions",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | FlyCamera.viewbox_key_event | ViewBox key event handler
Parameters
----------
event : instance of Event
The event. | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | def viewbox_key_event(self, event):
"""ViewBox key event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_key_event(self, event)
if event.handled or not self.interactive:
return
# E... | def viewbox_key_event(self, event):
"""ViewBox key event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_key_event(self, event)
if event.handled or not self.interactive:
return
# E... | [
"ViewBox",
"key",
"event",
"handler"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L326-L357 | [
"def",
"viewbox_key_event",
"(",
"self",
",",
"event",
")",
":",
"PerspectiveCamera",
".",
"viewbox_key_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"# Ensure the timer runs",
"i... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | FlyCamera.viewbox_mouse_event | ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event. | glue_vispy_viewers/extern/vispy/scene/cameras/fly.py | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_mouse_event(self, event)
if event.handled or not self.interactive:
return
... | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The event.
"""
PerspectiveCamera.viewbox_mouse_event(self, event)
if event.handled or not self.interactive:
return
... | [
"ViewBox",
"mouse",
"event",
"handler"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L359-L439 | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"PerspectiveCamera",
".",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
"if",
"event",
".",
"handled",
"or",
"not",
"self",
".",
"interactive",
":",
"return",
"if",
"event",
".",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _stdin_ready_posix | Return True if there's something to read on stdin (posix version). | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def _stdin_ready_posix():
"""Return True if there's something to read on stdin (posix version)."""
infds, outfds, erfds = select.select([sys.stdin],[],[],0)
return bool(infds) | def _stdin_ready_posix():
"""Return True if there's something to read on stdin (posix version)."""
infds, outfds, erfds = select.select([sys.stdin],[],[],0)
return bool(infds) | [
"Return",
"True",
"if",
"there",
"s",
"something",
"to",
"read",
"on",
"stdin",
"(",
"posix",
"version",
")",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L55-L58 | [
"def",
"_stdin_ready_posix",
"(",
")",
":",
"infds",
",",
"outfds",
",",
"erfds",
"=",
"select",
".",
"select",
"(",
"[",
"sys",
".",
"stdin",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"0",
")",
"return",
"bool",
"(",
"infds",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.set_inputhook | Set PyOS_InputHook to callback and return the previous one. | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def set_inputhook(self, callback):
"""Set PyOS_InputHook to callback and return the previous one."""
# On platforms with 'readline' support, it's all too likely to
# have a KeyboardInterrupt signal delivered *even before* an
# initial ``try:`` clause in the callback can be executed, so
... | def set_inputhook(self, callback):
"""Set PyOS_InputHook to callback and return the previous one."""
# On platforms with 'readline' support, it's all too likely to
# have a KeyboardInterrupt signal delivered *even before* an
# initial ``try:`` clause in the callback can be executed, so
... | [
"Set",
"PyOS_InputHook",
"to",
"callback",
"and",
"return",
"the",
"previous",
"one",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L138-L152 | [
"def",
"set_inputhook",
"(",
"self",
",",
"callback",
")",
":",
"# On platforms with 'readline' support, it's all too likely to",
"# have a KeyboardInterrupt signal delivered *even before* an",
"# initial ``try:`` clause in the callback can be executed, so",
"# we need to disable CTRL+C in thi... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.clear_inputhook | Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` methods. But
the actual value of the param... | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def clear_inputhook(self, app=None):
"""Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` metho... | def clear_inputhook(self, app=None):
"""Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` metho... | [
"Set",
"PyOS_InputHook",
"to",
"NULL",
"and",
"return",
"the",
"previous",
"one",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L154-L170 | [
"def",
"clear_inputhook",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"pyos_inputhook_ptr",
"=",
"self",
".",
"get_pyos_inputhook",
"(",
")",
"original",
"=",
"self",
".",
"get_pyos_inputhook_as_func",
"(",
")",
"pyos_inputhook_ptr",
".",
"value",
"=",
"ct... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.clear_app_refs | Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themselves. This
method is provided to clear ... | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def clear_app_refs(self, gui=None):
"""Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themsel... | def clear_app_refs(self, gui=None):
"""Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themsel... | [
"Clear",
"IPython",
"s",
"internal",
"reference",
"to",
"an",
"application",
"instance",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L172-L190 | [
"def",
"clear_app_refs",
"(",
"self",
",",
"gui",
"=",
"None",
")",
":",
"if",
"gui",
"is",
"None",
":",
"self",
".",
"apps",
"=",
"{",
"}",
"elif",
"gui",
"in",
"self",
".",
"apps",
":",
"del",
"self",
".",
"apps",
"[",
"gui",
"]"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.register | Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`InputHookBase`.
::
... | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def register(self, toolkitname, *aliases):
"""Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`I... | def register(self, toolkitname, *aliases):
"""Register a class to provide the event loop for a given GUI.
This is intended to be used as a class decorator. It should be passed
the names with which to register this GUI integration. The classes
themselves should subclass :class:`I... | [
"Register",
"a",
"class",
"to",
"provide",
"the",
"event",
"loop",
"for",
"a",
"given",
"GUI",
".",
"This",
"is",
"intended",
"to",
"be",
"used",
"as",
"a",
"class",
"decorator",
".",
"It",
"should",
"be",
"passed",
"the",
"names",
"with",
"which",
"to... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L192-L212 | [
"def",
"register",
"(",
"self",
",",
"toolkitname",
",",
"*",
"aliases",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"inst",
"=",
"cls",
"(",
"self",
")",
"self",
".",
"guihooks",
"[",
"toolkitname",
"]",
"=",
"inst",
"for",
"a",
"in",
"ali... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.enable_gui | Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
gui : optional, string or None
If None (or '... | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def enable_gui(self, gui=None, app=None):
"""Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
g... | def enable_gui(self, gui=None, app=None):
"""Switch amongst GUI input hooks by name.
This is a higher level method than :meth:`set_inputhook` - it uses the
GUI name to look up a registered object which enables the input hook
for that GUI.
Parameters
----------
g... | [
"Switch",
"amongst",
"GUI",
"input",
"hooks",
"by",
"name",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L218-L260 | [
"def",
"enable_gui",
"(",
"self",
",",
"gui",
"=",
"None",
",",
"app",
"=",
"None",
")",
":",
"if",
"gui",
"in",
"(",
"None",
",",
"GUI_NONE",
")",
":",
"return",
"self",
".",
"disable_gui",
"(",
")",
"if",
"gui",
"in",
"self",
".",
"aliases",
":... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | InputHookManager.disable_gui | Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`. | glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py | def disable_gui(self):
"""Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`.
"""
gui = self._current_gui
if gui in self.apps:
self.apps[gui]... | def disable_gui(self):
"""Disable GUI event loop integration.
If an application was registered, this sets its ``_in_event_loop``
attribute to False. It then calls :meth:`clear_inputhook`.
"""
gui = self._current_gui
if gui in self.apps:
self.apps[gui]... | [
"Disable",
"GUI",
"event",
"loop",
"integration",
".",
"If",
"an",
"application",
"was",
"registered",
"this",
"sets",
"its",
"_in_event_loop",
"attribute",
"to",
"False",
".",
"It",
"then",
"calls",
":",
"meth",
":",
"clear_inputhook",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L262-L271 | [
"def",
"disable_gui",
"(",
"self",
")",
":",
"gui",
"=",
"self",
".",
"_current_gui",
"if",
"gui",
"in",
"self",
".",
"apps",
":",
"self",
".",
"apps",
"[",
"gui",
"]",
".",
"_in_event_loop",
"=",
"False",
"return",
"self",
".",
"clear_inputhook",
"(",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | set_current_canvas | Make a canvas active. Used primarily by the canvas itself. | glue_vispy_viewers/extern/vispy/gloo/context.py | def set_current_canvas(canvas):
""" Make a canvas active. Used primarily by the canvas itself.
"""
# Notify glir
canvas.context._do_CURRENT_command = True
# Try to be quick
if canvasses and canvasses[-1]() is canvas:
return
# Make this the current
cc = [c() for c in canvasses if... | def set_current_canvas(canvas):
""" Make a canvas active. Used primarily by the canvas itself.
"""
# Notify glir
canvas.context._do_CURRENT_command = True
# Try to be quick
if canvasses and canvasses[-1]() is canvas:
return
# Make this the current
cc = [c() for c in canvasses if... | [
"Make",
"a",
"canvas",
"active",
".",
"Used",
"primarily",
"by",
"the",
"canvas",
"itself",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L63-L76 | [
"def",
"set_current_canvas",
"(",
"canvas",
")",
":",
"# Notify glir ",
"canvas",
".",
"context",
".",
"_do_CURRENT_command",
"=",
"True",
"# Try to be quick",
"if",
"canvasses",
"and",
"canvasses",
"[",
"-",
"1",
"]",
"(",
")",
"is",
"canvas",
":",
"return",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | forget_canvas | Forget about the given canvas. Used by the canvas when closed. | glue_vispy_viewers/extern/vispy/gloo/context.py | def forget_canvas(canvas):
""" Forget about the given canvas. Used by the canvas when closed.
"""
cc = [c() for c in canvasses if c() is not None]
while canvas in cc:
cc.remove(canvas)
canvasses[:] = [weakref.ref(c) for c in cc] | def forget_canvas(canvas):
""" Forget about the given canvas. Used by the canvas when closed.
"""
cc = [c() for c in canvasses if c() is not None]
while canvas in cc:
cc.remove(canvas)
canvasses[:] = [weakref.ref(c) for c in cc] | [
"Forget",
"about",
"the",
"given",
"canvas",
".",
"Used",
"by",
"the",
"canvas",
"when",
"closed",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L79-L85 | [
"def",
"forget_canvas",
"(",
"canvas",
")",
":",
"cc",
"=",
"[",
"c",
"(",
")",
"for",
"c",
"in",
"canvasses",
"if",
"c",
"(",
")",
"is",
"not",
"None",
"]",
"while",
"canvas",
"in",
"cc",
":",
"cc",
".",
"remove",
"(",
"canvas",
")",
"canvasses"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GLContext.create_shared | For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference. | glue_vispy_viewers/extern/vispy/gloo/context.py | def create_shared(self, name, ref):
""" For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference.
"""
if self._shared is not None:
raise RuntimeError('Can only se... | def create_shared(self, name, ref):
""" For the app backends to create the GLShared object.
Parameters
----------
name : str
The name.
ref : object
The reference.
"""
if self._shared is not None:
raise RuntimeError('Can only se... | [
"For",
"the",
"app",
"backends",
"to",
"create",
"the",
"GLShared",
"object",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L120-L132 | [
"def",
"create_shared",
"(",
"self",
",",
"name",
",",
"ref",
")",
":",
"if",
"self",
".",
"_shared",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Can only set_shared once.'",
")",
"self",
".",
"_shared",
"=",
"GLShared",
"(",
"name",
",",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GLContext.flush_commands | Flush
Parameters
----------
event : instance of Event
The event. | glue_vispy_viewers/extern/vispy/gloo/context.py | def flush_commands(self, event=None):
""" Flush
Parameters
----------
event : instance of Event
The event.
"""
if self._do_CURRENT_command:
self._do_CURRENT_command = False
canvas = get_current_canvas()
if canvas and hasatt... | def flush_commands(self, event=None):
""" Flush
Parameters
----------
event : instance of Event
The event.
"""
if self._do_CURRENT_command:
self._do_CURRENT_command = False
canvas = get_current_canvas()
if canvas and hasatt... | [
"Flush"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L160-L176 | [
"def",
"flush_commands",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"_do_CURRENT_command",
":",
"self",
".",
"_do_CURRENT_command",
"=",
"False",
"canvas",
"=",
"get_current_canvas",
"(",
")",
"if",
"canvas",
"and",
"hasattr",
"(",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GLShared.add_ref | Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references. | glue_vispy_viewers/extern/vispy/gloo/context.py | def add_ref(self, name, ref):
""" Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references.
"""
if self._name is None:
self._name = ... | def add_ref(self, name, ref):
""" Add a reference for the backend object that gives access
to the low level context. Used in vispy.app.canvas.backends.
The given name must match with that of previously added
references.
"""
if self._name is None:
self._name = ... | [
"Add",
"a",
"reference",
"for",
"the",
"backend",
"object",
"that",
"gives",
"access",
"to",
"the",
"low",
"level",
"context",
".",
"Used",
"in",
"vispy",
".",
"app",
".",
"canvas",
".",
"backends",
".",
"The",
"given",
"name",
"must",
"match",
"with",
... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L225-L236 | [
"def",
"add_ref",
"(",
"self",
",",
"name",
",",
"ref",
")",
":",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"name",
"elif",
"name",
"!=",
"self",
".",
"_name",
":",
"raise",
"RuntimeError",
"(",
"'Contexts can only share... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GLShared.ref | A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object. | glue_vispy_viewers/extern/vispy/gloo/context.py | def ref(self):
""" A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object.
"""
# Clean
self._refs = [r for ... | def ref(self):
""" A reference (stored internally via a weakref) to an object
that the backend system can use to obtain the low-level
information of the "reference context". In Vispy this will
typically be the CanvasBackend object.
"""
# Clean
self._refs = [r for ... | [
"A",
"reference",
"(",
"stored",
"internally",
"via",
"a",
"weakref",
")",
"to",
"an",
"object",
"that",
"the",
"backend",
"system",
"can",
"use",
"to",
"obtain",
"the",
"low",
"-",
"level",
"information",
"of",
"the",
"reference",
"context",
".",
"In",
... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/context.py#L246-L259 | [
"def",
"ref",
"(",
"self",
")",
":",
"# Clean",
"self",
".",
"_refs",
"=",
"[",
"r",
"for",
"r",
"in",
"self",
".",
"_refs",
"if",
"(",
"r",
"(",
")",
"is",
"not",
"None",
")",
"]",
"# Get ref",
"ref",
"=",
"self",
".",
"_refs",
"[",
"0",
"]"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | get_dpi | 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. | glue_vispy_viewers/extern/vispy/util/dpi/_quartz.py | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
display = quartz.CGMainDisplayID()
... | def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
"""
display = quartz.CGMainDisplayID()
... | [
"Get",
"screen",
"DPI",
"from",
"the",
"OS"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/dpi/_quartz.py#L10-L26 | [
"def",
"get_dpi",
"(",
"raise_error",
"=",
"True",
")",
":",
"display",
"=",
"quartz",
".",
"CGMainDisplayID",
"(",
")",
"mm",
"=",
"quartz",
".",
"CGDisplayScreenSize",
"(",
"display",
")",
"px",
"=",
"quartz",
".",
"CGDisplayBounds",
"(",
"display",
")",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Varying.link | Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``. | glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
... | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
... | [
"Link",
"this",
"Varying",
"to",
"another",
"object",
"from",
"which",
"it",
"will",
"derive",
"its",
"dtype",
".",
"This",
"method",
"is",
"used",
"internally",
"when",
"assigning",
"an",
"attribute",
"to",
"a",
"varying",
"using",
"syntax",
"Function",
"["... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py#L207-L214 | [
"def",
"link",
"(",
"self",
",",
"var",
")",
":",
"assert",
"self",
".",
"_dtype",
"is",
"not",
"None",
"or",
"hasattr",
"(",
"var",
",",
"'dtype'",
")",
"self",
".",
"_link",
"=",
"var",
"self",
".",
"changed",
"(",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | obj | Two Dimensional Shubert Function | examples/SH.py | def obj(x):
"""Two Dimensional Shubert Function"""
j = np.arange(1, 6)
tmp1 = np.dot(j, np.cos((j+1)*x[0] + j))
tmp2 = np.dot(j, np.cos((j+1)*x[1] + j))
return tmp1 * tmp2 | def obj(x):
"""Two Dimensional Shubert Function"""
j = np.arange(1, 6)
tmp1 = np.dot(j, np.cos((j+1)*x[0] + j))
tmp2 = np.dot(j, np.cos((j+1)*x[1] + j))
return tmp1 * tmp2 | [
"Two",
"Dimensional",
"Shubert",
"Function"
] | andim/scipydirect | python | https://github.com/andim/scipydirect/blob/ad36ab19e6ad64054a1d2abd22f1c993fc4b87be/examples/SH.py#L13-L19 | [
"def",
"obj",
"(",
"x",
")",
":",
"j",
"=",
"np",
".",
"arange",
"(",
"1",
",",
"6",
")",
"tmp1",
"=",
"np",
".",
"dot",
"(",
"j",
",",
"np",
".",
"cos",
"(",
"(",
"j",
"+",
"1",
")",
"*",
"x",
"[",
"0",
"]",
"+",
"j",
")",
")",
"tm... | ad36ab19e6ad64054a1d2abd22f1c993fc4b87be |
train | Bessel.besj | Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from equivalent FORTRAN library
Converte... | glue_vispy_viewers/extern/vispy/glsl/build-spatial-filters.py | def besj(self, x, n):
'''
Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from e... | def besj(self, x, n):
'''
Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from e... | [
"Function",
"BESJ",
"calculates",
"Bessel",
"function",
"of",
"first",
"kind",
"of",
"order",
"n",
"Arguments",
":",
"n",
"-",
"an",
"integer",
"(",
">",
"=",
"0",
")",
"the",
"order",
"x",
"-",
"value",
"at",
"which",
"the",
"Bessel",
"function",
"is"... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/glsl/build-spatial-filters.py#L493-L568 | [
"def",
"besj",
"(",
"self",
",",
"x",
",",
"n",
")",
":",
"if",
"n",
"<",
"0",
":",
"return",
"0.0",
"d",
"=",
"1e-6",
"b",
"=",
"0",
"if",
"math",
".",
"fabs",
"(",
"x",
")",
"<=",
"d",
":",
"if",
"n",
"!=",
"0",
":",
"return",
"0",
"r... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.copy | Create an exact copy of this quaternion. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def copy(self):
""" Create an exact copy of this quaternion.
"""
return Quaternion(self.w, self.x, self.y, self.z, False) | def copy(self):
""" Create an exact copy of this quaternion.
"""
return Quaternion(self.w, self.x, self.y, self.z, False) | [
"Create",
"an",
"exact",
"copy",
"of",
"this",
"quaternion",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L28-L31 | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Quaternion",
"(",
"self",
".",
"w",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"z",
",",
"False",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.norm | Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2 | glue_vispy_viewers/extern/vispy/util/quaternion.py | def norm(self):
""" Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2
"""
tmp = self.w**2 + self.x**2 + self.y**2 + self.z**2
return tmp**0.5 | def norm(self):
""" Returns the norm of the quaternion
norm = w**2 + x**2 + y**2 + z**2
"""
tmp = self.w**2 + self.x**2 + self.y**2 + self.z**2
return tmp**0.5 | [
"Returns",
"the",
"norm",
"of",
"the",
"quaternion",
"norm",
"=",
"w",
"**",
"2",
"+",
"x",
"**",
"2",
"+",
"y",
"**",
"2",
"+",
"z",
"**",
"2"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L33-L39 | [
"def",
"norm",
"(",
"self",
")",
":",
"tmp",
"=",
"self",
".",
"w",
"**",
"2",
"+",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"return",
"tmp",
"**",
"0.5"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion._normalize | Make the quaternion unit length. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def _normalize(self):
""" Make the quaternion unit length.
"""
# Get length
L = self.norm()
if not L:
raise ValueError('Quaternion cannot have 0-length.')
# Correct
self.w /= L
self.x /= L
self.y /= L
self.z /= L | def _normalize(self):
""" Make the quaternion unit length.
"""
# Get length
L = self.norm()
if not L:
raise ValueError('Quaternion cannot have 0-length.')
# Correct
self.w /= L
self.x /= L
self.y /= L
self.z /= L | [
"Make",
"the",
"quaternion",
"unit",
"length",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L41-L52 | [
"def",
"_normalize",
"(",
"self",
")",
":",
"# Get length",
"L",
"=",
"self",
".",
"norm",
"(",
")",
"if",
"not",
"L",
":",
"raise",
"ValueError",
"(",
"'Quaternion cannot have 0-length.'",
")",
"# Correct",
"self",
".",
"w",
"/=",
"L",
"self",
".",
"x",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.conjugate | Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def conjugate(self):
""" Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed.
"""
new = self.copy()
new.x *= -1
new.y *= -1
new.z *= -1
return new | def conjugate(self):
""" Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed.
"""
new = self.copy()
new.x *= -1
new.y *= -1
new.z *= -1
return new | [
"Obtain",
"the",
"conjugate",
"of",
"the",
"quaternion",
".",
"This",
"is",
"simply",
"the",
"same",
"quaternion",
"but",
"with",
"the",
"sign",
"of",
"the",
"imaginary",
"(",
"vector",
")",
"parts",
"reversed",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L61-L71 | [
"def",
"conjugate",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"copy",
"(",
")",
"new",
".",
"x",
"*=",
"-",
"1",
"new",
".",
"y",
"*=",
"-",
"1",
"new",
".",
"z",
"*=",
"-",
"1",
"return",
"new"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.inverse | returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def inverse(self):
""" returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate.
"""
new = self.conjugate()
tmp = self.norm()**2
new.w /= tmp
new.x /= tmp
new.y /= tmp
new.z /= tmp
... | def inverse(self):
""" returns q.conjugate()/q.norm()**2
So if the quaternion is unit length, it is the same
as the conjugate.
"""
new = self.conjugate()
tmp = self.norm()**2
new.w /= tmp
new.x /= tmp
new.y /= tmp
new.z /= tmp
... | [
"returns",
"q",
".",
"conjugate",
"()",
"/",
"q",
".",
"norm",
"()",
"**",
"2",
"So",
"if",
"the",
"quaternion",
"is",
"unit",
"length",
"it",
"is",
"the",
"same",
"as",
"the",
"conjugate",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L73-L85 | [
"def",
"inverse",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"conjugate",
"(",
")",
"tmp",
"=",
"self",
".",
"norm",
"(",
")",
"**",
"2",
"new",
".",
"w",
"/=",
"tmp",
"new",
".",
"x",
"/=",
"tmp",
"new",
".",
"y",
"/=",
"tmp",
"new",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.exp | Returns the exponent of the quaternion.
(not tested) | glue_vispy_viewers/extern/vispy/util/quaternion.py | def exp(self):
""" Returns the exponent of the quaternion.
(not tested)
"""
# Init
vecNorm = self.x**2 + self.y**2 + self.z**2
wPart = np.exp(self.w)
q = Quaternion()
# Calculate
q.w = wPart * np.cos(vecNorm)
q.x ... | def exp(self):
""" Returns the exponent of the quaternion.
(not tested)
"""
# Init
vecNorm = self.x**2 + self.y**2 + self.z**2
wPart = np.exp(self.w)
q = Quaternion()
# Calculate
q.w = wPart * np.cos(vecNorm)
q.x ... | [
"Returns",
"the",
"exponent",
"of",
"the",
"quaternion",
".",
"(",
"not",
"tested",
")"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L87-L103 | [
"def",
"exp",
"(",
"self",
")",
":",
"# Init",
"vecNorm",
"=",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"wPart",
"=",
"np",
".",
"exp",
"(",
"self",
".",
"w",
")",
"q",
"=",
"Quaternio... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.log | Returns the natural logarithm of the quaternion.
(not tested) | glue_vispy_viewers/extern/vispy/util/quaternion.py | def log(self):
""" Returns the natural logarithm of the quaternion.
(not tested)
"""
# Init
norm = self.norm()
vecNorm = self.x**2 + self.y**2 + self.z**2
tmp = self.w / norm
q = Quaternion()
# Calculate
q.w = np.log(norm... | def log(self):
""" Returns the natural logarithm of the quaternion.
(not tested)
"""
# Init
norm = self.norm()
vecNorm = self.x**2 + self.y**2 + self.z**2
tmp = self.w / norm
q = Quaternion()
# Calculate
q.w = np.log(norm... | [
"Returns",
"the",
"natural",
"logarithm",
"of",
"the",
"quaternion",
".",
"(",
"not",
"tested",
")"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L105-L122 | [
"def",
"log",
"(",
"self",
")",
":",
"# Init",
"norm",
"=",
"self",
".",
"norm",
"(",
")",
"vecNorm",
"=",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"y",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
"tmp",
"=",
"self",
".",
"w",
"/",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.rotate_point | Rotate a Point instance using this quaternion. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def rotate_point(self, p):
""" Rotate a Point instance using this quaternion.
"""
# Prepare
p = Quaternion(0, p[0], p[1], p[2], False) # Do not normalize!
q1 = self.normalize()
q2 = self.inverse()
# Apply rotation
r = (q1*p)*q2
# Make point and r... | def rotate_point(self, p):
""" Rotate a Point instance using this quaternion.
"""
# Prepare
p = Quaternion(0, p[0], p[1], p[2], False) # Do not normalize!
q1 = self.normalize()
q2 = self.inverse()
# Apply rotation
r = (q1*p)*q2
# Make point and r... | [
"Rotate",
"a",
"Point",
"instance",
"using",
"this",
"quaternion",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L152-L162 | [
"def",
"rotate_point",
"(",
"self",
",",
"p",
")",
":",
"# Prepare ",
"p",
"=",
"Quaternion",
"(",
"0",
",",
"p",
"[",
"0",
"]",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
",",
"False",
")",
"# Do not normalize!",
"q1",
"=",
"self",
".",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.get_matrix | Create a 4x4 homography matrix that represents the rotation
of the quaternion. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def get_matrix(self):
""" Create a 4x4 homography matrix that represents the rotation
of the quaternion.
"""
# Init matrix (remember, a matrix, not an array)
a = np.zeros((4, 4), dtype=np.float32)
w, x, y, z = self.w, self.x, self.y, self.z
# First row
a[0... | def get_matrix(self):
""" Create a 4x4 homography matrix that represents the rotation
of the quaternion.
"""
# Init matrix (remember, a matrix, not an array)
a = np.zeros((4, 4), dtype=np.float32)
w, x, y, z = self.w, self.x, self.y, self.z
# First row
a[0... | [
"Create",
"a",
"4x4",
"homography",
"matrix",
"that",
"represents",
"the",
"rotation",
"of",
"the",
"quaternion",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L164-L191 | [
"def",
"get_matrix",
"(",
"self",
")",
":",
"# Init matrix (remember, a matrix, not an array)",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
"4",
",",
"4",
")",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"w",
",",
"x",
",",
"y",
",",
"z",
"=",
"self",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.get_axis_angle | Get the axis-angle representation of the quaternion.
(The angle is in radians) | glue_vispy_viewers/extern/vispy/util/quaternion.py | def get_axis_angle(self):
""" Get the axis-angle representation of the quaternion.
(The angle is in radians)
"""
# Init
angle = 2 * np.arccos(max(min(self.w, 1.), -1.))
scale = (self.x**2 + self.y**2 + self.z**2)**0.5
# Calc axis
if scale:
... | def get_axis_angle(self):
""" Get the axis-angle representation of the quaternion.
(The angle is in radians)
"""
# Init
angle = 2 * np.arccos(max(min(self.w, 1.), -1.))
scale = (self.x**2 + self.y**2 + self.z**2)**0.5
# Calc axis
if scale:
... | [
"Get",
"the",
"axis",
"-",
"angle",
"representation",
"of",
"the",
"quaternion",
".",
"(",
"The",
"angle",
"is",
"in",
"radians",
")"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L193-L210 | [
"def",
"get_axis_angle",
"(",
"self",
")",
":",
"# Init",
"angle",
"=",
"2",
"*",
"np",
".",
"arccos",
"(",
"max",
"(",
"min",
"(",
"self",
".",
"w",
",",
"1.",
")",
",",
"-",
"1.",
")",
")",
"scale",
"=",
"(",
"self",
".",
"x",
"**",
"2",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.create_from_axis_angle | Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians). | glue_vispy_viewers/extern/vispy/util/quaternion.py | def create_from_axis_angle(cls, angle, ax, ay, az, degrees=False):
""" Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians).
"""
if degrees:
angle = np.radians(angle)
while angle < 0:
angle += np.pi*2
... | def create_from_axis_angle(cls, angle, ax, ay, az, degrees=False):
""" Classmethod to create a quaternion from an axis-angle representation.
(angle should be in radians).
"""
if degrees:
angle = np.radians(angle)
while angle < 0:
angle += np.pi*2
... | [
"Classmethod",
"to",
"create",
"a",
"quaternion",
"from",
"an",
"axis",
"-",
"angle",
"representation",
".",
"(",
"angle",
"should",
"be",
"in",
"radians",
")",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L213-L223 | [
"def",
"create_from_axis_angle",
"(",
"cls",
",",
"angle",
",",
"ax",
",",
"ay",
",",
"az",
",",
"degrees",
"=",
"False",
")",
":",
"if",
"degrees",
":",
"angle",
"=",
"np",
".",
"radians",
"(",
"angle",
")",
"while",
"angle",
"<",
"0",
":",
"angle... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Quaternion.create_from_euler_angles | Classmethod to create a quaternion given the euler angles. | glue_vispy_viewers/extern/vispy/util/quaternion.py | def create_from_euler_angles(cls, rx, ry, rz, degrees=False):
""" Classmethod to create a quaternion given the euler angles.
"""
if degrees:
rx, ry, rz = np.radians([rx, ry, rz])
# Obtain quaternions
qx = Quaternion(np.cos(rx/2), 0, 0, np.sin(rx/2))
qy = Quate... | def create_from_euler_angles(cls, rx, ry, rz, degrees=False):
""" Classmethod to create a quaternion given the euler angles.
"""
if degrees:
rx, ry, rz = np.radians([rx, ry, rz])
# Obtain quaternions
qx = Quaternion(np.cos(rx/2), 0, 0, np.sin(rx/2))
qy = Quate... | [
"Classmethod",
"to",
"create",
"a",
"quaternion",
"given",
"the",
"euler",
"angles",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L226-L236 | [
"def",
"create_from_euler_angles",
"(",
"cls",
",",
"rx",
",",
"ry",
",",
"rz",
",",
"degrees",
"=",
"False",
")",
":",
"if",
"degrees",
":",
"rx",
",",
"ry",
",",
"rz",
"=",
"np",
".",
"radians",
"(",
"[",
"rx",
",",
"ry",
",",
"rz",
"]",
")",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | as_enum | Turn a possibly string enum into an integer enum. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def as_enum(enum):
""" Turn a possibly string enum into an integer enum.
"""
if isinstance(enum, string_types):
try:
enum = getattr(gl, 'GL_' + enum.upper())
except AttributeError:
try:
enum = _internalformats['GL_' + enum.upper()]
except K... | def as_enum(enum):
""" Turn a possibly string enum into an integer enum.
"""
if isinstance(enum, string_types):
try:
enum = getattr(gl, 'GL_' + enum.upper())
except AttributeError:
try:
enum = _internalformats['GL_' + enum.upper()]
except K... | [
"Turn",
"a",
"possibly",
"string",
"enum",
"into",
"an",
"integer",
"enum",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L58-L69 | [
"def",
"as_enum",
"(",
"enum",
")",
":",
"if",
"isinstance",
"(",
"enum",
",",
"string_types",
")",
":",
"try",
":",
"enum",
"=",
"getattr",
"(",
"gl",
",",
"'GL_'",
"+",
"enum",
".",
"upper",
"(",
")",
")",
"except",
"AttributeError",
":",
"try",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | convert_shaders | Modify shading code so that we can write code once
and make it run "everywhere". | glue_vispy_viewers/extern/vispy/gloo/glir.py | def convert_shaders(convert, shaders):
""" Modify shading code so that we can write code once
and make it run "everywhere".
"""
# New version of the shaders
out = []
if convert == 'es2':
for isfragment, shader in enumerate(shaders):
has_version = False
has_prec... | def convert_shaders(convert, shaders):
""" Modify shading code so that we can write code once
and make it run "everywhere".
"""
# New version of the shaders
out = []
if convert == 'es2':
for isfragment, shader in enumerate(shaders):
has_version = False
has_prec... | [
"Modify",
"shading",
"code",
"so",
"that",
"we",
"can",
"write",
"code",
"once",
"and",
"make",
"it",
"run",
"everywhere",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L235-L293 | [
"def",
"convert_shaders",
"(",
"convert",
",",
"shaders",
")",
":",
"# New version of the shaders",
"out",
"=",
"[",
"]",
"if",
"convert",
"==",
"'es2'",
":",
"for",
"isfragment",
",",
"shader",
"in",
"enumerate",
"(",
"shaders",
")",
":",
"has_version",
"="... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | as_es2_command | Modify a desktop command so it works on es2. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def as_es2_command(command):
""" Modify a desktop command so it works on es2.
"""
if command[0] == 'FUNC':
return (command[0], re.sub(r'^gl([A-Z])',
lambda m: m.group(1).lower(), command[1])) + command[2:]
if command[0] == 'SHADERS':
return command[:2] + convert_shaders(... | def as_es2_command(command):
""" Modify a desktop command so it works on es2.
"""
if command[0] == 'FUNC':
return (command[0], re.sub(r'^gl([A-Z])',
lambda m: m.group(1).lower(), command[1])) + command[2:]
if command[0] == 'SHADERS':
return command[:2] + convert_shaders(... | [
"Modify",
"a",
"desktop",
"command",
"so",
"it",
"works",
"on",
"es2",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L296-L307 | [
"def",
"as_es2_command",
"(",
"command",
")",
":",
"if",
"command",
"[",
"0",
"]",
"==",
"'FUNC'",
":",
"return",
"(",
"command",
"[",
"0",
"]",
",",
"re",
".",
"sub",
"(",
"r'^gl([A-Z])'",
",",
"lambda",
"m",
":",
"m",
".",
"group",
"(",
"1",
")... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _check_pyopengl_3D | Helper to ensure users have OpenGL for 3D texture support (for now) | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _check_pyopengl_3D():
"""Helper to ensure users have OpenGL for 3D texture support (for now)"""
global USE_TEX_3D
USE_TEX_3D = True
try:
import OpenGL.GL as _gl
except ImportError:
raise ImportError('PyOpenGL is required for 3D texture support')
return _gl | def _check_pyopengl_3D():
"""Helper to ensure users have OpenGL for 3D texture support (for now)"""
global USE_TEX_3D
USE_TEX_3D = True
try:
import OpenGL.GL as _gl
except ImportError:
raise ImportError('PyOpenGL is required for 3D texture support')
return _gl | [
"Helper",
"to",
"ensure",
"users",
"have",
"OpenGL",
"for",
"3D",
"texture",
"support",
"(",
"for",
"now",
")"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L1133-L1141 | [
"def",
"_check_pyopengl_3D",
"(",
")",
":",
"global",
"USE_TEX_3D",
"USE_TEX_3D",
"=",
"True",
"try",
":",
"import",
"OpenGL",
".",
"GL",
"as",
"_gl",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'PyOpenGL is required for 3D texture support'",
")",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _GlirQueueShare.show | Print the list of commands currently in the queue. If filter is
given, print only commands that match the filter. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def show(self, filter=None):
""" Print the list of commands currently in the queue. If filter is
given, print only commands that match the filter.
"""
for command in self._commands:
if command[0] is None: # or command[1] in self._invalid_objects:
continue # ... | def show(self, filter=None):
""" Print the list of commands currently in the queue. If filter is
given, print only commands that match the filter.
"""
for command in self._commands:
if command[0] is None: # or command[1] in self._invalid_objects:
continue # ... | [
"Print",
"the",
"list",
"of",
"commands",
"currently",
"in",
"the",
"queue",
".",
"If",
"filter",
"is",
"given",
"print",
"only",
"commands",
"that",
"match",
"the",
"filter",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L110-L130 | [
"def",
"show",
"(",
"self",
",",
"filter",
"=",
"None",
")",
":",
"for",
"command",
"in",
"self",
".",
"_commands",
":",
"if",
"command",
"[",
"0",
"]",
"is",
"None",
":",
"# or command[1] in self._invalid_objects:",
"continue",
"# Skip nill commands",
"if",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _GlirQueueShare.flush | Flush all current commands to the GLIR interpreter. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def flush(self, parser):
""" Flush all current commands to the GLIR interpreter.
"""
if self._verbose:
show = self._verbose if isinstance(self._verbose, str) else None
self.show(show)
parser.parse(self._filter(self.clear(), parser)) | def flush(self, parser):
""" Flush all current commands to the GLIR interpreter.
"""
if self._verbose:
show = self._verbose if isinstance(self._verbose, str) else None
self.show(show)
parser.parse(self._filter(self.clear(), parser)) | [
"Flush",
"all",
"current",
"commands",
"to",
"the",
"GLIR",
"interpreter",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L140-L146 | [
"def",
"flush",
"(",
"self",
",",
"parser",
")",
":",
"if",
"self",
".",
"_verbose",
":",
"show",
"=",
"self",
".",
"_verbose",
"if",
"isinstance",
"(",
"self",
".",
"_verbose",
",",
"str",
")",
"else",
"None",
"self",
".",
"show",
"(",
"show",
")"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _GlirQueueShare._filter | Filter DATA/SIZE commands that are overridden by a
SIZE command. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _filter(self, commands, parser):
""" Filter DATA/SIZE commands that are overridden by a
SIZE command.
"""
resized = set()
commands2 = []
for command in reversed(commands):
if command[0] == 'SHADERS':
convert = parser.convert_shaders()
... | def _filter(self, commands, parser):
""" Filter DATA/SIZE commands that are overridden by a
SIZE command.
"""
resized = set()
commands2 = []
for command in reversed(commands):
if command[0] == 'SHADERS':
convert = parser.convert_shaders()
... | [
"Filter",
"DATA",
"/",
"SIZE",
"commands",
"that",
"are",
"overridden",
"by",
"a",
"SIZE",
"command",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L148-L166 | [
"def",
"_filter",
"(",
"self",
",",
"commands",
",",
"parser",
")",
":",
"resized",
"=",
"set",
"(",
")",
"commands2",
"=",
"[",
"]",
"for",
"command",
"in",
"reversed",
"(",
"commands",
")",
":",
"if",
"command",
"[",
"0",
"]",
"==",
"'SHADERS'",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirQueue.associate | Merge this queue with another.
Both queues will use a shared command list and either one can be used
to fill or flush the shared queue. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def associate(self, queue):
"""Merge this queue with another.
Both queues will use a shared command list and either one can be used
to fill or flush the shared queue.
"""
assert isinstance(queue, GlirQueue)
if queue._shared is self._shared:
return
# ... | def associate(self, queue):
"""Merge this queue with another.
Both queues will use a shared command list and either one can be used
to fill or flush the shared queue.
"""
assert isinstance(queue, GlirQueue)
if queue._shared is self._shared:
return
# ... | [
"Merge",
"this",
"queue",
"with",
"another",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L209-L227 | [
"def",
"associate",
"(",
"self",
",",
"queue",
")",
":",
"assert",
"isinstance",
"(",
"queue",
",",
"GlirQueue",
")",
"if",
"queue",
".",
"_shared",
"is",
"self",
".",
"_shared",
":",
"return",
"# merge commands",
"self",
".",
"_shared",
".",
"_commands",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirParser._parse | Parse a single command. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _parse(self, command):
""" Parse a single command.
"""
cmd, id_, args = command[0], command[1], command[2:]
if cmd == 'CURRENT':
# This context is made current
self.env.clear()
self._gl_initialize()
self.env['fbo'] = args[0]
... | def _parse(self, command):
""" Parse a single command.
"""
cmd, id_, args = command[0], command[1], command[2:]
if cmd == 'CURRENT':
# This context is made current
self.env.clear()
self._gl_initialize()
self.env['fbo'] = args[0]
... | [
"Parse",
"a",
"single",
"command",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L377-L443 | [
"def",
"_parse",
"(",
"self",
",",
"command",
")",
":",
"cmd",
",",
"id_",
",",
"args",
"=",
"command",
"[",
"0",
"]",
",",
"command",
"[",
"1",
"]",
",",
"command",
"[",
"2",
":",
"]",
"if",
"cmd",
"==",
"'CURRENT'",
":",
"# This context is made c... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirParser.parse | Parse a list of commands. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def parse(self, commands):
""" Parse a list of commands.
"""
# Get rid of dummy objects that represented deleted objects in
# the last parsing round.
to_delete = []
for id_, val in self._objects.items():
if val == JUST_DELETED:
to_delete.appen... | def parse(self, commands):
""" Parse a list of commands.
"""
# Get rid of dummy objects that represented deleted objects in
# the last parsing round.
to_delete = []
for id_, val in self._objects.items():
if val == JUST_DELETED:
to_delete.appen... | [
"Parse",
"a",
"list",
"of",
"commands",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L445-L459 | [
"def",
"parse",
"(",
"self",
",",
"commands",
")",
":",
"# Get rid of dummy objects that represented deleted objects in",
"# the last parsing round.",
"to_delete",
"=",
"[",
"]",
"for",
"id_",
",",
"val",
"in",
"self",
".",
"_objects",
".",
"items",
"(",
")",
":",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirParser._gl_initialize | Deal with compatibility; desktop does not have sprites
enabled by default. ES has. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _gl_initialize(self):
""" Deal with compatibility; desktop does not have sprites
enabled by default. ES has.
"""
if '.es' in gl.current_backend.__name__:
pass # ES2: no action required
else:
# Desktop, enable sprites
GL_VERTEX_PROGRAM_POIN... | def _gl_initialize(self):
""" Deal with compatibility; desktop does not have sprites
enabled by default. ES has.
"""
if '.es' in gl.current_backend.__name__:
pass # ES2: no action required
else:
# Desktop, enable sprites
GL_VERTEX_PROGRAM_POIN... | [
"Deal",
"with",
"compatibility",
";",
"desktop",
"does",
"not",
"have",
"sprites",
"enabled",
"by",
"default",
".",
"ES",
"has",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L466-L483 | [
"def",
"_gl_initialize",
"(",
"self",
")",
":",
"if",
"'.es'",
"in",
"gl",
".",
"current_backend",
".",
"__name__",
":",
"pass",
"# ES2: no action required",
"else",
":",
"# Desktop, enable sprites",
"GL_VERTEX_PROGRAM_POINT_SIZE",
"=",
"34370",
"GL_POINT_SPRITE",
"="... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.activate | Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def activate(self):
""" Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program.
"""
if self._handle != self._parser.env.get('current_program', False):
self... | def activate(self):
""" Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program.
"""
if self._handle != self._parser.env.get('current_program', False):
self... | [
"Avoid",
"overhead",
"in",
"calling",
"glUseProgram",
"with",
"same",
"arg",
".",
"Warning",
":",
"this",
"will",
"break",
"if",
"glUseProgram",
"is",
"used",
"somewhere",
"else",
".",
"Per",
"context",
"we",
"keep",
"track",
"of",
"one",
"current",
"program... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L596-L603 | [
"def",
"activate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_handle",
"!=",
"self",
".",
"_parser",
".",
"env",
".",
"get",
"(",
"'current_program'",
",",
"False",
")",
":",
"self",
".",
"_parser",
".",
"env",
"[",
"'current_program'",
"]",
"=",
"s... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.deactivate | Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def deactivate(self):
""" Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program.
"""
if self._parser.env.get('current_program', 0) != 0:
self._parser.env[... | def deactivate(self):
""" Avoid overhead in calling glUseProgram with same arg.
Warning: this will break if glUseProgram is used somewhere else.
Per context we keep track of one current program.
"""
if self._parser.env.get('current_program', 0) != 0:
self._parser.env[... | [
"Avoid",
"overhead",
"in",
"calling",
"glUseProgram",
"with",
"same",
"arg",
".",
"Warning",
":",
"this",
"will",
"break",
"if",
"glUseProgram",
"is",
"used",
"somewhere",
"else",
".",
"Per",
"context",
"we",
"keep",
"track",
"of",
"one",
"current",
"program... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L605-L612 | [
"def",
"deactivate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parser",
".",
"env",
".",
"get",
"(",
"'current_program'",
",",
"0",
")",
"!=",
"0",
":",
"self",
".",
"_parser",
".",
"env",
"[",
"'current_program'",
"]",
"=",
"0",
"gl",
".",
"glUs... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.set_shaders | This function takes care of setting the shading code and
compiling+linking it into a working program object that is ready
to use. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def set_shaders(self, vert, frag):
""" This function takes care of setting the shading code and
compiling+linking it into a working program object that is ready
to use.
"""
self._linked = False
# Create temporary shader objects
vert_handle = gl.glCreateShader(gl.G... | def set_shaders(self, vert, frag):
""" This function takes care of setting the shading code and
compiling+linking it into a working program object that is ready
to use.
"""
self._linked = False
# Create temporary shader objects
vert_handle = gl.glCreateShader(gl.G... | [
"This",
"function",
"takes",
"care",
"of",
"setting",
"the",
"shading",
"code",
"and",
"compiling",
"+",
"linking",
"it",
"into",
"a",
"working",
"program",
"object",
"that",
"is",
"ready",
"to",
"use",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L614-L653 | [
"def",
"set_shaders",
"(",
"self",
",",
"vert",
",",
"frag",
")",
":",
"self",
".",
"_linked",
"=",
"False",
"# Create temporary shader objects",
"vert_handle",
"=",
"gl",
".",
"glCreateShader",
"(",
"gl",
".",
"GL_VERTEX_SHADER",
")",
"frag_handle",
"=",
"gl"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram._get_active_attributes_and_uniforms | Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _get_active_attributes_and_uniforms(self):
""" Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this.
"""
# This match a name of the form "name[size]" (= array)
regex = re... | def _get_active_attributes_and_uniforms(self):
""" Retrieve active attributes and uniforms to be able to check that
all uniforms/attributes are set by the user.
Other GLIR implementations may omit this.
"""
# This match a name of the form "name[size]" (= array)
regex = re... | [
"Retrieve",
"active",
"attributes",
"and",
"uniforms",
"to",
"be",
"able",
"to",
"check",
"that",
"all",
"uniforms",
"/",
"attributes",
"are",
"set",
"by",
"the",
"user",
".",
"Other",
"GLIR",
"implementations",
"may",
"omit",
"this",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L655-L680 | [
"def",
"_get_active_attributes_and_uniforms",
"(",
"self",
")",
":",
"# This match a name of the form \"name[size]\" (= array)",
"regex",
"=",
"re",
".",
"compile",
"(",
"\"\"\"(?P<name>\\w+)\\s*(\\[(?P<size>\\d+)\\])\\s*\"\"\"",
")",
"# Get how many active attributes and uniforms ther... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram._parse_error | Parses a single GLSL error and extracts the linenr and description
Other GLIR implementations may omit this. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _parse_error(self, error):
""" Parses a single GLSL error and extracts the linenr and description
Other GLIR implementations may omit this.
"""
error = str(error)
# Nvidia
# 0(7): error C1008: undefined variable "MV"
m = re.match(r'(\d+)\((\d+)\)\s*:\s(.*)', e... | def _parse_error(self, error):
""" Parses a single GLSL error and extracts the linenr and description
Other GLIR implementations may omit this.
"""
error = str(error)
# Nvidia
# 0(7): error C1008: undefined variable "MV"
m = re.match(r'(\d+)\((\d+)\)\s*:\s(.*)', e... | [
"Parses",
"a",
"single",
"GLSL",
"error",
"and",
"extracts",
"the",
"linenr",
"and",
"description",
"Other",
"GLIR",
"implementations",
"may",
"omit",
"this",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L682-L703 | [
"def",
"_parse_error",
"(",
"self",
",",
"error",
")",
":",
"error",
"=",
"str",
"(",
"error",
")",
"# Nvidia",
"# 0(7): error C1008: undefined variable \"MV\"",
"m",
"=",
"re",
".",
"match",
"(",
"r'(\\d+)\\((\\d+)\\)\\s*:\\s(.*)'",
",",
"error",
")",
"if",
"m"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram._get_error | Get error and show the faulty line + some context
Other GLIR implementations may omit this. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def _get_error(self, code, errors, indentation=0):
"""Get error and show the faulty line + some context
Other GLIR implementations may omit this.
"""
# Init
results = []
lines = None
if code is not None:
lines = [line.strip() for line in code.split('\n... | def _get_error(self, code, errors, indentation=0):
"""Get error and show the faulty line + some context
Other GLIR implementations may omit this.
"""
# Init
results = []
lines = None
if code is not None:
lines = [line.strip() for line in code.split('\n... | [
"Get",
"error",
"and",
"show",
"the",
"faulty",
"line",
"+",
"some",
"context",
"Other",
"GLIR",
"implementations",
"may",
"omit",
"this",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L705-L731 | [
"def",
"_get_error",
"(",
"self",
",",
"code",
",",
"errors",
",",
"indentation",
"=",
"0",
")",
":",
"# Init",
"results",
"=",
"[",
"]",
"lines",
"=",
"None",
"if",
"code",
"is",
"not",
"None",
":",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.set_texture | Set a texture sampler. Value is the id of the texture to link. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def set_texture(self, name, value):
""" Set a texture sampler. Value is the id of the texture to link.
"""
if not self._linked:
raise RuntimeError('Cannot set uniform when program has no code')
# Get handle for the uniform, first try cache
handle = self._handles.get(n... | def set_texture(self, name, value):
""" Set a texture sampler. Value is the id of the texture to link.
"""
if not self._linked:
raise RuntimeError('Cannot set uniform when program has no code')
# Get handle for the uniform, first try cache
handle = self._handles.get(n... | [
"Set",
"a",
"texture",
"sampler",
".",
"Value",
"is",
"the",
"id",
"of",
"the",
"texture",
"to",
"link",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L733-L763 | [
"def",
"set_texture",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_linked",
":",
"raise",
"RuntimeError",
"(",
"'Cannot set uniform when program has no code'",
")",
"# Get handle for the uniform, first try cache",
"handle",
"=",
"self"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.set_uniform | Set a uniform value. Value is assumed to have been checked. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def set_uniform(self, name, type_, value):
""" Set a uniform value. Value is assumed to have been checked.
"""
if not self._linked:
raise RuntimeError('Cannot set uniform when program has no code')
# Get handle for the uniform, first try cache
handle = self._handles.g... | def set_uniform(self, name, type_, value):
""" Set a uniform value. Value is assumed to have been checked.
"""
if not self._linked:
raise RuntimeError('Cannot set uniform when program has no code')
# Get handle for the uniform, first try cache
handle = self._handles.g... | [
"Set",
"a",
"uniform",
"value",
".",
"Value",
"is",
"assumed",
"to",
"have",
"been",
"checked",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L765-L803 | [
"def",
"set_uniform",
"(",
"self",
",",
"name",
",",
"type_",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_linked",
":",
"raise",
"RuntimeError",
"(",
"'Cannot set uniform when program has no code'",
")",
"# Get handle for the uniform, first try cache",
"handle... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.set_attribute | Set an attribute value. Value is assumed to have been checked. | glue_vispy_viewers/extern/vispy/gloo/glir.py | def set_attribute(self, name, type_, value):
""" Set an attribute value. Value is assumed to have been checked.
"""
if not self._linked:
raise RuntimeError('Cannot set attribute when program has no code')
# Get handle for the attribute, first try cache
handle = self._... | def set_attribute(self, name, type_, value):
""" Set an attribute value. Value is assumed to have been checked.
"""
if not self._linked:
raise RuntimeError('Cannot set attribute when program has no code')
# Get handle for the attribute, first try cache
handle = self._... | [
"Set",
"an",
"attribute",
"value",
".",
"Value",
"is",
"assumed",
"to",
"have",
"been",
"checked",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L805-L846 | [
"def",
"set_attribute",
"(",
"self",
",",
"name",
",",
"type_",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_linked",
":",
"raise",
"RuntimeError",
"(",
"'Cannot set attribute when program has no code'",
")",
"# Get handle for the attribute, first try cache",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | GlirProgram.draw | Draw program in given mode, with given selection (IndexBuffer or
first, count). | glue_vispy_viewers/extern/vispy/gloo/glir.py | def draw(self, mode, selection):
""" Draw program in given mode, with given selection (IndexBuffer or
first, count).
"""
if not self._linked:
raise RuntimeError('Cannot draw program if code has not been set')
# Init
gl.check_error('Check before draw')
... | def draw(self, mode, selection):
""" Draw program in given mode, with given selection (IndexBuffer or
first, count).
"""
if not self._linked:
raise RuntimeError('Cannot draw program if code has not been set')
# Init
gl.check_error('Check before draw')
... | [
"Draw",
"program",
"in",
"given",
"mode",
"with",
"given",
"selection",
"(",
"IndexBuffer",
"or",
"first",
"count",
")",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/glir.py#L893-L920 | [
"def",
"draw",
"(",
"self",
",",
"mode",
",",
"selection",
")",
":",
"if",
"not",
"self",
".",
"_linked",
":",
"raise",
"RuntimeError",
"(",
"'Cannot draw program if code has not been set'",
")",
"# Init",
"gl",
".",
"check_error",
"(",
"'Check before draw'",
")... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | as_matrix_transform | Simplify a transform to a single matrix transform, which makes it a lot
faster to compute transformations.
Raises a TypeError if the transform cannot be simplified. | glue_vispy_viewers/utils.py | def as_matrix_transform(transform):
"""
Simplify a transform to a single matrix transform, which makes it a lot
faster to compute transformations.
Raises a TypeError if the transform cannot be simplified.
"""
if isinstance(transform, ChainTransform):
matrix = np.identity(4)
for ... | def as_matrix_transform(transform):
"""
Simplify a transform to a single matrix transform, which makes it a lot
faster to compute transformations.
Raises a TypeError if the transform cannot be simplified.
"""
if isinstance(transform, ChainTransform):
matrix = np.identity(4)
for ... | [
"Simplify",
"a",
"transform",
"to",
"a",
"single",
"matrix",
"transform",
"which",
"makes",
"it",
"a",
"lot",
"faster",
"to",
"compute",
"transformations",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/utils.py#L11-L37 | [
"def",
"as_matrix_transform",
"(",
"transform",
")",
":",
"if",
"isinstance",
"(",
"transform",
",",
"ChainTransform",
")",
":",
"matrix",
"=",
"np",
".",
"identity",
"(",
"4",
")",
"for",
"tr",
"in",
"transform",
".",
"transforms",
":",
"# We need to do the... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | circular | Places all nodes on a single circle.
Parameters
----------
adjacency_mat : matrix or sparse
The graph adjacency matrix
directed : bool
Whether the graph is directed. If this is True, is will also
generate the vertices for arrows, which can be passed to an
ArrowVisual.
... | glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/circular.py | def circular(adjacency_mat, directed=False):
"""Places all nodes on a single circle.
Parameters
----------
adjacency_mat : matrix or sparse
The graph adjacency matrix
directed : bool
Whether the graph is directed. If this is True, is will also
generate the vertices for arrow... | def circular(adjacency_mat, directed=False):
"""Places all nodes on a single circle.
Parameters
----------
adjacency_mat : matrix or sparse
The graph adjacency matrix
directed : bool
Whether the graph is directed. If this is True, is will also
generate the vertices for arrow... | [
"Places",
"all",
"nodes",
"on",
"a",
"single",
"circle",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/circular.py#L16-L49 | [
"def",
"circular",
"(",
"adjacency_mat",
",",
"directed",
"=",
"False",
")",
":",
"if",
"issparse",
"(",
"adjacency_mat",
")",
":",
"adjacency_mat",
"=",
"adjacency_mat",
".",
"tocoo",
"(",
")",
"num_nodes",
"=",
"adjacency_mat",
".",
"shape",
"[",
"0",
"]... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.