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
Metatab/metapack
metapack/cli/doc.py
yield_deps
def yield_deps(doc): """ TODO: This implementation is very specific to a particular environment and project, and should be generalized. :param doc: :return: """ this_node = DependencyNode(doc, None) for r in doc.references(): other_node = DependencyNode(r, this_node) yiel...
python
def yield_deps(doc): """ TODO: This implementation is very specific to a particular environment and project, and should be generalized. :param doc: :return: """ this_node = DependencyNode(doc, None) for r in doc.references(): other_node = DependencyNode(r, this_node) yiel...
[ "def", "yield_deps", "(", "doc", ")", ":", "this_node", "=", "DependencyNode", "(", "doc", ",", "None", ")", "for", "r", "in", "doc", ".", "references", "(", ")", ":", "other_node", "=", "DependencyNode", "(", "r", ",", "this_node", ")", "yield", "(", ...
TODO: This implementation is very specific to a particular environment and project, and should be generalized. :param doc: :return:
[ "TODO", ":", "This", "implementation", "is", "very", "specific", "to", "a", "particular", "environment", "and", "project", "and", "should", "be", "generalized", ".", ":", "param", "doc", ":", ":", "return", ":" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/doc.py#L246-L262
Metatab/metapack
metapack/cli/doc.py
wrap_url
def wrap_url(s, l): """Wrap a URL string""" parts = s.split('/') if len(parts) == 1: return parts[0] else: i = 0 lines = [] for j in range(i, len(parts) + 1): tv = '/'.join(parts[i:j]) nv = '/'.join(parts[i:j + 1]) if len(nv) > l or n...
python
def wrap_url(s, l): """Wrap a URL string""" parts = s.split('/') if len(parts) == 1: return parts[0] else: i = 0 lines = [] for j in range(i, len(parts) + 1): tv = '/'.join(parts[i:j]) nv = '/'.join(parts[i:j + 1]) if len(nv) > l or n...
[ "def", "wrap_url", "(", "s", ",", "l", ")", ":", "parts", "=", "s", ".", "split", "(", "'/'", ")", "if", "len", "(", "parts", ")", "==", "1", ":", "return", "parts", "[", "0", "]", "else", ":", "i", "=", "0", "lines", "=", "[", "]", "for", ...
Wrap a URL string
[ "Wrap", "a", "URL", "string" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/doc.py#L291-L308
Parsely/probably
probably/hll.py
HyperLogLog._get_rho
def _get_rho(self, w, arr): """ Return the least signifiant bit O(N) in the worst case """ lsb = 0 while not (w & arr[lsb]): lsb += 1 return lsb + 1
python
def _get_rho(self, w, arr): """ Return the least signifiant bit O(N) in the worst case """ lsb = 0 while not (w & arr[lsb]): lsb += 1 return lsb + 1
[ "def", "_get_rho", "(", "self", ",", "w", ",", "arr", ")", ":", "lsb", "=", "0", "while", "not", "(", "w", "&", "arr", "[", "lsb", "]", ")", ":", "lsb", "+=", "1", "return", "lsb", "+", "1" ]
Return the least signifiant bit O(N) in the worst case
[ "Return", "the", "least", "signifiant", "bit", "O", "(", "N", ")", "in", "the", "worst", "case" ]
train
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hll.py#L38-L45
Parsely/probably
probably/hll.py
HyperLogLog.add
def add(self, uuid): """ Adds a key to the HyperLogLog """ if uuid: # Computing the hash try: x = hash64(uuid) except UnicodeEncodeError: x = hash64(uuid.encode('ascii', 'ignore')) # Finding the register to update by using t...
python
def add(self, uuid): """ Adds a key to the HyperLogLog """ if uuid: # Computing the hash try: x = hash64(uuid) except UnicodeEncodeError: x = hash64(uuid.encode('ascii', 'ignore')) # Finding the register to update by using t...
[ "def", "add", "(", "self", ",", "uuid", ")", ":", "if", "uuid", ":", "# Computing the hash", "try", ":", "x", "=", "hash64", "(", "uuid", ")", "except", "UnicodeEncodeError", ":", "x", "=", "hash64", "(", "uuid", ".", "encode", "(", "'ascii'", ",", "...
Adds a key to the HyperLogLog
[ "Adds", "a", "key", "to", "the", "HyperLogLog" ]
train
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hll.py#L47-L60
Parsely/probably
probably/hll.py
HyperLogLog.estimate
def estimate(self): """ Returns the estimate of the cardinality """ E = self.alpha * float(self.m ** 2) / np.power(2.0, - self.M).sum() if E <= 2.5 * self.m: # Small range correction V = self.m - np.count_nonzero(self.M) return int(self.m * np.log(self.m / flo...
python
def estimate(self): """ Returns the estimate of the cardinality """ E = self.alpha * float(self.m ** 2) / np.power(2.0, - self.M).sum() if E <= 2.5 * self.m: # Small range correction V = self.m - np.count_nonzero(self.M) return int(self.m * np.log(self.m / flo...
[ "def", "estimate", "(", "self", ")", ":", "E", "=", "self", ".", "alpha", "*", "float", "(", "self", ".", "m", "**", "2", ")", "/", "np", ".", "power", "(", "2.0", ",", "-", "self", ".", "M", ")", ".", "sum", "(", ")", "if", "E", "<=", "2...
Returns the estimate of the cardinality
[ "Returns", "the", "estimate", "of", "the", "cardinality" ]
train
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hll.py#L72-L83
Metatab/metapack
metapack/terms.py
Resource.base_url
def base_url(self): """Base URL for resolving resource URLs""" if self.doc.package_url: return self.doc.package_url return self.doc._ref
python
def base_url(self): """Base URL for resolving resource URLs""" if self.doc.package_url: return self.doc.package_url return self.doc._ref
[ "def", "base_url", "(", "self", ")", ":", "if", "self", ".", "doc", ".", "package_url", ":", "return", "self", ".", "doc", ".", "package_url", "return", "self", ".", "doc", ".", "_ref" ]
Base URL for resolving resource URLs
[ "Base", "URL", "for", "resolving", "resource", "URLs" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L29-L35
Metatab/metapack
metapack/terms.py
Resource.env
def env(self): """The execution context for rowprocessors and row-generating notebooks and functions. """ from copy import copy env = copy(self.doc.env) assert env is not None, 'Got a null execution context' env.update(self._envvar_env) env.update(self.all_props) ...
python
def env(self): """The execution context for rowprocessors and row-generating notebooks and functions. """ from copy import copy env = copy(self.doc.env) assert env is not None, 'Got a null execution context' env.update(self._envvar_env) env.update(self.all_props) ...
[ "def", "env", "(", "self", ")", ":", "from", "copy", "import", "copy", "env", "=", "copy", "(", "self", ".", "doc", ".", "env", ")", "assert", "env", "is", "not", "None", ",", "'Got a null execution context'", "env", ".", "update", "(", "self", ".", ...
The execution context for rowprocessors and row-generating notebooks and functions.
[ "The", "execution", "context", "for", "rowprocessors", "and", "row", "-", "generating", "notebooks", "and", "functions", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L54-L66
Metatab/metapack
metapack/terms.py
Resource._resolved_url
def _resolved_url(self): """Return a URL that properly combines the base_url and a possibly relative resource url""" if not self.url: return None u = parse_app_url(self.url) if u.scheme == 'index': u = u.resolve() if u.scheme != 'file': ...
python
def _resolved_url(self): """Return a URL that properly combines the base_url and a possibly relative resource url""" if not self.url: return None u = parse_app_url(self.url) if u.scheme == 'index': u = u.resolve() if u.scheme != 'file': ...
[ "def", "_resolved_url", "(", "self", ")", ":", "if", "not", "self", ".", "url", ":", "return", "None", "u", "=", "parse_app_url", "(", "self", ".", "url", ")", "if", "u", ".", "scheme", "==", "'index'", ":", "u", "=", "u", ".", "resolve", "(", ")...
Return a URL that properly combines the base_url and a possibly relative resource url
[ "Return", "a", "URL", "that", "properly", "combines", "the", "base_url", "and", "a", "possibly", "relative", "resource", "url" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L115-L190
Metatab/metapack
metapack/terms.py
Resource.schema_term
def schema_term(self): """Return the Table term for this resource, which is referenced either by the `table` property or the `schema` property""" if not self.name: raise MetapackError("Resource for url '{}' doe not have name".format(self.url)) t = self.doc.find_first('Root....
python
def schema_term(self): """Return the Table term for this resource, which is referenced either by the `table` property or the `schema` property""" if not self.name: raise MetapackError("Resource for url '{}' doe not have name".format(self.url)) t = self.doc.find_first('Root....
[ "def", "schema_term", "(", "self", ")", ":", "if", "not", "self", ".", "name", ":", "raise", "MetapackError", "(", "\"Resource for url '{}' doe not have name\"", ".", "format", "(", "self", ".", "url", ")", ")", "t", "=", "self", ".", "doc", ".", "find_fir...
Return the Table term for this resource, which is referenced either by the `table` property or the `schema` property
[ "Return", "the", "Table", "term", "for", "this", "resource", "which", "is", "referenced", "either", "by", "the", "table", "property", "or", "the", "schema", "property" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L222-L239
Metatab/metapack
metapack/terms.py
Resource.headers
def headers(self): """Return the headers for the resource. Returns the AltName, if specified; if not, then the Name, and if that is empty, a name based on the column position. These headers are specifically applicable to the output table, and may not apply to the resource source. FOr those heade...
python
def headers(self): """Return the headers for the resource. Returns the AltName, if specified; if not, then the Name, and if that is empty, a name based on the column position. These headers are specifically applicable to the output table, and may not apply to the resource source. FOr those heade...
[ "def", "headers", "(", "self", ")", ":", "t", "=", "self", ".", "schema_term", "if", "t", ":", "return", "[", "self", ".", "_name_for_col_term", "(", "c", ",", "i", ")", "for", "i", ",", "c", "in", "enumerate", "(", "t", ".", "children", ",", "1"...
Return the headers for the resource. Returns the AltName, if specified; if not, then the Name, and if that is empty, a name based on the column position. These headers are specifically applicable to the output table, and may not apply to the resource source. FOr those headers, use source_headers
[ "Return", "the", "headers", "for", "the", "resource", ".", "Returns", "the", "AltName", "if", "specified", ";", "if", "not", "then", "the", "Name", "and", "if", "that", "is", "empty", "a", "name", "based", "on", "the", "column", "position", ".", "These",...
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L242-L254
Metatab/metapack
metapack/terms.py
Resource.source_headers
def source_headers(self): """"Returns the headers for the resource source. Specifically, does not include any header that is the EMPTY_SOURCE_HEADER value of _NONE_""" t = self.schema_term if t: return [self._name_for_col_term(c, i) for i, c in enumerate...
python
def source_headers(self): """"Returns the headers for the resource source. Specifically, does not include any header that is the EMPTY_SOURCE_HEADER value of _NONE_""" t = self.schema_term if t: return [self._name_for_col_term(c, i) for i, c in enumerate...
[ "def", "source_headers", "(", "self", ")", ":", "t", "=", "self", ".", "schema_term", "if", "t", ":", "return", "[", "self", ".", "_name_for_col_term", "(", "c", ",", "i", ")", "for", "i", ",", "c", "in", "enumerate", "(", "t", ".", "children", ","...
Returns the headers for the resource source. Specifically, does not include any header that is the EMPTY_SOURCE_HEADER value of _NONE_
[ "Returns", "the", "headers", "for", "the", "resource", "source", ".", "Specifically", "does", "not", "include", "any", "header", "that", "is", "the", "EMPTY_SOURCE_HEADER", "value", "of", "_NONE_" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L257-L269
Metatab/metapack
metapack/terms.py
Resource.columns
def columns(self): """Return column information from the schema or from an upstreram package""" try: # For resources that are metapack packages. r = self.expanded_url.resource.columns() return list(r) except AttributeError as e: pass ret...
python
def columns(self): """Return column information from the schema or from an upstreram package""" try: # For resources that are metapack packages. r = self.expanded_url.resource.columns() return list(r) except AttributeError as e: pass ret...
[ "def", "columns", "(", "self", ")", ":", "try", ":", "# For resources that are metapack packages.", "r", "=", "self", ".", "expanded_url", ".", "resource", ".", "columns", "(", ")", "return", "list", "(", "r", ")", "except", "AttributeError", "as", "e", ":",...
Return column information from the schema or from an upstreram package
[ "Return", "column", "information", "from", "the", "schema", "or", "from", "an", "upstreram", "package" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L273-L284
Metatab/metapack
metapack/terms.py
Resource.schema_columns
def schema_columns(self): """Return column informatino only from this schema""" t = self.schema_term columns = [] if t: for i, c in enumerate(t.children): if c.term_is("Table.Column"): p = c.all_props p['pos'] = i ...
python
def schema_columns(self): """Return column informatino only from this schema""" t = self.schema_term columns = [] if t: for i, c in enumerate(t.children): if c.term_is("Table.Column"): p = c.all_props p['pos'] = i ...
[ "def", "schema_columns", "(", "self", ")", ":", "t", "=", "self", ".", "schema_term", "columns", "=", "[", "]", "if", "t", ":", "for", "i", ",", "c", "in", "enumerate", "(", "t", ".", "children", ")", ":", "if", "c", ".", "term_is", "(", "\"Table...
Return column informatino only from this schema
[ "Return", "column", "informatino", "only", "from", "this", "schema" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L287-L306
Metatab/metapack
metapack/terms.py
Resource.row_processor_table
def row_processor_table(self, ignore_none=False): """Create a row processor from the schema, to convert the text values from the CSV into real types""" from rowgenerators.rowpipe import Table type_map = { None: None, 'string': 'str', 'text': 'str', ...
python
def row_processor_table(self, ignore_none=False): """Create a row processor from the schema, to convert the text values from the CSV into real types""" from rowgenerators.rowpipe import Table type_map = { None: None, 'string': 'str', 'text': 'str', ...
[ "def", "row_processor_table", "(", "self", ",", "ignore_none", "=", "False", ")", ":", "from", "rowgenerators", ".", "rowpipe", "import", "Table", "type_map", "=", "{", "None", ":", "None", ",", "'string'", ":", "'str'", ",", "'text'", ":", "'str'", ",", ...
Create a row processor from the schema, to convert the text values from the CSV into real types
[ "Create", "a", "row", "processor", "from", "the", "schema", "to", "convert", "the", "text", "values", "from", "the", "CSV", "into", "real", "types" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L308-L347
Metatab/metapack
metapack/terms.py
Resource.raw_row_generator
def raw_row_generator(self): """Like rowgenerator, but does not try to create a row processor table""" from rowgenerators import get_generator self.doc.set_sys_path() # Set sys path to package 'lib' dir in case of python function generator ru = self.resolved_url try: ...
python
def raw_row_generator(self): """Like rowgenerator, but does not try to create a row processor table""" from rowgenerators import get_generator self.doc.set_sys_path() # Set sys path to package 'lib' dir in case of python function generator ru = self.resolved_url try: ...
[ "def", "raw_row_generator", "(", "self", ")", ":", "from", "rowgenerators", "import", "get_generator", "self", ".", "doc", ".", "set_sys_path", "(", ")", "# Set sys path to package 'lib' dir in case of python function generator", "ru", "=", "self", ".", "resolved_url", ...
Like rowgenerator, but does not try to create a row processor table
[ "Like", "rowgenerator", "but", "does", "not", "try", "to", "create", "a", "row", "processor", "table" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L350-L380
Metatab/metapack
metapack/terms.py
Resource._get_header
def _get_header(self): """Get the header from the deinfed header rows, for use on references or resources where the schema has not been run""" try: header_lines = [int(e) for e in str(self.get_value('headerlines', 0)).split(',')] except ValueError as e: header_l...
python
def _get_header(self): """Get the header from the deinfed header rows, for use on references or resources where the schema has not been run""" try: header_lines = [int(e) for e in str(self.get_value('headerlines', 0)).split(',')] except ValueError as e: header_l...
[ "def", "_get_header", "(", "self", ")", ":", "try", ":", "header_lines", "=", "[", "int", "(", "e", ")", "for", "e", "in", "str", "(", "self", ".", "get_value", "(", "'headerlines'", ",", "0", ")", ")", ".", "split", "(", "','", ")", "]", "except...
Get the header from the deinfed header rows, for use on references or resources where the schema has not been run
[ "Get", "the", "header", "from", "the", "deinfed", "header", "rows", "for", "use", "on", "references", "or", "resources", "where", "the", "schema", "has", "not", "been", "run" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L426-L441
Metatab/metapack
metapack/terms.py
Resource.iterdict
def iterdict(self): """Iterate over the resource in dict records""" from collections import OrderedDict headers = None for row in self: if headers is None: headers = row continue yield OrderedDict(zip(headers, row))
python
def iterdict(self): """Iterate over the resource in dict records""" from collections import OrderedDict headers = None for row in self: if headers is None: headers = row continue yield OrderedDict(zip(headers, row))
[ "def", "iterdict", "(", "self", ")", ":", "from", "collections", "import", "OrderedDict", "headers", "=", "None", "for", "row", "in", "self", ":", "if", "headers", "is", "None", ":", "headers", "=", "row", "continue", "yield", "OrderedDict", "(", "zip", ...
Iterate over the resource in dict records
[ "Iterate", "over", "the", "resource", "in", "dict", "records" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L493-L505
Metatab/metapack
metapack/terms.py
Resource.iterrows
def iterrows(self): """Iterate over the resource as row proxy objects, which allow acessing colums as attributes""" row_proxy = None headers = None for row in self: if not headers: headers = row row_proxy = RowProxy(headers) ...
python
def iterrows(self): """Iterate over the resource as row proxy objects, which allow acessing colums as attributes""" row_proxy = None headers = None for row in self: if not headers: headers = row row_proxy = RowProxy(headers) ...
[ "def", "iterrows", "(", "self", ")", ":", "row_proxy", "=", "None", "headers", "=", "None", "for", "row", "in", "self", ":", "if", "not", "headers", ":", "headers", "=", "row", "row_proxy", "=", "RowProxy", "(", "headers", ")", "continue", "yield", "ro...
Iterate over the resource as row proxy objects, which allow acessing colums as attributes
[ "Iterate", "over", "the", "resource", "as", "row", "proxy", "objects", "which", "allow", "acessing", "colums", "as", "attributes" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L508-L524
Metatab/metapack
metapack/terms.py
Resource.iterrowproxy
def iterrowproxy(self, cls=RowProxy): """Iterate over the resource as row proxy objects, which allow acessing colums as attributes. Like iterrows, but allows for setting a specific RowProxy class. """ row_proxy = None headers = None for row in self: if not headers...
python
def iterrowproxy(self, cls=RowProxy): """Iterate over the resource as row proxy objects, which allow acessing colums as attributes. Like iterrows, but allows for setting a specific RowProxy class. """ row_proxy = None headers = None for row in self: if not headers...
[ "def", "iterrowproxy", "(", "self", ",", "cls", "=", "RowProxy", ")", ":", "row_proxy", "=", "None", "headers", "=", "None", "for", "row", "in", "self", ":", "if", "not", "headers", ":", "headers", "=", "row", "row_proxy", "=", "cls", "(", "headers", ...
Iterate over the resource as row proxy objects, which allow acessing colums as attributes. Like iterrows, but allows for setting a specific RowProxy class.
[ "Iterate", "over", "the", "resource", "as", "row", "proxy", "objects", "which", "allow", "acessing", "colums", "as", "attributes", ".", "Like", "iterrows", "but", "allows", "for", "setting", "a", "specific", "RowProxy", "class", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L526-L541
Metatab/metapack
metapack/terms.py
Resource.iterstruct
def iterstruct(self): """Yield data structures built from the JSON header specifications in a table""" from rowgenerators.rowpipe.json import add_to_struct json_headers = self.json_headers for row in islice(self, 1, None): # islice skips header d = {} for pos, j...
python
def iterstruct(self): """Yield data structures built from the JSON header specifications in a table""" from rowgenerators.rowpipe.json import add_to_struct json_headers = self.json_headers for row in islice(self, 1, None): # islice skips header d = {} for pos, j...
[ "def", "iterstruct", "(", "self", ")", ":", "from", "rowgenerators", ".", "rowpipe", ".", "json", "import", "add_to_struct", "json_headers", "=", "self", ".", "json_headers", "for", "row", "in", "islice", "(", "self", ",", "1", ",", "None", ")", ":", "# ...
Yield data structures built from the JSON header specifications in a table
[ "Yield", "data", "structures", "built", "from", "the", "JSON", "header", "specifications", "in", "a", "table" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L548-L558
Metatab/metapack
metapack/terms.py
Resource.iterjson
def iterjson(self, *args, **kwargs): """Yields the data structures from iterstruct as JSON strings""" from rowgenerators.rowpipe.json import VTEncoder import json if 'cls' not in kwargs: kwargs['cls'] = VTEncoder for s in self.iterstruct: yield (json.dum...
python
def iterjson(self, *args, **kwargs): """Yields the data structures from iterstruct as JSON strings""" from rowgenerators.rowpipe.json import VTEncoder import json if 'cls' not in kwargs: kwargs['cls'] = VTEncoder for s in self.iterstruct: yield (json.dum...
[ "def", "iterjson", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "rowgenerators", ".", "rowpipe", ".", "json", "import", "VTEncoder", "import", "json", "if", "'cls'", "not", "in", "kwargs", ":", "kwargs", "[", "'cls'", "]", ...
Yields the data structures from iterstruct as JSON strings
[ "Yields", "the", "data", "structures", "from", "iterstruct", "as", "JSON", "strings" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L560-L569
Metatab/metapack
metapack/terms.py
Resource.iteryaml
def iteryaml(self, *args, **kwargs): """Yields the data structures from iterstruct as YAML strings""" from rowgenerators.rowpipe.json import VTEncoder import yaml if 'cls' not in kwargs: kwargs['cls'] = VTEncoder for s in self.iterstruct: yield (yaml.saf...
python
def iteryaml(self, *args, **kwargs): """Yields the data structures from iterstruct as YAML strings""" from rowgenerators.rowpipe.json import VTEncoder import yaml if 'cls' not in kwargs: kwargs['cls'] = VTEncoder for s in self.iterstruct: yield (yaml.saf...
[ "def", "iteryaml", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "rowgenerators", ".", "rowpipe", ".", "json", "import", "VTEncoder", "import", "yaml", "if", "'cls'", "not", "in", "kwargs", ":", "kwargs", "[", "'cls'", "]", ...
Yields the data structures from iterstruct as YAML strings
[ "Yields", "the", "data", "structures", "from", "iterstruct", "as", "YAML", "strings" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L571-L580
Metatab/metapack
metapack/terms.py
Resource.dataframe
def dataframe(self, dtype=False, parse_dates=True, *args, **kwargs): """Return a pandas datafrome from the resource""" import pandas as pd rg = self.row_generator t = self.resolved_url.get_resource().get_target() if t.target_format == 'csv': return self.read_csv(...
python
def dataframe(self, dtype=False, parse_dates=True, *args, **kwargs): """Return a pandas datafrome from the resource""" import pandas as pd rg = self.row_generator t = self.resolved_url.get_resource().get_target() if t.target_format == 'csv': return self.read_csv(...
[ "def", "dataframe", "(", "self", ",", "dtype", "=", "False", ",", "parse_dates", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pandas", "as", "pd", "rg", "=", "self", ".", "row_generator", "t", "=", "self", ".", "reso...
Return a pandas datafrome from the resource
[ "Return", "a", "pandas", "datafrome", "from", "the", "resource" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L585-L612
Metatab/metapack
metapack/terms.py
Resource.geoframe
def geoframe(self, *args, **kwargs): """Return a Geo dataframe""" from geopandas import GeoDataFrame import geopandas as gpd from shapely.geometry.polygon import BaseGeometry from shapely.wkt import loads gdf = None try: gdf = self.resolved_url.geofr...
python
def geoframe(self, *args, **kwargs): """Return a Geo dataframe""" from geopandas import GeoDataFrame import geopandas as gpd from shapely.geometry.polygon import BaseGeometry from shapely.wkt import loads gdf = None try: gdf = self.resolved_url.geofr...
[ "def", "geoframe", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "geopandas", "import", "GeoDataFrame", "import", "geopandas", "as", "gpd", "from", "shapely", ".", "geometry", ".", "polygon", "import", "BaseGeometry", "from", "s...
Return a Geo dataframe
[ "Return", "a", "Geo", "dataframe" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L614-L678
Metatab/metapack
metapack/terms.py
Resource._update_pandas_kwargs
def _update_pandas_kwargs(self, dtype=False, parse_dates=True, kwargs= {}): """ Construct args suitable for pandas read_csv :param dtype: If true, create a dtype type map. Otherwise, pass argument value to read_csv :param parse_dates: If true, create a list of date/time columns for the parse_da...
python
def _update_pandas_kwargs(self, dtype=False, parse_dates=True, kwargs= {}): """ Construct args suitable for pandas read_csv :param dtype: If true, create a dtype type map. Otherwise, pass argument value to read_csv :param parse_dates: If true, create a list of date/time columns for the parse_da...
[ "def", "_update_pandas_kwargs", "(", "self", ",", "dtype", "=", "False", ",", "parse_dates", "=", "True", ",", "kwargs", "=", "{", "}", ")", ":", "from", "datetime", "import", "datetime", ",", "time", ",", "date", "type_map", "=", "{", "None", ":", "No...
Construct args suitable for pandas read_csv :param dtype: If true, create a dtype type map. Otherwise, pass argument value to read_csv :param parse_dates: If true, create a list of date/time columns for the parse_dates argument of read_csv :param kwargs: :return:
[ "Construct", "args", "suitable", "for", "pandas", "read_csv", ":", "param", "dtype", ":", "If", "true", "create", "a", "dtype", "type", "map", ".", "Otherwise", "pass", "argument", "value", "to", "read_csv", ":", "param", "parse_dates", ":", "If", "true", ...
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L681-L716
Metatab/metapack
metapack/terms.py
Resource.read_csv
def read_csv(self, dtype=False, parse_dates=True, *args, **kwargs): """Fetch the target and pass through to pandas.read_csv Don't provide the first argument of read_csv(); it is supplied internally. """ import pandas t = self.resolved_url.get_resource().get_target() k...
python
def read_csv(self, dtype=False, parse_dates=True, *args, **kwargs): """Fetch the target and pass through to pandas.read_csv Don't provide the first argument of read_csv(); it is supplied internally. """ import pandas t = self.resolved_url.get_resource().get_target() k...
[ "def", "read_csv", "(", "self", ",", "dtype", "=", "False", ",", "parse_dates", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pandas", "t", "=", "self", ".", "resolved_url", ".", "get_resource", "(", ")", ".", "get_targ...
Fetch the target and pass through to pandas.read_csv Don't provide the first argument of read_csv(); it is supplied internally.
[ "Fetch", "the", "target", "and", "pass", "through", "to", "pandas", ".", "read_csv" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L718-L730
Metatab/metapack
metapack/terms.py
Resource.read_fwf
def read_fwf(self, *args, **kwargs): """Fetch the target and pass through to pandas.read_fwf. Don't provide the first argument of read_fwf(); it is supplied internally. """ import pandas t = self.resolved_url.get_resource().get_target() return pandas.read_fwf(t.fspath, *args, ...
python
def read_fwf(self, *args, **kwargs): """Fetch the target and pass through to pandas.read_fwf. Don't provide the first argument of read_fwf(); it is supplied internally. """ import pandas t = self.resolved_url.get_resource().get_target() return pandas.read_fwf(t.fspath, *args, ...
[ "def", "read_fwf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pandas", "t", "=", "self", ".", "resolved_url", ".", "get_resource", "(", ")", ".", "get_target", "(", ")", "return", "pandas", ".", "read_fwf", "(", "t",...
Fetch the target and pass through to pandas.read_fwf. Don't provide the first argument of read_fwf(); it is supplied internally.
[ "Fetch", "the", "target", "and", "pass", "through", "to", "pandas", ".", "read_fwf", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L732-L740
Metatab/metapack
metapack/terms.py
Resource.readlines
def readlines(self): """Load the target, open it, and return the result from readlines()""" t = self.resolved_url.get_resource().get_target() with open(t.fspath) as f: return f.readlines()
python
def readlines(self): """Load the target, open it, and return the result from readlines()""" t = self.resolved_url.get_resource().get_target() with open(t.fspath) as f: return f.readlines()
[ "def", "readlines", "(", "self", ")", ":", "t", "=", "self", ".", "resolved_url", ".", "get_resource", "(", ")", ".", "get_target", "(", ")", "with", "open", "(", "t", ".", "fspath", ")", "as", "f", ":", "return", "f", ".", "readlines", "(", ")" ]
Load the target, open it, and return the result from readlines()
[ "Load", "the", "target", "open", "it", "and", "return", "the", "result", "from", "readlines", "()" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L742-L747
Metatab/metapack
metapack/terms.py
Resource.petl
def petl(self, *args, **kwargs): """Return a PETL source object""" import petl t = self.resolved_url.get_resource().get_target() if t.target_format == 'txt': return petl.fromtext(str(t.fspath), *args, **kwargs) elif t.target_format == 'csv': return petl....
python
def petl(self, *args, **kwargs): """Return a PETL source object""" import petl t = self.resolved_url.get_resource().get_target() if t.target_format == 'txt': return petl.fromtext(str(t.fspath), *args, **kwargs) elif t.target_format == 'csv': return petl....
[ "def", "petl", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "petl", "t", "=", "self", ".", "resolved_url", ".", "get_resource", "(", ")", ".", "get_target", "(", ")", "if", "t", ".", "target_format", "==", "'txt'", ":...
Return a PETL source object
[ "Return", "a", "PETL", "source", "object" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L749-L760
Metatab/metapack
metapack/terms.py
SqlQuery.context
def context(self): """Build the interpolation context from the schemas""" # Can't use self.columns b/c of recursion with resolved_url t = self.schema_term if not t: return {} sql_columns = [] all_columns = [] for i, c in enumerate(t.children): ...
python
def context(self): """Build the interpolation context from the schemas""" # Can't use self.columns b/c of recursion with resolved_url t = self.schema_term if not t: return {} sql_columns = [] all_columns = [] for i, c in enumerate(t.children): ...
[ "def", "context", "(", "self", ")", ":", "# Can't use self.columns b/c of recursion with resolved_url", "t", "=", "self", ".", "schema_term", "if", "not", "t", ":", "return", "{", "}", "sql_columns", "=", "[", "]", "all_columns", "=", "[", "]", "for", "i", "...
Build the interpolation context from the schemas
[ "Build", "the", "interpolation", "context", "from", "the", "schemas" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L839-L864
Metatab/metapack
metapack/jupyter/ipython.py
caller_locals
def caller_locals(): """Get the local variables in the caller's frame.""" import inspect frame = inspect.currentframe() try: return frame.f_back.f_back.f_locals finally: del frame
python
def caller_locals(): """Get the local variables in the caller's frame.""" import inspect frame = inspect.currentframe() try: return frame.f_back.f_back.f_locals finally: del frame
[ "def", "caller_locals", "(", ")", ":", "import", "inspect", "frame", "=", "inspect", ".", "currentframe", "(", ")", "try", ":", "return", "frame", ".", "f_back", ".", "f_back", ".", "f_locals", "finally", ":", "del", "frame" ]
Get the local variables in the caller's frame.
[ "Get", "the", "local", "variables", "in", "the", "caller", "s", "frame", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L15-L22
Metatab/metapack
metapack/jupyter/ipython.py
open_source_package
def open_source_package(dr=None): """Like open_package(), but always open the source package""" if dr is None: dr = getcwd() for i, e in enumerate(walk_up(dr)): intr = set([DEFAULT_METATAB_FILE, LINES_METATAB_FILE, IPYNB_METATAB_FILE]) & set(e[2]) if intr: return op(j...
python
def open_source_package(dr=None): """Like open_package(), but always open the source package""" if dr is None: dr = getcwd() for i, e in enumerate(walk_up(dr)): intr = set([DEFAULT_METATAB_FILE, LINES_METATAB_FILE, IPYNB_METATAB_FILE]) & set(e[2]) if intr: return op(j...
[ "def", "open_source_package", "(", "dr", "=", "None", ")", ":", "if", "dr", "is", "None", ":", "dr", "=", "getcwd", "(", ")", "for", "i", ",", "e", "in", "enumerate", "(", "walk_up", "(", "dr", ")", ")", ":", "intr", "=", "set", "(", "[", "DEFA...
Like open_package(), but always open the source package
[ "Like", "open_package", "()", "but", "always", "open", "the", "source", "package" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L30-L46
Metatab/metapack
metapack/jupyter/ipython.py
open_package
def open_package(locals=None, dr=None): """Try to open a package with the metatab_doc variable, which is set when a Notebook is run as a resource. If that does not exist, try the local _packages directory""" if locals is None: locals = caller_locals() try: # Running in a package build...
python
def open_package(locals=None, dr=None): """Try to open a package with the metatab_doc variable, which is set when a Notebook is run as a resource. If that does not exist, try the local _packages directory""" if locals is None: locals = caller_locals() try: # Running in a package build...
[ "def", "open_package", "(", "locals", "=", "None", ",", "dr", "=", "None", ")", ":", "if", "locals", "is", "None", ":", "locals", "=", "caller_locals", "(", ")", "try", ":", "# Running in a package build", "return", "op", "(", "locals", "[", "'metatab_doc'...
Try to open a package with the metatab_doc variable, which is set when a Notebook is run as a resource. If that does not exist, try the local _packages directory
[ "Try", "to", "open", "a", "package", "with", "the", "metatab_doc", "variable", "which", "is", "set", "when", "a", "Notebook", "is", "run", "as", "a", "resource", ".", "If", "that", "does", "not", "exist", "try", "the", "local", "_packages", "directory" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L48-L103
Metatab/metapack
metapack/jupyter/ipython.py
rebuild_schema
def rebuild_schema(doc, r, df): """Rebuild the schema for a resource based on a dataframe""" import numpy as np # Re-get the resource in the doc, since it may be different. try: r = doc.resource(r.name) except AttributeError: # Maybe r is actually a resource name r = doc.res...
python
def rebuild_schema(doc, r, df): """Rebuild the schema for a resource based on a dataframe""" import numpy as np # Re-get the resource in the doc, since it may be different. try: r = doc.resource(r.name) except AttributeError: # Maybe r is actually a resource name r = doc.res...
[ "def", "rebuild_schema", "(", "doc", ",", "r", ",", "df", ")", ":", "import", "numpy", "as", "np", "# Re-get the resource in the doc, since it may be different.", "try", ":", "r", "=", "doc", ".", "resource", "(", "r", ".", "name", ")", "except", "AttributeErr...
Rebuild the schema for a resource based on a dataframe
[ "Rebuild", "the", "schema", "for", "a", "resource", "based", "on", "a", "dataframe" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L106-L206
Metatab/metapack
metapack/jupyter/ipython.py
rewrite_schema
def rewrite_schema(r, df, doc=None): """Rebuild the schema for a resource based on a dataframe and re-write the doc""" from metapack.cli.core import write_doc if doc is None: doc = open_source_package() rebuild_schema(doc, r, df) write_doc(doc, doc.ref)
python
def rewrite_schema(r, df, doc=None): """Rebuild the schema for a resource based on a dataframe and re-write the doc""" from metapack.cli.core import write_doc if doc is None: doc = open_source_package() rebuild_schema(doc, r, df) write_doc(doc, doc.ref)
[ "def", "rewrite_schema", "(", "r", ",", "df", ",", "doc", "=", "None", ")", ":", "from", "metapack", ".", "cli", ".", "core", "import", "write_doc", "if", "doc", "is", "None", ":", "doc", "=", "open_source_package", "(", ")", "rebuild_schema", "(", "do...
Rebuild the schema for a resource based on a dataframe and re-write the doc
[ "Rebuild", "the", "schema", "for", "a", "resource", "based", "on", "a", "dataframe", "and", "re", "-", "write", "the", "doc" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L209-L219
Metatab/metapack
metapack/jupyter/ipython.py
interactive_rewrite_schema
def interactive_rewrite_schema(r, df, doc=None): """Rebuild the schema for a resource based on a dataframe and re-write the doc, but only if running the notebook interactively, not while building""" if 'metatab_doc' in caller_locals(): return False if doc is None: doc = open_source_pac...
python
def interactive_rewrite_schema(r, df, doc=None): """Rebuild the schema for a resource based on a dataframe and re-write the doc, but only if running the notebook interactively, not while building""" if 'metatab_doc' in caller_locals(): return False if doc is None: doc = open_source_pac...
[ "def", "interactive_rewrite_schema", "(", "r", ",", "df", ",", "doc", "=", "None", ")", ":", "if", "'metatab_doc'", "in", "caller_locals", "(", ")", ":", "return", "False", "if", "doc", "is", "None", ":", "doc", "=", "open_source_package", "(", ")", "rew...
Rebuild the schema for a resource based on a dataframe and re-write the doc, but only if running the notebook interactively, not while building
[ "Rebuild", "the", "schema", "for", "a", "resource", "based", "on", "a", "dataframe", "and", "re", "-", "write", "the", "doc", "but", "only", "if", "running", "the", "notebook", "interactively", "not", "while", "building" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L222-L234
Metatab/metapack
metapack/jupyter/ipython.py
get_dataframes
def get_dataframes(): """Yield tuples of dataframe variable name and the dataframe. Skips variables with names that start with an underscore""" for k, v in caller_locals().items(): if k.startswith('_'): continue if isinstance(v, pd.core.frame.DataFrame): yield k, v
python
def get_dataframes(): """Yield tuples of dataframe variable name and the dataframe. Skips variables with names that start with an underscore""" for k, v in caller_locals().items(): if k.startswith('_'): continue if isinstance(v, pd.core.frame.DataFrame): yield k, v
[ "def", "get_dataframes", "(", ")", ":", "for", "k", ",", "v", "in", "caller_locals", "(", ")", ".", "items", "(", ")", ":", "if", "k", ".", "startswith", "(", "'_'", ")", ":", "continue", "if", "isinstance", "(", "v", ",", "pd", ".", "core", ".",...
Yield tuples of dataframe variable name and the dataframe. Skips variables with names that start with an underscore
[ "Yield", "tuples", "of", "dataframe", "variable", "name", "and", "the", "dataframe", ".", "Skips", "variables", "with", "names", "that", "start", "with", "an", "underscore" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L237-L246
Metatab/metapack
metapack/jupyter/ipython.py
get_notebook_path
def get_notebook_path(): """ Return the full path of the jupyter notebook. """ kernel_id = re.search('kernel-(.*).json', ipykernel.connect.get_connection_file()).group(1) servers = list_running_servers() for ss in servers: response = requests.get(urljoin(ss['url...
python
def get_notebook_path(): """ Return the full path of the jupyter notebook. """ kernel_id = re.search('kernel-(.*).json', ipykernel.connect.get_connection_file()).group(1) servers = list_running_servers() for ss in servers: response = requests.get(urljoin(ss['url...
[ "def", "get_notebook_path", "(", ")", ":", "kernel_id", "=", "re", ".", "search", "(", "'kernel-(.*).json'", ",", "ipykernel", ".", "connect", ".", "get_connection_file", "(", ")", ")", ".", "group", "(", "1", ")", "servers", "=", "list_running_servers", "("...
Return the full path of the jupyter notebook.
[ "Return", "the", "full", "path", "of", "the", "jupyter", "notebook", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L257-L270
Metatab/metapack
metapack/jupyter/ipython.py
get_notebook_rel_path
def get_notebook_rel_path(pkg=None): """Get the path of a notebook, relative to the current soruce package""" pkg = pkg or open_source_package() pkg_path = str(pkg.package_url.fspath) nb_path = get_notebook_path() return nb_path.replace(pkg_path, '').strip('/')
python
def get_notebook_rel_path(pkg=None): """Get the path of a notebook, relative to the current soruce package""" pkg = pkg or open_source_package() pkg_path = str(pkg.package_url.fspath) nb_path = get_notebook_path() return nb_path.replace(pkg_path, '').strip('/')
[ "def", "get_notebook_rel_path", "(", "pkg", "=", "None", ")", ":", "pkg", "=", "pkg", "or", "open_source_package", "(", ")", "pkg_path", "=", "str", "(", "pkg", ".", "package_url", ".", "fspath", ")", "nb_path", "=", "get_notebook_path", "(", ")", "return"...
Get the path of a notebook, relative to the current soruce package
[ "Get", "the", "path", "of", "a", "notebook", "relative", "to", "the", "current", "soruce", "package" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L273-L279
Metatab/metapack
metapack/jupyter/ipython.py
add_dataframe
def add_dataframe(df, name, pkg=None, description=''): """Add a dataframe to a source package. Pass in either the name of the dataframe, or the dataframe. If the dataframeis passed it, the name will be the dataframe's variable name. The function will re-write the source package with the new resource. "...
python
def add_dataframe(df, name, pkg=None, description=''): """Add a dataframe to a source package. Pass in either the name of the dataframe, or the dataframe. If the dataframeis passed it, the name will be the dataframe's variable name. The function will re-write the source package with the new resource. "...
[ "def", "add_dataframe", "(", "df", ",", "name", ",", "pkg", "=", "None", ",", "description", "=", "''", ")", ":", "from", "warnings", "import", "warn", "from", "metapack", ".", "cli", ".", "core", "import", "alt_col_name", ",", "type_map", "import", "num...
Add a dataframe to a source package. Pass in either the name of the dataframe, or the dataframe. If the dataframeis passed it, the name will be the dataframe's variable name. The function will re-write the source package with the new resource.
[ "Add", "a", "dataframe", "to", "a", "source", "package", ".", "Pass", "in", "either", "the", "name", "of", "the", "dataframe", "or", "the", "dataframe", ".", "If", "the", "dataframeis", "passed", "it", "the", "name", "will", "be", "the", "dataframe", "s"...
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/ipython.py#L282-L349
project-rig/rig
rig/utils/docstrings.py
add_int_enums_to_docstring
def add_int_enums_to_docstring(enum): """Decorator for IntEnum which re-writes the documentation string so that Sphinx enumerates all the enumeration values. This is a work-around for Sphinx autodoc's inability to properly document IntEnums. This decorator adds enumeration names and values to the ...
python
def add_int_enums_to_docstring(enum): """Decorator for IntEnum which re-writes the documentation string so that Sphinx enumerates all the enumeration values. This is a work-around for Sphinx autodoc's inability to properly document IntEnums. This decorator adds enumeration names and values to the ...
[ "def", "add_int_enums_to_docstring", "(", "enum", ")", ":", "# The enum34 library (used for compatibility with Python < v3.4) rather", "# oddly set its docstring to None rather than some senible but empty", "# default...", "if", "enum", ".", "__doc__", "is", "None", ":", "# pragma: n...
Decorator for IntEnum which re-writes the documentation string so that Sphinx enumerates all the enumeration values. This is a work-around for Sphinx autodoc's inability to properly document IntEnums. This decorator adds enumeration names and values to the 'Attributes' section of the docstring of ...
[ "Decorator", "for", "IntEnum", "which", "re", "-", "writes", "the", "documentation", "string", "so", "that", "Sphinx", "enumerates", "all", "the", "enumeration", "values", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/docstrings.py#L12-L51
project-rig/rig
rig/utils/docstrings.py
add_signature_to_docstring
def add_signature_to_docstring(f, include_self=False, kw_only_args={}): """Decorator which adds the function signature of 'f' to the decorated function's docstring. Under Python 2, wrapping a function (even using functools.wraps) hides its signature to Sphinx's introspection tools so it is necessary to...
python
def add_signature_to_docstring(f, include_self=False, kw_only_args={}): """Decorator which adds the function signature of 'f' to the decorated function's docstring. Under Python 2, wrapping a function (even using functools.wraps) hides its signature to Sphinx's introspection tools so it is necessary to...
[ "def", "add_signature_to_docstring", "(", "f", ",", "include_self", "=", "False", ",", "kw_only_args", "=", "{", "}", ")", ":", "def", "decorate", "(", "f_wrapper", ")", ":", "args", ",", "varargs", ",", "keywords", ",", "defaults", "=", "inspect", ".", ...
Decorator which adds the function signature of 'f' to the decorated function's docstring. Under Python 2, wrapping a function (even using functools.wraps) hides its signature to Sphinx's introspection tools so it is necessary to include the function signature in the docstring to enable Sphinx to render...
[ "Decorator", "which", "adds", "the", "function", "signature", "of", "f", "to", "the", "decorated", "function", "s", "docstring", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/docstrings.py#L54-L165
project-rig/rig
rig/machine_control/machine_controller.py
_if_not_closed
def _if_not_closed(f): """Run the method iff. the memory view hasn't been closed and the parent object has not been freed.""" @add_signature_to_docstring(f) @functools.wraps(f) def f_(self, *args, **kwargs): if self.closed or self._parent._freed: raise OSError return f(se...
python
def _if_not_closed(f): """Run the method iff. the memory view hasn't been closed and the parent object has not been freed.""" @add_signature_to_docstring(f) @functools.wraps(f) def f_(self, *args, **kwargs): if self.closed or self._parent._freed: raise OSError return f(se...
[ "def", "_if_not_closed", "(", "f", ")", ":", "@", "add_signature_to_docstring", "(", "f", ")", "@", "functools", ".", "wraps", "(", "f", ")", "def", "f_", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "closed"...
Run the method iff. the memory view hasn't been closed and the parent object has not been freed.
[ "Run", "the", "method", "iff", ".", "the", "memory", "view", "hasn", "t", "been", "closed", "and", "the", "parent", "object", "has", "not", "been", "freed", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2482-L2492
project-rig/rig
rig/machine_control/machine_controller.py
_if_not_freed
def _if_not_freed(f): """Run the method iff. the memory view hasn't been closed.""" @add_signature_to_docstring(f) @functools.wraps(f) def f_(self, *args, **kwargs): if self._freed: raise OSError return f(self, *args, **kwargs) return f_
python
def _if_not_freed(f): """Run the method iff. the memory view hasn't been closed.""" @add_signature_to_docstring(f) @functools.wraps(f) def f_(self, *args, **kwargs): if self._freed: raise OSError return f(self, *args, **kwargs) return f_
[ "def", "_if_not_freed", "(", "f", ")", ":", "@", "add_signature_to_docstring", "(", "f", ")", "@", "functools", ".", "wraps", "(", "f", ")", "def", "f_", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_freed",...
Run the method iff. the memory view hasn't been closed.
[ "Run", "the", "method", "iff", ".", "the", "memory", "view", "hasn", "t", "been", "closed", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2738-L2747
project-rig/rig
rig/machine_control/machine_controller.py
unpack_routing_table_entry
def unpack_routing_table_entry(packed): """Unpack a routing table entry read from a SpiNNaker machine. Parameters ---------- packet : :py:class:`bytes` Bytes containing a packed routing table. Returns ------- (:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) or None ...
python
def unpack_routing_table_entry(packed): """Unpack a routing table entry read from a SpiNNaker machine. Parameters ---------- packet : :py:class:`bytes` Bytes containing a packed routing table. Returns ------- (:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) or None ...
[ "def", "unpack_routing_table_entry", "(", "packed", ")", ":", "# Unpack the routing table entry", "_", ",", "free", ",", "route", ",", "key", ",", "mask", "=", "struct", ".", "unpack", "(", "consts", ".", "RTE_PACK_STRING", ",", "packed", ")", "# If the top 8 bi...
Unpack a routing table entry read from a SpiNNaker machine. Parameters ---------- packet : :py:class:`bytes` Bytes containing a packed routing table. Returns ------- (:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) or None Tuple containing the routing entry, the...
[ "Unpack", "a", "routing", "table", "entry", "read", "from", "a", "SpiNNaker", "machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2838-L2869
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.scp_data_length
def scp_data_length(self): """The maximum SCP data field length supported by the machine (bytes). """ # If not known, query the machine if self._scp_data_length is None: data = self.get_software_version(255, 255, 0) self._scp_data_length = data.buffer_size...
python
def scp_data_length(self): """The maximum SCP data field length supported by the machine (bytes). """ # If not known, query the machine if self._scp_data_length is None: data = self.get_software_version(255, 255, 0) self._scp_data_length = data.buffer_size...
[ "def", "scp_data_length", "(", "self", ")", ":", "# If not known, query the machine", "if", "self", ".", "_scp_data_length", "is", "None", ":", "data", "=", "self", ".", "get_software_version", "(", "255", ",", "255", ",", "0", ")", "self", ".", "_scp_data_len...
The maximum SCP data field length supported by the machine (bytes).
[ "The", "maximum", "SCP", "data", "field", "length", "supported", "by", "the", "machine", "(", "bytes", ")", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L151-L159
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.root_chip
def root_chip(self): """The coordinates (x, y) of the chip used to boot the machine.""" # If not known, query the machine if self._root_chip is None: self._root_chip = self.get_software_version(255, 255, 0).position return self._root_chip
python
def root_chip(self): """The coordinates (x, y) of the chip used to boot the machine.""" # If not known, query the machine if self._root_chip is None: self._root_chip = self.get_software_version(255, 255, 0).position return self._root_chip
[ "def", "root_chip", "(", "self", ")", ":", "# If not known, query the machine", "if", "self", ".", "_root_chip", "is", "None", ":", "self", ".", "_root_chip", "=", "self", ".", "get_software_version", "(", "255", ",", "255", ",", "0", ")", ".", "position", ...
The coordinates (x, y) of the chip used to boot the machine.
[ "The", "coordinates", "(", "x", "y", ")", "of", "the", "chip", "used", "to", "boot", "the", "machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L173-L178
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.send_scp
def send_scp(self, *args, **kwargs): """Transmit an SCP Packet and return the response. This function is a thin wrapper around :py:meth:`rig.machine_control.scp_connection.SCPConnection.send_scp`. This function will attempt to use the SCP connection nearest the destination of t...
python
def send_scp(self, *args, **kwargs): """Transmit an SCP Packet and return the response. This function is a thin wrapper around :py:meth:`rig.machine_control.scp_connection.SCPConnection.send_scp`. This function will attempt to use the SCP connection nearest the destination of t...
[ "def", "send_scp", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Retrieve contextual arguments from the keyword arguments. The", "# context system ensures that these values are present.", "x", "=", "kwargs", ".", "pop", "(", "\"x\"", ")", "y", ...
Transmit an SCP Packet and return the response. This function is a thin wrapper around :py:meth:`rig.machine_control.scp_connection.SCPConnection.send_scp`. This function will attempt to use the SCP connection nearest the destination of the SCP command if multiple connections have been...
[ "Transmit", "an", "SCP", "Packet", "and", "return", "the", "response", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L182-L205
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._get_connection
def _get_connection(self, x, y): """Get the appropriate connection for a chip.""" if (self._width is None or self._height is None or self._root_chip is None): return self.connections[None] else: # If possible, use the local Ethernet connected chip ...
python
def _get_connection(self, x, y): """Get the appropriate connection for a chip.""" if (self._width is None or self._height is None or self._root_chip is None): return self.connections[None] else: # If possible, use the local Ethernet connected chip ...
[ "def", "_get_connection", "(", "self", ",", "x", ",", "y", ")", ":", "if", "(", "self", ".", "_width", "is", "None", "or", "self", ".", "_height", "is", "None", "or", "self", ".", "_root_chip", "is", "None", ")", ":", "return", "self", ".", "connec...
Get the appropriate connection for a chip.
[ "Get", "the", "appropriate", "connection", "for", "a", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L207-L224
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._send_scp
def _send_scp(self, x, y, p, *args, **kwargs): """Determine the best connection to use to send an SCP packet and use it to transmit. This internal version of the method is identical to send_scp except it has positional arguments for x, y and p. See the arguments for :py...
python
def _send_scp(self, x, y, p, *args, **kwargs): """Determine the best connection to use to send an SCP packet and use it to transmit. This internal version of the method is identical to send_scp except it has positional arguments for x, y and p. See the arguments for :py...
[ "def", "_send_scp", "(", "self", ",", "x", ",", "y", ",", "p", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Determine the size of packet we expect in return, this is usually the", "# size that we are informed we should expect by SCAMP/SARK or else is", "# the def...
Determine the best connection to use to send an SCP packet and use it to transmit. This internal version of the method is identical to send_scp except it has positional arguments for x, y and p. See the arguments for :py:meth:`~rig.machine_control.scp_connection.SCPConnection` ...
[ "Determine", "the", "best", "connection", "to", "use", "to", "send", "an", "SCP", "packet", "and", "use", "it", "to", "transmit", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L226-L246
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.boot
def boot(self, width=None, height=None, only_if_needed=True, check_booted=True, **boot_kwargs): """Boot a SpiNNaker machine. The system will be booted from the Ethernet connected chip whose hostname was given as the argument to the MachineController. With the default argume...
python
def boot(self, width=None, height=None, only_if_needed=True, check_booted=True, **boot_kwargs): """Boot a SpiNNaker machine. The system will be booted from the Ethernet connected chip whose hostname was given as the argument to the MachineController. With the default argume...
[ "def", "boot", "(", "self", ",", "width", "=", "None", ",", "height", "=", "None", ",", "only_if_needed", "=", "True", ",", "check_booted", "=", "True", ",", "*", "*", "boot_kwargs", ")", ":", "# Report deprecated width/height arguments", "if", "width", "is"...
Boot a SpiNNaker machine. The system will be booted from the Ethernet connected chip whose hostname was given as the argument to the MachineController. With the default arguments this method will only boot systems which have not already been booted and will wait until machine is complet...
[ "Boot", "a", "SpiNNaker", "machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L248-L376
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.discover_connections
def discover_connections(self, x=255, y=255): """Attempt to discover all available Ethernet connections to a machine. After calling this method, :py:class:`.MachineController` will attempt to communicate via the Ethernet connection on the same board as the destination chip for all comma...
python
def discover_connections(self, x=255, y=255): """Attempt to discover all available Ethernet connections to a machine. After calling this method, :py:class:`.MachineController` will attempt to communicate via the Ethernet connection on the same board as the destination chip for all comma...
[ "def", "discover_connections", "(", "self", ",", "x", "=", "255", ",", "y", "=", "255", ")", ":", "working_chips", "=", "set", "(", "(", "x", ",", "y", ")", "for", "(", "x", ",", "y", ")", ",", "route", "in", "iteritems", "(", "self", ".", "get...
Attempt to discover all available Ethernet connections to a machine. After calling this method, :py:class:`.MachineController` will attempt to communicate via the Ethernet connection on the same board as the destination chip for all commands. If called multiple times, existing connecti...
[ "Attempt", "to", "discover", "all", "available", "Ethernet", "connections", "to", "a", "machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L379-L440
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.application
def application(self, app_id): """Update the context to use the given application ID and stop the application when done. For example:: with cn.application(54): # All commands in this block will use app_id=54. # On leaving the block `cn.send_signal("s...
python
def application(self, app_id): """Update the context to use the given application ID and stop the application when done. For example:: with cn.application(54): # All commands in this block will use app_id=54. # On leaving the block `cn.send_signal("s...
[ "def", "application", "(", "self", ",", "app_id", ")", ":", "# Get a new context and add a method that will be called before the", "# context is removed from the stack.", "context", "=", "self", "(", "app_id", "=", "app_id", ")", "context", ".", "before_close", "(", "lamb...
Update the context to use the given application ID and stop the application when done. For example:: with cn.application(54): # All commands in this block will use app_id=54. # On leaving the block `cn.send_signal("stop", 54)` is # automatica...
[ "Update", "the", "context", "to", "use", "the", "given", "application", "ID", "and", "stop", "the", "application", "when", "done", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L443-L458
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_software_version
def get_software_version(self, x=255, y=255, processor=0): """Get the software version for a given SpiNNaker core. Returns ------- :py:class:`.CoreInfo` Information about the software running on a core. """ sver = self._send_scp(x, y, processor, SCPCommands.s...
python
def get_software_version(self, x=255, y=255, processor=0): """Get the software version for a given SpiNNaker core. Returns ------- :py:class:`.CoreInfo` Information about the software running on a core. """ sver = self._send_scp(x, y, processor, SCPCommands.s...
[ "def", "get_software_version", "(", "self", ",", "x", "=", "255", ",", "y", "=", "255", ",", "processor", "=", "0", ")", ":", "sver", "=", "self", ".", "_send_scp", "(", "x", ",", "y", ",", "processor", ",", "SCPCommands", ".", "sver", ")", "# Form...
Get the software version for a given SpiNNaker core. Returns ------- :py:class:`.CoreInfo` Information about the software running on a core.
[ "Get", "the", "software", "version", "for", "a", "given", "SpiNNaker", "core", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L461-L485
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_ip_address
def get_ip_address(self, x, y): """Get the IP address of a particular SpiNNaker chip's Ethernet link. Returns ------- str or None The IPv4 address (as a string) of the chip's Ethernet link or None if the chip does not have an Ethernet connection or the link is ...
python
def get_ip_address(self, x, y): """Get the IP address of a particular SpiNNaker chip's Ethernet link. Returns ------- str or None The IPv4 address (as a string) of the chip's Ethernet link or None if the chip does not have an Ethernet connection or the link is ...
[ "def", "get_ip_address", "(", "self", ",", "x", ",", "y", ")", ":", "chip_info", "=", "self", ".", "get_chip_info", "(", "x", "=", "x", ",", "y", "=", "y", ")", "return", "chip_info", ".", "ip_address", "if", "chip_info", ".", "ethernet_up", "else", ...
Get the IP address of a particular SpiNNaker chip's Ethernet link. Returns ------- str or None The IPv4 address (as a string) of the chip's Ethernet link or None if the chip does not have an Ethernet connection or the link is currently down.
[ "Get", "the", "IP", "address", "of", "a", "particular", "SpiNNaker", "chip", "s", "Ethernet", "link", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L488-L499
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.write
def write(self, address, data, x, y, p=0): """Write a bytestring to an address in memory. It is strongly encouraged to only read and write to blocks of memory allocated using :py:meth:`.sdram_alloc`. Additionally, :py:meth:`.sdram_alloc_as_filelike` can be used to safely wrap re...
python
def write(self, address, data, x, y, p=0): """Write a bytestring to an address in memory. It is strongly encouraged to only read and write to blocks of memory allocated using :py:meth:`.sdram_alloc`. Additionally, :py:meth:`.sdram_alloc_as_filelike` can be used to safely wrap re...
[ "def", "write", "(", "self", ",", "address", ",", "data", ",", "x", ",", "y", ",", "p", "=", "0", ")", ":", "# Call the SCPConnection to perform the write on our behalf", "connection", "=", "self", ".", "_get_connection", "(", "x", ",", "y", ")", "return", ...
Write a bytestring to an address in memory. It is strongly encouraged to only read and write to blocks of memory allocated using :py:meth:`.sdram_alloc`. Additionally, :py:meth:`.sdram_alloc_as_filelike` can be used to safely wrap read/write access to memory with a file-like interface a...
[ "Write", "a", "bytestring", "to", "an", "address", "in", "memory", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L502-L524
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.read
def read(self, address, length_bytes, x, y, p=0): """Read a bytestring from an address in memory. Parameters ---------- address : int The address at which to start reading the data. length_bytes : int The number of bytes to read from memory. Large reads a...
python
def read(self, address, length_bytes, x, y, p=0): """Read a bytestring from an address in memory. Parameters ---------- address : int The address at which to start reading the data. length_bytes : int The number of bytes to read from memory. Large reads a...
[ "def", "read", "(", "self", ",", "address", ",", "length_bytes", ",", "x", ",", "y", ",", "p", "=", "0", ")", ":", "# Call the SCPConnection to perform the read on our behalf", "connection", "=", "self", ".", "_get_connection", "(", "x", ",", "y", ")", "retu...
Read a bytestring from an address in memory. Parameters ---------- address : int The address at which to start reading the data. length_bytes : int The number of bytes to read from memory. Large reads are transparently broken into multiple SCP read co...
[ "Read", "a", "bytestring", "from", "an", "address", "in", "memory", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L527-L546
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.write_across_link
def write_across_link(self, address, data, x, y, link): """Write a bytestring to an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. This...
python
def write_across_link(self, address, data, x, y, link): """Write a bytestring to an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. This...
[ "def", "write_across_link", "(", "self", ",", "address", ",", "data", ",", "x", ",", "y", ",", "link", ")", ":", "if", "address", "%", "4", ":", "raise", "ValueError", "(", "\"Addresses must be word-aligned.\"", ")", "if", "len", "(", "data", ")", "%", ...
Write a bytestring to an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. This method instructs a monitor processor to send 'POKE' neares...
[ "Write", "a", "bytestring", "to", "an", "address", "in", "memory", "on", "a", "neigbouring", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L549-L600
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.read_across_link
def read_across_link(self, address, length_bytes, x, y, link): """Read a bytestring from an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. ...
python
def read_across_link(self, address, length_bytes, x, y, link): """Read a bytestring from an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. ...
[ "def", "read_across_link", "(", "self", ",", "address", ",", "length_bytes", ",", "x", ",", "y", ",", "link", ")", ":", "if", "address", "%", "4", ":", "raise", "ValueError", "(", "\"Addresses must be word-aligned.\"", ")", "if", "length_bytes", "%", "4", ...
Read a bytestring from an address in memory on a neigbouring chip. .. warning:: This function is intended for low-level debug use only and is not optimised for performance nor intended for more general use. This method instructs a monitor processor to send 'PEEK' neare...
[ "Read", "a", "bytestring", "from", "an", "address", "in", "memory", "on", "a", "neigbouring", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L603-L667
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.read_struct_field
def read_struct_field(self, struct_name, field_name, x, y, p=0): """Read the value out of a struct maintained by SARK. This method is particularly useful for reading fields from the ``sv`` struct which, for example, holds information about system status. See ``sark.h`` for details. ...
python
def read_struct_field(self, struct_name, field_name, x, y, p=0): """Read the value out of a struct maintained by SARK. This method is particularly useful for reading fields from the ``sv`` struct which, for example, holds information about system status. See ``sark.h`` for details. ...
[ "def", "read_struct_field", "(", "self", ",", "struct_name", ",", "field_name", ",", "x", ",", "y", ",", "p", "=", "0", ")", ":", "# Look up the struct and field", "field", ",", "address", ",", "pack_chars", "=", "self", ".", "_get_struct_field_and_address", "...
Read the value out of a struct maintained by SARK. This method is particularly useful for reading fields from the ``sv`` struct which, for example, holds information about system status. See ``sark.h`` for details. Parameters ---------- struct_name : string ...
[ "Read", "the", "value", "out", "of", "a", "struct", "maintained", "by", "SARK", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L677-L718
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.write_struct_field
def write_struct_field(self, struct_name, field_name, values, x, y, p=0): """Write a value into a struct. This method is particularly useful for writing values into the ``sv`` struct which contains some configuration data. See ``sark.h`` for details. Parameters -------...
python
def write_struct_field(self, struct_name, field_name, values, x, y, p=0): """Write a value into a struct. This method is particularly useful for writing values into the ``sv`` struct which contains some configuration data. See ``sark.h`` for details. Parameters -------...
[ "def", "write_struct_field", "(", "self", ",", "struct_name", ",", "field_name", ",", "values", ",", "x", ",", "y", ",", "p", "=", "0", ")", ":", "# Look up the struct and field", "field", ",", "address", ",", "pack_chars", "=", "self", ".", "_get_struct_fie...
Write a value into a struct. This method is particularly useful for writing values into the ``sv`` struct which contains some configuration data. See ``sark.h`` for details. Parameters ---------- struct_name : string Name of the struct to write to, e.g., `"...
[ "Write", "a", "value", "into", "a", "struct", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L721-L752
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._get_vcpu_field_and_address
def _get_vcpu_field_and_address(self, field_name, x, y, p): """Get the field and address for a VCPU struct field.""" vcpu_struct = self.structs[b"vcpu"] field = vcpu_struct[six.b(field_name)] address = (self.read_struct_field("sv", "vcpu_base", x, y) + vcpu_struct.size...
python
def _get_vcpu_field_and_address(self, field_name, x, y, p): """Get the field and address for a VCPU struct field.""" vcpu_struct = self.structs[b"vcpu"] field = vcpu_struct[six.b(field_name)] address = (self.read_struct_field("sv", "vcpu_base", x, y) + vcpu_struct.size...
[ "def", "_get_vcpu_field_and_address", "(", "self", ",", "field_name", ",", "x", ",", "y", ",", "p", ")", ":", "vcpu_struct", "=", "self", ".", "structs", "[", "b\"vcpu\"", "]", "field", "=", "vcpu_struct", "[", "six", ".", "b", "(", "field_name", ")", ...
Get the field and address for a VCPU struct field.
[ "Get", "the", "field", "and", "address", "for", "a", "VCPU", "struct", "field", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L754-L761
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.read_vcpu_struct_field
def read_vcpu_struct_field(self, field_name, x, y, p): """Read a value out of the VCPU struct for a specific core. Similar to :py:meth:`.read_struct_field` except this method accesses the individual VCPU struct for to each core and contains application runtime status. Parameter...
python
def read_vcpu_struct_field(self, field_name, x, y, p): """Read a value out of the VCPU struct for a specific core. Similar to :py:meth:`.read_struct_field` except this method accesses the individual VCPU struct for to each core and contains application runtime status. Parameter...
[ "def", "read_vcpu_struct_field", "(", "self", ",", "field_name", ",", "x", ",", "y", ",", "p", ")", ":", "# Get the base address of the VCPU struct for this chip, then advance", "# to get the correct VCPU struct for the requested core.", "field", ",", "address", ",", "pack_ch...
Read a value out of the VCPU struct for a specific core. Similar to :py:meth:`.read_struct_field` except this method accesses the individual VCPU struct for to each core and contains application runtime status. Parameters ---------- field_name : string Name ...
[ "Read", "a", "value", "out", "of", "the", "VCPU", "struct", "for", "a", "specific", "core", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L764-L802
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.write_vcpu_struct_field
def write_vcpu_struct_field(self, field_name, value, x, y, p): """Write a value to the VCPU struct for a specific core. Parameters ---------- field_name : string Name of the field to write (e.g. `"user0"`) value : Value to write to this field. """...
python
def write_vcpu_struct_field(self, field_name, value, x, y, p): """Write a value to the VCPU struct for a specific core. Parameters ---------- field_name : string Name of the field to write (e.g. `"user0"`) value : Value to write to this field. """...
[ "def", "write_vcpu_struct_field", "(", "self", ",", "field_name", ",", "value", ",", "x", ",", "y", ",", "p", ")", ":", "field", ",", "address", ",", "pack_chars", "=", "self", ".", "_get_vcpu_field_and_address", "(", "field_name", ",", "x", ",", "y", ",...
Write a value to the VCPU struct for a specific core. Parameters ---------- field_name : string Name of the field to write (e.g. `"user0"`) value : Value to write to this field.
[ "Write", "a", "value", "to", "the", "VCPU", "struct", "for", "a", "specific", "core", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L805-L829
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_processor_status
def get_processor_status(self, p, x, y): """Get the status of a given core and the application executing on it. Returns ------- :py:class:`.ProcessorStatus` Representation of the current state of the processor. """ # Get the VCPU base address = (self....
python
def get_processor_status(self, p, x, y): """Get the status of a given core and the application executing on it. Returns ------- :py:class:`.ProcessorStatus` Representation of the current state of the processor. """ # Get the VCPU base address = (self....
[ "def", "get_processor_status", "(", "self", ",", "p", ",", "x", ",", "y", ")", ":", "# Get the VCPU base", "address", "=", "(", "self", ".", "read_struct_field", "(", "\"sv\"", ",", "\"vcpu_base\"", ",", "x", ",", "y", ")", "+", "self", ".", "structs", ...
Get the status of a given core and the application executing on it. Returns ------- :py:class:`.ProcessorStatus` Representation of the current state of the processor.
[ "Get", "the", "status", "of", "a", "given", "core", "and", "the", "application", "executing", "on", "it", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L832-L871
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_iobuf
def get_iobuf(self, p, x, y): """Read the messages ``io_printf``'d into the ``IOBUF`` buffer on a specified core. See also: :py:meth:`.get_iobuf_bytes` which returns the undecoded raw bytes in the ``IOBUF``. Useful if the IOBUF contains non-text or non-UTF-8 encoded text. ...
python
def get_iobuf(self, p, x, y): """Read the messages ``io_printf``'d into the ``IOBUF`` buffer on a specified core. See also: :py:meth:`.get_iobuf_bytes` which returns the undecoded raw bytes in the ``IOBUF``. Useful if the IOBUF contains non-text or non-UTF-8 encoded text. ...
[ "def", "get_iobuf", "(", "self", ",", "p", ",", "x", ",", "y", ")", ":", "return", "self", ".", "get_iobuf_bytes", "(", "p", ",", "x", ",", "y", ")", ".", "decode", "(", "\"utf-8\"", ")" ]
Read the messages ``io_printf``'d into the ``IOBUF`` buffer on a specified core. See also: :py:meth:`.get_iobuf_bytes` which returns the undecoded raw bytes in the ``IOBUF``. Useful if the IOBUF contains non-text or non-UTF-8 encoded text. Returns ------- str ...
[ "Read", "the", "messages", "io_printf", "d", "into", "the", "IOBUF", "buffer", "on", "a", "specified", "core", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L874-L887
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_iobuf_bytes
def get_iobuf_bytes(self, p, x, y): """Read raw bytes ``io_printf``'d into the ``IOBUF`` buffer on a specified core. This may be useful when the data contained in the ``IOBUF`` is not UTF-8 encoded text. See also: :py:meth:`.get_iobuf` which returns a decoded string rather ...
python
def get_iobuf_bytes(self, p, x, y): """Read raw bytes ``io_printf``'d into the ``IOBUF`` buffer on a specified core. This may be useful when the data contained in the ``IOBUF`` is not UTF-8 encoded text. See also: :py:meth:`.get_iobuf` which returns a decoded string rather ...
[ "def", "get_iobuf_bytes", "(", "self", ",", "p", ",", "x", ",", "y", ")", ":", "# The IOBUF data is stored in a linked-list of blocks of memory in", "# SDRAM. The size of each block is given in SV", "iobuf_size", "=", "self", ".", "read_struct_field", "(", "\"sv\"", ",", ...
Read raw bytes ``io_printf``'d into the ``IOBUF`` buffer on a specified core. This may be useful when the data contained in the ``IOBUF`` is not UTF-8 encoded text. See also: :py:meth:`.get_iobuf` which returns a decoded string rather than raw bytes. Returns --...
[ "Read", "raw", "bytes", "io_printf", "d", "into", "the", "IOBUF", "buffer", "on", "a", "specified", "core", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L890-L921
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_router_diagnostics
def get_router_diagnostics(self, x, y): """Get the values of the router diagnostic counters. Returns ------- :py:class:`~.RouterDiagnostics` Description of the state of the counters. """ # Read the block of memory data = self.read(0xe1000300, 64, x=x,...
python
def get_router_diagnostics(self, x, y): """Get the values of the router diagnostic counters. Returns ------- :py:class:`~.RouterDiagnostics` Description of the state of the counters. """ # Read the block of memory data = self.read(0xe1000300, 64, x=x,...
[ "def", "get_router_diagnostics", "(", "self", ",", "x", ",", "y", ")", ":", "# Read the block of memory", "data", "=", "self", ".", "read", "(", "0xe1000300", ",", "64", ",", "x", "=", "x", ",", "y", "=", "y", ")", "# Convert to 16 ints, then process that as...
Get the values of the router diagnostic counters. Returns ------- :py:class:`~.RouterDiagnostics` Description of the state of the counters.
[ "Get", "the", "values", "of", "the", "router", "diagnostic", "counters", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L924-L936
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.iptag_set
def iptag_set(self, iptag, addr, port, x, y): """Set the value of an IPTag. Forward SDP packets with the specified IP tag sent by a SpiNNaker application to a given external IP address. A :ref:`tutorial example <scp-and-sdp-tutorial>` of the use of IP Tags to send and receive S...
python
def iptag_set(self, iptag, addr, port, x, y): """Set the value of an IPTag. Forward SDP packets with the specified IP tag sent by a SpiNNaker application to a given external IP address. A :ref:`tutorial example <scp-and-sdp-tutorial>` of the use of IP Tags to send and receive S...
[ "def", "iptag_set", "(", "self", ",", "iptag", ",", "addr", ",", "port", ",", "x", ",", "y", ")", ":", "# Format the IP address", "ip_addr", "=", "struct", ".", "pack", "(", "'!4B'", ",", "*", "map", "(", "int", ",", "socket", ".", "gethostbyname", "...
Set the value of an IPTag. Forward SDP packets with the specified IP tag sent by a SpiNNaker application to a given external IP address. A :ref:`tutorial example <scp-and-sdp-tutorial>` of the use of IP Tags to send and receive SDP packets to and from applications is also avail...
[ "Set", "the", "value", "of", "an", "IPTag", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L939-L963
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.iptag_get
def iptag_get(self, iptag, x, y): """Get the value of an IPTag. Parameters ---------- iptag : int Index of the IPTag to get Returns ------- :py:class:`.IPTag` The IPTag returned from SpiNNaker. """ ack = self._send_scp(x, ...
python
def iptag_get(self, iptag, x, y): """Get the value of an IPTag. Parameters ---------- iptag : int Index of the IPTag to get Returns ------- :py:class:`.IPTag` The IPTag returned from SpiNNaker. """ ack = self._send_scp(x, ...
[ "def", "iptag_get", "(", "self", ",", "iptag", ",", "x", ",", "y", ")", ":", "ack", "=", "self", ".", "_send_scp", "(", "x", ",", "y", ",", "0", ",", "SCPCommands", ".", "iptag", ",", "int", "(", "consts", ".", "IPTagCommands", ".", "get", ")", ...
Get the value of an IPTag. Parameters ---------- iptag : int Index of the IPTag to get Returns ------- :py:class:`.IPTag` The IPTag returned from SpiNNaker.
[ "Get", "the", "value", "of", "an", "IPTag", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L966-L982
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.iptag_clear
def iptag_clear(self, iptag, x, y): """Clear an IPTag. Parameters ---------- iptag : int Index of the IPTag to clear. """ self._send_scp(x, y, 0, SCPCommands.iptag, int(consts.IPTagCommands.clear) << 16 | iptag)
python
def iptag_clear(self, iptag, x, y): """Clear an IPTag. Parameters ---------- iptag : int Index of the IPTag to clear. """ self._send_scp(x, y, 0, SCPCommands.iptag, int(consts.IPTagCommands.clear) << 16 | iptag)
[ "def", "iptag_clear", "(", "self", ",", "iptag", ",", "x", ",", "y", ")", ":", "self", ".", "_send_scp", "(", "x", ",", "y", ",", "0", ",", "SCPCommands", ".", "iptag", ",", "int", "(", "consts", ".", "IPTagCommands", ".", "clear", ")", "<<", "16...
Clear an IPTag. Parameters ---------- iptag : int Index of the IPTag to clear.
[ "Clear", "an", "IPTag", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L985-L994
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.set_led
def set_led(self, led, action=None, x=Required, y=Required): """Set or toggle the state of an LED. .. note:: By default, SARK takes control of LED 0 and so changes to this LED will not typically last long enough to be useful. Parameters ---------- led : ...
python
def set_led(self, led, action=None, x=Required, y=Required): """Set or toggle the state of an LED. .. note:: By default, SARK takes control of LED 0 and so changes to this LED will not typically last long enough to be useful. Parameters ---------- led : ...
[ "def", "set_led", "(", "self", ",", "led", ",", "action", "=", "None", ",", "x", "=", "Required", ",", "y", "=", "Required", ")", ":", "if", "isinstance", "(", "led", ",", "int", ")", ":", "leds", "=", "[", "led", "]", "else", ":", "leds", "=",...
Set or toggle the state of an LED. .. note:: By default, SARK takes control of LED 0 and so changes to this LED will not typically last long enough to be useful. Parameters ---------- led : int or iterable Number of the LED or an iterable of LEDs to ...
[ "Set", "or", "toggle", "the", "state", "of", "an", "LED", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L997-L1017
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.fill
def fill(self, address, data, size, x, y, p): """Fill a region of memory with the specified byte. Parameters ---------- data : int Data with which to fill memory. If `address` and `size` are word aligned then `data` is assumed to be a word; otherwise it is ...
python
def fill(self, address, data, size, x, y, p): """Fill a region of memory with the specified byte. Parameters ---------- data : int Data with which to fill memory. If `address` and `size` are word aligned then `data` is assumed to be a word; otherwise it is ...
[ "def", "fill", "(", "self", ",", "address", ",", "data", ",", "size", ",", "x", ",", "y", ",", "p", ")", ":", "if", "size", "%", "4", "or", "address", "%", "4", ":", "# If neither the size nor the address are word aligned we have to", "# use `write` as `sark_w...
Fill a region of memory with the specified byte. Parameters ---------- data : int Data with which to fill memory. If `address` and `size` are word aligned then `data` is assumed to be a word; otherwise it is assumed to be a byte. Notes ----- ...
[ "Fill", "a", "region", "of", "memory", "with", "the", "specified", "byte", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1020-L1043
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.sdram_alloc
def sdram_alloc(self, size, tag=0, x=Required, y=Required, app_id=Required, clear=False): """Allocate a region of SDRAM for an application. Requests SARK to allocate a block of SDRAM for an application and raises a :py:exc:`.SpiNNakerMemoryError` on failure. This allocation ...
python
def sdram_alloc(self, size, tag=0, x=Required, y=Required, app_id=Required, clear=False): """Allocate a region of SDRAM for an application. Requests SARK to allocate a block of SDRAM for an application and raises a :py:exc:`.SpiNNakerMemoryError` on failure. This allocation ...
[ "def", "sdram_alloc", "(", "self", ",", "size", ",", "tag", "=", "0", ",", "x", "=", "Required", ",", "y", "=", "Required", ",", "app_id", "=", "Required", ",", "clear", "=", "False", ")", ":", "assert", "0", "<=", "tag", "<", "256", "# Construct a...
Allocate a region of SDRAM for an application. Requests SARK to allocate a block of SDRAM for an application and raises a :py:exc:`.SpiNNakerMemoryError` on failure. This allocation will be freed when the application is stopped. Parameters ---------- size : int ...
[ "Allocate", "a", "region", "of", "SDRAM", "for", "an", "application", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1046-L1124
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.sdram_alloc_as_filelike
def sdram_alloc_as_filelike(self, size, tag=0, x=Required, y=Required, app_id=Required, clear=False): """Like :py:meth:`.sdram_alloc` but returns a :py:class:`file-like object <.MemoryIO>` which allows safe reading and writing to the block that is allocated. ...
python
def sdram_alloc_as_filelike(self, size, tag=0, x=Required, y=Required, app_id=Required, clear=False): """Like :py:meth:`.sdram_alloc` but returns a :py:class:`file-like object <.MemoryIO>` which allows safe reading and writing to the block that is allocated. ...
[ "def", "sdram_alloc_as_filelike", "(", "self", ",", "size", ",", "tag", "=", "0", ",", "x", "=", "Required", ",", "y", "=", "Required", ",", "app_id", "=", "Required", ",", "clear", "=", "False", ")", ":", "# Perform the malloc", "start_address", "=", "s...
Like :py:meth:`.sdram_alloc` but returns a :py:class:`file-like object <.MemoryIO>` which allows safe reading and writing to the block that is allocated. Returns ------- :py:class:`.MemoryIO` File-like object which allows accessing the newly allocated region ...
[ "Like", ":", "py", ":", "meth", ":", ".", "sdram_alloc", "but", "returns", "a", ":", "py", ":", "class", ":", "file", "-", "like", "object", "<", ".", "MemoryIO", ">", "which", "allows", "safe", "reading", "and", "writing", "to", "the", "block", "tha...
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1127-L1170
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.sdram_free
def sdram_free(self, ptr, x=Required, y=Required): """Free an allocated block of memory in SDRAM. .. note:: All unfreed SDRAM allocations associated with an application are automatically freed when the 'stop' signal is sent (e.g. after leaving a :py:meth:`.applicati...
python
def sdram_free(self, ptr, x=Required, y=Required): """Free an allocated block of memory in SDRAM. .. note:: All unfreed SDRAM allocations associated with an application are automatically freed when the 'stop' signal is sent (e.g. after leaving a :py:meth:`.applicati...
[ "def", "sdram_free", "(", "self", ",", "ptr", ",", "x", "=", "Required", ",", "y", "=", "Required", ")", ":", "self", ".", "_send_scp", "(", "x", ",", "y", ",", "0", ",", "SCPCommands", ".", "alloc_free", ",", "consts", ".", "AllocOperations", ".", ...
Free an allocated block of memory in SDRAM. .. note:: All unfreed SDRAM allocations associated with an application are automatically freed when the 'stop' signal is sent (e.g. after leaving a :py:meth:`.application` block). As such, this method is only useful wh...
[ "Free", "an", "allocated", "block", "of", "memory", "in", "SDRAM", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1173-L1190
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._get_next_nn_id
def _get_next_nn_id(self): """Get the next nearest neighbour ID.""" self._nn_id = self._nn_id + 1 if self._nn_id < 126 else 1 return self._nn_id * 2
python
def _get_next_nn_id(self): """Get the next nearest neighbour ID.""" self._nn_id = self._nn_id + 1 if self._nn_id < 126 else 1 return self._nn_id * 2
[ "def", "_get_next_nn_id", "(", "self", ")", ":", "self", ".", "_nn_id", "=", "self", ".", "_nn_id", "+", "1", "if", "self", ".", "_nn_id", "<", "126", "else", "1", "return", "self", ".", "_nn_id", "*", "2" ]
Get the next nearest neighbour ID.
[ "Get", "the", "next", "nearest", "neighbour", "ID", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1192-L1195
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._send_ffs
def _send_ffs(self, pid, n_blocks, fr): """Send a flood-fill start packet. The cores and regions that the application should be loaded to will be specified by a stream of flood-fill core select packets (FFCS). """ sfr = fr | (1 << 31) self._send_scp( 255, 255...
python
def _send_ffs(self, pid, n_blocks, fr): """Send a flood-fill start packet. The cores and regions that the application should be loaded to will be specified by a stream of flood-fill core select packets (FFCS). """ sfr = fr | (1 << 31) self._send_scp( 255, 255...
[ "def", "_send_ffs", "(", "self", ",", "pid", ",", "n_blocks", ",", "fr", ")", ":", "sfr", "=", "fr", "|", "(", "1", "<<", "31", ")", "self", ".", "_send_scp", "(", "255", ",", "255", ",", "0", ",", "SCPCommands", ".", "nearest_neighbour_packet", ",...
Send a flood-fill start packet. The cores and regions that the application should be loaded to will be specified by a stream of flood-fill core select packets (FFCS).
[ "Send", "a", "flood", "-", "fill", "start", "packet", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1197-L1208
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._send_ffcs
def _send_ffcs(self, region, core_mask, fr): """Send a flood-fill core select packet. This packet was added in a patched SC&MP 1.34*. Each packet includes a region and a core mask; every core that is in the region ORs the core mask with a mask it stores locally. On receiving a flood-fil...
python
def _send_ffcs(self, region, core_mask, fr): """Send a flood-fill core select packet. This packet was added in a patched SC&MP 1.34*. Each packet includes a region and a core mask; every core that is in the region ORs the core mask with a mask it stores locally. On receiving a flood-fil...
[ "def", "_send_ffcs", "(", "self", ",", "region", ",", "core_mask", ",", "fr", ")", ":", "arg1", "=", "(", "NNCommands", ".", "flood_fill_core_select", "<<", "24", ")", "|", "core_mask", "arg2", "=", "region", "self", ".", "_send_scp", "(", "255", ",", ...
Send a flood-fill core select packet. This packet was added in a patched SC&MP 1.34*. Each packet includes a region and a core mask; every core that is in the region ORs the core mask with a mask it stores locally. On receiving a flood-fill end (FFE) packet the application is loaded to ...
[ "Send", "a", "flood", "-", "fill", "core", "select", "packet", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1210-L1227
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._send_ffd
def _send_ffd(self, pid, aplx_data, address): """Send flood-fill data packets.""" block = 0 pos = 0 aplx_size = len(aplx_data) while pos < aplx_size: # Get the next block of data, send and progress the block # counter and the address data = ap...
python
def _send_ffd(self, pid, aplx_data, address): """Send flood-fill data packets.""" block = 0 pos = 0 aplx_size = len(aplx_data) while pos < aplx_size: # Get the next block of data, send and progress the block # counter and the address data = ap...
[ "def", "_send_ffd", "(", "self", ",", "pid", ",", "aplx_data", ",", "address", ")", ":", "block", "=", "0", "pos", "=", "0", "aplx_size", "=", "len", "(", "aplx_data", ")", "while", "pos", "<", "aplx_size", ":", "# Get the next block of data, send and progre...
Send flood-fill data packets.
[ "Send", "flood", "-", "fill", "data", "packets", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1229-L1250
project-rig/rig
rig/machine_control/machine_controller.py
MachineController._send_ffe
def _send_ffe(self, pid, app_id, app_flags, fr): """Send a flood-fill end packet. The cores and regions that the application should be loaded to will have been specified by a stream of flood-fill core select packets (FFCS). """ arg1 = (NNCommands.flood_fill_end << 24) | ...
python
def _send_ffe(self, pid, app_id, app_flags, fr): """Send a flood-fill end packet. The cores and regions that the application should be loaded to will have been specified by a stream of flood-fill core select packets (FFCS). """ arg1 = (NNCommands.flood_fill_end << 24) | ...
[ "def", "_send_ffe", "(", "self", ",", "pid", ",", "app_id", ",", "app_flags", ",", "fr", ")", ":", "arg1", "=", "(", "NNCommands", ".", "flood_fill_end", "<<", "24", ")", "|", "pid", "arg2", "=", "(", "app_id", "<<", "24", ")", "|", "(", "app_flags...
Send a flood-fill end packet. The cores and regions that the application should be loaded to will have been specified by a stream of flood-fill core select packets (FFCS).
[ "Send", "a", "flood", "-", "fill", "end", "packet", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1252-L1262
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.flood_fill_aplx
def flood_fill_aplx(self, *args, **kwargs): """Unreliably flood-fill APLX to a set of application cores. .. note:: Most users should use the :py:meth:`.load_application` wrapper around this method which guarantees successful loading. This method can be called in either...
python
def flood_fill_aplx(self, *args, **kwargs): """Unreliably flood-fill APLX to a set of application cores. .. note:: Most users should use the :py:meth:`.load_application` wrapper around this method which guarantees successful loading. This method can be called in either...
[ "def", "flood_fill_aplx", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Coerce the arguments into a single form. If there are two arguments", "# then assume that we have filename and a map of chips and cores;", "# otherwise there should be ONE argument which is ...
Unreliably flood-fill APLX to a set of application cores. .. note:: Most users should use the :py:meth:`.load_application` wrapper around this method which guarantees successful loading. This method can be called in either of the following ways:: flood_fill_aplx("...
[ "Unreliably", "flood", "-", "fill", "APLX", "to", "a", "set", "of", "application", "cores", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1265-L1368
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.load_application
def load_application(self, *args, **kwargs): """Load an application to a set of application cores. This method guarantees that once it returns, all required cores will have been loaded. If this is not possible after a small number of attempts, a :py:exc:`.SpiNNakerLoadingError` will be ...
python
def load_application(self, *args, **kwargs): """Load an application to a set of application cores. This method guarantees that once it returns, all required cores will have been loaded. If this is not possible after a small number of attempts, a :py:exc:`.SpiNNakerLoadingError` will be ...
[ "def", "load_application", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Get keyword arguments", "app_id", "=", "kwargs", ".", "pop", "(", "\"app_id\"", ")", "wait", "=", "kwargs", ".", "pop", "(", "\"wait\"", ")", "n_tries", "=", ...
Load an application to a set of application cores. This method guarantees that once it returns, all required cores will have been loaded. If this is not possible after a small number of attempts, a :py:exc:`.SpiNNakerLoadingError` will be raised. This method can be called in either of ...
[ "Load", "an", "application", "to", "a", "set", "of", "application", "cores", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1373-L1491
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.send_signal
def send_signal(self, signal, app_id): """Transmit a signal to applications. .. warning:: In current implementations of SARK, signals are highly likely to arrive but this is not guaranteed (especially when the system's network is heavily utilised). Users should treat...
python
def send_signal(self, signal, app_id): """Transmit a signal to applications. .. warning:: In current implementations of SARK, signals are highly likely to arrive but this is not guaranteed (especially when the system's network is heavily utilised). Users should treat...
[ "def", "send_signal", "(", "self", ",", "signal", ",", "app_id", ")", ":", "if", "isinstance", "(", "signal", ",", "str", ")", ":", "try", ":", "signal", "=", "getattr", "(", "consts", ".", "AppSignal", ",", "signal", ")", "except", "AttributeError", "...
Transmit a signal to applications. .. warning:: In current implementations of SARK, signals are highly likely to arrive but this is not guaranteed (especially when the system's network is heavily utilised). Users should treat this mechanism with caution. Future v...
[ "Transmit", "a", "signal", "to", "applications", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1494-L1528
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.count_cores_in_state
def count_cores_in_state(self, state, app_id): """Count the number of cores in a given state. .. warning:: In current implementations of SARK, signals (which are used to determine the state of cores) are highly likely to arrive but this is not guaranteed (especially ...
python
def count_cores_in_state(self, state, app_id): """Count the number of cores in a given state. .. warning:: In current implementations of SARK, signals (which are used to determine the state of cores) are highly likely to arrive but this is not guaranteed (especially ...
[ "def", "count_cores_in_state", "(", "self", ",", "state", ",", "app_id", ")", ":", "if", "(", "isinstance", "(", "state", ",", "collections", ".", "Iterable", ")", "and", "not", "isinstance", "(", "state", ",", "str", ")", ")", ":", "# If the state is iter...
Count the number of cores in a given state. .. warning:: In current implementations of SARK, signals (which are used to determine the state of cores) are highly likely to arrive but this is not guaranteed (especially when the system's network is heavily utilised)...
[ "Count", "the", "number", "of", "cores", "in", "a", "given", "state", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1531-L1587
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.wait_for_cores_to_reach_state
def wait_for_cores_to_reach_state(self, state, count, app_id, poll_interval=0.1, timeout=None): """Block until the specified number of cores reach the specified state. This is a simple utility-wrapper around the :py:meth:`.count_cores_in_state` method which...
python
def wait_for_cores_to_reach_state(self, state, count, app_id, poll_interval=0.1, timeout=None): """Block until the specified number of cores reach the specified state. This is a simple utility-wrapper around the :py:meth:`.count_cores_in_state` method which...
[ "def", "wait_for_cores_to_reach_state", "(", "self", ",", "state", ",", "count", ",", "app_id", ",", "poll_interval", "=", "0.1", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "not", "None", ":", "timeout_time", "=", "time", ".", "time", ...
Block until the specified number of cores reach the specified state. This is a simple utility-wrapper around the :py:meth:`.count_cores_in_state` method which polls the machine until (at least) the supplied number of cores has reached the specified state. .. warning:: ...
[ "Block", "until", "the", "specified", "number", "of", "cores", "reach", "the", "specified", "state", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1590-L1646
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.load_routing_tables
def load_routing_tables(self, routing_tables, app_id): """Allocate space for an load multicast routing tables. The routing table entries will be removed automatically when the associated application is stopped. Parameters ---------- routing_tables : {(x, y): \ ...
python
def load_routing_tables(self, routing_tables, app_id): """Allocate space for an load multicast routing tables. The routing table entries will be removed automatically when the associated application is stopped. Parameters ---------- routing_tables : {(x, y): \ ...
[ "def", "load_routing_tables", "(", "self", ",", "routing_tables", ",", "app_id", ")", ":", "for", "(", "x", ",", "y", ")", ",", "table", "in", "iteritems", "(", "routing_tables", ")", ":", "self", ".", "load_routing_table_entries", "(", "table", ",", "x", ...
Allocate space for an load multicast routing tables. The routing table entries will be removed automatically when the associated application is stopped. Parameters ---------- routing_tables : {(x, y): \ [:py:class:`~rig.routing_table.RoutingTableEntry`...
[ "Allocate", "space", "for", "an", "load", "multicast", "routing", "tables", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1649-L1671
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.load_routing_table_entries
def load_routing_table_entries(self, entries, x, y, app_id): """Allocate space for and load multicast routing table entries into the router of a SpiNNaker chip. .. note:: This method only loads routing table entries for a single chip. Most users should use :py:meth:`.loa...
python
def load_routing_table_entries(self, entries, x, y, app_id): """Allocate space for and load multicast routing table entries into the router of a SpiNNaker chip. .. note:: This method only loads routing table entries for a single chip. Most users should use :py:meth:`.loa...
[ "def", "load_routing_table_entries", "(", "self", ",", "entries", ",", "x", ",", "y", ",", "app_id", ")", ":", "count", "=", "len", "(", "entries", ")", "# Try to allocate room for the entries", "rv", "=", "self", ".", "_send_scp", "(", "x", ",", "y", ",",...
Allocate space for and load multicast routing table entries into the router of a SpiNNaker chip. .. note:: This method only loads routing table entries for a single chip. Most users should use :py:meth:`.load_routing_tables` which loads routing tables to multiple chi...
[ "Allocate", "space", "for", "and", "load", "multicast", "routing", "table", "entries", "into", "the", "router", "of", "a", "SpiNNaker", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1674-L1725
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_routing_table_entries
def get_routing_table_entries(self, x, y): """Dump the multicast routing table of a given chip. Returns ------- [(:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) \ or None, ...] Ordered list of routing table entries with app_ids and core...
python
def get_routing_table_entries(self, x, y): """Dump the multicast routing table of a given chip. Returns ------- [(:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) \ or None, ...] Ordered list of routing table entries with app_ids and core...
[ "def", "get_routing_table_entries", "(", "self", ",", "x", ",", "y", ")", ":", "# Determine where to read from, perform the read", "rtr_addr", "=", "self", ".", "read_struct_field", "(", "\"sv\"", ",", "\"rtr_copy\"", ",", "x", ",", "y", ")", "read_size", "=", "...
Dump the multicast routing table of a given chip. Returns ------- [(:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) \ or None, ...] Ordered list of routing table entries with app_ids and core numbers.
[ "Dump", "the", "multicast", "routing", "table", "of", "a", "given", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1728-L1748
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.clear_routing_table_entries
def clear_routing_table_entries(self, x, y, app_id): """Clear the routing table entries associated with a given application. """ # Construct the arguments arg1 = (app_id << 8) | consts.AllocOperations.free_rtr_by_app self._send_scp(x, y, 0, SCPCommands.alloc_free, arg1, 0x1)
python
def clear_routing_table_entries(self, x, y, app_id): """Clear the routing table entries associated with a given application. """ # Construct the arguments arg1 = (app_id << 8) | consts.AllocOperations.free_rtr_by_app self._send_scp(x, y, 0, SCPCommands.alloc_free, arg1, 0x1)
[ "def", "clear_routing_table_entries", "(", "self", ",", "x", ",", "y", ",", "app_id", ")", ":", "# Construct the arguments", "arg1", "=", "(", "app_id", "<<", "8", ")", "|", "consts", ".", "AllocOperations", ".", "free_rtr_by_app", "self", ".", "_send_scp", ...
Clear the routing table entries associated with a given application.
[ "Clear", "the", "routing", "table", "entries", "associated", "with", "a", "given", "application", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1751-L1756
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_p2p_routing_table
def get_p2p_routing_table(self, x, y): """Dump the contents of a chip's P2P routing table. This method can be indirectly used to get a list of functioning chips. .. note:: This method only returns the entries for chips within the bounds of the system. E.g. if booted wit...
python
def get_p2p_routing_table(self, x, y): """Dump the contents of a chip's P2P routing table. This method can be indirectly used to get a list of functioning chips. .. note:: This method only returns the entries for chips within the bounds of the system. E.g. if booted wit...
[ "def", "get_p2p_routing_table", "(", "self", ",", "x", ",", "y", ")", ":", "table", "=", "{", "}", "# Get the dimensions of the system", "p2p_dims", "=", "self", ".", "read_struct_field", "(", "\"sv\"", ",", "\"p2p_dims\"", ",", "x", ",", "y", ")", "width", ...
Dump the contents of a chip's P2P routing table. This method can be indirectly used to get a list of functioning chips. .. note:: This method only returns the entries for chips within the bounds of the system. E.g. if booted with 8x8 only entries for these 8x8 chips...
[ "Dump", "the", "contents", "of", "a", "chip", "s", "P2P", "routing", "table", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1759-L1800
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_chip_info
def get_chip_info(self, x, y): """Get general information about the resources available on a chip. Returns ------- :py:class:`.ChipInfo` A named tuple indicating the number of working cores, the states of all working cores, the set of working links and the size o...
python
def get_chip_info(self, x, y): """Get general information about the resources available on a chip. Returns ------- :py:class:`.ChipInfo` A named tuple indicating the number of working cores, the states of all working cores, the set of working links and the size o...
[ "def", "get_chip_info", "(", "self", ",", "x", ",", "y", ")", ":", "info", "=", "self", ".", "_send_scp", "(", "x", ",", "y", ",", "0", ",", "SCPCommands", ".", "info", ",", "expected_args", "=", "3", ")", "# Unpack values encoded in the argument fields", ...
Get general information about the resources available on a chip. Returns ------- :py:class:`.ChipInfo` A named tuple indicating the number of working cores, the states of all working cores, the set of working links and the size of the largest free block in SD...
[ "Get", "general", "information", "about", "the", "resources", "available", "on", "a", "chip", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1803-L1840
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_system_info
def get_system_info(self, x=255, y=255): """Discover the integrity and resource availability of a whole SpiNNaker system. This command performs :py:meth:`.get_chip_info` on all working chips in the system returning an enhanced :py:class:`dict` (:py:class:`.SystemInfo`) containin...
python
def get_system_info(self, x=255, y=255): """Discover the integrity and resource availability of a whole SpiNNaker system. This command performs :py:meth:`.get_chip_info` on all working chips in the system returning an enhanced :py:class:`dict` (:py:class:`.SystemInfo`) containin...
[ "def", "get_system_info", "(", "self", ",", "x", "=", "255", ",", "y", "=", "255", ")", ":", "# A quick way of getting a list of working chips", "p2p_tables", "=", "self", ".", "get_p2p_routing_table", "(", "x", ",", "y", ")", "# Calculate the extent of the system",...
Discover the integrity and resource availability of a whole SpiNNaker system. This command performs :py:meth:`.get_chip_info` on all working chips in the system returning an enhanced :py:class:`dict` (:py:class:`.SystemInfo`) containing a look-up from chip coordinate to :py:clas...
[ "Discover", "the", "integrity", "and", "resource", "availability", "of", "a", "whole", "SpiNNaker", "system", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1869-L1928
project-rig/rig
rig/machine_control/machine_controller.py
MachineController.get_machine
def get_machine(self, x=255, y=255, default_num_cores=18): """**Deprecated.** Probe the machine to discover which cores and links are working. .. warning:: This method has been deprecated in favour of :py:meth:`.get_system_info` for getting information about the ...
python
def get_machine(self, x=255, y=255, default_num_cores=18): """**Deprecated.** Probe the machine to discover which cores and links are working. .. warning:: This method has been deprecated in favour of :py:meth:`.get_system_info` for getting information about the ...
[ "def", "get_machine", "(", "self", ",", "x", "=", "255", ",", "y", "=", "255", ",", "default_num_cores", "=", "18", ")", ":", "warnings", ".", "warn", "(", "\"MachineController.get_machine() is deprecated, \"", "\"see get_system_info().\"", ",", "DeprecationWarning"...
**Deprecated.** Probe the machine to discover which cores and links are working. .. warning:: This method has been deprecated in favour of :py:meth:`.get_system_info` for getting information about the general resources available in a SpiNNaker machine. This method ma...
[ "**", "Deprecated", ".", "**", "Probe", "the", "machine", "to", "discover", "which", "cores", "and", "links", "are", "working", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1930-L1993
project-rig/rig
rig/machine_control/machine_controller.py
SystemInfo.ethernet_connected_chips
def ethernet_connected_chips(self): """Iterate over the coordinates of Ethernet connected chips. Yields ------ ((x, y), str) The coordinate and IP address of each Ethernet connected chip in the system. """ for xy, chip_info in six.iteritems(self):...
python
def ethernet_connected_chips(self): """Iterate over the coordinates of Ethernet connected chips. Yields ------ ((x, y), str) The coordinate and IP address of each Ethernet connected chip in the system. """ for xy, chip_info in six.iteritems(self):...
[ "def", "ethernet_connected_chips", "(", "self", ")", ":", "for", "xy", ",", "chip_info", "in", "six", ".", "iteritems", "(", "self", ")", ":", "if", "chip_info", ".", "ethernet_up", ":", "yield", "(", "xy", ",", "chip_info", ".", "ip_address", ")" ]
Iterate over the coordinates of Ethernet connected chips. Yields ------ ((x, y), str) The coordinate and IP address of each Ethernet connected chip in the system.
[ "Iterate", "over", "the", "coordinates", "of", "Ethernet", "connected", "chips", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2146-L2157
project-rig/rig
rig/machine_control/machine_controller.py
SystemInfo.dead_chips
def dead_chips(self): """Generate the coordinates of all dead chips. Yields ------ (x, y) The coordinate of a dead chip. """ for x in range(self.width): for y in range(self.height): if (x, y) not in self: yield ...
python
def dead_chips(self): """Generate the coordinates of all dead chips. Yields ------ (x, y) The coordinate of a dead chip. """ for x in range(self.width): for y in range(self.height): if (x, y) not in self: yield ...
[ "def", "dead_chips", "(", "self", ")", ":", "for", "x", "in", "range", "(", "self", ".", "width", ")", ":", "for", "y", "in", "range", "(", "self", ".", "height", ")", ":", "if", "(", "x", ",", "y", ")", "not", "in", "self", ":", "yield", "("...
Generate the coordinates of all dead chips. Yields ------ (x, y) The coordinate of a dead chip.
[ "Generate", "the", "coordinates", "of", "all", "dead", "chips", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2159-L2170
project-rig/rig
rig/machine_control/machine_controller.py
SystemInfo.links
def links(self): """Generate the coordinates of all working links. Yields ------ (x, y, :py:class:`rig.links.Links`) A working link leaving a chip from the perspective of the chip. For example ``(0, 0, Links.north)`` would be the link going north from ...
python
def links(self): """Generate the coordinates of all working links. Yields ------ (x, y, :py:class:`rig.links.Links`) A working link leaving a chip from the perspective of the chip. For example ``(0, 0, Links.north)`` would be the link going north from ...
[ "def", "links", "(", "self", ")", ":", "for", "(", "x", ",", "y", ")", ",", "chip_info", "in", "iteritems", "(", "self", ")", ":", "for", "link", "in", "chip_info", ".", "working_links", ":", "yield", "(", "x", ",", "y", ",", "link", ")" ]
Generate the coordinates of all working links. Yields ------ (x, y, :py:class:`rig.links.Links`) A working link leaving a chip from the perspective of the chip. For example ``(0, 0, Links.north)`` would be the link going north from chip (0, 0) to chip (0, 1).
[ "Generate", "the", "coordinates", "of", "all", "working", "links", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2172-L2184
project-rig/rig
rig/machine_control/machine_controller.py
SystemInfo.dead_links
def dead_links(self): """Generate the coordinates of all dead links leaving working chips. Any link leading to a dead chip will also be included in the list of dead links. In non-torroidal SpiNNaker sysmtes (e.g. single SpiNN-5 boards), links on the periphery of the system will be marke...
python
def dead_links(self): """Generate the coordinates of all dead links leaving working chips. Any link leading to a dead chip will also be included in the list of dead links. In non-torroidal SpiNNaker sysmtes (e.g. single SpiNN-5 boards), links on the periphery of the system will be marke...
[ "def", "dead_links", "(", "self", ")", ":", "for", "(", "x", ",", "y", ")", ",", "chip_info", "in", "iteritems", "(", "self", ")", ":", "for", "link", "in", "Links", ":", "if", "link", "not", "in", "chip_info", ".", "working_links", ":", "yield", "...
Generate the coordinates of all dead links leaving working chips. Any link leading to a dead chip will also be included in the list of dead links. In non-torroidal SpiNNaker sysmtes (e.g. single SpiNN-5 boards), links on the periphery of the system will be marked as dead. Yields ...
[ "Generate", "the", "coordinates", "of", "all", "dead", "links", "leaving", "working", "chips", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2186-L2203
project-rig/rig
rig/machine_control/machine_controller.py
SystemInfo.cores
def cores(self): """Generate the set of all cores in the system. Yields ------ (x, y, p, :py:class:`~rig.machine_control.consts.AppState`) A core in the machine, and its state. Cores related to a specific chip are yielded consecutively in ascending order of core ...
python
def cores(self): """Generate the set of all cores in the system. Yields ------ (x, y, p, :py:class:`~rig.machine_control.consts.AppState`) A core in the machine, and its state. Cores related to a specific chip are yielded consecutively in ascending order of core ...
[ "def", "cores", "(", "self", ")", ":", "for", "(", "x", ",", "y", ")", ",", "chip_info", "in", "iteritems", "(", "self", ")", ":", "for", "p", ",", "state", "in", "enumerate", "(", "chip_info", ".", "core_states", ")", ":", "yield", "(", "x", ","...
Generate the set of all cores in the system. Yields ------ (x, y, p, :py:class:`~rig.machine_control.consts.AppState`) A core in the machine, and its state. Cores related to a specific chip are yielded consecutively in ascending order of core number.
[ "Generate", "the", "set", "of", "all", "cores", "in", "the", "system", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2205-L2216
project-rig/rig
rig/machine_control/machine_controller.py
SlicedMemoryIO.read
def read(self, n_bytes=-1): """Read a number of bytes from the memory. .. note:: Reads beyond the specified memory range will be truncated. .. note:: Produces a :py:exc:`.TruncationWarning` if fewer bytes are read than requested. These warnings can be conver...
python
def read(self, n_bytes=-1): """Read a number of bytes from the memory. .. note:: Reads beyond the specified memory range will be truncated. .. note:: Produces a :py:exc:`.TruncationWarning` if fewer bytes are read than requested. These warnings can be conver...
[ "def", "read", "(", "self", ",", "n_bytes", "=", "-", "1", ")", ":", "# If n_bytes is negative then calculate it as the number of bytes left", "if", "n_bytes", "<", "0", ":", "n_bytes", "=", "self", ".", "_end_address", "-", "self", ".", "address", "# Determine ho...
Read a number of bytes from the memory. .. note:: Reads beyond the specified memory range will be truncated. .. note:: Produces a :py:exc:`.TruncationWarning` if fewer bytes are read than requested. These warnings can be converted into exceptions using :...
[ "Read", "a", "number", "of", "bytes", "from", "the", "memory", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2588-L2632