repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline._assign_uid
def _assign_uid(self, sid): """ Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of current object """ self._uid = ru.generate_id( 'pipeline.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid) for stage in sel...
python
def _assign_uid(self, sid): """ Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of current object """ self._uid = ru.generate_id( 'pipeline.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid) for stage in sel...
[ "def", "_assign_uid", "(", "self", ",", "sid", ")", ":", "self", ".", "_uid", "=", "ru", ".", "generate_id", "(", "'pipeline.%(item_counter)04d'", ",", "ru", ".", "ID_CUSTOM", ",", "namespace", "=", "sid", ")", "for", "stage", "in", "self", ".", "_stages...
Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of current object
[ "Purpose", ":", "Assign", "a", "uid", "to", "the", "current", "object", "based", "on", "the", "sid", "passed", ".", "Pass", "the", "current", "uid", "to", "children", "of", "current", "object" ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L369-L379
radical-cybertools/radical.entk
src/radical/entk/pipeline/pipeline.py
Pipeline._pass_uid
def _pass_uid(self): """ Purpose: Pass current Pipeline's uid to all Stages. :argument: List of Stage objects (optional) """ for stage in self._stages: stage.parent_pipeline['uid'] = self._uid stage.parent_pipeline['name'] = self._name stage....
python
def _pass_uid(self): """ Purpose: Pass current Pipeline's uid to all Stages. :argument: List of Stage objects (optional) """ for stage in self._stages: stage.parent_pipeline['uid'] = self._uid stage.parent_pipeline['name'] = self._name stage....
[ "def", "_pass_uid", "(", "self", ")", ":", "for", "stage", "in", "self", ".", "_stages", ":", "stage", ".", "parent_pipeline", "[", "'uid'", "]", "=", "self", ".", "_uid", "stage", ".", "parent_pipeline", "[", "'name'", "]", "=", "self", ".", "_name", ...
Purpose: Pass current Pipeline's uid to all Stages. :argument: List of Stage objects (optional)
[ "Purpose", ":", "Pass", "current", "Pipeline", "s", "uid", "to", "all", "Stages", "." ]
train
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L381-L391
xym-tool/xym
xym/xym.py
hexdump
def hexdump(src, length=16, sep='.'): """ Hexdump function by sbz and 7h3rAm on Github: (https://gist.github.com/7h3rAm/5603718). :param src: Source, the string to be shown in hexadecimal format :param length: Number of hex characters to print in one row :param sep: Unprintable characters repres...
python
def hexdump(src, length=16, sep='.'): """ Hexdump function by sbz and 7h3rAm on Github: (https://gist.github.com/7h3rAm/5603718). :param src: Source, the string to be shown in hexadecimal format :param length: Number of hex characters to print in one row :param sep: Unprintable characters repres...
[ "def", "hexdump", "(", "src", ",", "length", "=", "16", ",", "sep", "=", "'.'", ")", ":", "filtr", "=", "''", ".", "join", "(", "[", "(", "len", "(", "repr", "(", "chr", "(", "x", ")", ")", ")", "==", "3", ")", "and", "chr", "(", "x", ")"...
Hexdump function by sbz and 7h3rAm on Github: (https://gist.github.com/7h3rAm/5603718). :param src: Source, the string to be shown in hexadecimal format :param length: Number of hex characters to print in one row :param sep: Unprintable characters representation :return:
[ "Hexdump", "function", "by", "sbz", "and", "7h3rAm", "on", "Github", ":", "(", "https", ":", "//", "gist", ".", "github", ".", "com", "/", "7h3rAm", "/", "5603718", ")", ".", ":", "param", "src", ":", "Source", "the", "string", "to", "be", "shown", ...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L30-L48
xym-tool/xym
xym/xym.py
xym
def xym(source_id, srcdir, dstdir, strict=False, strict_examples=False, debug_level=0, add_line_refs=False, force_revision_pyang=False, force_revision_regexp=False): """ Extracts YANG model from an IETF RFC or draft text file. This is the main (external) API entry for the module. :param add_lin...
python
def xym(source_id, srcdir, dstdir, strict=False, strict_examples=False, debug_level=0, add_line_refs=False, force_revision_pyang=False, force_revision_regexp=False): """ Extracts YANG model from an IETF RFC or draft text file. This is the main (external) API entry for the module. :param add_lin...
[ "def", "xym", "(", "source_id", ",", "srcdir", ",", "dstdir", ",", "strict", "=", "False", ",", "strict_examples", "=", "False", ",", "debug_level", "=", "0", ",", "add_line_refs", "=", "False", ",", "force_revision_pyang", "=", "False", ",", "force_revision...
Extracts YANG model from an IETF RFC or draft text file. This is the main (external) API entry for the module. :param add_line_refs: :param source_id: identifier (file name or URL) of a draft or RFC file containing one or more YANG models :param srcdir: If source_id points to a file, the opt...
[ "Extracts", "YANG", "model", "from", "an", "IETF", "RFC", "or", "draft", "text", "file", ".", "This", "is", "the", "main", "(", "external", ")", "API", "entry", "for", "the", "module", "." ]
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L527-L574
xym-tool/xym
xym/xym.py
YangModuleExtractor.warning
def warning(self, s): """ Prints out a warning message to stderr. :param s: The warning string to print :return: None """ print(" WARNING: '%s', %s" % (self.src_id, s), file=sys.stderr)
python
def warning(self, s): """ Prints out a warning message to stderr. :param s: The warning string to print :return: None """ print(" WARNING: '%s', %s" % (self.src_id, s), file=sys.stderr)
[ "def", "warning", "(", "self", ",", "s", ")", ":", "print", "(", "\" WARNING: '%s', %s\"", "%", "(", "self", ".", "src_id", ",", "s", ")", ",", "file", "=", "sys", ".", "stderr", ")" ]
Prints out a warning message to stderr. :param s: The warning string to print :return: None
[ "Prints", "out", "a", "warning", "message", "to", "stderr", ".", ":", "param", "s", ":", "The", "warning", "string", "to", "print", ":", "return", ":", "None" ]
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L95-L101
xym-tool/xym
xym/xym.py
YangModuleExtractor.error
def error(self, s): """ Prints out an error message to stderr. :param s: The error string to print :return: None """ print(" ERROR: '%s', %s" % (self.src_id, s), file=sys.stderr)
python
def error(self, s): """ Prints out an error message to stderr. :param s: The error string to print :return: None """ print(" ERROR: '%s', %s" % (self.src_id, s), file=sys.stderr)
[ "def", "error", "(", "self", ",", "s", ")", ":", "print", "(", "\" ERROR: '%s', %s\"", "%", "(", "self", ".", "src_id", ",", "s", ")", ",", "file", "=", "sys", ".", "stderr", ")" ]
Prints out an error message to stderr. :param s: The error string to print :return: None
[ "Prints", "out", "an", "error", "message", "to", "stderr", ".", ":", "param", "s", ":", "The", "error", "string", "to", "print", ":", "return", ":", "None" ]
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L103-L109
xym-tool/xym
xym/xym.py
YangModuleExtractor.remove_leading_spaces
def remove_leading_spaces(self, input_model): """ This function is a part of the model post-processing pipeline. It removes leading spaces from an extracted module; depending on the formatting of the draft/rfc text, may have multiple spaces prepended to each line. The function a...
python
def remove_leading_spaces(self, input_model): """ This function is a part of the model post-processing pipeline. It removes leading spaces from an extracted module; depending on the formatting of the draft/rfc text, may have multiple spaces prepended to each line. The function a...
[ "def", "remove_leading_spaces", "(", "self", ",", "input_model", ")", ":", "leading_spaces", "=", "1024", "output_model", "=", "[", "]", "for", "mline", "in", "input_model", ":", "line", "=", "mline", "[", "0", "]", "if", "line", ".", "rstrip", "(", "' \...
This function is a part of the model post-processing pipeline. It removes leading spaces from an extracted module; depending on the formatting of the draft/rfc text, may have multiple spaces prepended to each line. The function also determines the length of the longest line in the modul...
[ "This", "function", "is", "a", "part", "of", "the", "model", "post", "-", "processing", "pipeline", ".", "It", "removes", "leading", "spaces", "from", "an", "extracted", "module", ";", "depending", "on", "the", "formatting", "of", "the", "draft", "/", "rfc...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L211-L235
xym-tool/xym
xym/xym.py
YangModuleExtractor.add_line_references
def add_line_references(self, input_model): """ This function is a part of the model post-processing pipeline. For each line in the module, it adds a reference to the line number in the original draft/RFC from where the module line was extracted. :param input_model: The YANG mode...
python
def add_line_references(self, input_model): """ This function is a part of the model post-processing pipeline. For each line in the module, it adds a reference to the line number in the original draft/RFC from where the module line was extracted. :param input_model: The YANG mode...
[ "def", "add_line_references", "(", "self", ",", "input_model", ")", ":", "output_model", "=", "[", "]", "for", "ln", "in", "input_model", ":", "line_len", "=", "len", "(", "ln", "[", "0", "]", ")", "line_ref", "=", "(", "'// %4d'", "%", "ln", "[", "1...
This function is a part of the model post-processing pipeline. For each line in the module, it adds a reference to the line number in the original draft/RFC from where the module line was extracted. :param input_model: The YANG model to be processed :return: Modified YANG model, where li...
[ "This", "function", "is", "a", "part", "of", "the", "model", "post", "-", "processing", "pipeline", ".", "For", "each", "line", "in", "the", "module", "it", "adds", "a", "reference", "to", "the", "line", "number", "in", "the", "original", "draft", "/", ...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L237-L253
xym-tool/xym
xym/xym.py
YangModuleExtractor.remove_extra_empty_lines
def remove_extra_empty_lines(self, input_model): """ Removes superfluous newlines from a YANG model that was extracted from a draft or RFC text. Newlines are removed whenever 2 or more consecutive empty lines are found in the model. This function is a part of the model post-proce...
python
def remove_extra_empty_lines(self, input_model): """ Removes superfluous newlines from a YANG model that was extracted from a draft or RFC text. Newlines are removed whenever 2 or more consecutive empty lines are found in the model. This function is a part of the model post-proce...
[ "def", "remove_extra_empty_lines", "(", "self", ",", "input_model", ")", ":", "ncnt", "=", "0", "output_model", "=", "[", "]", "for", "ln", "in", "input_model", ":", "if", "ln", "[", "0", "]", ".", "strip", "(", "' \\n\\r'", ")", "is", "''", ":", "if...
Removes superfluous newlines from a YANG model that was extracted from a draft or RFC text. Newlines are removed whenever 2 or more consecutive empty lines are found in the model. This function is a part of the model post-processing pipeline. :param input_model: The YANG model to be proc...
[ "Removes", "superfluous", "newlines", "from", "a", "YANG", "model", "that", "was", "extracted", "from", "a", "draft", "or", "RFC", "text", ".", "Newlines", "are", "removed", "whenever", "2", "or", "more", "consecutive", "empty", "lines", "are", "found", "in"...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L255-L278
xym-tool/xym
xym/xym.py
YangModuleExtractor.post_process_model
def post_process_model(self, input_model, add_line_refs): """ This function defines the order and execution logic for actions that are performed in the model post-processing pipeline. :param input_model: The YANG model to be processed in the pipeline :param add_line_refs: Flag th...
python
def post_process_model(self, input_model, add_line_refs): """ This function defines the order and execution logic for actions that are performed in the model post-processing pipeline. :param input_model: The YANG model to be processed in the pipeline :param add_line_refs: Flag th...
[ "def", "post_process_model", "(", "self", ",", "input_model", ",", "add_line_refs", ")", ":", "intermediate_model", "=", "self", ".", "remove_leading_spaces", "(", "input_model", ")", "intermediate_model", "=", "self", ".", "remove_extra_empty_lines", "(", "intermedia...
This function defines the order and execution logic for actions that are performed in the model post-processing pipeline. :param input_model: The YANG model to be processed in the pipeline :param add_line_refs: Flag that controls whether line number references should be added to the ...
[ "This", "function", "defines", "the", "order", "and", "execution", "logic", "for", "actions", "that", "are", "performed", "in", "the", "model", "post", "-", "processing", "pipeline", ".", ":", "param", "input_model", ":", "The", "YANG", "model", "to", "be", ...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L280-L294
xym-tool/xym
xym/xym.py
YangModuleExtractor.write_model_to_file
def write_model_to_file(self, mdl, fn): """ Write a YANG model that was extracted from a source identifier (URL or source .txt file) to a .yang destination file :param mdl: YANG model, as a list of lines :param fn: Name of the YANG model file :return: """ ...
python
def write_model_to_file(self, mdl, fn): """ Write a YANG model that was extracted from a source identifier (URL or source .txt file) to a .yang destination file :param mdl: YANG model, as a list of lines :param fn: Name of the YANG model file :return: """ ...
[ "def", "write_model_to_file", "(", "self", ",", "mdl", ",", "fn", ")", ":", "# Write the model to file", "output", "=", "''", ".", "join", "(", "self", ".", "post_process_model", "(", "mdl", ",", "self", ".", "add_line_refs", ")", ")", "if", "fn", ":", "...
Write a YANG model that was extracted from a source identifier (URL or source .txt file) to a .yang destination file :param mdl: YANG model, as a list of lines :param fn: Name of the YANG model file :return:
[ "Write", "a", "YANG", "model", "that", "was", "extracted", "from", "a", "source", "identifier", "(", "URL", "or", "source", ".", "txt", "file", ")", "to", "a", ".", "yang", "destination", "file", ":", "param", "mdl", ":", "YANG", "model", "as", "a", ...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L296-L316
xym-tool/xym
xym/xym.py
YangModuleExtractor.debug_print_line
def debug_print_line(self, i, level, line): """ Debug print of the currently parsed line :param i: The line number of the line that is being currently parsed :param level: Parser level :param line: the line that is currently being parsed :return: None """ ...
python
def debug_print_line(self, i, level, line): """ Debug print of the currently parsed line :param i: The line number of the line that is being currently parsed :param level: Parser level :param line: the line that is currently being parsed :return: None """ ...
[ "def", "debug_print_line", "(", "self", ",", "i", ",", "level", ",", "line", ")", ":", "if", "self", ".", "debug_level", "==", "2", ":", "print", "(", "\"Line %d (%d): '%s'\"", "%", "(", "i", "+", "1", ",", "level", ",", "line", ".", "rstrip", "(", ...
Debug print of the currently parsed line :param i: The line number of the line that is being currently parsed :param level: Parser level :param line: the line that is currently being parsed :return: None
[ "Debug", "print", "of", "the", "currently", "parsed", "line", ":", "param", "i", ":", "The", "line", "number", "of", "the", "line", "that", "is", "being", "currently", "parsed", ":", "param", "level", ":", "Parser", "level", ":", "param", "line", ":", ...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L318-L330
xym-tool/xym
xym/xym.py
YangModuleExtractor.debug_print_strip_msg
def debug_print_strip_msg(self, i, line): """ Debug print indicating that an empty line is being skipped :param i: The line number of the line that is being currently parsed :param line: the parsed line :return: None """ if self.debug_level == 2: print...
python
def debug_print_strip_msg(self, i, line): """ Debug print indicating that an empty line is being skipped :param i: The line number of the line that is being currently parsed :param line: the parsed line :return: None """ if self.debug_level == 2: print...
[ "def", "debug_print_strip_msg", "(", "self", ",", "i", ",", "line", ")", ":", "if", "self", ".", "debug_level", "==", "2", ":", "print", "(", "\" Stripping Line %d: '%s'\"", "%", "(", "i", "+", "1", ",", "line", ".", "rstrip", "(", "' \\r\\n\\t\\f'", ...
Debug print indicating that an empty line is being skipped :param i: The line number of the line that is being currently parsed :param line: the parsed line :return: None
[ "Debug", "print", "indicating", "that", "an", "empty", "line", "is", "being", "skipped", ":", "param", "i", ":", "The", "line", "number", "of", "the", "line", "that", "is", "being", "currently", "parsed", ":", "param", "line", ":", "the", "parsed", "line...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L332-L343
xym-tool/xym
xym/xym.py
YangModuleExtractor.strip_empty_lines_forward
def strip_empty_lines_forward(self, content, i): """ Skip over empty lines :param content: parsed text :param i: current parsed line :return: number of skipped lined """ while i < len(content): line = content[i].strip(' \r\n\t\f') if line !...
python
def strip_empty_lines_forward(self, content, i): """ Skip over empty lines :param content: parsed text :param i: current parsed line :return: number of skipped lined """ while i < len(content): line = content[i].strip(' \r\n\t\f') if line !...
[ "def", "strip_empty_lines_forward", "(", "self", ",", "content", ",", "i", ")", ":", "while", "i", "<", "len", "(", "content", ")", ":", "line", "=", "content", "[", "i", "]", ".", "strip", "(", "' \\r\\n\\t\\f'", ")", "if", "line", "!=", "''", ":", ...
Skip over empty lines :param content: parsed text :param i: current parsed line :return: number of skipped lined
[ "Skip", "over", "empty", "lines", ":", "param", "content", ":", "parsed", "text", ":", "param", "i", ":", "current", "parsed", "line", ":", "return", ":", "number", "of", "skipped", "lined" ]
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L345-L358
xym-tool/xym
xym/xym.py
YangModuleExtractor.strip_empty_lines_backward
def strip_empty_lines_backward(self, model, max_lines_to_strip): """ Strips empty lines preceding the line that is currently being parsed. This fucntion is called when the parser encounters a Footer. :param model: lines that were added to the model up to this point :param line_nu...
python
def strip_empty_lines_backward(self, model, max_lines_to_strip): """ Strips empty lines preceding the line that is currently being parsed. This fucntion is called when the parser encounters a Footer. :param model: lines that were added to the model up to this point :param line_nu...
[ "def", "strip_empty_lines_backward", "(", "self", ",", "model", ",", "max_lines_to_strip", ")", ":", "for", "l", "in", "range", "(", "0", ",", "max_lines_to_strip", ")", ":", "if", "model", "[", "-", "1", "]", "[", "0", "]", ".", "strip", "(", "' \\r\\...
Strips empty lines preceding the line that is currently being parsed. This fucntion is called when the parser encounters a Footer. :param model: lines that were added to the model up to this point :param line_num: the number of teh line being parsed :param max_lines_to_strip: max number ...
[ "Strips", "empty", "lines", "preceding", "the", "line", "that", "is", "currently", "being", "parsed", ".", "This", "fucntion", "is", "called", "when", "the", "parser", "encounters", "a", "Footer", ".", ":", "param", "model", ":", "lines", "that", "were", "...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L360-L373
xym-tool/xym
xym/xym.py
YangModuleExtractor.extract_yang_model
def extract_yang_model(self, content): """ Extracts one or more YANG models from an RFC or draft text string in which the models are specified. The function skips over page formatting (Page Headers and Footers) and performs basic YANG module syntax checking. In strict mode, the f...
python
def extract_yang_model(self, content): """ Extracts one or more YANG models from an RFC or draft text string in which the models are specified. The function skips over page formatting (Page Headers and Footers) and performs basic YANG module syntax checking. In strict mode, the f...
[ "def", "extract_yang_model", "(", "self", ",", "content", ")", ":", "model", "=", "[", "]", "output_file", "=", "None", "in_model", "=", "False", "example_match", "=", "False", "i", "=", "0", "level", "=", "0", "quotes", "=", "0", "while", "i", "<", ...
Extracts one or more YANG models from an RFC or draft text string in which the models are specified. The function skips over page formatting (Page Headers and Footers) and performs basic YANG module syntax checking. In strict mode, the function also enforces the <CODE BEGINS> / <CODE END...
[ "Extracts", "one", "or", "more", "YANG", "models", "from", "an", "RFC", "or", "draft", "text", "string", "in", "which", "the", "models", "are", "specified", ".", "The", "function", "skips", "over", "page", "formatting", "(", "Page", "Headers", "and", "Foot...
train
https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L375-L524
rbarrois/mpdlcd
mpdlcd/utils.py
auto_retry
def auto_retry(fun): """Decorator for retrying method calls, based on instance parameters.""" @functools.wraps(fun) def decorated(instance, *args, **kwargs): """Wrapper around a decorated function.""" cfg = instance._retry_config remaining_tries = cfg.retry_attempts current_...
python
def auto_retry(fun): """Decorator for retrying method calls, based on instance parameters.""" @functools.wraps(fun) def decorated(instance, *args, **kwargs): """Wrapper around a decorated function.""" cfg = instance._retry_config remaining_tries = cfg.retry_attempts current_...
[ "def", "auto_retry", "(", "fun", ")", ":", "@", "functools", ".", "wraps", "(", "fun", ")", "def", "decorated", "(", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapper around a decorated function.\"\"\"", "cfg", "=", "instance", ...
Decorator for retrying method calls, based on instance parameters.
[ "Decorator", "for", "retrying", "method", "calls", "based", "on", "instance", "parameters", "." ]
train
https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/utils.py#L50-L81
rbarrois/mpdlcd
mpdlcd/utils.py
extract_pattern
def extract_pattern(fmt): """Extracts used strings from a %(foo)s pattern.""" class FakeDict(object): def __init__(self): self.seen_keys = set() def __getitem__(self, key): self.seen_keys.add(key) return '' def keys(self): return self.see...
python
def extract_pattern(fmt): """Extracts used strings from a %(foo)s pattern.""" class FakeDict(object): def __init__(self): self.seen_keys = set() def __getitem__(self, key): self.seen_keys.add(key) return '' def keys(self): return self.see...
[ "def", "extract_pattern", "(", "fmt", ")", ":", "class", "FakeDict", "(", "object", ")", ":", "def", "__init__", "(", "self", ")", ":", "self", ".", "seen_keys", "=", "set", "(", ")", "def", "__getitem__", "(", "self", ",", "key", ")", ":", "self", ...
Extracts used strings from a %(foo)s pattern.
[ "Extracts", "used", "strings", "from", "a", "%", "(", "foo", ")", "s", "pattern", "." ]
train
https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/utils.py#L84-L103
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isoline.py
iso_mesh_line
def iso_mesh_line(vertices, tris, vertex_data, levels): """Generate an isocurve from vertex data in a surface mesh. Parameters ---------- vertices : ndarray, shape (Nv, 3) Vertex coordinates. tris : ndarray, shape (Nf, 3) Indices of triangular element into the vertices array. ve...
python
def iso_mesh_line(vertices, tris, vertex_data, levels): """Generate an isocurve from vertex data in a surface mesh. Parameters ---------- vertices : ndarray, shape (Nv, 3) Vertex coordinates. tris : ndarray, shape (Nf, 3) Indices of triangular element into the vertices array. ve...
[ "def", "iso_mesh_line", "(", "vertices", ",", "tris", ",", "vertex_data", ",", "levels", ")", ":", "lines", "=", "None", "connects", "=", "None", "vertex_level", "=", "None", "level_index", "=", "None", "if", "not", "all", "(", "[", "isinstance", "(", "x...
Generate an isocurve from vertex data in a surface mesh. Parameters ---------- vertices : ndarray, shape (Nv, 3) Vertex coordinates. tris : ndarray, shape (Nf, 3) Indices of triangular element into the vertices array. vertex_data : ndarray, shape (Nv,) data at vertex. le...
[ "Generate", "an", "isocurve", "from", "vertex", "data", "in", "a", "surface", "mesh", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L14-L91
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isoline.py
IsolineVisual.set_data
def set_data(self, vertices=None, tris=None, data=None): """Set the data Parameters ---------- vertices : ndarray, shape (Nv, 3) | None Vertex coordinates. tris : ndarray, shape (Nf, 3) | None Indices into the vertex array. data : ndarray, shape (...
python
def set_data(self, vertices=None, tris=None, data=None): """Set the data Parameters ---------- vertices : ndarray, shape (Nv, 3) | None Vertex coordinates. tris : ndarray, shape (Nf, 3) | None Indices into the vertex array. data : ndarray, shape (...
[ "def", "set_data", "(", "self", ",", "vertices", "=", "None", ",", "tris", "=", "None", ",", "data", "=", "None", ")", ":", "# modifier pour tenier compte des None self._recompute = True", "if", "data", "is", "not", "None", ":", "self", ".", "_data", "=", "d...
Set the data Parameters ---------- vertices : ndarray, shape (Nv, 3) | None Vertex coordinates. tris : ndarray, shape (Nf, 3) | None Indices into the vertex array. data : ndarray, shape (Nv,) | None scalar at vertices
[ "Set", "the", "data" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L150-L172
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isoline.py
IsolineVisual.set_color
def set_color(self, color): """Set the color Parameters ---------- color : instance of Color The color to use. """ if color is not None: self._color_lev = color self._need_color_update = True self.update()
python
def set_color(self, color): """Set the color Parameters ---------- color : instance of Color The color to use. """ if color is not None: self._color_lev = color self._need_color_update = True self.update()
[ "def", "set_color", "(", "self", ",", "color", ")", ":", "if", "color", "is", "not", "None", ":", "self", ".", "_color_lev", "=", "color", "self", ".", "_need_color_update", "=", "True", "self", ".", "update", "(", ")" ]
Set the color Parameters ---------- color : instance of Color The color to use.
[ "Set", "the", "color" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L178-L189
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isoline.py
IsolineVisual._compute_iso_color
def _compute_iso_color(self): """ compute LineVisual color from level index and corresponding level color """ level_color = [] colors = self._lc for i, index in enumerate(self._li): level_color.append(np.zeros((index, 4)) + colors[i]) self._cl = np.vst...
python
def _compute_iso_color(self): """ compute LineVisual color from level index and corresponding level color """ level_color = [] colors = self._lc for i, index in enumerate(self._li): level_color.append(np.zeros((index, 4)) + colors[i]) self._cl = np.vst...
[ "def", "_compute_iso_color", "(", "self", ")", ":", "level_color", "=", "[", "]", "colors", "=", "self", ".", "_lc", "for", "i", ",", "index", "in", "enumerate", "(", "self", ".", "_li", ")", ":", "level_color", ".", "append", "(", "np", ".", "zeros"...
compute LineVisual color from level index and corresponding level color
[ "compute", "LineVisual", "color", "from", "level", "index", "and", "corresponding", "level", "color" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L214-L222
glue-viz/glue-vispy-viewers
glue_vispy_viewers/volume/layer_artist.py
VolumeLayerArtist.remove
def remove(self): """ Remove the layer artist for good """ self._multivol.deallocate(self.id) ARRAY_CACHE.pop(self.id, None) PIXEL_CACHE.pop(self.id, None)
python
def remove(self): """ Remove the layer artist for good """ self._multivol.deallocate(self.id) ARRAY_CACHE.pop(self.id, None) PIXEL_CACHE.pop(self.id, None)
[ "def", "remove", "(", "self", ")", ":", "self", ".", "_multivol", ".", "deallocate", "(", "self", ".", "id", ")", "ARRAY_CACHE", ".", "pop", "(", "self", ".", "id", ",", "None", ")", "PIXEL_CACHE", ".", "pop", "(", "self", ".", "id", ",", "None", ...
Remove the layer artist for good
[ "Remove", "the", "layer", "artist", "for", "good" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/volume/layer_artist.py#L151-L157
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py
_inject
def _inject(): """ Inject functions and constants from PyOpenGL but leave out the names that are deprecated or that we provide in our API. """ # Get namespaces NS = globals() GLNS = _GL.__dict__ # Get names that we use in our API used_names = [] used_names.extend([names[0] ...
python
def _inject(): """ Inject functions and constants from PyOpenGL but leave out the names that are deprecated or that we provide in our API. """ # Get namespaces NS = globals() GLNS = _GL.__dict__ # Get names that we use in our API used_names = [] used_names.extend([names[0] ...
[ "def", "_inject", "(", ")", ":", "# Get namespaces", "NS", "=", "globals", "(", ")", "GLNS", "=", "_GL", ".", "__dict__", "# Get names that we use in our API", "used_names", "=", "[", "]", "used_names", ".", "extend", "(", "[", "names", "[", "0", "]", "for...
Inject functions and constants from PyOpenGL but leave out the names that are deprecated or that we provide in our API.
[ "Inject", "functions", "and", "constants", "from", "PyOpenGL", "but", "leave", "out", "the", "names", "that", "are", "deprecated", "or", "that", "we", "provide", "in", "our", "API", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py#L17-L53
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/six.py
_find_module
def _find_module(name, path=None): """ Alternative to `imp.find_module` that can also search in subpackages. """ parts = name.split('.') for part in parts: if path is not None: path = [path] fh, path, descr = imp.find_module(part, path) if fh is not None and pa...
python
def _find_module(name, path=None): """ Alternative to `imp.find_module` that can also search in subpackages. """ parts = name.split('.') for part in parts: if path is not None: path = [path] fh, path, descr = imp.find_module(part, path) if fh is not None and pa...
[ "def", "_find_module", "(", "name", ",", "path", "=", "None", ")", ":", "parts", "=", "name", ".", "split", "(", "'.'", ")", "for", "part", "in", "parts", ":", "if", "path", "is", "not", "None", ":", "path", "=", "[", "path", "]", "fh", ",", "p...
Alternative to `imp.find_module` that can also search in subpackages.
[ "Alternative", "to", "imp", ".", "find_module", "that", "can", "also", "search", "in", "subpackages", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/six.py#L25-L40
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
triangulate
def triangulate(vertices): """Triangulate a set of vertices Parameters ---------- vertices : array-like The vertices. Returns ------- vertices : array-like The vertices. tringles : array-like The triangles. """ n = len(vertices) vertices = np.asarray...
python
def triangulate(vertices): """Triangulate a set of vertices Parameters ---------- vertices : array-like The vertices. Returns ------- vertices : array-like The vertices. tringles : array-like The triangles. """ n = len(vertices) vertices = np.asarray...
[ "def", "triangulate", "(", "vertices", ")", ":", "n", "=", "len", "(", "vertices", ")", "vertices", "=", "np", ".", "asarray", "(", "vertices", ")", "zmean", "=", "vertices", "[", ":", ",", "2", "]", ".", "mean", "(", ")", "vertices_2d", "=", "vert...
Triangulate a set of vertices Parameters ---------- vertices : array-like The vertices. Returns ------- vertices : array-like The vertices. tringles : array-like The triangles.
[ "Triangulate", "a", "set", "of", "vertices" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L999-L1029
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation.triangulate
def triangulate(self): """Do the triangulation """ self._initialize() pts = self.pts front = self._front ## Begin sweep (sec. 3.4) for i in range(3, pts.shape[0]): pi = pts[i] #debug("========== New point %d: %s ==========...
python
def triangulate(self): """Do the triangulation """ self._initialize() pts = self.pts front = self._front ## Begin sweep (sec. 3.4) for i in range(3, pts.shape[0]): pi = pts[i] #debug("========== New point %d: %s ==========...
[ "def", "triangulate", "(", "self", ")", ":", "self", ".", "_initialize", "(", ")", "pts", "=", "self", ".", "pts", "front", "=", "self", ".", "_front", "## Begin sweep (sec. 3.4)", "for", "i", "in", "range", "(", "3", ",", "pts", ".", "shape", "[", "...
Do the triangulation
[ "Do", "the", "triangulation" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L128-L214
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edge_event
def _edge_event(self, i, j): """ Force edge (i, j) to be present in mesh. This works by removing intersected triangles and filling holes up to the cutting edge. """ front_index = self._front.index(i) #debug(" == edge event ==") front = self._fro...
python
def _edge_event(self, i, j): """ Force edge (i, j) to be present in mesh. This works by removing intersected triangles and filling holes up to the cutting edge. """ front_index = self._front.index(i) #debug(" == edge event ==") front = self._fro...
[ "def", "_edge_event", "(", "self", ",", "i", ",", "j", ")", ":", "front_index", "=", "self", ".", "_front", ".", "index", "(", "i", ")", "#debug(\" == edge event ==\")", "front", "=", "self", ".", "_front", "# First just see whether this edge is already present",...
Force edge (i, j) to be present in mesh. This works by removing intersected triangles and filling holes up to the cutting edge.
[ "Force", "edge", "(", "i", "j", ")", "to", "be", "present", "in", "mesh", ".", "This", "works", "by", "removing", "intersected", "triangles", "and", "filling", "holes", "up", "to", "the", "cutting", "edge", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L279-L493
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._find_cut_triangle
def _find_cut_triangle(self, edge): """ Return the triangle that has edge[0] as one of its vertices and is bisected by edge. Return None if no triangle is found. """ edges = [] # opposite edge for each triangle attached to edge[0] for tri in self.tris: ...
python
def _find_cut_triangle(self, edge): """ Return the triangle that has edge[0] as one of its vertices and is bisected by edge. Return None if no triangle is found. """ edges = [] # opposite edge for each triangle attached to edge[0] for tri in self.tris: ...
[ "def", "_find_cut_triangle", "(", "self", ",", "edge", ")", ":", "edges", "=", "[", "]", "# opposite edge for each triangle attached to edge[0]", "for", "tri", "in", "self", ".", "tris", ":", "if", "edge", "[", "0", "]", "in", "tri", ":", "edges", ".", "ap...
Return the triangle that has edge[0] as one of its vertices and is bisected by edge. Return None if no triangle is found.
[ "Return", "the", "triangle", "that", "has", "edge", "[", "0", "]", "as", "one", "of", "its", "vertices", "and", "is", "bisected", "by", "edge", ".", "Return", "None", "if", "no", "triangle", "is", "found", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L497-L518
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edge_in_front
def _edge_in_front(self, edge): """ Return the index where *edge* appears in the current front. If the edge is not in the front, return -1 """ e = (list(edge), list(edge)[::-1]) for i in range(len(self._front)-1): if self._front[i:i+2] in e: return i ...
python
def _edge_in_front(self, edge): """ Return the index where *edge* appears in the current front. If the edge is not in the front, return -1 """ e = (list(edge), list(edge)[::-1]) for i in range(len(self._front)-1): if self._front[i:i+2] in e: return i ...
[ "def", "_edge_in_front", "(", "self", ",", "edge", ")", ":", "e", "=", "(", "list", "(", "edge", ")", ",", "list", "(", "edge", ")", "[", ":", ":", "-", "1", "]", ")", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_front", ")", ...
Return the index where *edge* appears in the current front. If the edge is not in the front, return -1
[ "Return", "the", "index", "where", "*", "edge", "*", "appears", "in", "the", "current", "front", ".", "If", "the", "edge", "is", "not", "in", "the", "front", "return", "-", "1" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L520-L528
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edge_opposite_point
def _edge_opposite_point(self, tri, i): """ Given a triangle, return the edge that is opposite point i. Vertexes are returned in the same orientation as in tri. """ ind = tri.index(i) return (tri[(ind+1) % 3], tri[(ind+2) % 3])
python
def _edge_opposite_point(self, tri, i): """ Given a triangle, return the edge that is opposite point i. Vertexes are returned in the same orientation as in tri. """ ind = tri.index(i) return (tri[(ind+1) % 3], tri[(ind+2) % 3])
[ "def", "_edge_opposite_point", "(", "self", ",", "tri", ",", "i", ")", ":", "ind", "=", "tri", ".", "index", "(", "i", ")", "return", "(", "tri", "[", "(", "ind", "+", "1", ")", "%", "3", "]", ",", "tri", "[", "(", "ind", "+", "2", ")", "%"...
Given a triangle, return the edge that is opposite point i. Vertexes are returned in the same orientation as in tri.
[ "Given", "a", "triangle", "return", "the", "edge", "that", "is", "opposite", "point", "i", ".", "Vertexes", "are", "returned", "in", "the", "same", "orientation", "as", "in", "tri", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L530-L535
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._adjacent_tri
def _adjacent_tri(self, edge, i): """ Given a triangle formed by edge and i, return the triangle that shares edge. *i* may be either a point or the entire triangle. """ if not np.isscalar(i): i = [x for x in i if x not in edge][0] try: pt1 = self....
python
def _adjacent_tri(self, edge, i): """ Given a triangle formed by edge and i, return the triangle that shares edge. *i* may be either a point or the entire triangle. """ if not np.isscalar(i): i = [x for x in i if x not in edge][0] try: pt1 = self....
[ "def", "_adjacent_tri", "(", "self", ",", "edge", ",", "i", ")", ":", "if", "not", "np", ".", "isscalar", "(", "i", ")", ":", "i", "=", "[", "x", "for", "x", "in", "i", "if", "x", "not", "in", "edge", "]", "[", "0", "]", "try", ":", "pt1", ...
Given a triangle formed by edge and i, return the triangle that shares edge. *i* may be either a point or the entire triangle.
[ "Given", "a", "triangle", "formed", "by", "edge", "and", "i", "return", "the", "triangle", "that", "shares", "edge", ".", "*", "i", "*", "may", "be", "either", "a", "point", "or", "the", "entire", "triangle", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L537-L557
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._tri_from_edge
def _tri_from_edge(self, edge): """Return the only tri that contains *edge*. If two tris share this edge, raise an exception. """ edge = tuple(edge) p1 = self._edges_lookup.get(edge, None) p2 = self._edges_lookup.get(edge[::-1], None) if p1 is None: if...
python
def _tri_from_edge(self, edge): """Return the only tri that contains *edge*. If two tris share this edge, raise an exception. """ edge = tuple(edge) p1 = self._edges_lookup.get(edge, None) p2 = self._edges_lookup.get(edge[::-1], None) if p1 is None: if...
[ "def", "_tri_from_edge", "(", "self", ",", "edge", ")", ":", "edge", "=", "tuple", "(", "edge", ")", "p1", "=", "self", ".", "_edges_lookup", ".", "get", "(", "edge", ",", "None", ")", "p2", "=", "self", ".", "_edges_lookup", ".", "get", "(", "edge...
Return the only tri that contains *edge*. If two tris share this edge, raise an exception.
[ "Return", "the", "only", "tri", "that", "contains", "*", "edge", "*", ".", "If", "two", "tris", "share", "this", "edge", "raise", "an", "exception", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L559-L573
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edges_in_tri_except
def _edges_in_tri_except(self, tri, edge): """Return the edges in *tri*, excluding *edge*. """ edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)] try: edges.remove(tuple(edge)) except ValueError: edges.remove(tuple(edge[::-1])) return edges
python
def _edges_in_tri_except(self, tri, edge): """Return the edges in *tri*, excluding *edge*. """ edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)] try: edges.remove(tuple(edge)) except ValueError: edges.remove(tuple(edge[::-1])) return edges
[ "def", "_edges_in_tri_except", "(", "self", ",", "tri", ",", "edge", ")", ":", "edges", "=", "[", "(", "tri", "[", "i", "]", ",", "tri", "[", "(", "i", "+", "1", ")", "%", "3", "]", ")", "for", "i", "in", "range", "(", "3", ")", "]", "try",...
Return the edges in *tri*, excluding *edge*.
[ "Return", "the", "edges", "in", "*", "tri", "*", "excluding", "*", "edge", "*", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L575-L583
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edge_below_front
def _edge_below_front(self, edge, front_index): """Return True if *edge* is below the current front. One of the points in *edge* must be _on_ the front, at *front_index*. """ f0 = self._front[front_index-1] f1 = self._front[front_index+1] return (self._orientati...
python
def _edge_below_front(self, edge, front_index): """Return True if *edge* is below the current front. One of the points in *edge* must be _on_ the front, at *front_index*. """ f0 = self._front[front_index-1] f1 = self._front[front_index+1] return (self._orientati...
[ "def", "_edge_below_front", "(", "self", ",", "edge", ",", "front_index", ")", ":", "f0", "=", "self", ".", "_front", "[", "front_index", "-", "1", "]", "f1", "=", "self", ".", "_front", "[", "front_index", "+", "1", "]", "return", "(", "self", ".", ...
Return True if *edge* is below the current front. One of the points in *edge* must be _on_ the front, at *front_index*.
[ "Return", "True", "if", "*", "edge", "*", "is", "below", "the", "current", "front", ".", "One", "of", "the", "points", "in", "*", "edge", "*", "must", "be", "_on_", "the", "front", "at", "*", "front_index", "*", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L585-L593
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._intersected_edge
def _intersected_edge(self, edges, cut_edge): """ Given a list of *edges*, return the first that is intersected by *cut_edge*. """ for edge in edges: if self._edges_intersect(edge, cut_edge): return edge
python
def _intersected_edge(self, edges, cut_edge): """ Given a list of *edges*, return the first that is intersected by *cut_edge*. """ for edge in edges: if self._edges_intersect(edge, cut_edge): return edge
[ "def", "_intersected_edge", "(", "self", ",", "edges", ",", "cut_edge", ")", ":", "for", "edge", "in", "edges", ":", "if", "self", ".", "_edges_intersect", "(", "edge", ",", "cut_edge", ")", ":", "return", "edge" ]
Given a list of *edges*, return the first that is intersected by *cut_edge*.
[ "Given", "a", "list", "of", "*", "edges", "*", "return", "the", "first", "that", "is", "intersected", "by", "*", "cut_edge", "*", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L601-L607
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._find_edge_intersections
def _find_edge_intersections(self): """ Return a dictionary containing, for each edge in self.edges, a list of the positions at which the edge should be split. """ edges = self.pts[self.edges] cuts = {} # { edge: [(intercept, point), ...], ... } for i in range(ed...
python
def _find_edge_intersections(self): """ Return a dictionary containing, for each edge in self.edges, a list of the positions at which the edge should be split. """ edges = self.pts[self.edges] cuts = {} # { edge: [(intercept, point), ...], ... } for i in range(ed...
[ "def", "_find_edge_intersections", "(", "self", ")", ":", "edges", "=", "self", ".", "pts", "[", "self", ".", "edges", "]", "cuts", "=", "{", "}", "# { edge: [(intercept, point), ...], ... }", "for", "i", "in", "range", "(", "edges", ".", "shape", "[", "0"...
Return a dictionary containing, for each edge in self.edges, a list of the positions at which the edge should be split.
[ "Return", "a", "dictionary", "containing", "for", "each", "edge", "in", "self", ".", "edges", "a", "list", "of", "the", "positions", "at", "which", "the", "edge", "should", "be", "split", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L609-L655
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._projection
def _projection(self, a, b, c): """Return projection of (a,b) onto (a,c) Arguments are point locations, not indexes. """ ab = b - a ac = c - a return a + ((ab*ac).sum() / (ac*ac).sum()) * ac
python
def _projection(self, a, b, c): """Return projection of (a,b) onto (a,c) Arguments are point locations, not indexes. """ ab = b - a ac = c - a return a + ((ab*ac).sum() / (ac*ac).sum()) * ac
[ "def", "_projection", "(", "self", ",", "a", ",", "b", ",", "c", ")", ":", "ab", "=", "b", "-", "a", "ac", "=", "c", "-", "a", "return", "a", "+", "(", "(", "ab", "*", "ac", ")", ".", "sum", "(", ")", "/", "(", "ac", "*", "ac", ")", "...
Return projection of (a,b) onto (a,c) Arguments are point locations, not indexes.
[ "Return", "projection", "of", "(", "a", "b", ")", "onto", "(", "a", "c", ")", "Arguments", "are", "point", "locations", "not", "indexes", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L760-L766
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._edges_intersect
def _edges_intersect(self, edge1, edge2): """ Return 1 if edges intersect completely (endpoints excluded) """ h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)], self.pts[np.array(edge2)]) h21 = self._intersect_edge_arrays(self....
python
def _edges_intersect(self, edge1, edge2): """ Return 1 if edges intersect completely (endpoints excluded) """ h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)], self.pts[np.array(edge2)]) h21 = self._intersect_edge_arrays(self....
[ "def", "_edges_intersect", "(", "self", ",", "edge1", ",", "edge2", ")", ":", "h12", "=", "self", ".", "_intersect_edge_arrays", "(", "self", ".", "pts", "[", "np", ".", "array", "(", "edge1", ")", "]", ",", "self", ".", "pts", "[", "np", ".", "arr...
Return 1 if edges intersect completely (endpoints excluded)
[ "Return", "1", "if", "edges", "intersect", "completely", "(", "endpoints", "excluded", ")" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L809-L823
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._intersection_matrix
def _intersection_matrix(self, lines): """ Return a 2D array of intercepts such that intercepts[i, j] is the intercept of lines[i] onto lines[j]. *lines* must be an array of point locations with shape (N, 2, 2), where the axes are (lines, points_per_line, xy_per_point)....
python
def _intersection_matrix(self, lines): """ Return a 2D array of intercepts such that intercepts[i, j] is the intercept of lines[i] onto lines[j]. *lines* must be an array of point locations with shape (N, 2, 2), where the axes are (lines, points_per_line, xy_per_point)....
[ "def", "_intersection_matrix", "(", "self", ",", "lines", ")", ":", "return", "self", ".", "_intersect_edge_arrays", "(", "lines", "[", ":", ",", "np", ".", "newaxis", ",", "...", "]", ",", "lines", "[", "np", ".", "newaxis", ",", "...", "]", ")" ]
Return a 2D array of intercepts such that intercepts[i, j] is the intercept of lines[i] onto lines[j]. *lines* must be an array of point locations with shape (N, 2, 2), where the axes are (lines, points_per_line, xy_per_point). The intercept is described in intersect_e...
[ "Return", "a", "2D", "array", "of", "intercepts", "such", "that", "intercepts", "[", "i", "j", "]", "is", "the", "intercept", "of", "lines", "[", "i", "]", "onto", "lines", "[", "j", "]", ".", "*", "lines", "*", "must", "be", "an", "array", "of", ...
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L825-L836
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._intersect_edge_arrays
def _intersect_edge_arrays(self, lines1, lines2): """Return the intercepts of all lines defined in *lines1* as they intersect all lines in *lines2*. Arguments are of shape (..., 2, 2), where axes are: 0: number of lines 1: two points per line 2: x,y pa...
python
def _intersect_edge_arrays(self, lines1, lines2): """Return the intercepts of all lines defined in *lines1* as they intersect all lines in *lines2*. Arguments are of shape (..., 2, 2), where axes are: 0: number of lines 1: two points per line 2: x,y pa...
[ "def", "_intersect_edge_arrays", "(", "self", ",", "lines1", ",", "lines2", ")", ":", "# vector for each line in lines1", "l1", "=", "lines1", "[", "...", ",", "1", ",", ":", "]", "-", "lines1", "[", "...", ",", "0", ",", ":", "]", "# vector for each line ...
Return the intercepts of all lines defined in *lines1* as they intersect all lines in *lines2*. Arguments are of shape (..., 2, 2), where axes are: 0: number of lines 1: two points per line 2: x,y pair per point Lines are compared elementwise across t...
[ "Return", "the", "intercepts", "of", "all", "lines", "defined", "in", "*", "lines1", "*", "as", "they", "intersect", "all", "lines", "in", "*", "lines2", "*", ".", "Arguments", "are", "of", "shape", "(", "...", "2", "2", ")", "where", "axes", "are", ...
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L838-L878
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/triangulation.py
Triangulation._orientation
def _orientation(self, edge, point): """ Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1], -1 if counterclockwise, and 0 if parallel. """ v1 = self.pts[point] - self.pts[edge[0]] v2 = self.pts[edge[1]] - self.pts[edge[0]] c = np.cross(v1, v2) # positive i...
python
def _orientation(self, edge, point): """ Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1], -1 if counterclockwise, and 0 if parallel. """ v1 = self.pts[point] - self.pts[edge[0]] v2 = self.pts[edge[1]] - self.pts[edge[0]] c = np.cross(v1, v2) # positive i...
[ "def", "_orientation", "(", "self", ",", "edge", ",", "point", ")", ":", "v1", "=", "self", ".", "pts", "[", "point", "]", "-", "self", ".", "pts", "[", "edge", "[", "0", "]", "]", "v2", "=", "self", ".", "pts", "[", "edge", "[", "1", "]", ...
Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1], -1 if counterclockwise, and 0 if parallel.
[ "Returns", "+", "1", "if", "edge", "[", "0", "]", "-", ">", "point", "is", "clockwise", "from", "edge", "[", "0", "]", "-", ">", "edge", "[", "1", "]", "-", "1", "if", "counterclockwise", "and", "0", "if", "parallel", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L880-L887
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ipython/ipython.py
load_ipython_extension
def load_ipython_extension(ipython): """ Entry point of the IPython extension Parameters ---------- IPython : IPython interpreter An instance of the IPython interpreter that is handed over to the extension """ import IPython # don't continue if IPython version is < 3.0 ...
python
def load_ipython_extension(ipython): """ Entry point of the IPython extension Parameters ---------- IPython : IPython interpreter An instance of the IPython interpreter that is handed over to the extension """ import IPython # don't continue if IPython version is < 3.0 ...
[ "def", "load_ipython_extension", "(", "ipython", ")", ":", "import", "IPython", "# don't continue if IPython version is < 3.0", "ipy_version", "=", "LooseVersion", "(", "IPython", ".", "__version__", ")", "if", "ipy_version", "<", "LooseVersion", "(", "\"3.0.0\"", ")", ...
Entry point of the IPython extension Parameters ---------- IPython : IPython interpreter An instance of the IPython interpreter that is handed over to the extension
[ "Entry", "point", "of", "the", "IPython", "extension" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L9-L30
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ipython/ipython.py
_load_webgl_backend
def _load_webgl_backend(ipython): """ Load the webgl backend for the IPython notebook""" from .. import app app_instance = app.use_app("ipynb_webgl") if app_instance.backend_name == "ipynb_webgl": ipython.write("Vispy IPython module has loaded successfully") else: # TODO: Improve t...
python
def _load_webgl_backend(ipython): """ Load the webgl backend for the IPython notebook""" from .. import app app_instance = app.use_app("ipynb_webgl") if app_instance.backend_name == "ipynb_webgl": ipython.write("Vispy IPython module has loaded successfully") else: # TODO: Improve t...
[ "def", "_load_webgl_backend", "(", "ipython", ")", ":", "from", ".", ".", "import", "app", "app_instance", "=", "app", ".", "use_app", "(", "\"ipynb_webgl\"", ")", "if", "app_instance", ".", "backend_name", "==", "\"ipynb_webgl\"", ":", "ipython", ".", "write"...
Load the webgl backend for the IPython notebook
[ "Load", "the", "webgl", "backend", "for", "the", "IPython", "notebook" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L33-L43
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/collections/collection.py
Collection.draw
def draw(self, mode=None): """ Draw collection """ if self._need_update: self._update() program = self._programs[0] mode = mode or self._mode if self._indices_list is not None: program.draw(mode, self._indices_buffer) else: program.d...
python
def draw(self, mode=None): """ Draw collection """ if self._need_update: self._update() program = self._programs[0] mode = mode or self._mode if self._indices_list is not None: program.draw(mode, self._indices_buffer) else: program.d...
[ "def", "draw", "(", "self", ",", "mode", "=", "None", ")", ":", "if", "self", ".", "_need_update", ":", "self", ".", "_update", "(", ")", "program", "=", "self", ".", "_programs", "[", "0", "]", "mode", "=", "mode", "or", "self", ".", "_mode", "i...
Draw collection
[ "Draw", "collection" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/collection.py#L197-L209
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/filter.py
gaussian_filter
def gaussian_filter(data, sigma): """ Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter) """ if np.isscalar(sigma): sigma = (sigma,) * data.ndim baseline = data.mean() filtered = data - baseline ...
python
def gaussian_filter(data, sigma): """ Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter) """ if np.isscalar(sigma): sigma = (sigma,) * data.ndim baseline = data.mean() filtered = data - baseline ...
[ "def", "gaussian_filter", "(", "data", ",", "sigma", ")", ":", "if", "np", ".", "isscalar", "(", "sigma", ")", ":", "sigma", "=", "(", "sigma", ",", ")", "*", "data", ".", "ndim", "baseline", "=", "data", ".", "mean", "(", ")", "filtered", "=", "...
Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter)
[ "Drop", "-", "in", "replacement", "for", "scipy", ".", "ndimage", ".", "gaussian_filter", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/filter.py#L8-L44
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/transforms.py
translate
def translate(offset, dtype=None): """Translate by an offset (x, y, z) . Parameters ---------- offset : array-like, shape (3,) Translation in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix descr...
python
def translate(offset, dtype=None): """Translate by an offset (x, y, z) . Parameters ---------- offset : array-like, shape (3,) Translation in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix descr...
[ "def", "translate", "(", "offset", ",", "dtype", "=", "None", ")", ":", "assert", "len", "(", "offset", ")", "==", "3", "x", ",", "y", ",", "z", "=", "offset", "M", "=", "np", ".", "array", "(", "[", "[", "1.", ",", "0.", ",", "0.", ",", "0...
Translate by an offset (x, y, z) . Parameters ---------- offset : array-like, shape (3,) Translation in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix describing the translation.
[ "Translate", "by", "an", "offset", "(", "x", "y", "z", ")", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L15-L36
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/transforms.py
scale
def scale(s, dtype=None): """Non-uniform scaling along the x, y, and z axes Parameters ---------- s : array-like, shape (3,) Scaling in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix describing ...
python
def scale(s, dtype=None): """Non-uniform scaling along the x, y, and z axes Parameters ---------- s : array-like, shape (3,) Scaling in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix describing ...
[ "def", "scale", "(", "s", ",", "dtype", "=", "None", ")", ":", "assert", "len", "(", "s", ")", "==", "3", "return", "np", ".", "array", "(", "np", ".", "diag", "(", "np", ".", "concatenate", "(", "[", "s", ",", "(", "1.", ",", ")", "]", ")"...
Non-uniform scaling along the x, y, and z axes Parameters ---------- s : array-like, shape (3,) Scaling in x, y, z. dtype : dtype | None Output type (if None, don't cast). Returns ------- M : ndarray Transformation matrix describing the scaling.
[ "Non", "-", "uniform", "scaling", "along", "the", "x", "y", "and", "z", "axes" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L39-L55
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/transforms.py
rotate
def rotate(angle, axis, dtype=None): """The 3x3 rotation matrix for rotation about a vector. Parameters ---------- angle : float The angle of rotation, in degrees. axis : ndarray The x, y, z coordinates of the axis direction vector. """ angle = np.radians(angle) assert l...
python
def rotate(angle, axis, dtype=None): """The 3x3 rotation matrix for rotation about a vector. Parameters ---------- angle : float The angle of rotation, in degrees. axis : ndarray The x, y, z coordinates of the axis direction vector. """ angle = np.radians(angle) assert l...
[ "def", "rotate", "(", "angle", ",", "axis", ",", "dtype", "=", "None", ")", ":", "angle", "=", "np", ".", "radians", "(", "angle", ")", "assert", "len", "(", "axis", ")", "==", "3", "x", ",", "y", ",", "z", "=", "axis", "/", "np", ".", "linal...
The 3x3 rotation matrix for rotation about a vector. Parameters ---------- angle : float The angle of rotation, in degrees. axis : ndarray The x, y, z coordinates of the axis direction vector.
[ "The", "3x3", "rotation", "matrix", "for", "rotation", "about", "a", "vector", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L58-L77
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/transforms.py
perspective
def perspective(fovy, aspect, znear, zfar): """Create perspective projection matrix Parameters ---------- fovy : float The field of view along the y axis. aspect : float Aspect ratio of the view. znear : float Near coordinate of the field of view. zfar : float ...
python
def perspective(fovy, aspect, znear, zfar): """Create perspective projection matrix Parameters ---------- fovy : float The field of view along the y axis. aspect : float Aspect ratio of the view. znear : float Near coordinate of the field of view. zfar : float ...
[ "def", "perspective", "(", "fovy", ",", "aspect", ",", "znear", ",", "zfar", ")", ":", "assert", "(", "znear", "!=", "zfar", ")", "h", "=", "math", ".", "tan", "(", "fovy", "/", "360.0", "*", "math", ".", "pi", ")", "*", "znear", "w", "=", "h",...
Create perspective projection matrix Parameters ---------- fovy : float The field of view along the y axis. aspect : float Aspect ratio of the view. znear : float Near coordinate of the field of view. zfar : float Far coordinate of the field of view. Returns...
[ "Create", "perspective", "projection", "matrix" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L156-L178
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/transforms.py
affine_map
def affine_map(points1, points2): """ Find a 3D transformation matrix that maps points1 onto points2. Arguments are specified as arrays of four 3D coordinates, shape (4, 3). """ A = np.ones((4, 4)) A[:, :3] = points1 B = np.ones((4, 4)) B[:, :3] = points2 # solve 3 sets of linear equat...
python
def affine_map(points1, points2): """ Find a 3D transformation matrix that maps points1 onto points2. Arguments are specified as arrays of four 3D coordinates, shape (4, 3). """ A = np.ones((4, 4)) A[:, :3] = points1 B = np.ones((4, 4)) B[:, :3] = points2 # solve 3 sets of linear equat...
[ "def", "affine_map", "(", "points1", ",", "points2", ")", ":", "A", "=", "np", ".", "ones", "(", "(", "4", ",", "4", ")", ")", "A", "[", ":", ",", ":", "3", "]", "=", "points1", "B", "=", "np", ".", "ones", "(", "(", "4", ",", "4", ")", ...
Find a 3D transformation matrix that maps points1 onto points2. Arguments are specified as arrays of four 3D coordinates, shape (4, 3).
[ "Find", "a", "3D", "transformation", "matrix", "that", "maps", "points1", "onto", "points2", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/transforms.py#L181-L198
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/profiler.py
Profiler.finish
def finish(self, msg=None): """Add a final message; flush the message list if no parent profiler. """ if self._finished or self.disable: return self._finished = True if msg is not None: self(msg) self._new_msg("< Exiting %s, total time: %0....
python
def finish(self, msg=None): """Add a final message; flush the message list if no parent profiler. """ if self._finished or self.disable: return self._finished = True if msg is not None: self(msg) self._new_msg("< Exiting %s, total time: %0....
[ "def", "finish", "(", "self", ",", "msg", "=", "None", ")", ":", "if", "self", ".", "_finished", "or", "self", ".", "disable", ":", "return", "self", ".", "_finished", "=", "True", "if", "msg", "is", "not", "None", ":", "self", "(", "msg", ")", "...
Add a final message; flush the message list if no parent profiler.
[ "Add", "a", "final", "message", ";", "flush", "the", "message", "list", "if", "no", "parent", "profiler", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/profiler.py#L121-L133
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_init
def _init(): """ Create global Config object, parse command flags """ global config, _data_path, _allowed_config_keys app_dir = _get_vispy_app_dir() if app_dir is not None: _data_path = op.join(app_dir, 'data') _test_data_path = op.join(app_dir, 'test_data') else: _data_...
python
def _init(): """ Create global Config object, parse command flags """ global config, _data_path, _allowed_config_keys app_dir = _get_vispy_app_dir() if app_dir is not None: _data_path = op.join(app_dir, 'data') _test_data_path = op.join(app_dir, 'test_data') else: _data_...
[ "def", "_init", "(", ")", ":", "global", "config", ",", "_data_path", ",", "_allowed_config_keys", "app_dir", "=", "_get_vispy_app_dir", "(", ")", "if", "app_dir", "is", "not", "None", ":", "_data_path", "=", "op", ".", "join", "(", "app_dir", ",", "'data'...
Create global Config object, parse command flags
[ "Create", "global", "Config", "object", "parse", "command", "flags" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L35-L88
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_parse_command_line_arguments
def _parse_command_line_arguments(): """ Transform vispy specific command line args to vispy config. Put into a function so that any variables dont leak in the vispy namespace. """ global config # Get command line args for vispy argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',...
python
def _parse_command_line_arguments(): """ Transform vispy specific command line args to vispy config. Put into a function so that any variables dont leak in the vispy namespace. """ global config # Get command line args for vispy argnames = ['vispy-backend=', 'vispy-gl-debug', 'vispy-glir-file=',...
[ "def", "_parse_command_line_arguments", "(", ")", ":", "global", "config", "# Get command line args for vispy", "argnames", "=", "[", "'vispy-backend='", ",", "'vispy-gl-debug'", ",", "'vispy-glir-file='", ",", "'vispy-log='", ",", "'vispy-help'", ",", "'vispy-profile='", ...
Transform vispy specific command line args to vispy config. Put into a function so that any variables dont leak in the vispy namespace.
[ "Transform", "vispy", "specific", "command", "line", "args", "to", "vispy", "config", ".", "Put", "into", "a", "function", "so", "that", "any", "variables", "dont", "leak", "in", "the", "vispy", "namespace", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L138-L180
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_get_vispy_app_dir
def _get_vispy_app_dir(): """Helper to get the default directory for storing vispy data""" # Define default user directory user_dir = os.path.expanduser('~') # Get system app data dir path = None if sys.platform.startswith('win'): path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP...
python
def _get_vispy_app_dir(): """Helper to get the default directory for storing vispy data""" # Define default user directory user_dir = os.path.expanduser('~') # Get system app data dir path = None if sys.platform.startswith('win'): path1, path2 = os.getenv('LOCALAPPDATA'), os.getenv('APP...
[ "def", "_get_vispy_app_dir", "(", ")", ":", "# Define default user directory", "user_dir", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "# Get system app data dir", "path", "=", "None", "if", "sys", ".", "platform", ".", "startswith", "(", "'win'"...
Helper to get the default directory for storing vispy data
[ "Helper", "to", "get", "the", "default", "directory", "for", "storing", "vispy", "data" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L188-L224
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_get_config_fname
def _get_config_fname(): """Helper for the vispy config file""" directory = _get_vispy_app_dir() if directory is None: return None fname = op.join(directory, 'vispy.json') if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None: fname = op.join(_TempDir(), 'vispy.json') retu...
python
def _get_config_fname(): """Helper for the vispy config file""" directory = _get_vispy_app_dir() if directory is None: return None fname = op.join(directory, 'vispy.json') if os.environ.get('_VISPY_CONFIG_TESTING', None) is not None: fname = op.join(_TempDir(), 'vispy.json') retu...
[ "def", "_get_config_fname", "(", ")", ":", "directory", "=", "_get_vispy_app_dir", "(", ")", "if", "directory", "is", "None", ":", "return", "None", "fname", "=", "op", ".", "join", "(", "directory", ",", "'vispy.json'", ")", "if", "os", ".", "environ", ...
Helper for the vispy config file
[ "Helper", "for", "the", "vispy", "config", "file" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L300-L308
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_load_config
def _load_config(): """Helper to load prefs from ~/.vispy/vispy.json""" fname = _get_config_fname() if fname is None or not op.isfile(fname): return dict() with open(fname, 'r') as fid: config = json.load(fid) return config
python
def _load_config(): """Helper to load prefs from ~/.vispy/vispy.json""" fname = _get_config_fname() if fname is None or not op.isfile(fname): return dict() with open(fname, 'r') as fid: config = json.load(fid) return config
[ "def", "_load_config", "(", ")", ":", "fname", "=", "_get_config_fname", "(", ")", "if", "fname", "is", "None", "or", "not", "op", ".", "isfile", "(", "fname", ")", ":", "return", "dict", "(", ")", "with", "open", "(", "fname", ",", "'r'", ")", "as...
Helper to load prefs from ~/.vispy/vispy.json
[ "Helper", "to", "load", "prefs", "from", "~", "/", ".", "vispy", "/", "vispy", ".", "json" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L311-L318
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
save_config
def save_config(**kwargs): """Save configuration keys to vispy config file Parameters ---------- **kwargs : keyword arguments Key/value pairs to save to the config file. """ if kwargs == {}: kwargs = config._config current_config = _load_config() current_config.update(**...
python
def save_config(**kwargs): """Save configuration keys to vispy config file Parameters ---------- **kwargs : keyword arguments Key/value pairs to save to the config file. """ if kwargs == {}: kwargs = config._config current_config = _load_config() current_config.update(**...
[ "def", "save_config", "(", "*", "*", "kwargs", ")", ":", "if", "kwargs", "==", "{", "}", ":", "kwargs", "=", "config", ".", "_config", "current_config", "=", "_load_config", "(", ")", "current_config", ".", "update", "(", "*", "*", "kwargs", ")", "# wr...
Save configuration keys to vispy config file Parameters ---------- **kwargs : keyword arguments Key/value pairs to save to the config file.
[ "Save", "configuration", "keys", "to", "vispy", "config", "file" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L321-L340
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
set_data_dir
def set_data_dir(directory=None, create=False, save=False): """Set vispy data download directory Parameters ---------- directory : str | None The directory to use. create : bool If True, create directory if it doesn't exist. save : bool If True, save the configuration to...
python
def set_data_dir(directory=None, create=False, save=False): """Set vispy data download directory Parameters ---------- directory : str | None The directory to use. create : bool If True, create directory if it doesn't exist. save : bool If True, save the configuration to...
[ "def", "set_data_dir", "(", "directory", "=", "None", ",", "create", "=", "False", ",", "save", "=", "False", ")", ":", "if", "directory", "is", "None", ":", "directory", "=", "_data_path", "if", "_data_path", "is", "None", ":", "raise", "IOError", "(", ...
Set vispy data download directory Parameters ---------- directory : str | None The directory to use. create : bool If True, create directory if it doesn't exist. save : bool If True, save the configuration to the vispy config.
[ "Set", "vispy", "data", "download", "directory" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L343-L367
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
_enable_profiling
def _enable_profiling(): """ Start profiling and register callback to print stats when the program exits. """ import cProfile import atexit global _profiler _profiler = cProfile.Profile() _profiler.enable() atexit.register(_profile_atexit)
python
def _enable_profiling(): """ Start profiling and register callback to print stats when the program exits. """ import cProfile import atexit global _profiler _profiler = cProfile.Profile() _profiler.enable() atexit.register(_profile_atexit)
[ "def", "_enable_profiling", "(", ")", ":", "import", "cProfile", "import", "atexit", "global", "_profiler", "_profiler", "=", "cProfile", ".", "Profile", "(", ")", "_profiler", ".", "enable", "(", ")", "atexit", ".", "register", "(", "_profile_atexit", ")" ]
Start profiling and register callback to print stats when the program exits.
[ "Start", "profiling", "and", "register", "callback", "to", "print", "stats", "when", "the", "program", "exits", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L370-L379
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/config.py
sys_info
def sys_info(fname=None, overwrite=False): """Get relevant system and debugging information Parameters ---------- fname : str | None Filename to dump info to. Use None to simply print. overwrite : bool If True, overwrite file (if it exists). Returns ------- out : str ...
python
def sys_info(fname=None, overwrite=False): """Get relevant system and debugging information Parameters ---------- fname : str | None Filename to dump info to. Use None to simply print. overwrite : bool If True, overwrite file (if it exists). Returns ------- out : str ...
[ "def", "sys_info", "(", "fname", "=", "None", ",", "overwrite", "=", "False", ")", ":", "if", "fname", "is", "not", "None", "and", "op", ".", "isfile", "(", "fname", ")", "and", "not", "overwrite", ":", "raise", "IOError", "(", "'file exists, use overwri...
Get relevant system and debugging information Parameters ---------- fname : str | None Filename to dump info to. Use None to simply print. overwrite : bool If True, overwrite file (if it exists). Returns ------- out : str The system information as a string.
[ "Get", "relevant", "system", "and", "debugging", "information" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/config.py#L390-L442
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/normals.py
compact
def compact(vertices, indices, tolerance=1e-3): """ Compact vertices and indices within given tolerance """ # Transform vertices into a structured array for np.unique to work n = len(vertices) V = np.zeros(n, dtype=[("pos", np.float32, 3)]) V["pos"][:, 0] = vertices[:, 0] V["pos"][:, 1] = verti...
python
def compact(vertices, indices, tolerance=1e-3): """ Compact vertices and indices within given tolerance """ # Transform vertices into a structured array for np.unique to work n = len(vertices) V = np.zeros(n, dtype=[("pos", np.float32, 3)]) V["pos"][:, 0] = vertices[:, 0] V["pos"][:, 1] = verti...
[ "def", "compact", "(", "vertices", ",", "indices", ",", "tolerance", "=", "1e-3", ")", ":", "# Transform vertices into a structured array for np.unique to work", "n", "=", "len", "(", "vertices", ")", "V", "=", "np", ".", "zeros", "(", "n", ",", "dtype", "=", ...
Compact vertices and indices within given tolerance
[ "Compact", "vertices", "and", "indices", "within", "given", "tolerance" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L10-L49
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/geometry/normals.py
normals
def normals(vertices, indices): """ Compute normals over a triangulated surface Parameters ---------- vertices : ndarray (n,3) triangles vertices indices : ndarray (p,3) triangles indices """ # Compact similar vertices vertices, indices, mapping = compact(vertices...
python
def normals(vertices, indices): """ Compute normals over a triangulated surface Parameters ---------- vertices : ndarray (n,3) triangles vertices indices : ndarray (p,3) triangles indices """ # Compact similar vertices vertices, indices, mapping = compact(vertices...
[ "def", "normals", "(", "vertices", ",", "indices", ")", ":", "# Compact similar vertices", "vertices", ",", "indices", ",", "mapping", "=", "compact", "(", "vertices", ",", "indices", ")", "T", "=", "vertices", "[", "indices", "]", "N", "=", "np", ".", "...
Compute normals over a triangulated surface Parameters ---------- vertices : ndarray (n,3) triangles vertices indices : ndarray (p,3) triangles indices
[ "Compute", "normals", "over", "a", "triangulated", "surface" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/normals.py#L52-L82
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.create_native
def create_native(self): """ Create the native widget if not already done so. If the widget is already created, this function does nothing. """ if self._backend is not None: return # Make sure that the app is active assert self._app.native # Instantiat...
python
def create_native(self): """ Create the native widget if not already done so. If the widget is already created, this function does nothing. """ if self._backend is not None: return # Make sure that the app is active assert self._app.native # Instantiat...
[ "def", "create_native", "(", "self", ")", ":", "if", "self", ".", "_backend", "is", "not", "None", ":", "return", "# Make sure that the app is active", "assert", "self", ".", "_app", ".", "native", "# Instantiate the backend with the right class", "self", ".", "_app...
Create the native widget if not already done so. If the widget is already created, this function does nothing.
[ "Create", "the", "native", "widget", "if", "not", "already", "done", "so", ".", "If", "the", "widget", "is", "already", "created", "this", "function", "does", "nothing", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L213-L231
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.connect
def connect(self, fun): """ Connect a function to an event The name of the function should be on_X, with X the name of the event (e.g. 'on_draw'). This method is typically used as a decorator on a function definition for an event handler. Parameters ---------- ...
python
def connect(self, fun): """ Connect a function to an event The name of the function should be on_X, with X the name of the event (e.g. 'on_draw'). This method is typically used as a decorator on a function definition for an event handler. Parameters ---------- ...
[ "def", "connect", "(", "self", ",", "fun", ")", ":", "# Get and check name", "name", "=", "fun", ".", "__name__", "if", "not", "name", ".", "startswith", "(", "'on_'", ")", ":", "raise", "ValueError", "(", "'When connecting a function based on its name, '", "'th...
Connect a function to an event The name of the function should be on_X, with X the name of the event (e.g. 'on_draw'). This method is typically used as a decorator on a function definition for an event handler. Parameters ---------- fun : callable T...
[ "Connect", "a", "function", "to", "an", "event" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L302-L330
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.size
def size(self): """ The size of canvas/window """ size = self._backend._vispy_get_size() return (size[0] // self._px_scale, size[1] // self._px_scale)
python
def size(self): """ The size of canvas/window """ size = self._backend._vispy_get_size() return (size[0] // self._px_scale, size[1] // self._px_scale)
[ "def", "size", "(", "self", ")", ":", "size", "=", "self", ".", "_backend", ".", "_vispy_get_size", "(", ")", "return", "(", "size", "[", "0", "]", "//", "self", ".", "_px_scale", ",", "size", "[", "1", "]", "//", "self", ".", "_px_scale", ")" ]
The size of canvas/window
[ "The", "size", "of", "canvas", "/", "window" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L334-L337
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.show
def show(self, visible=True, run=False): """Show or hide the canvas Parameters ---------- visible : bool Make the canvas visible. run : bool Run the backend event loop. """ self._backend._vispy_set_visible(visible) if run: ...
python
def show(self, visible=True, run=False): """Show or hide the canvas Parameters ---------- visible : bool Make the canvas visible. run : bool Run the backend event loop. """ self._backend._vispy_set_visible(visible) if run: ...
[ "def", "show", "(", "self", ",", "visible", "=", "True", ",", "run", "=", "False", ")", ":", "self", ".", "_backend", ".", "_vispy_set_visible", "(", "visible", ")", "if", "run", ":", "self", ".", "app", ".", "run", "(", ")" ]
Show or hide the canvas Parameters ---------- visible : bool Make the canvas visible. run : bool Run the backend event loop.
[ "Show", "or", "hide", "the", "canvas" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L419-L431
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.close
def close(self): """Close the canvas Notes ----- This will usually destroy the GL context. For Qt, the context (and widget) will be destroyed only if the widget is top-level. To avoid having the widget destroyed (more like standard Qt behavior), consider making t...
python
def close(self): """Close the canvas Notes ----- This will usually destroy the GL context. For Qt, the context (and widget) will be destroyed only if the widget is top-level. To avoid having the widget destroyed (more like standard Qt behavior), consider making t...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_backend", "is", "not", "None", "and", "not", "self", ".", "_closed", ":", "self", ".", "_closed", "=", "True", "self", ".", "events", ".", "close", "(", ")", "self", ".", "_backend", ".", ...
Close the canvas Notes ----- This will usually destroy the GL context. For Qt, the context (and widget) will be destroyed only if the widget is top-level. To avoid having the widget destroyed (more like standard Qt behavior), consider making the widget a sub-widget.
[ "Close", "the", "canvas" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L444-L458
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas._update_fps
def _update_fps(self, event): """Update the fps after every window""" self._frame_count += 1 diff = time() - self._basetime if (diff > self._fps_window): self._fps = self._frame_count / diff self._basetime = time() self._frame_count = 0 sel...
python
def _update_fps(self, event): """Update the fps after every window""" self._frame_count += 1 diff = time() - self._basetime if (diff > self._fps_window): self._fps = self._frame_count / diff self._basetime = time() self._frame_count = 0 sel...
[ "def", "_update_fps", "(", "self", ",", "event", ")", ":", "self", ".", "_frame_count", "+=", "1", "diff", "=", "time", "(", ")", "-", "self", ".", "_basetime", "if", "(", "diff", ">", "self", ".", "_fps_window", ")", ":", "self", ".", "_fps", "=",...
Update the fps after every window
[ "Update", "the", "fps", "after", "every", "window" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L460-L468
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.measure_fps
def measure_fps(self, window=1, callback='%1.1f FPS'): """Measure the current FPS Sets the update window, connects the draw event to update_fps and sets the callback function. Parameters ---------- window : float The time-window (in seconds) to calculate FPS...
python
def measure_fps(self, window=1, callback='%1.1f FPS'): """Measure the current FPS Sets the update window, connects the draw event to update_fps and sets the callback function. Parameters ---------- window : float The time-window (in seconds) to calculate FPS...
[ "def", "measure_fps", "(", "self", ",", "window", "=", "1", ",", "callback", "=", "'%1.1f FPS'", ")", ":", "# Connect update_fps function to draw", "self", ".", "events", ".", "draw", ".", "disconnect", "(", "self", ".", "_update_fps", ")", "if", "callback", ...
Measure the current FPS Sets the update window, connects the draw event to update_fps and sets the callback function. Parameters ---------- window : float The time-window (in seconds) to calculate FPS. Default 1.0. callback : function | str The f...
[ "Measure", "the", "current", "FPS" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L470-L499
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
Canvas.render
def render(self): """ Render the canvas to an offscreen buffer and return the image array. Returns ------- image : array Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the upper-left corner of the rendered region. """ ...
python
def render(self): """ Render the canvas to an offscreen buffer and return the image array. Returns ------- image : array Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the upper-left corner of the rendered region. """ ...
[ "def", "render", "(", "self", ")", ":", "self", ".", "set_current", "(", ")", "size", "=", "self", ".", "physical_size", "fbo", "=", "FrameBuffer", "(", "color", "=", "RenderBuffer", "(", "size", "[", ":", ":", "-", "1", "]", ")", ",", "depth", "="...
Render the canvas to an offscreen buffer and return the image array. Returns ------- image : array Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the upper-left corner of the rendered region.
[ "Render", "the", "canvas", "to", "an", "offscreen", "buffer", "and", "return", "the", "image", "array", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L520-L541
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
MouseEvent.drag_events
def drag_events(self): """ Return a list of all mouse events in the current drag operation. Returns None if there is no current drag operation. """ if not self.is_dragging: return None event = self events = [] while True: # mouse_press ev...
python
def drag_events(self): """ Return a list of all mouse events in the current drag operation. Returns None if there is no current drag operation. """ if not self.is_dragging: return None event = self events = [] while True: # mouse_press ev...
[ "def", "drag_events", "(", "self", ")", ":", "if", "not", "self", ".", "is_dragging", ":", "return", "None", "event", "=", "self", "events", "=", "[", "]", "while", "True", ":", "# mouse_press events can only be the start of a trail", "if", "event", "is", "Non...
Return a list of all mouse events in the current drag operation. Returns None if there is no current drag operation.
[ "Return", "a", "list", "of", "all", "mouse", "events", "in", "the", "current", "drag", "operation", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L639-L656
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/canvas.py
MouseEvent.trail
def trail(self): """ Return an (N, 2) array of mouse coordinates for every event in the current mouse drag operation. Returns None if there is no current drag operation. """ events = self.drag_events() if events is None: return None trail = np.empty(...
python
def trail(self): """ Return an (N, 2) array of mouse coordinates for every event in the current mouse drag operation. Returns None if there is no current drag operation. """ events = self.drag_events() if events is None: return None trail = np.empty(...
[ "def", "trail", "(", "self", ")", ":", "events", "=", "self", ".", "drag_events", "(", ")", "if", "events", "is", "None", ":", "return", "None", "trail", "=", "np", ".", "empty", "(", "(", "len", "(", "events", ")", ",", "2", ")", ",", "dtype", ...
Return an (N, 2) array of mouse coordinates for every event in the current mouse drag operation. Returns None if there is no current drag operation.
[ "Return", "an", "(", "N", "2", ")", "array", "of", "mouse", "coordinates", "for", "every", "event", "in", "the", "current", "mouse", "drag", "operation", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L658-L672
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.width_min
def width_min(self, width_min): """Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget """ if width_min is None: self._width_limits[0] = 0 return width_min = float(wi...
python
def width_min(self, width_min): """Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget """ if width_min is None: self._width_limits[0] = 0 return width_min = float(wi...
[ "def", "width_min", "(", "self", ",", "width_min", ")", ":", "if", "width_min", "is", "None", ":", "self", ".", "_width_limits", "[", "0", "]", "=", "0", "return", "width_min", "=", "float", "(", "width_min", ")", "assert", "(", "0", "<=", "width_min",...
Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget
[ "Set", "the", "minimum", "height", "of", "the", "widget" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L133-L151
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.width_max
def width_max(self, width_max): """Set the maximum width of the widget. Parameters ---------- width_max: None | float the maximum width of the widget. if None, maximum width is unbounded """ if width_max is None: self._width_limits[1] ...
python
def width_max(self, width_max): """Set the maximum width of the widget. Parameters ---------- width_max: None | float the maximum width of the widget. if None, maximum width is unbounded """ if width_max is None: self._width_limits[1] ...
[ "def", "width_max", "(", "self", ",", "width_max", ")", ":", "if", "width_max", "is", "None", ":", "self", ".", "_width_limits", "[", "1", "]", "=", "None", "return", "width_max", "=", "float", "(", "width_max", ")", "assert", "(", "self", ".", "width_...
Set the maximum width of the widget. Parameters ---------- width_max: None | float the maximum width of the widget. if None, maximum width is unbounded
[ "Set", "the", "maximum", "width", "of", "the", "widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L159-L176
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.height_min
def height_min(self, height_min): """Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget """ if height_min is None: self._height_limits[0] = 0 return height_min = floa...
python
def height_min(self, height_min): """Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget """ if height_min is None: self._height_limits[0] = 0 return height_min = floa...
[ "def", "height_min", "(", "self", ",", "height_min", ")", ":", "if", "height_min", "is", "None", ":", "self", ".", "_height_limits", "[", "0", "]", "=", "0", "return", "height_min", "=", "float", "(", "height_min", ")", "assert", "(", "height_min", ">=",...
Set the minimum height of the widget Parameters ---------- height_min: float the minimum height of the widget
[ "Set", "the", "minimum", "height", "of", "the", "widget" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L189-L206
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.height_max
def height_max(self, height_max): """Set the maximum height of the widget. Parameters ---------- height_max: None | float the maximum height of the widget. if None, maximum height is unbounded """ if height_max is None: self._height_li...
python
def height_max(self, height_max): """Set the maximum height of the widget. Parameters ---------- height_max: None | float the maximum height of the widget. if None, maximum height is unbounded """ if height_max is None: self._height_li...
[ "def", "height_max", "(", "self", ",", "height_max", ")", ":", "if", "height_max", "is", "None", ":", "self", ".", "_height_limits", "[", "1", "]", "=", "None", "return", "height_max", "=", "float", "(", "height_max", ")", "assert", "(", "0", "<=", "se...
Set the maximum height of the widget. Parameters ---------- height_max: None | float the maximum height of the widget. if None, maximum height is unbounded
[ "Set", "the", "maximum", "height", "of", "the", "widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L214-L230
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.inner_rect
def inner_rect(self): """The rectangular area inside the margin, border, and padding. Generally widgets should avoid drawing or placing sub-widgets outside this rectangle. """ m = self.margin + self._border_width + self.padding if not self.border_color.is_blank: ...
python
def inner_rect(self): """The rectangular area inside the margin, border, and padding. Generally widgets should avoid drawing or placing sub-widgets outside this rectangle. """ m = self.margin + self._border_width + self.padding if not self.border_color.is_blank: ...
[ "def", "inner_rect", "(", "self", ")", ":", "m", "=", "self", ".", "margin", "+", "self", ".", "_border_width", "+", "self", ".", "padding", "if", "not", "self", ".", "border_color", ".", "is_blank", ":", "m", "+=", "1", "return", "Rect", "(", "(", ...
The rectangular area inside the margin, border, and padding. Generally widgets should avoid drawing or placing sub-widgets outside this rectangle.
[ "The", "rectangular", "area", "inside", "the", "margin", "border", "and", "padding", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L245-L254
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget._update_clipper
def _update_clipper(self): """Called whenever the clipper for this widget may need to be updated. """ if self.clip_children and self._clipper is None: self._clipper = Clipper() elif not self.clip_children: self._clipper = None if self._clipper is None: ...
python
def _update_clipper(self): """Called whenever the clipper for this widget may need to be updated. """ if self.clip_children and self._clipper is None: self._clipper = Clipper() elif not self.clip_children: self._clipper = None if self._clipper is None: ...
[ "def", "_update_clipper", "(", "self", ")", ":", "if", "self", ".", "clip_children", "and", "self", ".", "_clipper", "is", "None", ":", "self", ".", "_clipper", "=", "Clipper", "(", ")", "elif", "not", "self", ".", "clip_children", ":", "self", ".", "_...
Called whenever the clipper for this widget may need to be updated.
[ "Called", "whenever", "the", "clipper", "for", "this", "widget", "may", "need", "to", "be", "updated", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L283-L294
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget._update_line
def _update_line(self): """ Update border line to match new shape """ w = self._border_width m = self.margin # border is drawn within the boundaries of the widget: # # size = (8, 7) margin=2 # internal rect = (3, 3, 2, 1) # ........ # ...........
python
def _update_line(self): """ Update border line to match new shape """ w = self._border_width m = self.margin # border is drawn within the boundaries of the widget: # # size = (8, 7) margin=2 # internal rect = (3, 3, 2, 1) # ........ # ...........
[ "def", "_update_line", "(", "self", ")", ":", "w", "=", "self", ".", "_border_width", "m", "=", "self", ".", "margin", "# border is drawn within the boundaries of the widget:", "#", "# size = (8, 7) margin=2", "# internal rect = (3, 3, 2, 1)", "# ........", "# ...........
Update border line to match new shape
[ "Update", "border", "line", "to", "match", "new", "shape" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L344-L390
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.add_widget
def add_widget(self, widget): """ Add a Widget as a managed child of this Widget. The child will be automatically positioned and sized to fill the entire space inside this Widget (unless _update_child_widgets is redefined). Parameters ---------- widget :...
python
def add_widget(self, widget): """ Add a Widget as a managed child of this Widget. The child will be automatically positioned and sized to fill the entire space inside this Widget (unless _update_child_widgets is redefined). Parameters ---------- widget :...
[ "def", "add_widget", "(", "self", ",", "widget", ")", ":", "self", ".", "_widgets", ".", "append", "(", "widget", ")", "widget", ".", "parent", "=", "self", "self", ".", "_update_child_widgets", "(", ")", "return", "widget" ]
Add a Widget as a managed child of this Widget. The child will be automatically positioned and sized to fill the entire space inside this Widget (unless _update_child_widgets is redefined). Parameters ---------- widget : instance of Widget The widget to add....
[ "Add", "a", "Widget", "as", "a", "managed", "child", "of", "this", "Widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L419-L440
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.add_grid
def add_grid(self, *args, **kwargs): """ Create a new Grid and add it as a child widget. All arguments are given to Grid(). """ from .grid import Grid grid = Grid(*args, **kwargs) return self.add_widget(grid)
python
def add_grid(self, *args, **kwargs): """ Create a new Grid and add it as a child widget. All arguments are given to Grid(). """ from .grid import Grid grid = Grid(*args, **kwargs) return self.add_widget(grid)
[ "def", "add_grid", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", "grid", "import", "Grid", "grid", "=", "Grid", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "add_widget", "(", "grid", ")"...
Create a new Grid and add it as a child widget. All arguments are given to Grid().
[ "Create", "a", "new", "Grid", "and", "add", "it", "as", "a", "child", "widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L442-L450
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.add_view
def add_view(self, *args, **kwargs): """ Create a new ViewBox and add it as a child widget. All arguments are given to ViewBox(). """ from .viewbox import ViewBox view = ViewBox(*args, **kwargs) return self.add_widget(view)
python
def add_view(self, *args, **kwargs): """ Create a new ViewBox and add it as a child widget. All arguments are given to ViewBox(). """ from .viewbox import ViewBox view = ViewBox(*args, **kwargs) return self.add_widget(view)
[ "def", "add_view", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", "viewbox", "import", "ViewBox", "view", "=", "ViewBox", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "add_widget", "(", "vie...
Create a new ViewBox and add it as a child widget. All arguments are given to ViewBox().
[ "Create", "a", "new", "ViewBox", "and", "add", "it", "as", "a", "child", "widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L452-L460
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/widget.py
Widget.remove_widget
def remove_widget(self, widget): """ Remove a Widget as a managed child of this Widget. Parameters ---------- widget : instance of Widget The widget to remove. """ self._widgets.remove(widget) widget.parent = None self._update_child_wi...
python
def remove_widget(self, widget): """ Remove a Widget as a managed child of this Widget. Parameters ---------- widget : instance of Widget The widget to remove. """ self._widgets.remove(widget) widget.parent = None self._update_child_wi...
[ "def", "remove_widget", "(", "self", ",", "widget", ")", ":", "self", ".", "_widgets", ".", "remove", "(", "widget", ")", "widget", ".", "parent", "=", "None", "self", ".", "_update_child_widgets", "(", ")" ]
Remove a Widget as a managed child of this Widget. Parameters ---------- widget : instance of Widget The widget to remove.
[ "Remove", "a", "Widget", "as", "a", "managed", "child", "of", "this", "Widget", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/widget.py#L462-L473
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/io/datasets.py
pack_unit
def pack_unit(value): """Packs float values between [0,1] into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel """ pack = np.zeros(value.shape + (4,), dtype=np.ubyte) for i in range(4): value, pack[..., i] = np.modf(value * 256.) return pack
python
def pack_unit(value): """Packs float values between [0,1] into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel """ pack = np.zeros(value.shape + (4,), dtype=np.ubyte) for i in range(4): value, pack[..., i] = np.modf(value * 256.) return pack
[ "def", "pack_unit", "(", "value", ")", ":", "pack", "=", "np", ".", "zeros", "(", "value", ".", "shape", "+", "(", "4", ",", ")", ",", "dtype", "=", "np", ".", "ubyte", ")", "for", "i", "in", "range", "(", "4", ")", ":", "value", ",", "pack",...
Packs float values between [0,1] into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel
[ "Packs", "float", "values", "between", "[", "0", "1", "]", "into", "4", "unsigned", "int8" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L38-L49
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/io/datasets.py
pack_ieee
def pack_ieee(value): """Packs float ieee binary representation into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel """ return np.fromstring(value.tostring(), np.ubyte).reshape((value.shape + (4,)))
python
def pack_ieee(value): """Packs float ieee binary representation into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel """ return np.fromstring(value.tostring(), np.ubyte).reshape((value.shape + (4,)))
[ "def", "pack_ieee", "(", "value", ")", ":", "return", "np", ".", "fromstring", "(", "value", ".", "tostring", "(", ")", ",", "np", ".", "ubyte", ")", ".", "reshape", "(", "(", "value", ".", "shape", "+", "(", "4", ",", ")", ")", ")" ]
Packs float ieee binary representation into 4 unsigned int8 Returns ------- pack: array packed interpolation kernel
[ "Packs", "float", "ieee", "binary", "representation", "into", "4", "unsigned", "int8" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L52-L61
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/io/datasets.py
load_spatial_filters
def load_spatial_filters(packed=True): """Load spatial-filters kernel Parameters ---------- packed : bool Whether or not the data should be in "packed" representation for use in GLSL code. Returns ------- kernel : array 16x1024x4 (packed float in rgba) or 16...
python
def load_spatial_filters(packed=True): """Load spatial-filters kernel Parameters ---------- packed : bool Whether or not the data should be in "packed" representation for use in GLSL code. Returns ------- kernel : array 16x1024x4 (packed float in rgba) or 16...
[ "def", "load_spatial_filters", "(", "packed", "=", "True", ")", ":", "names", "=", "(", "\"Bilinear\"", ",", "\"Hanning\"", ",", "\"Hamming\"", ",", "\"Hermite\"", ",", "\"Kaiser\"", ",", "\"Quadric\"", ",", "\"Bicubic\"", ",", "\"CatRom\"", ",", "\"Mitchell\"",...
Load spatial-filters kernel Parameters ---------- packed : bool Whether or not the data should be in "packed" representation for use in GLSL code. Returns ------- kernel : array 16x1024x4 (packed float in rgba) or 16x1024 (unpacked float) 16 interpolatio...
[ "Load", "spatial", "-", "filters", "kernel" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L64-L94
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/fonts/_triage.py
list_fonts
def list_fonts(): """List system fonts Returns ------- fonts : list of str List of system fonts. """ vals = _list_fonts() for font in _vispy_fonts: vals += [font] if font not in vals else [] vals = sorted(vals, key=lambda s: s.lower()) return vals
python
def list_fonts(): """List system fonts Returns ------- fonts : list of str List of system fonts. """ vals = _list_fonts() for font in _vispy_fonts: vals += [font] if font not in vals else [] vals = sorted(vals, key=lambda s: s.lower()) return vals
[ "def", "list_fonts", "(", ")", ":", "vals", "=", "_list_fonts", "(", ")", "for", "font", "in", "_vispy_fonts", ":", "vals", "+=", "[", "font", "]", "if", "font", "not", "in", "vals", "else", "[", "]", "vals", "=", "sorted", "(", "vals", ",", "key",...
List system fonts Returns ------- fonts : list of str List of system fonts.
[ "List", "system", "fonts" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fonts/_triage.py#L24-L36
brouberol/contexttimer
contexttimer/timeout.py
timeout
def timeout(limit, handler): """A decorator ensuring that the decorated function tun time does not exceeds the argument limit. :args limit: the time limit :type limit: int :args handler: the handler function called when the decorated function times out. :type handler: callable Example...
python
def timeout(limit, handler): """A decorator ensuring that the decorated function tun time does not exceeds the argument limit. :args limit: the time limit :type limit: int :args handler: the handler function called when the decorated function times out. :type handler: callable Example...
[ "def", "timeout", "(", "limit", ",", "handler", ")", ":", "def", "wrapper", "(", "f", ")", ":", "def", "wrapped_f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "old_handler", "=", "signal", ".", "getsignal", "(", "signal", ".", "SIGALRM", ...
A decorator ensuring that the decorated function tun time does not exceeds the argument limit. :args limit: the time limit :type limit: int :args handler: the handler function called when the decorated function times out. :type handler: callable Example: >>>def timeout_handler(limit, ...
[ "A", "decorator", "ensuring", "that", "the", "decorated", "function", "tun", "time", "does", "not", "exceeds", "the", "argument", "limit", "." ]
train
https://github.com/brouberol/contexttimer/blob/a866f420ed4c10f29abf252c58b11f9db6706100/contexttimer/timeout.py#L39-L80
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/base.py
BaseCanvasBackend._process_backend_kwargs
def _process_backend_kwargs(self, kwargs): """ Simple utility to retrieve kwargs in predetermined order. Also checks whether the values of the backend arguments do not violate the backend capabilities. """ # Verify given argument with capability of the backend app = self....
python
def _process_backend_kwargs(self, kwargs): """ Simple utility to retrieve kwargs in predetermined order. Also checks whether the values of the backend arguments do not violate the backend capabilities. """ # Verify given argument with capability of the backend app = self....
[ "def", "_process_backend_kwargs", "(", "self", ",", "kwargs", ")", ":", "# Verify given argument with capability of the backend", "app", "=", "self", ".", "_vispy_canvas", ".", "app", "capability", "=", "app", ".", "backend_module", ".", "capability", "if", "kwargs", ...
Simple utility to retrieve kwargs in predetermined order. Also checks whether the values of the backend arguments do not violate the backend capabilities.
[ "Simple", "utility", "to", "retrieve", "kwargs", "in", "predetermined", "order", ".", "Also", "checks", "whether", "the", "values", "of", "the", "backend", "arguments", "do", "not", "violate", "the", "backend", "capabilities", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/base.py#L80-L106
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/fly.py
FlyCamera._set_range
def _set_range(self, init): """ Reset the view. """ #PerspectiveCamera._set_range(self, init) # Stop moving self._speed *= 0.0 # Get window size (and store factor now to sync with resizing) w, h = self._viewbox.size w, h = float(w), float(h) # ...
python
def _set_range(self, init): """ Reset the view. """ #PerspectiveCamera._set_range(self, init) # Stop moving self._speed *= 0.0 # Get window size (and store factor now to sync with resizing) w, h = self._viewbox.size w, h = float(w), float(h) # ...
[ "def", "_set_range", "(", "self", ",", "init", ")", ":", "#PerspectiveCamera._set_range(self, init)", "# Stop moving", "self", ".", "_speed", "*=", "0.0", "# Get window size (and store factor now to sync with resizing)", "w", ",", "h", "=", "self", ".", "_viewbox", ".",...
Reset the view.
[ "Reset", "the", "view", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L146-L200
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/fly.py
FlyCamera.on_timer
def on_timer(self, event): """Timer event handler Parameters ---------- event : instance of Event The event. """ # Set relative speed and acceleration rel_speed = event.dt rel_acc = 0.1 # Get what's forward pf, pr, pl, pu = s...
python
def on_timer(self, event): """Timer event handler Parameters ---------- event : instance of Event The event. """ # Set relative speed and acceleration rel_speed = event.dt rel_acc = 0.1 # Get what's forward pf, pr, pl, pu = s...
[ "def", "on_timer", "(", "self", ",", "event", ")", ":", "# Set relative speed and acceleration", "rel_speed", "=", "event", ".", "dt", "rel_acc", "=", "0.1", "# Get what's forward", "pf", ",", "pr", ",", "pl", ",", "pu", "=", "self", ".", "_get_directions", ...
Timer event handler Parameters ---------- event : instance of Event The event.
[ "Timer", "event", "handler" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L231-L324
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/fly.py
FlyCamera.viewbox_key_event
def viewbox_key_event(self, event): """ViewBox key event handler Parameters ---------- event : instance of Event The event. """ PerspectiveCamera.viewbox_key_event(self, event) if event.handled or not self.interactive: return # E...
python
def viewbox_key_event(self, event): """ViewBox key event handler Parameters ---------- event : instance of Event The event. """ PerspectiveCamera.viewbox_key_event(self, event) if event.handled or not self.interactive: return # E...
[ "def", "viewbox_key_event", "(", "self", ",", "event", ")", ":", "PerspectiveCamera", ".", "viewbox_key_event", "(", "self", ",", "event", ")", "if", "event", ".", "handled", "or", "not", "self", ".", "interactive", ":", "return", "# Ensure the timer runs", "i...
ViewBox key event handler Parameters ---------- event : instance of Event The event.
[ "ViewBox", "key", "event", "handler" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L326-L357
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/fly.py
FlyCamera.viewbox_mouse_event
def viewbox_mouse_event(self, event): """ViewBox mouse event handler Parameters ---------- event : instance of Event The event. """ PerspectiveCamera.viewbox_mouse_event(self, event) if event.handled or not self.interactive: return ...
python
def viewbox_mouse_event(self, event): """ViewBox mouse event handler Parameters ---------- event : instance of Event The event. """ PerspectiveCamera.viewbox_mouse_event(self, event) if event.handled or not self.interactive: return ...
[ "def", "viewbox_mouse_event", "(", "self", ",", "event", ")", ":", "PerspectiveCamera", ".", "viewbox_mouse_event", "(", "self", ",", "event", ")", "if", "event", ".", "handled", "or", "not", "self", ".", "interactive", ":", "return", "if", "event", ".", "...
ViewBox mouse event handler Parameters ---------- event : instance of Event The event.
[ "ViewBox", "mouse", "event", "handler" ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/fly.py#L359-L439
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
_stdin_ready_posix
def _stdin_ready_posix(): """Return True if there's something to read on stdin (posix version).""" infds, outfds, erfds = select.select([sys.stdin],[],[],0) return bool(infds)
python
def _stdin_ready_posix(): """Return True if there's something to read on stdin (posix version).""" infds, outfds, erfds = select.select([sys.stdin],[],[],0) return bool(infds)
[ "def", "_stdin_ready_posix", "(", ")", ":", "infds", ",", "outfds", ",", "erfds", "=", "select", ".", "select", "(", "[", "sys", ".", "stdin", "]", ",", "[", "]", ",", "[", "]", ",", "0", ")", "return", "bool", "(", "infds", ")" ]
Return True if there's something to read on stdin (posix version).
[ "Return", "True", "if", "there", "s", "something", "to", "read", "on", "stdin", "(", "posix", "version", ")", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L55-L58
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
InputHookManager.set_inputhook
def set_inputhook(self, callback): """Set PyOS_InputHook to callback and return the previous one.""" # On platforms with 'readline' support, it's all too likely to # have a KeyboardInterrupt signal delivered *even before* an # initial ``try:`` clause in the callback can be executed, so ...
python
def set_inputhook(self, callback): """Set PyOS_InputHook to callback and return the previous one.""" # On platforms with 'readline' support, it's all too likely to # have a KeyboardInterrupt signal delivered *even before* an # initial ``try:`` clause in the callback can be executed, so ...
[ "def", "set_inputhook", "(", "self", ",", "callback", ")", ":", "# On platforms with 'readline' support, it's all too likely to", "# have a KeyboardInterrupt signal delivered *even before* an", "# initial ``try:`` clause in the callback can be executed, so", "# we need to disable CTRL+C in thi...
Set PyOS_InputHook to callback and return the previous one.
[ "Set", "PyOS_InputHook", "to", "callback", "and", "return", "the", "previous", "one", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L138-L152
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
InputHookManager.clear_inputhook
def clear_inputhook(self, app=None): """Set PyOS_InputHook to NULL and return the previous one. Parameters ---------- app : optional, ignored This parameter is allowed only so that clear_inputhook() can be called with a similar interface as all the ``enable_*`` metho...
python
def clear_inputhook(self, app=None): """Set PyOS_InputHook to NULL and return the previous one. Parameters ---------- app : optional, ignored This parameter is allowed only so that clear_inputhook() can be called with a similar interface as all the ``enable_*`` metho...
[ "def", "clear_inputhook", "(", "self", ",", "app", "=", "None", ")", ":", "pyos_inputhook_ptr", "=", "self", ".", "get_pyos_inputhook", "(", ")", "original", "=", "self", ".", "get_pyos_inputhook_as_func", "(", ")", "pyos_inputhook_ptr", ".", "value", "=", "ct...
Set PyOS_InputHook to NULL and return the previous one. Parameters ---------- app : optional, ignored This parameter is allowed only so that clear_inputhook() can be called with a similar interface as all the ``enable_*`` methods. But the actual value of the param...
[ "Set", "PyOS_InputHook", "to", "NULL", "and", "return", "the", "previous", "one", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L154-L170
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
InputHookManager.clear_app_refs
def clear_app_refs(self, gui=None): """Clear IPython's internal reference to an application instance. Whenever we create an app for a user on qt4 or wx, we hold a reference to the app. This is needed because in some cases bad things can happen if a user doesn't hold a reference themsel...
python
def clear_app_refs(self, gui=None): """Clear IPython's internal reference to an application instance. Whenever we create an app for a user on qt4 or wx, we hold a reference to the app. This is needed because in some cases bad things can happen if a user doesn't hold a reference themsel...
[ "def", "clear_app_refs", "(", "self", ",", "gui", "=", "None", ")", ":", "if", "gui", "is", "None", ":", "self", ".", "apps", "=", "{", "}", "elif", "gui", "in", "self", ".", "apps", ":", "del", "self", ".", "apps", "[", "gui", "]" ]
Clear IPython's internal reference to an application instance. Whenever we create an app for a user on qt4 or wx, we hold a reference to the app. This is needed because in some cases bad things can happen if a user doesn't hold a reference themselves. This method is provided to clear ...
[ "Clear", "IPython", "s", "internal", "reference", "to", "an", "application", "instance", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L172-L190
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
InputHookManager.register
def register(self, toolkitname, *aliases): """Register a class to provide the event loop for a given GUI. This is intended to be used as a class decorator. It should be passed the names with which to register this GUI integration. The classes themselves should subclass :class:`I...
python
def register(self, toolkitname, *aliases): """Register a class to provide the event loop for a given GUI. This is intended to be used as a class decorator. It should be passed the names with which to register this GUI integration. The classes themselves should subclass :class:`I...
[ "def", "register", "(", "self", ",", "toolkitname", ",", "*", "aliases", ")", ":", "def", "decorator", "(", "cls", ")", ":", "inst", "=", "cls", "(", "self", ")", "self", ".", "guihooks", "[", "toolkitname", "]", "=", "inst", "for", "a", "in", "ali...
Register a class to provide the event loop for a given GUI. This is intended to be used as a class decorator. It should be passed the names with which to register this GUI integration. The classes themselves should subclass :class:`InputHookBase`. :: ...
[ "Register", "a", "class", "to", "provide", "the", "event", "loop", "for", "a", "given", "GUI", ".", "This", "is", "intended", "to", "be", "used", "as", "a", "class", "decorator", ".", "It", "should", "be", "passed", "the", "names", "with", "which", "to...
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L192-L212
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py
InputHookManager.enable_gui
def enable_gui(self, gui=None, app=None): """Switch amongst GUI input hooks by name. This is a higher level method than :meth:`set_inputhook` - it uses the GUI name to look up a registered object which enables the input hook for that GUI. Parameters ---------- g...
python
def enable_gui(self, gui=None, app=None): """Switch amongst GUI input hooks by name. This is a higher level method than :meth:`set_inputhook` - it uses the GUI name to look up a registered object which enables the input hook for that GUI. Parameters ---------- g...
[ "def", "enable_gui", "(", "self", ",", "gui", "=", "None", ",", "app", "=", "None", ")", ":", "if", "gui", "in", "(", "None", ",", "GUI_NONE", ")", ":", "return", "self", ".", "disable_gui", "(", ")", "if", "gui", "in", "self", ".", "aliases", ":...
Switch amongst GUI input hooks by name. This is a higher level method than :meth:`set_inputhook` - it uses the GUI name to look up a registered object which enables the input hook for that GUI. Parameters ---------- gui : optional, string or None If None (or '...
[ "Switch", "amongst", "GUI", "input", "hooks", "by", "name", "." ]
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/ipy_inputhook.py#L218-L260