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
project-rig/rig
rig/scripts/rig_counters.py
press_enter
def press_enter(multiple=False, silent=False): """Return a generator function which yields every time the user presses return.""" def f(): try: while True: if silent: yield input() else: sys.stderr.write("<press ent...
python
def press_enter(multiple=False, silent=False): """Return a generator function which yields every time the user presses return.""" def f(): try: while True: if silent: yield input() else: sys.stderr.write("<press ent...
[ "def", "press_enter", "(", "multiple", "=", "False", ",", "silent", "=", "False", ")", ":", "def", "f", "(", ")", ":", "try", ":", "while", "True", ":", "if", "silent", ":", "yield", "input", "(", ")", "else", ":", "sys", ".", "stderr", ".", "wri...
Return a generator function which yields every time the user presses return.
[ "Return", "a", "generator", "function", "which", "yields", "every", "time", "the", "user", "presses", "return", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_counters.py#L78-L101
project-rig/rig
rig/machine_control/unbooted_ping.py
listen
def listen(timeout=6.0, port=BOOT_PORT): """Listen for a 'ping' broadcast message from an unbooted SpiNNaker board. Unbooted SpiNNaker boards send out a UDP broadcast message every 4-ish seconds on port 54321. This function listens for such messages and reports the IP address that it came from. Pa...
python
def listen(timeout=6.0, port=BOOT_PORT): """Listen for a 'ping' broadcast message from an unbooted SpiNNaker board. Unbooted SpiNNaker boards send out a UDP broadcast message every 4-ish seconds on port 54321. This function listens for such messages and reports the IP address that it came from. Pa...
[ "def", "listen", "(", "timeout", "=", "6.0", ",", "port", "=", "BOOT_PORT", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "# Don't take control of this socket in the system (i.e. allow other", ...
Listen for a 'ping' broadcast message from an unbooted SpiNNaker board. Unbooted SpiNNaker boards send out a UDP broadcast message every 4-ish seconds on port 54321. This function listens for such messages and reports the IP address that it came from. Parameters ---------- timeout : float ...
[ "Listen", "for", "a", "ping", "broadcast", "message", "from", "an", "unbooted", "SpiNNaker", "board", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/unbooted_ping.py#L8-L42
Metatab/metapack
metapack/cli/s3.py
clear_cache
def clear_cache(m, files_processed): """Remove any files we may have uploaded from the cache. """ for what, reason, url, path in files_processed: cp = m.doc.downloader.cache_path(url) if m.cache.exists(cp): m.cache.remove(cp)
python
def clear_cache(m, files_processed): """Remove any files we may have uploaded from the cache. """ for what, reason, url, path in files_processed: cp = m.doc.downloader.cache_path(url) if m.cache.exists(cp): m.cache.remove(cp)
[ "def", "clear_cache", "(", "m", ",", "files_processed", ")", ":", "for", "what", ",", "reason", ",", "url", ",", "path", "in", "files_processed", ":", "cp", "=", "m", ".", "doc", ".", "downloader", ".", "cache_path", "(", "url", ")", "if", "m", ".", ...
Remove any files we may have uploaded from the cache.
[ "Remove", "any", "files", "we", "may", "have", "uploaded", "from", "the", "cache", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/s3.py#L135-L142
Metatab/metapack
metapack/jupyter/magic.py
fill_categorical_na
def fill_categorical_na(df, nan_cat='NA'): """Fill categoricals with 'NA', possibly creating a new category, and fill other NaNa with blanks """ for col in df.columns[df.isna().any()].tolist(): if df[col].dtype.name != 'category': # If not categorical, fill with a blank, which creates a...
python
def fill_categorical_na(df, nan_cat='NA'): """Fill categoricals with 'NA', possibly creating a new category, and fill other NaNa with blanks """ for col in df.columns[df.isna().any()].tolist(): if df[col].dtype.name != 'category': # If not categorical, fill with a blank, which creates a...
[ "def", "fill_categorical_na", "(", "df", ",", "nan_cat", "=", "'NA'", ")", ":", "for", "col", "in", "df", ".", "columns", "[", "df", ".", "isna", "(", ")", ".", "any", "(", ")", "]", ".", "tolist", "(", ")", ":", "if", "df", "[", "col", "]", ...
Fill categoricals with 'NA', possibly creating a new category, and fill other NaNa with blanks
[ "Fill", "categoricals", "with", "NA", "possibly", "creating", "a", "new", "category", "and", "fill", "other", "NaNa", "with", "blanks" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/magic.py#L41-L59
boazmohar/pySparkUtils
pySparkUtils/utils.py
executor_ips
def executor_ips(sc): """ gets the unique ip addresses of the executors of the current application This uses the REST API of the status web UI on the driver (http://spark.apache.org/docs/latest/monitoring.html) :param sc: Spark context :return: set of ip addresses """ try: app_i...
python
def executor_ips(sc): """ gets the unique ip addresses of the executors of the current application This uses the REST API of the status web UI on the driver (http://spark.apache.org/docs/latest/monitoring.html) :param sc: Spark context :return: set of ip addresses """ try: app_i...
[ "def", "executor_ips", "(", "sc", ")", ":", "try", ":", "app_id", "=", "sc", ".", "applicationId", "except", "AttributeError", ":", "app_id", "=", "sc", ".", "getConf", "(", ")", ".", "get", "(", "'spark.app.id'", ")", "# for getting the url (see: https://gith...
gets the unique ip addresses of the executors of the current application This uses the REST API of the status web UI on the driver (http://spark.apache.org/docs/latest/monitoring.html) :param sc: Spark context :return: set of ip addresses
[ "gets", "the", "unique", "ip", "addresses", "of", "the", "executors", "of", "the", "current", "application", "This", "uses", "the", "REST", "API", "of", "the", "status", "web", "UI", "on", "the", "driver", "(", "http", ":", "//", "spark", ".", "apache", ...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L21-L45
boazmohar/pySparkUtils
pySparkUtils/utils.py
change
def change(sc=None, app_name='customSpark', master=None, wait='ips', min_cores=None, min_ips=None, timeout=30, refresh_rate=0.5, fail_on_timeout=False, **kwargs): """ Returns a new Spark Context (sc) object with added properties set :param sc: current SparkContext if None will create a new one ...
python
def change(sc=None, app_name='customSpark', master=None, wait='ips', min_cores=None, min_ips=None, timeout=30, refresh_rate=0.5, fail_on_timeout=False, **kwargs): """ Returns a new Spark Context (sc) object with added properties set :param sc: current SparkContext if None will create a new one ...
[ "def", "change", "(", "sc", "=", "None", ",", "app_name", "=", "'customSpark'", ",", "master", "=", "None", ",", "wait", "=", "'ips'", ",", "min_cores", "=", "None", ",", "min_ips", "=", "None", ",", "timeout", "=", "30", ",", "refresh_rate", "=", "0...
Returns a new Spark Context (sc) object with added properties set :param sc: current SparkContext if None will create a new one :param app_name: name of new spark app :param master: url to master, if None will get from current sc :param wait: when to return after asking for a new sc (or max of tim...
[ "Returns", "a", "new", "Spark", "Context", "(", "sc", ")", "object", "with", "added", "properties", "set", ":", "param", "sc", ":", "current", "SparkContext", "if", "None", "will", "create", "a", "new", "one", ":", "param", "app_name", ":", "name", "of",...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L48-L126
boazmohar/pySparkUtils
pySparkUtils/utils.py
fallback
def fallback(func): """ Decorator function for functions that handle spark context. If a function changes sc we might lose it if an error occurs in the function. In the event of an error this decorator will log the error but return sc. :param func: function to decorate :return: decorated func...
python
def fallback(func): """ Decorator function for functions that handle spark context. If a function changes sc we might lose it if an error occurs in the function. In the event of an error this decorator will log the error but return sc. :param func: function to decorate :return: decorated func...
[ "def", "fallback", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "dec", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "Exception", "a...
Decorator function for functions that handle spark context. If a function changes sc we might lose it if an error occurs in the function. In the event of an error this decorator will log the error but return sc. :param func: function to decorate :return: decorated function
[ "Decorator", "function", "for", "functions", "that", "handle", "spark", "context", ".", "If", "a", "function", "changes", "sc", "we", "might", "lose", "it", "if", "an", "error", "occurs", "in", "the", "function", ".", "In", "the", "event", "of", "an", "e...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L129-L153
boazmohar/pySparkUtils
pySparkUtils/utils.py
thunder_decorator
def thunder_decorator(func): """ Decorator for functions so they could get as input a thunder.Images / thunder.Series object, while they are expecting an rdd. Also will return the data from rdd to the appropriate type Assumes only one input object of type Images/Series, and up to one output object of typ...
python
def thunder_decorator(func): """ Decorator for functions so they could get as input a thunder.Images / thunder.Series object, while they are expecting an rdd. Also will return the data from rdd to the appropriate type Assumes only one input object of type Images/Series, and up to one output object of typ...
[ "def", "thunder_decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "dec", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# find Images / Series object in args\r", "result", "=", "None", "args", "=", "list", "(", "args", ")",...
Decorator for functions so they could get as input a thunder.Images / thunder.Series object, while they are expecting an rdd. Also will return the data from rdd to the appropriate type Assumes only one input object of type Images/Series, and up to one output object of type RDD :param func: function to ...
[ "Decorator", "for", "functions", "so", "they", "could", "get", "as", "input", "a", "thunder", ".", "Images", "/", "thunder", ".", "Series", "object", "while", "they", "are", "expecting", "an", "rdd", ".", "Also", "will", "return", "the", "data", "from", ...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L156-L251
boazmohar/pySparkUtils
pySparkUtils/utils.py
balanced_repartition
def balanced_repartition(data, partitions): """ balanced_repartition(data, partitions) Reparations an RDD making sure data is evenly distributed across partitions for Spark version < 2.1 (see: https://issues.apache.org/jira/browse/SPARK-17817) or < 2.3 when #partitions is power of 2 (see: https://is...
python
def balanced_repartition(data, partitions): """ balanced_repartition(data, partitions) Reparations an RDD making sure data is evenly distributed across partitions for Spark version < 2.1 (see: https://issues.apache.org/jira/browse/SPARK-17817) or < 2.3 when #partitions is power of 2 (see: https://is...
[ "def", "balanced_repartition", "(", "data", ",", "partitions", ")", ":", "def", "repartition", "(", "data_inner", ",", "partitions_inner", ")", ":", "# repartition by zipping an index to the data, repartition by % on it and removing it\r", "data_inner", "=", "data_inner", "."...
balanced_repartition(data, partitions) Reparations an RDD making sure data is evenly distributed across partitions for Spark version < 2.1 (see: https://issues.apache.org/jira/browse/SPARK-17817) or < 2.3 when #partitions is power of 2 (see: https://issues.apache.org/jira/browse/SPARK-21782) :para...
[ "balanced_repartition", "(", "data", "partitions", ")", "Reparations", "an", "RDD", "making", "sure", "data", "is", "evenly", "distributed", "across", "partitions", "for", "Spark", "version", "<", "2", ".", "1", "(", "see", ":", "https", ":", "//", "issues",...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L255-L275
boazmohar/pySparkUtils
pySparkUtils/utils.py
regroup
def regroup(rdd, groups=10, check_first=False): """ Regroup an rdd using a new key added that is 0 ... number of groups - 1 :param rdd: input rdd as a (k,v) pairs :param groups: number of groups to concatenate to :param check_first: check if first value is a key value pair. :return: a new rdd...
python
def regroup(rdd, groups=10, check_first=False): """ Regroup an rdd using a new key added that is 0 ... number of groups - 1 :param rdd: input rdd as a (k,v) pairs :param groups: number of groups to concatenate to :param check_first: check if first value is a key value pair. :return: a new rdd...
[ "def", "regroup", "(", "rdd", ",", "groups", "=", "10", ",", "check_first", "=", "False", ")", ":", "if", "check_first", ":", "first", "=", "rdd", ".", "first", "(", ")", "if", "isinstance", "(", "first", ",", "(", "list", ",", "tuple", ",", "colle...
Regroup an rdd using a new key added that is 0 ... number of groups - 1 :param rdd: input rdd as a (k,v) pairs :param groups: number of groups to concatenate to :param check_first: check if first value is a key value pair. :return: a new rdd in the form of (groupNum, list of (k, v) in that group) ...
[ "Regroup", "an", "rdd", "using", "a", "new", "key", "added", "that", "is", "0", "...", "number", "of", "groups", "-", "1", ":", "param", "rdd", ":", "input", "rdd", "as", "a", "(", "k", "v", ")", "pairs", ":", "param", "groups", ":", "number", "o...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L279-L305
boazmohar/pySparkUtils
pySparkUtils/utils.py
save_rdd_as_pickle
def save_rdd_as_pickle(rdd, path, batch_size=10, overwrite=False): """ Saves an rdd by grouping all the records of each partition as one pickle file :param rdd: rdd to save :param path: where to save :param batch_size: batch size to pass to spark saveAsPickleFile :param overwrite: if director...
python
def save_rdd_as_pickle(rdd, path, batch_size=10, overwrite=False): """ Saves an rdd by grouping all the records of each partition as one pickle file :param rdd: rdd to save :param path: where to save :param batch_size: batch size to pass to spark saveAsPickleFile :param overwrite: if director...
[ "def", "save_rdd_as_pickle", "(", "rdd", ",", "path", ",", "batch_size", "=", "10", ",", "overwrite", "=", "False", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "overwrite", ":", "logging", ".", "getLogger", "(", "'py...
Saves an rdd by grouping all the records of each partition as one pickle file :param rdd: rdd to save :param path: where to save :param batch_size: batch size to pass to spark saveAsPickleFile :param overwrite: if directory exist whether to overwrite
[ "Saves", "an", "rdd", "by", "grouping", "all", "the", "records", "of", "each", "partition", "as", "one", "pickle", "file", ":", "param", "rdd", ":", "rdd", "to", "save", ":", "param", "path", ":", "where", "to", "save", ":", "param", "batch_size", ":",...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L309-L328
boazmohar/pySparkUtils
pySparkUtils/utils.py
load_rdd_from_pickle
def load_rdd_from_pickle(sc, path, min_partitions=None, return_type='images'): """ Loads an rdd that was saved as one pickle file per partition :param sc: Spark Context :param path: directory to load from :param min_partitions: minimum number of partitions. If None will be sc.defaultParallelism ...
python
def load_rdd_from_pickle(sc, path, min_partitions=None, return_type='images'): """ Loads an rdd that was saved as one pickle file per partition :param sc: Spark Context :param path: directory to load from :param min_partitions: minimum number of partitions. If None will be sc.defaultParallelism ...
[ "def", "load_rdd_from_pickle", "(", "sc", ",", "path", ",", "min_partitions", "=", "None", ",", "return_type", "=", "'images'", ")", ":", "if", "min_partitions", "is", "None", ":", "min_partitions", "=", "sc", ".", "defaultParallelism", "rdd", "=", "sc", "."...
Loads an rdd that was saved as one pickle file per partition :param sc: Spark Context :param path: directory to load from :param min_partitions: minimum number of partitions. If None will be sc.defaultParallelism :param return_type: what to return: 'rdd' - RDD 'images' - Thunder ...
[ "Loads", "an", "rdd", "that", "was", "saved", "as", "one", "pickle", "file", "per", "partition", ":", "param", "sc", ":", "Spark", "Context", ":", "param", "path", ":", "directory", "to", "load", "from", ":", "param", "min_partitions", ":", "minimum", "n...
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/utils.py#L331-L357
Metatab/metapack
metapack/jupyter/pandas.py
MetatabDataFrame.geo
def geo(self): """Return a geopandas dataframe""" import geopandas as gpd from shapely.geometry.polygon import BaseGeometry from shapely.wkt import loads gdf = gpd.GeoDataFrame(self) first = next(gdf.iterrows())[1].geometry if isinstance(first, str): ...
python
def geo(self): """Return a geopandas dataframe""" import geopandas as gpd from shapely.geometry.polygon import BaseGeometry from shapely.wkt import loads gdf = gpd.GeoDataFrame(self) first = next(gdf.iterrows())[1].geometry if isinstance(first, str): ...
[ "def", "geo", "(", "self", ")", ":", "import", "geopandas", "as", "gpd", "from", "shapely", ".", "geometry", ".", "polygon", "import", "BaseGeometry", "from", "shapely", ".", "wkt", "import", "loads", "gdf", "=", "gpd", ".", "GeoDataFrame", "(", "self", ...
Return a geopandas dataframe
[ "Return", "a", "geopandas", "dataframe" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/pandas.py#L51-L79
Metatab/metapack
metapack/jupyter/pandas.py
MetatabDataFrame.rows
def rows(self): """Yield rows like a partition does, with a header first, then rows. """ yield [self.index.name] + list(self.columns) for t in self.itertuples(): yield list(t)
python
def rows(self): """Yield rows like a partition does, with a header first, then rows. """ yield [self.index.name] + list(self.columns) for t in self.itertuples(): yield list(t)
[ "def", "rows", "(", "self", ")", ":", "yield", "[", "self", ".", "index", ".", "name", "]", "+", "list", "(", "self", ".", "columns", ")", "for", "t", "in", "self", ".", "itertuples", "(", ")", ":", "yield", "list", "(", "t", ")" ]
Yield rows like a partition does, with a header first, then rows.
[ "Yield", "rows", "like", "a", "partition", "does", "with", "a", "header", "first", "then", "rows", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/pandas.py#L128-L134
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
_matches_node_set_props
def _matches_node_set_props(type_info, node_set_props): """ Check whether the node_set properties match the given model type definition """ matches = None for key in node_set_props: ns_val = node_set_props[key] if key in type_info: if ns_val==type_info[key]: ...
python
def _matches_node_set_props(type_info, node_set_props): """ Check whether the node_set properties match the given model type definition """ matches = None for key in node_set_props: ns_val = node_set_props[key] if key in type_info: if ns_val==type_info[key]: ...
[ "def", "_matches_node_set_props", "(", "type_info", ",", "node_set_props", ")", ":", "matches", "=", "None", "for", "key", "in", "node_set_props", ":", "ns_val", "=", "node_set_props", "[", "key", "]", "if", "key", "in", "type_info", ":", "if", "ns_val", "==...
Check whether the node_set properties match the given model type definition
[ "Check", "whether", "the", "node_set", "properties", "match", "the", "given", "model", "type", "definition" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L62-L77
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
get_neuroml_from_sonata
def get_neuroml_from_sonata(sonata_filename, id, generate_lems = True, format='xml'): """ Return a NeuroMLDocument with (most of) the contents of the Sonata model """ from neuroml.hdf5.NetworkBuilder import NetworkBuilder neuroml_handler = NetworkBuilder() sr = SonataReader(filename=s...
python
def get_neuroml_from_sonata(sonata_filename, id, generate_lems = True, format='xml'): """ Return a NeuroMLDocument with (most of) the contents of the Sonata model """ from neuroml.hdf5.NetworkBuilder import NetworkBuilder neuroml_handler = NetworkBuilder() sr = SonataReader(filename=s...
[ "def", "get_neuroml_from_sonata", "(", "sonata_filename", ",", "id", ",", "generate_lems", "=", "True", ",", "format", "=", "'xml'", ")", ":", "from", "neuroml", ".", "hdf5", ".", "NetworkBuilder", "import", "NetworkBuilder", "neuroml_handler", "=", "NetworkBuilde...
Return a NeuroMLDocument with (most of) the contents of the Sonata model
[ "Return", "a", "NeuroMLDocument", "with", "(", "most", "of", ")", "the", "contents", "of", "the", "Sonata", "model" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L901-L934
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
SonataReader.subs
def subs(self, path): """ Search the strings in a config file for a substitutable value, e.g. "morphologies_dir": "$COMPONENT_DIR/morphologies", """ #print_v('Checking for: \n %s, \n %s \n in %s'%(self.substitutes,self.init_substitutes,path)) if type(path) == ...
python
def subs(self, path): """ Search the strings in a config file for a substitutable value, e.g. "morphologies_dir": "$COMPONENT_DIR/morphologies", """ #print_v('Checking for: \n %s, \n %s \n in %s'%(self.substitutes,self.init_substitutes,path)) if type(path) == ...
[ "def", "subs", "(", "self", ",", "path", ")", ":", "#print_v('Checking for: \\n %s, \\n %s \\n in %s'%(self.substitutes,self.init_substitutes,path))", "if", "type", "(", "path", ")", "==", "int", "or", "type", "(", "path", ")", "==", "float", ":", "return", "path...
Search the strings in a config file for a substitutable value, e.g. "morphologies_dir": "$COMPONENT_DIR/morphologies",
[ "Search", "the", "strings", "in", "a", "config", "file", "for", "a", "substitutable", "value", "e", ".", "g", ".", "morphologies_dir", ":", "$COMPONENT_DIR", "/", "morphologies" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L117-L133
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
SonataReader.parse
def parse(self, handler): """ Main method to parse the Sonata files and call the appropriate methods in the handler """ ######################################################################## # load the main configuration scripts main_config_filename =...
python
def parse(self, handler): """ Main method to parse the Sonata files and call the appropriate methods in the handler """ ######################################################################## # load the main configuration scripts main_config_filename =...
[ "def", "parse", "(", "self", ",", "handler", ")", ":", "########################################################################", "# load the main configuration scripts ", "main_config_filename", "=", "os", ".", "path", ".", "abspath", "(", "self", ".", "parameters", "...
Main method to parse the Sonata files and call the appropriate methods in the handler
[ "Main", "method", "to", "parse", "the", "Sonata", "files", "and", "call", "the", "appropriate", "methods", "in", "the", "handler" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L136-L606
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
SonataReader.add_neuroml_components
def add_neuroml_components(self, nml_doc): """ Based on cell & synapse properties found, create the corresponding NeuroML components """ is_nest = False print_v("Adding NeuroML cells to: %s"%nml_doc.id) #pp.pprint(self.pop_comp_info) for c in...
python
def add_neuroml_components(self, nml_doc): """ Based on cell & synapse properties found, create the corresponding NeuroML components """ is_nest = False print_v("Adding NeuroML cells to: %s"%nml_doc.id) #pp.pprint(self.pop_comp_info) for c in...
[ "def", "add_neuroml_components", "(", "self", ",", "nml_doc", ")", ":", "is_nest", "=", "False", "print_v", "(", "\"Adding NeuroML cells to: %s\"", "%", "nml_doc", ".", "id", ")", "#pp.pprint(self.pop_comp_info)", "for", "c", "in", "self", ".", "pop_comp_info", ":...
Based on cell & synapse properties found, create the corresponding NeuroML components
[ "Based", "on", "cell", "&", "synapse", "properties", "found", "create", "the", "corresponding", "NeuroML", "components" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L699-L831
NeuroML/NeuroMLlite
neuromllite/SonataReader.py
SonataReader.generate_lems_file
def generate_lems_file(self, nml_file_name, nml_doc): """ Generate a LEMS file to use in simulations of the NeuroML file """ #pp.pprint(self.simulation_config) #pp.pprint(self.pop_comp_info) #pp.pprint(self.node_set_mappings) if 'output' in s...
python
def generate_lems_file(self, nml_file_name, nml_doc): """ Generate a LEMS file to use in simulations of the NeuroML file """ #pp.pprint(self.simulation_config) #pp.pprint(self.pop_comp_info) #pp.pprint(self.node_set_mappings) if 'output' in s...
[ "def", "generate_lems_file", "(", "self", ",", "nml_file_name", ",", "nml_doc", ")", ":", "#pp.pprint(self.simulation_config)", "#pp.pprint(self.pop_comp_info)", "#pp.pprint(self.node_set_mappings)", "if", "'output'", "in", "self", ".", "simulation_config", ":", "gen_spike_sa...
Generate a LEMS file to use in simulations of the NeuroML file
[ "Generate", "a", "LEMS", "file", "to", "use", "in", "simulations", "of", "the", "NeuroML", "file" ]
train
https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/SonataReader.py#L834-L898
ungarj/tilematrix
tilematrix/_funcs.py
clip_geometry_to_srs_bounds
def clip_geometry_to_srs_bounds(geometry, pyramid, multipart=False): """ Clip input geometry to SRS bounds of given TilePyramid. If geometry passes the antimeridian, it will be split up in a multipart geometry and shifted to within the SRS boundaries. Note: geometry SRS must be the TilePyramid SRS!...
python
def clip_geometry_to_srs_bounds(geometry, pyramid, multipart=False): """ Clip input geometry to SRS bounds of given TilePyramid. If geometry passes the antimeridian, it will be split up in a multipart geometry and shifted to within the SRS boundaries. Note: geometry SRS must be the TilePyramid SRS!...
[ "def", "clip_geometry_to_srs_bounds", "(", "geometry", ",", "pyramid", ",", "multipart", "=", "False", ")", ":", "if", "not", "geometry", ".", "is_valid", ":", "raise", "ValueError", "(", "\"invalid geometry given\"", ")", "pyramid_bbox", "=", "box", "(", "*", ...
Clip input geometry to SRS bounds of given TilePyramid. If geometry passes the antimeridian, it will be split up in a multipart geometry and shifted to within the SRS boundaries. Note: geometry SRS must be the TilePyramid SRS! - geometry: any shapely geometry - pyramid: a TilePyramid object - ...
[ "Clip", "input", "geometry", "to", "SRS", "bounds", "of", "given", "TilePyramid", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L19-L60
ungarj/tilematrix
tilematrix/_funcs.py
snap_bounds
def snap_bounds(bounds=None, tile_pyramid=None, zoom=None, pixelbuffer=0): """ Extend bounds to be aligned with union of tile bboxes. - bounds: (left, bottom, right, top) - tile_pyramid: a TilePyramid object - zoom: target zoom level - pixelbuffer: apply pixelbuffer """ bounds = Bounds(...
python
def snap_bounds(bounds=None, tile_pyramid=None, zoom=None, pixelbuffer=0): """ Extend bounds to be aligned with union of tile bboxes. - bounds: (left, bottom, right, top) - tile_pyramid: a TilePyramid object - zoom: target zoom level - pixelbuffer: apply pixelbuffer """ bounds = Bounds(...
[ "def", "snap_bounds", "(", "bounds", "=", "None", ",", "tile_pyramid", "=", "None", ",", "zoom", "=", "None", ",", "pixelbuffer", "=", "0", ")", ":", "bounds", "=", "Bounds", "(", "*", "bounds", ")", "validate_zoom", "(", "zoom", ")", "lb", "=", "_ti...
Extend bounds to be aligned with union of tile bboxes. - bounds: (left, bottom, right, top) - tile_pyramid: a TilePyramid object - zoom: target zoom level - pixelbuffer: apply pixelbuffer
[ "Extend", "bounds", "to", "be", "aligned", "with", "union", "of", "tile", "bboxes", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L63-L78
ungarj/tilematrix
tilematrix/_funcs.py
_verify_shape_bounds
def _verify_shape_bounds(shape, bounds): """Verify that shape corresponds to bounds apect ratio.""" if not isinstance(shape, (tuple, list)) or len(shape) != 2: raise TypeError( "shape must be a tuple or list with two elements: %s" % str(shape) ) if not isinstance(bounds, (tuple, ...
python
def _verify_shape_bounds(shape, bounds): """Verify that shape corresponds to bounds apect ratio.""" if not isinstance(shape, (tuple, list)) or len(shape) != 2: raise TypeError( "shape must be a tuple or list with two elements: %s" % str(shape) ) if not isinstance(bounds, (tuple, ...
[ "def", "_verify_shape_bounds", "(", "shape", ",", "bounds", ")", ":", "if", "not", "isinstance", "(", "shape", ",", "(", "tuple", ",", "list", ")", ")", "or", "len", "(", "shape", ")", "!=", "2", ":", "raise", "TypeError", "(", "\"shape must be a tuple o...
Verify that shape corresponds to bounds apect ratio.
[ "Verify", "that", "shape", "corresponds", "to", "bounds", "apect", "ratio", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L81-L110
ungarj/tilematrix
tilematrix/_funcs.py
_tile_intersecting_tilepyramid
def _tile_intersecting_tilepyramid(tile, tp): """Return all tiles from tilepyramid intersecting with tile.""" if tile.tp.grid != tp.grid: raise ValueError("Tile and TilePyramid source grids must be the same.") tile_metatiling = tile.tile_pyramid.metatiling pyramid_metatiling = tp.metatiling ...
python
def _tile_intersecting_tilepyramid(tile, tp): """Return all tiles from tilepyramid intersecting with tile.""" if tile.tp.grid != tp.grid: raise ValueError("Tile and TilePyramid source grids must be the same.") tile_metatiling = tile.tile_pyramid.metatiling pyramid_metatiling = tp.metatiling ...
[ "def", "_tile_intersecting_tilepyramid", "(", "tile", ",", "tp", ")", ":", "if", "tile", ".", "tp", ".", "grid", "!=", "tp", ".", "grid", ":", "raise", "ValueError", "(", "\"Tile and TilePyramid source grids must be the same.\"", ")", "tile_metatiling", "=", "tile...
Return all tiles from tilepyramid intersecting with tile.
[ "Return", "all", "tiles", "from", "tilepyramid", "intersecting", "with", "tile", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L126-L149
ungarj/tilematrix
tilematrix/_funcs.py
_global_tiles_from_bounds
def _global_tiles_from_bounds(tp, bounds, zoom): """Return also Tiles if bounds cross the antimeridian.""" seen = set() # clip to tilepyramid top and bottom bounds left, right = bounds.left, bounds.right top = tp.top if bounds.top > tp.top else bounds.top bottom = tp.bottom if bounds.bottom < t...
python
def _global_tiles_from_bounds(tp, bounds, zoom): """Return also Tiles if bounds cross the antimeridian.""" seen = set() # clip to tilepyramid top and bottom bounds left, right = bounds.left, bounds.right top = tp.top if bounds.top > tp.top else bounds.top bottom = tp.bottom if bounds.bottom < t...
[ "def", "_global_tiles_from_bounds", "(", "tp", ",", "bounds", ",", "zoom", ")", ":", "seen", "=", "set", "(", ")", "# clip to tilepyramid top and bottom bounds", "left", ",", "right", "=", "bounds", ".", "left", ",", "bounds", ".", "right", "top", "=", "tp",...
Return also Tiles if bounds cross the antimeridian.
[ "Return", "also", "Tiles", "if", "bounds", "cross", "the", "antimeridian", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L152-L201
ungarj/tilematrix
tilematrix/_funcs.py
_tiles_from_cleaned_bounds
def _tiles_from_cleaned_bounds(tp, bounds, zoom): """Return all tiles intersecting with bounds.""" lb = _tile_from_xy(tp, bounds.left, bounds.bottom, zoom, on_edge_use="rt") rt = _tile_from_xy(tp, bounds.right, bounds.top, zoom, on_edge_use="lb") for tile_id in product([zoom], range(rt.row, lb.row + 1),...
python
def _tiles_from_cleaned_bounds(tp, bounds, zoom): """Return all tiles intersecting with bounds.""" lb = _tile_from_xy(tp, bounds.left, bounds.bottom, zoom, on_edge_use="rt") rt = _tile_from_xy(tp, bounds.right, bounds.top, zoom, on_edge_use="lb") for tile_id in product([zoom], range(rt.row, lb.row + 1),...
[ "def", "_tiles_from_cleaned_bounds", "(", "tp", ",", "bounds", ",", "zoom", ")", ":", "lb", "=", "_tile_from_xy", "(", "tp", ",", "bounds", ".", "left", ",", "bounds", ".", "bottom", ",", "zoom", ",", "on_edge_use", "=", "\"rt\"", ")", "rt", "=", "_til...
Return all tiles intersecting with bounds.
[ "Return", "all", "tiles", "intersecting", "with", "bounds", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_funcs.py#L204-L209
Metatab/metapack
metapack/cli/open.py
open_args
def open_args(subparsers): """ The `mp open` command will open a resource with the system application, such as Excel or OpenOffice """ parser = subparsers.add_parser( 'open', help='open a CSV resoruce with a system application', description=open_args.__doc__, formatter_c...
python
def open_args(subparsers): """ The `mp open` command will open a resource with the system application, such as Excel or OpenOffice """ parser = subparsers.add_parser( 'open', help='open a CSV resoruce with a system application', description=open_args.__doc__, formatter_c...
[ "def", "open_args", "(", "subparsers", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'open'", ",", "help", "=", "'open a CSV resoruce with a system application'", ",", "description", "=", "open_args", ".", "__doc__", ",", "formatter_class", "=", ...
The `mp open` command will open a resource with the system application, such as Excel or OpenOffice
[ "The", "mp", "open", "command", "will", "open", "a", "resource", "with", "the", "system", "application", "such", "as", "Excel", "or", "OpenOffice" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/open.py#L23-L40
project-rig/rig
rig/place_and_route/route/ner.py
memoized_concentric_hexagons
def memoized_concentric_hexagons(radius): """A memoized wrapper around :py:func:`rig.geometry.concentric_hexagons` which memoizes the coordinates and stores them as a tuple. Note that the caller must manually offset the coordinates as required. This wrapper is used to avoid the need to repeatedly call ...
python
def memoized_concentric_hexagons(radius): """A memoized wrapper around :py:func:`rig.geometry.concentric_hexagons` which memoizes the coordinates and stores them as a tuple. Note that the caller must manually offset the coordinates as required. This wrapper is used to avoid the need to repeatedly call ...
[ "def", "memoized_concentric_hexagons", "(", "radius", ")", ":", "out", "=", "_concentric_hexagons", ".", "get", "(", "radius", ")", "if", "out", "is", "None", ":", "out", "=", "tuple", "(", "concentric_hexagons", "(", "radius", ")", ")", "_concentric_hexagons"...
A memoized wrapper around :py:func:`rig.geometry.concentric_hexagons` which memoizes the coordinates and stores them as a tuple. Note that the caller must manually offset the coordinates as required. This wrapper is used to avoid the need to repeatedly call :py:func:`rig.geometry.concentric_hexagons` f...
[ "A", "memoized", "wrapper", "around", ":", "py", ":", "func", ":", "rig", ".", "geometry", ".", "concentric_hexagons", "which", "memoizes", "the", "coordinates", "and", "stores", "them", "as", "a", "tuple", ".", "Note", "that", "the", "caller", "must", "ma...
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L38-L52
project-rig/rig
rig/place_and_route/route/ner.py
ner_net
def ner_net(source, destinations, width, height, wrap_around=False, radius=10): """Produce a shortest path tree for a given net using NER. This is the kernel of the NER algorithm. Parameters ---------- source : (x, y) The coordinate of the source vertex. destinations : iterable([(x, y)...
python
def ner_net(source, destinations, width, height, wrap_around=False, radius=10): """Produce a shortest path tree for a given net using NER. This is the kernel of the NER algorithm. Parameters ---------- source : (x, y) The coordinate of the source vertex. destinations : iterable([(x, y)...
[ "def", "ner_net", "(", "source", ",", "destinations", ",", "width", ",", "height", ",", "wrap_around", "=", "False", ",", "radius", "=", "10", ")", ":", "# Map from (x, y) to RoutingTree objects", "route", "=", "{", "source", ":", "RoutingTree", "(", "source",...
Produce a shortest path tree for a given net using NER. This is the kernel of the NER algorithm. Parameters ---------- source : (x, y) The coordinate of the source vertex. destinations : iterable([(x, y), ...]) The coordinates of destination vertices. width : int Width ...
[ "Produce", "a", "shortest", "path", "tree", "for", "a", "given", "net", "using", "NER", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L55-L228
project-rig/rig
rig/place_and_route/route/ner.py
copy_and_disconnect_tree
def copy_and_disconnect_tree(root, machine): """Copy a RoutingTree (containing nothing but RoutingTrees), disconnecting nodes which are not connected in the machine. Note that if a dead chip is part of the input RoutingTree, no corresponding node will be included in the copy. The assumption behind this...
python
def copy_and_disconnect_tree(root, machine): """Copy a RoutingTree (containing nothing but RoutingTrees), disconnecting nodes which are not connected in the machine. Note that if a dead chip is part of the input RoutingTree, no corresponding node will be included in the copy. The assumption behind this...
[ "def", "copy_and_disconnect_tree", "(", "root", ",", "machine", ")", ":", "new_root", "=", "None", "# Lookup for copied routing tree {(x, y): RoutingTree, ...}", "new_lookup", "=", "{", "}", "# List of missing connections in the copied routing tree [(new_parent,", "# new_child), .....
Copy a RoutingTree (containing nothing but RoutingTrees), disconnecting nodes which are not connected in the machine. Note that if a dead chip is part of the input RoutingTree, no corresponding node will be included in the copy. The assumption behind this is that the only reason a tree would visit a de...
[ "Copy", "a", "RoutingTree", "(", "containing", "nothing", "but", "RoutingTrees", ")", "disconnecting", "nodes", "which", "are", "not", "connected", "in", "the", "machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L231-L306
project-rig/rig
rig/place_and_route/route/ner.py
a_star
def a_star(sink, heuristic_source, sources, machine, wrap_around): """Use A* to find a path from any of the sources to the sink. Note that the heuristic means that the search will proceed towards heuristic_source without any concern for any other sources. This means that the algorithm may miss a very c...
python
def a_star(sink, heuristic_source, sources, machine, wrap_around): """Use A* to find a path from any of the sources to the sink. Note that the heuristic means that the search will proceed towards heuristic_source without any concern for any other sources. This means that the algorithm may miss a very c...
[ "def", "a_star", "(", "sink", ",", "heuristic_source", ",", "sources", ",", "machine", ",", "wrap_around", ")", ":", "# Select the heuristic function to use for distances", "if", "wrap_around", ":", "heuristic", "=", "(", "lambda", "node", ":", "shortest_torus_path_le...
Use A* to find a path from any of the sources to the sink. Note that the heuristic means that the search will proceed towards heuristic_source without any concern for any other sources. This means that the algorithm may miss a very close neighbour in order to pursue its goal of reaching heuristic_sourc...
[ "Use", "A", "*", "to", "find", "a", "path", "from", "any", "of", "the", "sources", "to", "the", "sink", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L309-L410
project-rig/rig
rig/place_and_route/route/ner.py
route_has_dead_links
def route_has_dead_links(root, machine): """Quickly determine if a route uses any dead links. Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingTree` The root of the RoutingTree which contains nothing but RoutingTrees (i.e. no vertices and links). mach...
python
def route_has_dead_links(root, machine): """Quickly determine if a route uses any dead links. Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingTree` The root of the RoutingTree which contains nothing but RoutingTrees (i.e. no vertices and links). mach...
[ "def", "route_has_dead_links", "(", "root", ",", "machine", ")", ":", "for", "direction", ",", "(", "x", ",", "y", ")", ",", "routes", "in", "root", ".", "traverse", "(", ")", ":", "for", "route", "in", "routes", ":", "if", "(", "x", ",", "y", ",...
Quickly determine if a route uses any dead links. Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingTree` The root of the RoutingTree which contains nothing but RoutingTrees (i.e. no vertices and links). machine : :py:class:`~rig.place_and_route.Machine` ...
[ "Quickly", "determine", "if", "a", "route", "uses", "any", "dead", "links", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L413-L433
project-rig/rig
rig/place_and_route/route/ner.py
avoid_dead_links
def avoid_dead_links(root, machine, wrap_around=False): """Modify a RoutingTree to route-around dead links in a Machine. Uses A* to reconnect disconnected branches of the tree (due to dead links in the machine). Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingT...
python
def avoid_dead_links(root, machine, wrap_around=False): """Modify a RoutingTree to route-around dead links in a Machine. Uses A* to reconnect disconnected branches of the tree (due to dead links in the machine). Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingT...
[ "def", "avoid_dead_links", "(", "root", ",", "machine", ",", "wrap_around", "=", "False", ")", ":", "# Make a copy of the RoutingTree with all broken parts disconnected", "root", ",", "lookup", ",", "broken_links", "=", "copy_and_disconnect_tree", "(", "root", ",", "mac...
Modify a RoutingTree to route-around dead links in a Machine. Uses A* to reconnect disconnected branches of the tree (due to dead links in the machine). Parameters ---------- root : :py:class:`~rig.place_and_route.routing_tree.RoutingTree` The root of the RoutingTree which contains nothing...
[ "Modify", "a", "RoutingTree", "to", "route", "-", "around", "dead", "links", "in", "a", "Machine", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L436-L514
project-rig/rig
rig/place_and_route/route/ner.py
route
def route(vertices_resources, nets, machine, constraints, placements, allocations={}, core_resource=Cores, radius=20): """Routing algorithm based on Neighbour Exploring Routing (NER). Algorithm refrence: J. Navaridas et al. SpiNNaker: Enhanced multicast routing, Parallel Computing (2014). htt...
python
def route(vertices_resources, nets, machine, constraints, placements, allocations={}, core_resource=Cores, radius=20): """Routing algorithm based on Neighbour Exploring Routing (NER). Algorithm refrence: J. Navaridas et al. SpiNNaker: Enhanced multicast routing, Parallel Computing (2014). htt...
[ "def", "route", "(", "vertices_resources", ",", "nets", ",", "machine", ",", "constraints", ",", "placements", ",", "allocations", "=", "{", "}", ",", "core_resource", "=", "Cores", ",", "radius", "=", "20", ")", ":", "wrap_around", "=", "machine", ".", ...
Routing algorithm based on Neighbour Exploring Routing (NER). Algorithm refrence: J. Navaridas et al. SpiNNaker: Enhanced multicast routing, Parallel Computing (2014). http://dx.doi.org/10.1016/j.parco.2015.01.002 This algorithm attempts to use NER to generate routing trees for all nets and routes...
[ "Routing", "algorithm", "based", "on", "Neighbour", "Exploring", "Routing", "(", "NER", ")", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L517-L577
project-rig/rig
rig/scripts/rig_ps.py
match
def match(string, patterns): """Given a string return true if it matches the supplied list of patterns. Parameters ---------- string : str The string to be matched. patterns : None or [pattern, ...] The series of regular expressions to attempt to match. """ if patterns i...
python
def match(string, patterns): """Given a string return true if it matches the supplied list of patterns. Parameters ---------- string : str The string to be matched. patterns : None or [pattern, ...] The series of regular expressions to attempt to match. """ if patterns i...
[ "def", "match", "(", "string", ",", "patterns", ")", ":", "if", "patterns", "is", "None", ":", "return", "True", "else", ":", "return", "any", "(", "re", ".", "match", "(", "pattern", ",", "string", ")", "for", "pattern", "in", "patterns", ")" ]
Given a string return true if it matches the supplied list of patterns. Parameters ---------- string : str The string to be matched. patterns : None or [pattern, ...] The series of regular expressions to attempt to match.
[ "Given", "a", "string", "return", "true", "if", "it", "matches", "the", "supplied", "list", "of", "patterns", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_ps.py#L21-L36
project-rig/rig
rig/scripts/rig_ps.py
get_process_list
def get_process_list(mc, x_=None, y_=None, p_=None, app_ids=None, applications=None, states=None): """Scan a SpiNNaker system's cores filtering by the specified features. Generates ------- (x, y, core, state, runtime_exception, application, app_id) """ system_info = mc.get...
python
def get_process_list(mc, x_=None, y_=None, p_=None, app_ids=None, applications=None, states=None): """Scan a SpiNNaker system's cores filtering by the specified features. Generates ------- (x, y, core, state, runtime_exception, application, app_id) """ system_info = mc.get...
[ "def", "get_process_list", "(", "mc", ",", "x_", "=", "None", ",", "y_", "=", "None", ",", "p_", "=", "None", ",", "app_ids", "=", "None", ",", "applications", "=", "None", ",", "states", "=", "None", ")", ":", "system_info", "=", "mc", ".", "get_s...
Scan a SpiNNaker system's cores filtering by the specified features. Generates ------- (x, y, core, state, runtime_exception, application, app_id)
[ "Scan", "a", "SpiNNaker", "system", "s", "cores", "filtering", "by", "the", "specified", "features", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_ps.py#L39-L77
project-rig/rig
rig/place_and_route/utils.py
build_machine
def build_machine(system_info, core_resource=Cores, sdram_resource=SDRAM, sram_resource=SRAM): """Build a :py:class:`~rig.place_and_route.Machine` object from a :py:class:`~rig.machine_control.machine_controller.SystemInfo` object. .. note:: Lin...
python
def build_machine(system_info, core_resource=Cores, sdram_resource=SDRAM, sram_resource=SRAM): """Build a :py:class:`~rig.place_and_route.Machine` object from a :py:class:`~rig.machine_control.machine_controller.SystemInfo` object. .. note:: Lin...
[ "def", "build_machine", "(", "system_info", ",", "core_resource", "=", "Cores", ",", "sdram_resource", "=", "SDRAM", ",", "sram_resource", "=", "SRAM", ")", ":", "try", ":", "max_cores", "=", "max", "(", "c", ".", "num_cores", "for", "c", "in", "itervalues...
Build a :py:class:`~rig.place_and_route.Machine` object from a :py:class:`~rig.machine_control.machine_controller.SystemInfo` object. .. note:: Links are tested by sending a 'PEEK' command down the link which checks to see if the remote device responds correctly. If the link is dead, no...
[ "Build", "a", ":", "py", ":", "class", ":", "~rig", ".", "place_and_route", ".", "Machine", "object", "from", "a", ":", "py", ":", "class", ":", "~rig", ".", "machine_control", ".", "machine_controller", ".", "SystemInfo", "object", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/utils.py#L18-L116
project-rig/rig
rig/place_and_route/utils.py
_get_minimal_core_reservations
def _get_minimal_core_reservations(core_resource, cores, chip=None): """Yield a minimal set of :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` objects which reserve the specified set of cores. Parameters ---------- core_resource : resource type The type of resourc...
python
def _get_minimal_core_reservations(core_resource, cores, chip=None): """Yield a minimal set of :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` objects which reserve the specified set of cores. Parameters ---------- core_resource : resource type The type of resourc...
[ "def", "_get_minimal_core_reservations", "(", "core_resource", ",", "cores", ",", "chip", "=", "None", ")", ":", "reservation", "=", "None", "# Cores is in ascending order", "for", "core", "in", "cores", ":", "if", "reservation", "is", "None", ":", "reservation", ...
Yield a minimal set of :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` objects which reserve the specified set of cores. Parameters ---------- core_resource : resource type The type of resource representing cores. cores : [int, ...] The core numbers to res...
[ "Yield", "a", "minimal", "set", "of", ":", "py", ":", "class", ":", "~rig", ".", "place_and_route", ".", "constraints", ".", "ReserveResourceConstraint", "objects", "which", "reserve", "the", "specified", "set", "of", "cores", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/utils.py#L119-L152
project-rig/rig
rig/place_and_route/utils.py
build_core_constraints
def build_core_constraints(system_info, core_resource=Cores): """Return a set of place-and-route :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` which reserve any cores that that are already in use. The returned list of :py:class:`~rig.place_and_route.constraints.ReserveResou...
python
def build_core_constraints(system_info, core_resource=Cores): """Return a set of place-and-route :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` which reserve any cores that that are already in use. The returned list of :py:class:`~rig.place_and_route.constraints.ReserveResou...
[ "def", "build_core_constraints", "(", "system_info", ",", "core_resource", "=", "Cores", ")", ":", "constraints", "=", "[", "]", "# Find the set of cores which are universally reserved", "globally_reserved", "=", "None", "for", "chip_info", "in", "itervalues", "(", "sys...
Return a set of place-and-route :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint` which reserve any cores that that are already in use. The returned list of :py:class:`~rig.place_and_route.constraints.ReserveResourceConstraint`\ s reserves all cores not in an Idle state (i.e. n...
[ "Return", "a", "set", "of", "place", "-", "and", "-", "route", ":", "py", ":", "class", ":", "~rig", ".", "place_and_route", ".", "constraints", ".", "ReserveResourceConstraint", "which", "reserve", "any", "cores", "that", "that", "are", "already", "in", "...
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/utils.py#L155-L219
project-rig/rig
rig/place_and_route/utils.py
build_application_map
def build_application_map(vertices_applications, placements, allocations, core_resource=Cores): """Build a mapping from application to a list of cores where the application is used. This utility function assumes that each vertex is associated with a specific application. ...
python
def build_application_map(vertices_applications, placements, allocations, core_resource=Cores): """Build a mapping from application to a list of cores where the application is used. This utility function assumes that each vertex is associated with a specific application. ...
[ "def", "build_application_map", "(", "vertices_applications", ",", "placements", ",", "allocations", ",", "core_resource", "=", "Cores", ")", ":", "application_map", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "set", ")", ")", "for", "vertex", ",...
Build a mapping from application to a list of cores where the application is used. This utility function assumes that each vertex is associated with a specific application. Parameters ---------- vertices_applications : {vertex: application, ...} Applications are represented by the path...
[ "Build", "a", "mapping", "from", "application", "to", "a", "list", "of", "cores", "where", "the", "application", "is", "used", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/utils.py#L222-L253
project-rig/rig
rig/place_and_route/utils.py
build_routing_tables
def build_routing_tables(routes, net_keys, omit_default_routes=True): """**DEPRECATED** Convert a set of RoutingTrees into a per-chip set of routing tables. .. warning:: This method has been deprecated in favour of :py:meth:`rig.routing_table.routing_tree_to_tables` and :py:meth:`ri...
python
def build_routing_tables(routes, net_keys, omit_default_routes=True): """**DEPRECATED** Convert a set of RoutingTrees into a per-chip set of routing tables. .. warning:: This method has been deprecated in favour of :py:meth:`rig.routing_table.routing_tree_to_tables` and :py:meth:`ri...
[ "def", "build_routing_tables", "(", "routes", ",", "net_keys", ",", "omit_default_routes", "=", "True", ")", ":", "from", "rig", ".", "routing_table", "import", "routing_tree_to_tables", ",", "remove_default_routes", "warnings", ".", "warn", "(", "\"build_routing_tabl...
**DEPRECATED** Convert a set of RoutingTrees into a per-chip set of routing tables. .. warning:: This method has been deprecated in favour of :py:meth:`rig.routing_table.routing_tree_to_tables` and :py:meth:`rig.routing_table.minimise`. E.g. most applications should use somethi...
[ "**", "DEPRECATED", "**", "Convert", "a", "set", "of", "RoutingTrees", "into", "a", "per", "-", "chip", "set", "of", "routing", "tables", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/utils.py#L256-L330
NicolasLM/spinach
spinach/contrib/sentry.py
register_sentry
def register_sentry(raven_client, namespace: Optional[str]=None, send_retries: bool=False): """Register the Sentry integration. Exceptions making jobs fail are sent to Sentry. :param raven_client: configured Raven client used to sent errors to Sentry :param namespace: optionally on...
python
def register_sentry(raven_client, namespace: Optional[str]=None, send_retries: bool=False): """Register the Sentry integration. Exceptions making jobs fail are sent to Sentry. :param raven_client: configured Raven client used to sent errors to Sentry :param namespace: optionally on...
[ "def", "register_sentry", "(", "raven_client", ",", "namespace", ":", "Optional", "[", "str", "]", "=", "None", ",", "send_retries", ":", "bool", "=", "False", ")", ":", "@", "signals", ".", "job_started", ".", "connect_via", "(", "namespace", ")", "def", ...
Register the Sentry integration. Exceptions making jobs fail are sent to Sentry. :param raven_client: configured Raven client used to sent errors to Sentry :param namespace: optionally only register the Sentry integration for a particular Spinach :class:`Engine` :param send_retries: whether...
[ "Register", "the", "Sentry", "integration", "." ]
train
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/contrib/sentry.py#L6-L40
Metatab/metapack
metapack/cli/url.py
add_resource
def add_resource(mt_file, ref, cache): """Add a resources entry, downloading the intuiting the file, replacing entries with the same reference""" if isinstance(mt_file, MetapackDoc): doc = mt_file else: doc = MetapackDoc(mt_file) if not 'Resources' in doc: doc.new_section('...
python
def add_resource(mt_file, ref, cache): """Add a resources entry, downloading the intuiting the file, replacing entries with the same reference""" if isinstance(mt_file, MetapackDoc): doc = mt_file else: doc = MetapackDoc(mt_file) if not 'Resources' in doc: doc.new_section('...
[ "def", "add_resource", "(", "mt_file", ",", "ref", ",", "cache", ")", ":", "if", "isinstance", "(", "mt_file", ",", "MetapackDoc", ")", ":", "doc", "=", "mt_file", "else", ":", "doc", "=", "MetapackDoc", "(", "mt_file", ")", "if", "not", "'Resources'", ...
Add a resources entry, downloading the intuiting the file, replacing entries with the same reference
[ "Add", "a", "resources", "entry", "downloading", "the", "intuiting", "the", "file", "replacing", "entries", "with", "the", "same", "reference" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/url.py#L92-L130
ungarj/tilematrix
tilematrix/_tile.py
Tile.bounds
def bounds(self, pixelbuffer=0): """ Return Tile boundaries. - pixelbuffer: tile buffer in pixels """ left = self._left bottom = self._bottom right = self._right top = self._top if pixelbuffer: offset = self.pixel_x_size * float(pixelb...
python
def bounds(self, pixelbuffer=0): """ Return Tile boundaries. - pixelbuffer: tile buffer in pixels """ left = self._left bottom = self._bottom right = self._right top = self._top if pixelbuffer: offset = self.pixel_x_size * float(pixelb...
[ "def", "bounds", "(", "self", ",", "pixelbuffer", "=", "0", ")", ":", "left", "=", "self", ".", "_left", "bottom", "=", "self", ".", "_bottom", "right", "=", "self", ".", "_right", "top", "=", "self", ".", "_top", "if", "pixelbuffer", ":", "offset", ...
Return Tile boundaries. - pixelbuffer: tile buffer in pixels
[ "Return", "Tile", "boundaries", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L93-L113
ungarj/tilematrix
tilematrix/_tile.py
Tile.affine
def affine(self, pixelbuffer=0): """ Return an Affine object of tile. - pixelbuffer: tile buffer in pixels """ return Affine( self.pixel_x_size, 0, self.bounds(pixelbuffer).left, 0, -self.pixel_y_size, self....
python
def affine(self, pixelbuffer=0): """ Return an Affine object of tile. - pixelbuffer: tile buffer in pixels """ return Affine( self.pixel_x_size, 0, self.bounds(pixelbuffer).left, 0, -self.pixel_y_size, self....
[ "def", "affine", "(", "self", ",", "pixelbuffer", "=", "0", ")", ":", "return", "Affine", "(", "self", ".", "pixel_x_size", ",", "0", ",", "self", ".", "bounds", "(", "pixelbuffer", ")", ".", "left", ",", "0", ",", "-", "self", ".", "pixel_y_size", ...
Return an Affine object of tile. - pixelbuffer: tile buffer in pixels
[ "Return", "an", "Affine", "object", "of", "tile", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L123-L136
ungarj/tilematrix
tilematrix/_tile.py
Tile.shape
def shape(self, pixelbuffer=0): """ Return a tuple of tile height and width. - pixelbuffer: tile buffer in pixels """ # apply pixelbuffers height = self._base_shape.height + 2 * pixelbuffer width = self._base_shape.width + 2 * pixelbuffer if pixelbuffer a...
python
def shape(self, pixelbuffer=0): """ Return a tuple of tile height and width. - pixelbuffer: tile buffer in pixels """ # apply pixelbuffers height = self._base_shape.height + 2 * pixelbuffer width = self._base_shape.width + 2 * pixelbuffer if pixelbuffer a...
[ "def", "shape", "(", "self", ",", "pixelbuffer", "=", "0", ")", ":", "# apply pixelbuffers", "height", "=", "self", ".", "_base_shape", ".", "height", "+", "2", "*", "pixelbuffer", "width", "=", "self", ".", "_base_shape", ".", "width", "+", "2", "*", ...
Return a tuple of tile height and width. - pixelbuffer: tile buffer in pixels
[ "Return", "a", "tuple", "of", "tile", "height", "and", "width", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L138-L154
ungarj/tilematrix
tilematrix/_tile.py
Tile.is_valid
def is_valid(self): """Return True if tile is available in tile pyramid.""" if not all([ isinstance(self.zoom, int), self.zoom >= 0, isinstance(self.row, int), self.row >= 0, isinstance(self.col, int), self.col >= 0 ]): ...
python
def is_valid(self): """Return True if tile is available in tile pyramid.""" if not all([ isinstance(self.zoom, int), self.zoom >= 0, isinstance(self.row, int), self.row >= 0, isinstance(self.col, int), self.col >= 0 ]): ...
[ "def", "is_valid", "(", "self", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "self", ".", "zoom", ",", "int", ")", ",", "self", ".", "zoom", ">=", "0", ",", "isinstance", "(", "self", ".", "row", ",", "int", ")", ",", "self", ".",...
Return True if tile is available in tile pyramid.
[ "Return", "True", "if", "tile", "is", "available", "in", "tile", "pyramid", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L156-L173
ungarj/tilematrix
tilematrix/_tile.py
Tile.get_parent
def get_parent(self): """Return tile from previous zoom level.""" return None if self.zoom == 0 else self.tile_pyramid.tile( self.zoom - 1, self.row // 2, self.col // 2 )
python
def get_parent(self): """Return tile from previous zoom level.""" return None if self.zoom == 0 else self.tile_pyramid.tile( self.zoom - 1, self.row // 2, self.col // 2 )
[ "def", "get_parent", "(", "self", ")", ":", "return", "None", "if", "self", ".", "zoom", "==", "0", "else", "self", ".", "tile_pyramid", ".", "tile", "(", "self", ".", "zoom", "-", "1", ",", "self", ".", "row", "//", "2", ",", "self", ".", "col",...
Return tile from previous zoom level.
[ "Return", "tile", "from", "previous", "zoom", "level", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L175-L179
ungarj/tilematrix
tilematrix/_tile.py
Tile.get_children
def get_children(self): """Return tiles from next zoom level.""" next_zoom = self.zoom + 1 return [ self.tile_pyramid.tile( next_zoom, self.row * 2 + row_offset, self.col * 2 + col_offset ) for row_offset, col_of...
python
def get_children(self): """Return tiles from next zoom level.""" next_zoom = self.zoom + 1 return [ self.tile_pyramid.tile( next_zoom, self.row * 2 + row_offset, self.col * 2 + col_offset ) for row_offset, col_of...
[ "def", "get_children", "(", "self", ")", ":", "next_zoom", "=", "self", ".", "zoom", "+", "1", "return", "[", "self", ".", "tile_pyramid", ".", "tile", "(", "next_zoom", ",", "self", ".", "row", "*", "2", "+", "row_offset", ",", "self", ".", "col", ...
Return tiles from next zoom level.
[ "Return", "tiles", "from", "next", "zoom", "level", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L181-L200
ungarj/tilematrix
tilematrix/_tile.py
Tile.get_neighbors
def get_neighbors(self, connectedness=8): """ Return tile neighbors. Tile neighbors are unique, i.e. in some edge cases, where both the left and right neighbor wrapped around the antimeridian is the same. Also, neighbors ouside the northern and southern TilePyramid boundaries ar...
python
def get_neighbors(self, connectedness=8): """ Return tile neighbors. Tile neighbors are unique, i.e. in some edge cases, where both the left and right neighbor wrapped around the antimeridian is the same. Also, neighbors ouside the northern and southern TilePyramid boundaries ar...
[ "def", "get_neighbors", "(", "self", ",", "connectedness", "=", "8", ")", ":", "if", "connectedness", "not", "in", "[", "4", ",", "8", "]", ":", "raise", "ValueError", "(", "\"only connectedness values 8 or 4 are allowed\"", ")", "unique_neighbors", "=", "{", ...
Return tile neighbors. Tile neighbors are unique, i.e. in some edge cases, where both the left and right neighbor wrapped around the antimeridian is the same. Also, neighbors ouside the northern and southern TilePyramid boundaries are excluded, because they are invalid. -------...
[ "Return", "tile", "neighbors", "." ]
train
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tile.py#L202-L263
project-rig/rig
rig/bitfield.py
BitField.add_field
def add_field(self, identifier, length=None, start_at=None, tags=None): """Add a new field to the BitField. If any existing fields' values are set, the newly created field will become a child of those fields. This means that this field will exist only when the parent fields' values are ...
python
def add_field(self, identifier, length=None, start_at=None, tags=None): """Add a new field to the BitField. If any existing fields' values are set, the newly created field will become a child of those fields. This means that this field will exist only when the parent fields' values are ...
[ "def", "add_field", "(", "self", ",", "identifier", ",", "length", "=", "None", ",", "start_at", "=", "None", ",", "tags", "=", "None", ")", ":", "# Check for zero-length fields", "if", "length", "is", "not", "None", "and", "length", "<=", "0", ":", "rai...
Add a new field to the BitField. If any existing fields' values are set, the newly created field will become a child of those fields. This means that this field will exist only when the parent fields' values are set as they are currently. Parameters ---------- identifie...
[ "Add", "a", "new", "field", "to", "the", "BitField", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L81-L189
project-rig/rig
rig/bitfield.py
BitField.get_value
def get_value(self, tag=None, field=None): """Generate an integer whose bits are set according to the values of fields in this bit field. All other bits are set to zero. Parameters ---------- tag : str Optionally specifies that the value should only include fields wi...
python
def get_value(self, tag=None, field=None): """Generate an integer whose bits are set according to the values of fields in this bit field. All other bits are set to zero. Parameters ---------- tag : str Optionally specifies that the value should only include fields wi...
[ "def", "get_value", "(", "self", ",", "tag", "=", "None", ",", "field", "=", "None", ")", ":", "assert", "not", "(", "tag", "is", "not", "None", "and", "field", "is", "not", "None", ")", ",", "\"Cannot filter by tag and field simultaneously.\"", "selected_fi...
Generate an integer whose bits are set according to the values of fields in this bit field. All other bits are set to zero. Parameters ---------- tag : str Optionally specifies that the value should only include fields with the specified tag. field : str ...
[ "Generate", "an", "integer", "whose", "bits", "are", "set", "according", "to", "the", "values", "of", "fields", "in", "this", "bit", "field", ".", "All", "other", "bits", "are", "set", "to", "zero", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L260-L307
project-rig/rig
rig/bitfield.py
BitField.get_mask
def get_mask(self, tag=None, field=None): """Get the mask for all fields which exist in the current bit field. Parameters ---------- tag : str Optionally specifies that the mask should only include fields with the specified tag. field : str Op...
python
def get_mask(self, tag=None, field=None): """Get the mask for all fields which exist in the current bit field. Parameters ---------- tag : str Optionally specifies that the mask should only include fields with the specified tag. field : str Op...
[ "def", "get_mask", "(", "self", ",", "tag", "=", "None", ",", "field", "=", "None", ")", ":", "if", "tag", "is", "not", "None", "and", "field", "is", "not", "None", ":", "raise", "TypeError", "(", "\"get_mask() takes exactly one keyword argument, \"", "\"eit...
Get the mask for all fields which exist in the current bit field. Parameters ---------- tag : str Optionally specifies that the mask should only include fields with the specified tag. field : str Optionally specifies that the mask should only include ...
[ "Get", "the", "mask", "for", "all", "fields", "which", "exist", "in", "the", "current", "bit", "field", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L309-L348
project-rig/rig
rig/bitfield.py
BitField._select_by_field_or_tag
def _select_by_field_or_tag(self, tag=None, field=None): """For internal use only. Returns an OrderedDict of {identifier: field} representing fields which match the supplied field/tag. Parameters ---------- tag : str Optionally specifies that the mask should only inc...
python
def _select_by_field_or_tag(self, tag=None, field=None): """For internal use only. Returns an OrderedDict of {identifier: field} representing fields which match the supplied field/tag. Parameters ---------- tag : str Optionally specifies that the mask should only inc...
[ "def", "_select_by_field_or_tag", "(", "self", ",", "tag", "=", "None", ",", "field", "=", "None", ")", ":", "# Get the set of fields whose values will be included in the value", "if", "field", "is", "not", "None", ":", "# Select just the specified field (checking the field...
For internal use only. Returns an OrderedDict of {identifier: field} representing fields which match the supplied field/tag. Parameters ---------- tag : str Optionally specifies that the mask should only include fields with the specified tag. field : str ...
[ "For", "internal", "use", "only", ".", "Returns", "an", "OrderedDict", "of", "{", "identifier", ":", "field", "}", "representing", "fields", "which", "match", "the", "supplied", "field", "/", "tag", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L350-L394
project-rig/rig
rig/bitfield.py
BitField.get_tags
def get_tags(self, field): """Get the set of tags for a given field. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field whose tag should be read. Returns ...
python
def get_tags(self, field): """Get the set of tags for a given field. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field whose tag should be read. Returns ...
[ "def", "get_tags", "(", "self", ",", "field", ")", ":", "return", "self", ".", "fields", ".", "get_field", "(", "field", ",", "self", ".", "field_values", ")", ".", "tags", ".", "copy", "(", ")" ]
Get the set of tags for a given field. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field whose tag should be read. Returns ------- set([tag, ...]...
[ "Get", "the", "set", "of", "tags", "for", "a", "given", "field", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L396-L417
project-rig/rig
rig/bitfield.py
BitField.get_location_and_length
def get_location_and_length(self, field): """Get the location and length of a field within the bitfield. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field of inte...
python
def get_location_and_length(self, field): """Get the location and length of a field within the bitfield. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field of inte...
[ "def", "get_location_and_length", "(", "self", ",", "field", ")", ":", "field_obj", "=", "self", ".", "fields", ".", "get_field", "(", "field", ",", "self", ".", "field_values", ")", "if", "field_obj", ".", "length", "is", "None", "or", "field_obj", ".", ...
Get the location and length of a field within the bitfield. .. note:: The named field must be accessible given the current set of values defined. Parameters ---------- field : str The field of interest. Returns ------- locati...
[ "Get", "the", "location", "and", "length", "of", "a", "field", "within", "the", "bitfield", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L419-L453
project-rig/rig
rig/bitfield.py
BitField.assign_fields
def assign_fields(self): """Assign a position & length to any fields which do not have one. Users should typically call this method after all field values have been assigned, otherwise fields may be fixed at an inadequate size. """ # We must fix fields at every level of the hier...
python
def assign_fields(self): """Assign a position & length to any fields which do not have one. Users should typically call this method after all field values have been assigned, otherwise fields may be fixed at an inadequate size. """ # We must fix fields at every level of the hier...
[ "def", "assign_fields", "(", "self", ")", ":", "# We must fix fields at every level of the hierarchy separately", "# (otherwise fields of children won't be allowed to overlap). Here we", "# do a breadth-first iteration over the hierarchy to fix fields with", "# given starting positions; then we do...
Assign a position & length to any fields which do not have one. Users should typically call this method after all field values have been assigned, otherwise fields may be fixed at an inadequate size.
[ "Assign", "a", "position", "&", "length", "to", "any", "fields", "which", "do", "not", "have", "one", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L455-L501
project-rig/rig
rig/bitfield.py
BitField._assign_fields
def _assign_fields(self, identifiers, field_values, assign_positions, assigned_bits=0): """For internal use only. Assign lengths & positions to a subset of all potential fields with the supplied field_values. This method will check for any assigned bits of all potential ...
python
def _assign_fields(self, identifiers, field_values, assign_positions, assigned_bits=0): """For internal use only. Assign lengths & positions to a subset of all potential fields with the supplied field_values. This method will check for any assigned bits of all potential ...
[ "def", "_assign_fields", "(", "self", ",", "identifiers", ",", "field_values", ",", "assign_positions", ",", "assigned_bits", "=", "0", ")", ":", "# Calculate a mask of already allocated fields' bits", "for", "i", ",", "f", "in", "self", ".", "fields", ".", "poten...
For internal use only. Assign lengths & positions to a subset of all potential fields with the supplied field_values. This method will check for any assigned bits of all potential fields but will only assign those fields whose identifiers are provided. Parameters ---------- ...
[ "For", "internal", "use", "only", ".", "Assign", "lengths", "&", "positions", "to", "a", "subset", "of", "all", "potential", "fields", "with", "the", "supplied", "field_values", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L857-L903
project-rig/rig
rig/bitfield.py
BitField._assign_field
def _assign_field(self, assigned_bits, identifier, field_values): """For internal use only. Assign a length and position to a field which may have either one of these values missing. Parameters ---------- assigned_bits : int A bit mask of bits already in use by othe...
python
def _assign_field(self, assigned_bits, identifier, field_values): """For internal use only. Assign a length and position to a field which may have either one of these values missing. Parameters ---------- assigned_bits : int A bit mask of bits already in use by othe...
[ "def", "_assign_field", "(", "self", ",", "assigned_bits", ",", "identifier", ",", "field_values", ")", ":", "field", "=", "self", ".", "fields", ".", "get_field", "(", "identifier", ",", "field_values", ")", "length", "=", "field", ".", "length", "if", "l...
For internal use only. Assign a length and position to a field which may have either one of these values missing. Parameters ---------- assigned_bits : int A bit mask of bits already in use by other fields identifier : str The identifier of the field to ...
[ "For", "internal", "use", "only", ".", "Assign", "a", "length", "and", "position", "to", "a", "field", "which", "may", "have", "either", "one", "of", "these", "values", "missing", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L905-L976
Metatab/metapack
metapack/package/excel.py
ExcelPackageBuilder._load_resources
def _load_resources(self): """Remove the geography from the files, since it isn't particularly useful in Excel""" for t in self.doc.find('Root.Table'): for c in t.find('Table.Column'): if c.get_value('datatype') == 'geometry': c['transform'] = '^empty_str...
python
def _load_resources(self): """Remove the geography from the files, since it isn't particularly useful in Excel""" for t in self.doc.find('Root.Table'): for c in t.find('Table.Column'): if c.get_value('datatype') == 'geometry': c['transform'] = '^empty_str...
[ "def", "_load_resources", "(", "self", ")", ":", "for", "t", "in", "self", ".", "doc", ".", "find", "(", "'Root.Table'", ")", ":", "for", "c", "in", "t", ".", "find", "(", "'Table.Column'", ")", ":", "if", "c", ".", "get_value", "(", "'datatype'", ...
Remove the geography from the files, since it isn't particularly useful in Excel
[ "Remove", "the", "geography", "from", "the", "files", "since", "it", "isn", "t", "particularly", "useful", "in", "Excel" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/excel.py#L91-L100
Metatab/metapack
metapack/cli/metaaws.py
user_policy_to_dict
def user_policy_to_dict(doc): """Convert a bucket policy to a dict mapping principal/prefix names to 'R' or 'W' """ import json if not isinstance(doc, dict): doc = json.loads(doc) d = {} def get_statement(name): for s in doc['Statement']: if s['Sid'] == name: ...
python
def user_policy_to_dict(doc): """Convert a bucket policy to a dict mapping principal/prefix names to 'R' or 'W' """ import json if not isinstance(doc, dict): doc = json.loads(doc) d = {} def get_statement(name): for s in doc['Statement']: if s['Sid'] == name: ...
[ "def", "user_policy_to_dict", "(", "doc", ")", ":", "import", "json", "if", "not", "isinstance", "(", "doc", ",", "dict", ")", ":", "doc", "=", "json", ".", "loads", "(", "doc", ")", "d", "=", "{", "}", "def", "get_statement", "(", "name", ")", ":"...
Convert a bucket policy to a dict mapping principal/prefix names to 'R' or 'W'
[ "Convert", "a", "bucket", "policy", "to", "a", "dict", "mapping", "principal", "/", "prefix", "names", "to", "R", "or", "W" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L225-L251
Metatab/metapack
metapack/cli/metaaws.py
make_bucket_policy_statements
def make_bucket_policy_statements(bucket): """Return the statemtns in a bucket policy as a dict of dicts""" import yaml from os.path import dirname, join, abspath import copy import metatab with open(join(dirname(abspath(metatab.__file__)), 'support', 'policy_parts.yaml')) as f: parts =...
python
def make_bucket_policy_statements(bucket): """Return the statemtns in a bucket policy as a dict of dicts""" import yaml from os.path import dirname, join, abspath import copy import metatab with open(join(dirname(abspath(metatab.__file__)), 'support', 'policy_parts.yaml')) as f: parts =...
[ "def", "make_bucket_policy_statements", "(", "bucket", ")", ":", "import", "yaml", "from", "os", ".", "path", "import", "dirname", ",", "join", ",", "abspath", "import", "copy", "import", "metatab", "with", "open", "(", "join", "(", "dirname", "(", "abspath"...
Return the statemtns in a bucket policy as a dict of dicts
[ "Return", "the", "statemtns", "in", "a", "bucket", "policy", "as", "a", "dict", "of", "dicts" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L254-L294
Metatab/metapack
metapack/cli/metaaws.py
bucket_dict_to_policy
def bucket_dict_to_policy(args, bucket_name, d): """ Create a bucket policy document from a permissions dict. The dictionary d maps (user, prefix) to 'R' or 'W'. :param bucket_name: :param d: :return: """ import json iam = get_resource(args, 'iam') statements = make_bucket_p...
python
def bucket_dict_to_policy(args, bucket_name, d): """ Create a bucket policy document from a permissions dict. The dictionary d maps (user, prefix) to 'R' or 'W'. :param bucket_name: :param d: :return: """ import json iam = get_resource(args, 'iam') statements = make_bucket_p...
[ "def", "bucket_dict_to_policy", "(", "args", ",", "bucket_name", ",", "d", ")", ":", "import", "json", "iam", "=", "get_resource", "(", "args", ",", "'iam'", ")", "statements", "=", "make_bucket_policy_statements", "(", "bucket_name", ")", "user_stats", "=", "...
Create a bucket policy document from a permissions dict. The dictionary d maps (user, prefix) to 'R' or 'W'. :param bucket_name: :param d: :return:
[ "Create", "a", "bucket", "policy", "document", "from", "a", "permissions", "dict", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L297-L346
Metatab/metapack
metapack/cli/metaaws.py
bucket_policy_to_dict
def bucket_policy_to_dict(policy): """Produce a dictionary of read, write permissions for an existing bucket policy document""" import json if not isinstance(policy, dict): policy = json.loads(policy) statements = {s['Sid']: s for s in policy['Statement']} d = {} for rw in ('Read', '...
python
def bucket_policy_to_dict(policy): """Produce a dictionary of read, write permissions for an existing bucket policy document""" import json if not isinstance(policy, dict): policy = json.loads(policy) statements = {s['Sid']: s for s in policy['Statement']} d = {} for rw in ('Read', '...
[ "def", "bucket_policy_to_dict", "(", "policy", ")", ":", "import", "json", "if", "not", "isinstance", "(", "policy", ",", "dict", ")", ":", "policy", "=", "json", ".", "loads", "(", "policy", ")", "statements", "=", "{", "s", "[", "'Sid'", "]", ":", ...
Produce a dictionary of read, write permissions for an existing bucket policy document
[ "Produce", "a", "dictionary", "of", "read", "write", "permissions", "for", "an", "existing", "bucket", "policy", "document" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L349-L375
Metatab/metapack
metapack/cli/metaaws.py
get_iam_account
def get_iam_account(l, args, user_name): """Return the local Account for a user name, by fetching User and looking up the arn. """ iam = get_resource(args, 'iam') user = iam.User(user_name) user.load() return l.find_or_new_account(user.arn)
python
def get_iam_account(l, args, user_name): """Return the local Account for a user name, by fetching User and looking up the arn. """ iam = get_resource(args, 'iam') user = iam.User(user_name) user.load() return l.find_or_new_account(user.arn)
[ "def", "get_iam_account", "(", "l", ",", "args", ",", "user_name", ")", ":", "iam", "=", "get_resource", "(", "args", ",", "'iam'", ")", "user", "=", "iam", ".", "User", "(", "user_name", ")", "user", ".", "load", "(", ")", "return", "l", ".", "fin...
Return the local Account for a user name, by fetching User and looking up the arn.
[ "Return", "the", "local", "Account", "for", "a", "user", "name", "by", "fetching", "User", "and", "looking", "up", "the", "arn", "." ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L540-L548
boazmohar/pySparkUtils
pySparkUtils/SVD.py
getSVD
def getSVD(data, k, getComponents=False, getS=False, normalization='mean'): """ Wrapper for computeSVD that will normalize and handle a Thunder Images object :param data: Thunder Images object :param k: number of components to keep :param getComponents: will return the components if true, otherwise wil...
python
def getSVD(data, k, getComponents=False, getS=False, normalization='mean'): """ Wrapper for computeSVD that will normalize and handle a Thunder Images object :param data: Thunder Images object :param k: number of components to keep :param getComponents: will return the components if true, otherwise wil...
[ "def", "getSVD", "(", "data", ",", "k", ",", "getComponents", "=", "False", ",", "getS", "=", "False", ",", "normalization", "=", "'mean'", ")", ":", "if", "normalization", "==", "'nanmean'", ":", "data2", "=", "data", ".", "tordd", "(", ")", ".", "s...
Wrapper for computeSVD that will normalize and handle a Thunder Images object :param data: Thunder Images object :param k: number of components to keep :param getComponents: will return the components if true, otherwise will return None :returns: projections, components, s
[ "Wrapper", "for", "computeSVD", "that", "will", "normalize", "and", "handle", "a", "Thunder", "Images", "object" ]
train
https://github.com/boazmohar/pySparkUtils/blob/5891b75327eb8b91af8558642edf7af82c5991b1/pySparkUtils/SVD.py#L77-L111
NicolasLM/spinach
spinach/utils.py
human_duration
def human_duration(duration_seconds: float) -> str: """Convert a duration in seconds into a human friendly string.""" if duration_seconds < 0.001: return '0 ms' if duration_seconds < 1: return '{} ms'.format(int(duration_seconds * 1000)) return '{} s'.format(int(duration_seconds))
python
def human_duration(duration_seconds: float) -> str: """Convert a duration in seconds into a human friendly string.""" if duration_seconds < 0.001: return '0 ms' if duration_seconds < 1: return '{} ms'.format(int(duration_seconds * 1000)) return '{} s'.format(int(duration_seconds))
[ "def", "human_duration", "(", "duration_seconds", ":", "float", ")", "->", "str", ":", "if", "duration_seconds", "<", "0.001", ":", "return", "'0 ms'", "if", "duration_seconds", "<", "1", ":", "return", "'{} ms'", ".", "format", "(", "int", "(", "duration_se...
Convert a duration in seconds into a human friendly string.
[ "Convert", "a", "duration", "in", "seconds", "into", "a", "human", "friendly", "string", "." ]
train
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/utils.py#L13-L19
NicolasLM/spinach
spinach/utils.py
call_with_retry
def call_with_retry(func: Callable, exceptions, max_retries: int, logger: Logger, *args, **kwargs): """Call a function and retry it on failure.""" attempt = 0 while True: try: return func(*args, **kwargs) except exceptions as e: attempt += 1 ...
python
def call_with_retry(func: Callable, exceptions, max_retries: int, logger: Logger, *args, **kwargs): """Call a function and retry it on failure.""" attempt = 0 while True: try: return func(*args, **kwargs) except exceptions as e: attempt += 1 ...
[ "def", "call_with_retry", "(", "func", ":", "Callable", ",", "exceptions", ",", "max_retries", ":", "int", ",", "logger", ":", "Logger", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "attempt", "=", "0", "while", "True", ":", "try", ":", "retu...
Call a function and retry it on failure.
[ "Call", "a", "function", "and", "retry", "it", "on", "failure", "." ]
train
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/utils.py#L49-L63
NicolasLM/spinach
spinach/utils.py
exponential_backoff
def exponential_backoff(attempt: int, cap: int=1200) -> timedelta: """Calculate a delay to retry using an exponential backoff algorithm. It is an exponential backoff with random jitter to prevent failures from being retried at the same time. It is a good fit for most applications. :arg attempt: th...
python
def exponential_backoff(attempt: int, cap: int=1200) -> timedelta: """Calculate a delay to retry using an exponential backoff algorithm. It is an exponential backoff with random jitter to prevent failures from being retried at the same time. It is a good fit for most applications. :arg attempt: th...
[ "def", "exponential_backoff", "(", "attempt", ":", "int", ",", "cap", ":", "int", "=", "1200", ")", "->", "timedelta", ":", "base", "=", "3", "temp", "=", "min", "(", "base", "*", "2", "**", "attempt", ",", "cap", ")", "return", "timedelta", "(", "...
Calculate a delay to retry using an exponential backoff algorithm. It is an exponential backoff with random jitter to prevent failures from being retried at the same time. It is a good fit for most applications. :arg attempt: the number of attempts made :arg cap: maximum delay, defaults to 20 minu...
[ "Calculate", "a", "delay", "to", "retry", "using", "an", "exponential", "backoff", "algorithm", "." ]
train
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/utils.py#L66-L78
NicolasLM/spinach
spinach/utils.py
handle_sigterm
def handle_sigterm(): """Handle SIGTERM like a normal SIGINT (KeyboardInterrupt). By default Docker sends a SIGTERM for stopping containers, giving them time to terminate before getting killed. If a process does not catch this signal and does nothing, it just gets killed. Handling SIGTERM like SIG...
python
def handle_sigterm(): """Handle SIGTERM like a normal SIGINT (KeyboardInterrupt). By default Docker sends a SIGTERM for stopping containers, giving them time to terminate before getting killed. If a process does not catch this signal and does nothing, it just gets killed. Handling SIGTERM like SIG...
[ "def", "handle_sigterm", "(", ")", ":", "original_sigterm_handler", "=", "signal", ".", "getsignal", "(", "signal", ".", "SIGTERM", ")", "signal", ".", "signal", "(", "signal", ".", "SIGTERM", ",", "signal", ".", "default_int_handler", ")", "try", ":", "yiel...
Handle SIGTERM like a normal SIGINT (KeyboardInterrupt). By default Docker sends a SIGTERM for stopping containers, giving them time to terminate before getting killed. If a process does not catch this signal and does nothing, it just gets killed. Handling SIGTERM like SIGINT allows to gracefully term...
[ "Handle", "SIGTERM", "like", "a", "normal", "SIGINT", "(", "KeyboardInterrupt", ")", "." ]
train
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/utils.py#L82-L99
project-rig/rig
rig/type_casts.py
float_to_fp
def float_to_fp(signed, n_bits, n_frac): """Return a function to convert a floating point value to a fixed point value. For example, a function to convert a float to a signed fractional representation with 8 bits overall and 4 fractional bits (S3.4) can be constructed and used with:: >>> s...
python
def float_to_fp(signed, n_bits, n_frac): """Return a function to convert a floating point value to a fixed point value. For example, a function to convert a float to a signed fractional representation with 8 bits overall and 4 fractional bits (S3.4) can be constructed and used with:: >>> s...
[ "def", "float_to_fp", "(", "signed", ",", "n_bits", ",", "n_frac", ")", ":", "# Calculate the maximum and minimum values", "if", "signed", ":", "max_v", "=", "(", "1", "<<", "(", "n_bits", "-", "1", ")", ")", "-", "1", "min_v", "=", "-", "max_v", "-", ...
Return a function to convert a floating point value to a fixed point value. For example, a function to convert a float to a signed fractional representation with 8 bits overall and 4 fractional bits (S3.4) can be constructed and used with:: >>> s34 = float_to_fp(signed=True, n_bits=8, n_frac=4...
[ "Return", "a", "function", "to", "convert", "a", "floating", "point", "value", "to", "a", "fixed", "point", "value", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/type_casts.py#L7-L70
project-rig/rig
rig/type_casts.py
float_to_fix
def float_to_fix(signed, n_bits, n_frac): """**DEPRECATED** Return a function to convert a floating point value to a fixed point value. .. warning:: This function is deprecated in favour of :py:meth:`~.float_to_fp`. For example, a function to convert a float to a signed fractional represen...
python
def float_to_fix(signed, n_bits, n_frac): """**DEPRECATED** Return a function to convert a floating point value to a fixed point value. .. warning:: This function is deprecated in favour of :py:meth:`~.float_to_fp`. For example, a function to convert a float to a signed fractional represen...
[ "def", "float_to_fix", "(", "signed", ",", "n_bits", ",", "n_frac", ")", ":", "warnings", ".", "warn", "(", "\"float_to_fix() is deprecated, see float_to_fp\"", ",", "DeprecationWarning", ")", "mask", "=", "int", "(", "2", "**", "n_bits", "-", "1", ")", "min_v...
**DEPRECATED** Return a function to convert a floating point value to a fixed point value. .. warning:: This function is deprecated in favour of :py:meth:`~.float_to_fp`. For example, a function to convert a float to a signed fractional representation with 8 bits overall and 4 fractional bits ...
[ "**", "DEPRECATED", "**", "Return", "a", "function", "to", "convert", "a", "floating", "point", "value", "to", "a", "fixed", "point", "value", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/type_casts.py#L110-L195
project-rig/rig
rig/type_casts.py
fix_to_float
def fix_to_float(signed, n_bits, n_frac): """**DEPRECATED** Return a function to convert a fixed point value to a floating point value. .. warning:: This function is deprecated in favour of :py:meth:`~.fp_to_float`. For example, a function to convert from signed fractional representations ...
python
def fix_to_float(signed, n_bits, n_frac): """**DEPRECATED** Return a function to convert a fixed point value to a floating point value. .. warning:: This function is deprecated in favour of :py:meth:`~.fp_to_float`. For example, a function to convert from signed fractional representations ...
[ "def", "fix_to_float", "(", "signed", ",", "n_bits", ",", "n_frac", ")", ":", "warnings", ".", "warn", "(", "\"fix_to_float() is deprecated, see fp_to_float\"", ",", "DeprecationWarning", ")", "validate_fp_params", "(", "signed", ",", "n_bits", ",", "n_frac", ")", ...
**DEPRECATED** Return a function to convert a fixed point value to a floating point value. .. warning:: This function is deprecated in favour of :py:meth:`~.fp_to_float`. For example, a function to convert from signed fractional representations with 8 bits overall and 4 fractional representati...
[ "**", "DEPRECATED", "**", "Return", "a", "function", "to", "convert", "a", "fixed", "point", "value", "to", "a", "floating", "point", "value", "." ]
train
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/type_casts.py#L198-L270
happyleavesaoc/python-voobly
voobly/__init__.py
get_metadata_path
def get_metadata_path(name): """Get reference metadata file path.""" return pkg_resources.resource_filename('voobly', os.path.join(METADATA_PATH, '{}.json'.format(name)))
python
def get_metadata_path(name): """Get reference metadata file path.""" return pkg_resources.resource_filename('voobly', os.path.join(METADATA_PATH, '{}.json'.format(name)))
[ "def", "get_metadata_path", "(", "name", ")", ":", "return", "pkg_resources", ".", "resource_filename", "(", "'voobly'", ",", "os", ".", "path", ".", "join", "(", "METADATA_PATH", ",", "'{}.json'", ".", "format", "(", "name", ")", ")", ")" ]
Get reference metadata file path.
[ "Get", "reference", "metadata", "file", "path", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L85-L87
happyleavesaoc/python-voobly
voobly/__init__.py
_save_cookies
def _save_cookies(requests_cookiejar, filename): """Save cookies to a file.""" with open(filename, 'wb') as handle: pickle.dump(requests_cookiejar, handle)
python
def _save_cookies(requests_cookiejar, filename): """Save cookies to a file.""" with open(filename, 'wb') as handle: pickle.dump(requests_cookiejar, handle)
[ "def", "_save_cookies", "(", "requests_cookiejar", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "handle", ":", "pickle", ".", "dump", "(", "requests_cookiejar", ",", "handle", ")" ]
Save cookies to a file.
[ "Save", "cookies", "to", "a", "file", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L100-L103
happyleavesaoc/python-voobly
voobly/__init__.py
_make_request
def _make_request(session, url, argument=None, params=None, raw=False): """Make a request to API endpoint.""" if not params: params = {} params['key'] = session.auth.key try: if argument: request_url = '{}{}{}{}'.format(session.auth.base_url, VOOBLY_API_URL, url, argument) ...
python
def _make_request(session, url, argument=None, params=None, raw=False): """Make a request to API endpoint.""" if not params: params = {} params['key'] = session.auth.key try: if argument: request_url = '{}{}{}{}'.format(session.auth.base_url, VOOBLY_API_URL, url, argument) ...
[ "def", "_make_request", "(", "session", ",", "url", ",", "argument", "=", "None", ",", "params", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "params", ":", "params", "=", "{", "}", "params", "[", "'key'", "]", "=", "session", ".",...
Make a request to API endpoint.
[ "Make", "a", "request", "to", "API", "endpoint", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L112-L136
happyleavesaoc/python-voobly
voobly/__init__.py
make_scrape_request
def make_scrape_request(session, url, mode='get', data=None): """Make a request to URL.""" try: html = session.request(mode, url, data=data) except RequestException: raise VooblyError('failed to connect') if SCRAPE_FETCH_ERROR in html.text: raise VooblyError('not logged in') ...
python
def make_scrape_request(session, url, mode='get', data=None): """Make a request to URL.""" try: html = session.request(mode, url, data=data) except RequestException: raise VooblyError('failed to connect') if SCRAPE_FETCH_ERROR in html.text: raise VooblyError('not logged in') ...
[ "def", "make_scrape_request", "(", "session", ",", "url", ",", "mode", "=", "'get'", ",", "data", "=", "None", ")", ":", "try", ":", "html", "=", "session", ".", "request", "(", "mode", ",", "url", ",", "data", "=", "data", ")", "except", "RequestExc...
Make a request to URL.
[ "Make", "a", "request", "to", "URL", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L139-L149
happyleavesaoc/python-voobly
voobly/__init__.py
get_ladder
def get_ladder(session, ladder_id, user_id=None, user_ids=None, start=0, limit=LADDER_RESULT_LIMIT): """Get ladder.""" params = { 'start': start, 'limit': limit } if isinstance(ladder_id, str): ladder_id = lookup_ladder_id(ladder_id) if limit > LADDER_RESULT_LIMIT: ra...
python
def get_ladder(session, ladder_id, user_id=None, user_ids=None, start=0, limit=LADDER_RESULT_LIMIT): """Get ladder.""" params = { 'start': start, 'limit': limit } if isinstance(ladder_id, str): ladder_id = lookup_ladder_id(ladder_id) if limit > LADDER_RESULT_LIMIT: ra...
[ "def", "get_ladder", "(", "session", ",", "ladder_id", ",", "user_id", "=", "None", ",", "user_ids", "=", "None", ",", "start", "=", "0", ",", "limit", "=", "LADDER_RESULT_LIMIT", ")", ":", "params", "=", "{", "'start'", ":", "start", ",", "'limit'", "...
Get ladder.
[ "Get", "ladder", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L167-L186
happyleavesaoc/python-voobly
voobly/__init__.py
get_lobbies
def get_lobbies(session, game_id): """Get lobbies for a game.""" if isinstance(game_id, str): game_id = lookup_game_id(game_id) lobbies = _make_request(session, LOBBY_URL, game_id) for lobby in lobbies: # pylint: disable=len-as-condition if len(lobby['ladders']) > 0: ...
python
def get_lobbies(session, game_id): """Get lobbies for a game.""" if isinstance(game_id, str): game_id = lookup_game_id(game_id) lobbies = _make_request(session, LOBBY_URL, game_id) for lobby in lobbies: # pylint: disable=len-as-condition if len(lobby['ladders']) > 0: ...
[ "def", "get_lobbies", "(", "session", ",", "game_id", ")", ":", "if", "isinstance", "(", "game_id", ",", "str", ")", ":", "game_id", "=", "lookup_game_id", "(", "game_id", ")", "lobbies", "=", "_make_request", "(", "session", ",", "LOBBY_URL", ",", "game_i...
Get lobbies for a game.
[ "Get", "lobbies", "for", "a", "game", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L189-L198
happyleavesaoc/python-voobly
voobly/__init__.py
get_user
def get_user(session, user_id): """Get user.""" try: user_id = int(user_id) except ValueError: user_id = find_user(session, user_id) resp = _make_request(session, USER_URL, user_id) if not resp: raise VooblyError('user id not found') return resp[0]
python
def get_user(session, user_id): """Get user.""" try: user_id = int(user_id) except ValueError: user_id = find_user(session, user_id) resp = _make_request(session, USER_URL, user_id) if not resp: raise VooblyError('user id not found') return resp[0]
[ "def", "get_user", "(", "session", ",", "user_id", ")", ":", "try", ":", "user_id", "=", "int", "(", "user_id", ")", "except", "ValueError", ":", "user_id", "=", "find_user", "(", "session", ",", "user_id", ")", "resp", "=", "_make_request", "(", "sessio...
Get user.
[ "Get", "user", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L201-L210
happyleavesaoc/python-voobly
voobly/__init__.py
find_user
def find_user(session, username): """Find user by name - returns user ID.""" resp = _make_request(session, FIND_USER_URL, username) if not resp: raise VooblyError('user not found') try: return int(resp[0]['uid']) except ValueError: raise VooblyError('user not found')
python
def find_user(session, username): """Find user by name - returns user ID.""" resp = _make_request(session, FIND_USER_URL, username) if not resp: raise VooblyError('user not found') try: return int(resp[0]['uid']) except ValueError: raise VooblyError('user not found')
[ "def", "find_user", "(", "session", ",", "username", ")", ":", "resp", "=", "_make_request", "(", "session", ",", "FIND_USER_URL", ",", "username", ")", "if", "not", "resp", ":", "raise", "VooblyError", "(", "'user not found'", ")", "try", ":", "return", "...
Find user by name - returns user ID.
[ "Find", "user", "by", "name", "-", "returns", "user", "ID", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L213-L221
happyleavesaoc/python-voobly
voobly/__init__.py
find_users
def find_users(session, *usernames): """Find multiple users by name.""" user_string = ','.join(usernames) return _make_request(session, FIND_USERS_URL, user_string)
python
def find_users(session, *usernames): """Find multiple users by name.""" user_string = ','.join(usernames) return _make_request(session, FIND_USERS_URL, user_string)
[ "def", "find_users", "(", "session", ",", "*", "usernames", ")", ":", "user_string", "=", "','", ".", "join", "(", "usernames", ")", "return", "_make_request", "(", "session", ",", "FIND_USERS_URL", ",", "user_string", ")" ]
Find multiple users by name.
[ "Find", "multiple", "users", "by", "name", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L224-L227
happyleavesaoc/python-voobly
voobly/__init__.py
user
def user(session, uid, ladder_ids=None): """Get all possible user info by name.""" data = get_user(session, uid) resp = dict(data) if not ladder_ids: return resp resp['ladders'] = {} for ladder_id in ladder_ids: if isinstance(ladder_id, str): ladder_id = lookup_ladder...
python
def user(session, uid, ladder_ids=None): """Get all possible user info by name.""" data = get_user(session, uid) resp = dict(data) if not ladder_ids: return resp resp['ladders'] = {} for ladder_id in ladder_ids: if isinstance(ladder_id, str): ladder_id = lookup_ladder...
[ "def", "user", "(", "session", ",", "uid", ",", "ladder_ids", "=", "None", ")", ":", "data", "=", "get_user", "(", "session", ",", "uid", ")", "resp", "=", "dict", "(", "data", ")", "if", "not", "ladder_ids", ":", "return", "resp", "resp", "[", "'l...
Get all possible user info by name.
[ "Get", "all", "possible", "user", "info", "by", "name", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L236-L252
happyleavesaoc/python-voobly
voobly/__init__.py
ladders
def ladders(session, game_id): """Get a list of ladder IDs.""" if isinstance(game_id, str): game_id = lookup_game_id(game_id) lobbies = get_lobbies(session, game_id) ladder_ids = set() for lobby in lobbies: ladder_ids |= set(lobby['ladders']) return list(ladder_ids)
python
def ladders(session, game_id): """Get a list of ladder IDs.""" if isinstance(game_id, str): game_id = lookup_game_id(game_id) lobbies = get_lobbies(session, game_id) ladder_ids = set() for lobby in lobbies: ladder_ids |= set(lobby['ladders']) return list(ladder_ids)
[ "def", "ladders", "(", "session", ",", "game_id", ")", ":", "if", "isinstance", "(", "game_id", ",", "str", ")", ":", "game_id", "=", "lookup_game_id", "(", "game_id", ")", "lobbies", "=", "get_lobbies", "(", "session", ",", "game_id", ")", "ladder_ids", ...
Get a list of ladder IDs.
[ "Get", "a", "list", "of", "ladder", "IDs", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L255-L263
happyleavesaoc/python-voobly
voobly/__init__.py
authenticated
def authenticated(function): """Re-authenticate if session expired.""" def wrapped(session, *args, **kwargs): """Wrap function.""" try: return function(session, *args, **kwargs) except VooblyError: with session.cache_disabled(): _LOGGER.info("attem...
python
def authenticated(function): """Re-authenticate if session expired.""" def wrapped(session, *args, **kwargs): """Wrap function.""" try: return function(session, *args, **kwargs) except VooblyError: with session.cache_disabled(): _LOGGER.info("attem...
[ "def", "authenticated", "(", "function", ")", ":", "def", "wrapped", "(", "session", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap function.\"\"\"", "try", ":", "return", "function", "(", "session", ",", "*", "args", ",", "*", "*", "...
Re-authenticate if session expired.
[ "Re", "-", "authenticate", "if", "session", "expired", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L266-L277
happyleavesaoc/python-voobly
voobly/__init__.py
get_clan_matches
def get_clan_matches(session, subdomain, clan_id, from_timestamp=None, limit=None): """Get recent matches by clan.""" return get_recent_matches(session, 'https://{}.voobly.com/{}/{}/0'.format( subdomain, TEAM_MATCHES_URL, clan_id), from_timestamp, limit)
python
def get_clan_matches(session, subdomain, clan_id, from_timestamp=None, limit=None): """Get recent matches by clan.""" return get_recent_matches(session, 'https://{}.voobly.com/{}/{}/0'.format( subdomain, TEAM_MATCHES_URL, clan_id), from_timestamp, limit)
[ "def", "get_clan_matches", "(", "session", ",", "subdomain", ",", "clan_id", ",", "from_timestamp", "=", "None", ",", "limit", "=", "None", ")", ":", "return", "get_recent_matches", "(", "session", ",", "'https://{}.voobly.com/{}/{}/0'", ".", "format", "(", "sub...
Get recent matches by clan.
[ "Get", "recent", "matches", "by", "clan", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L368-L371
happyleavesaoc/python-voobly
voobly/__init__.py
get_user_matches
def get_user_matches(session, user_id, from_timestamp=None, limit=None): """Get recent matches by user.""" return get_recent_matches(session, '{}{}/{}/Matches/games/matches/user/{}/0'.format( session.auth.base_url, PROFILE_URL, user_id, user_id), from_timestamp, limit)
python
def get_user_matches(session, user_id, from_timestamp=None, limit=None): """Get recent matches by user.""" return get_recent_matches(session, '{}{}/{}/Matches/games/matches/user/{}/0'.format( session.auth.base_url, PROFILE_URL, user_id, user_id), from_timestamp, limit)
[ "def", "get_user_matches", "(", "session", ",", "user_id", ",", "from_timestamp", "=", "None", ",", "limit", "=", "None", ")", ":", "return", "get_recent_matches", "(", "session", ",", "'{}{}/{}/Matches/games/matches/user/{}/0'", ".", "format", "(", "session", "."...
Get recent matches by user.
[ "Get", "recent", "matches", "by", "user", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L375-L378
happyleavesaoc/python-voobly
voobly/__init__.py
get_recent_matches
def get_recent_matches(session, init_url, from_timestamp, limit): """Get recently played user matches.""" if not from_timestamp: from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1) matches = [] page_id = 0 done = False while not done and page_id < MAX_MATCH_PAGE_ID: ...
python
def get_recent_matches(session, init_url, from_timestamp, limit): """Get recently played user matches.""" if not from_timestamp: from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1) matches = [] page_id = 0 done = False while not done and page_id < MAX_MATCH_PAGE_ID: ...
[ "def", "get_recent_matches", "(", "session", ",", "init_url", ",", "from_timestamp", ",", "limit", ")", ":", "if", "not", "from_timestamp", ":", "from_timestamp", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "datetime", ".", "timedelta", "(",...
Get recently played user matches.
[ "Get", "recently", "played", "user", "matches", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L381-L408
happyleavesaoc/python-voobly
voobly/__init__.py
get_ladder_matches
def get_ladder_matches(session, ladder_id, from_timestamp=None, limit=LADDER_MATCH_LIMIT): """Get recently played ladder matches.""" if not from_timestamp: from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1) matches = [] page_id = 0 done = False i = 0 while not done...
python
def get_ladder_matches(session, ladder_id, from_timestamp=None, limit=LADDER_MATCH_LIMIT): """Get recently played ladder matches.""" if not from_timestamp: from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1) matches = [] page_id = 0 done = False i = 0 while not done...
[ "def", "get_ladder_matches", "(", "session", ",", "ladder_id", ",", "from_timestamp", "=", "None", ",", "limit", "=", "LADDER_MATCH_LIMIT", ")", ":", "if", "not", "from_timestamp", ":", "from_timestamp", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ...
Get recently played ladder matches.
[ "Get", "recently", "played", "ladder", "matches", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L412-L439
happyleavesaoc/python-voobly
voobly/__init__.py
get_match
def get_match(session, match_id): """Get match metadata.""" url = '{}{}/{}'.format(session.auth.base_url, MATCH_URL, match_id) parsed = make_scrape_request(session, url) game = parsed.find('h3').text if game != GAME_AOC: raise ValueError('not an aoc match') date_played = parsed.find(text...
python
def get_match(session, match_id): """Get match metadata.""" url = '{}{}/{}'.format(session.auth.base_url, MATCH_URL, match_id) parsed = make_scrape_request(session, url) game = parsed.find('h3').text if game != GAME_AOC: raise ValueError('not an aoc match') date_played = parsed.find(text...
[ "def", "get_match", "(", "session", ",", "match_id", ")", ":", "url", "=", "'{}{}/{}'", ".", "format", "(", "session", ".", "auth", ".", "base_url", ",", "MATCH_URL", ",", "match_id", ")", "parsed", "=", "make_scrape_request", "(", "session", ",", "url", ...
Get match metadata.
[ "Get", "match", "metadata", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L443-L495
happyleavesaoc/python-voobly
voobly/__init__.py
download_rec
def download_rec(session, rec_url, target_path): """Download and extract a recorded game.""" try: resp = session.get(session.auth.base_url + rec_url) except RequestException: raise VooblyError('failed to connect for download') try: downloaded = zipfile.ZipFile(io.BytesIO(resp.con...
python
def download_rec(session, rec_url, target_path): """Download and extract a recorded game.""" try: resp = session.get(session.auth.base_url + rec_url) except RequestException: raise VooblyError('failed to connect for download') try: downloaded = zipfile.ZipFile(io.BytesIO(resp.con...
[ "def", "download_rec", "(", "session", ",", "rec_url", ",", "target_path", ")", ":", "try", ":", "resp", "=", "session", ".", "get", "(", "session", ".", "auth", ".", "base_url", "+", "rec_url", ")", "except", "RequestException", ":", "raise", "VooblyError...
Download and extract a recorded game.
[ "Download", "and", "extract", "a", "recorded", "game", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L499-L510
happyleavesaoc/python-voobly
voobly/__init__.py
login
def login(session): """Login to Voobly.""" if not session.auth.username or not session.auth.password: raise VooblyError('must supply username and password') _LOGGER.info("logging in (no valid cookie found)") session.cookies.clear() try: session.get(session.auth.base_url + LOGIN_PAGE)...
python
def login(session): """Login to Voobly.""" if not session.auth.username or not session.auth.password: raise VooblyError('must supply username and password') _LOGGER.info("logging in (no valid cookie found)") session.cookies.clear() try: session.get(session.auth.base_url + LOGIN_PAGE)...
[ "def", "login", "(", "session", ")", ":", "if", "not", "session", ".", "auth", ".", "username", "or", "not", "session", ".", "auth", ".", "password", ":", "raise", "VooblyError", "(", "'must supply username and password'", ")", "_LOGGER", ".", "info", "(", ...
Login to Voobly.
[ "Login", "to", "Voobly", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L513-L529
happyleavesaoc/python-voobly
voobly/__init__.py
get_session
def get_session(key=None, username=None, password=None, cache=True, cache_expiry=datetime.timedelta(days=7), cookie_path=COOKIE_PATH, backend='memory', version=VERSION_GLOBAL): """Get Voobly API session.""" class VooblyAuth(AuthBase): # pylint: disable=too-few-public-methods ...
python
def get_session(key=None, username=None, password=None, cache=True, cache_expiry=datetime.timedelta(days=7), cookie_path=COOKIE_PATH, backend='memory', version=VERSION_GLOBAL): """Get Voobly API session.""" class VooblyAuth(AuthBase): # pylint: disable=too-few-public-methods ...
[ "def", "get_session", "(", "key", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "cache", "=", "True", ",", "cache_expiry", "=", "datetime", ".", "timedelta", "(", "days", "=", "7", ")", ",", "cookie_path", "=", "COOKIE_P...
Get Voobly API session.
[ "Get", "Voobly", "API", "session", "." ]
train
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L532-L561
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
main
def main(): """The entry point for the Hyper-V Neutron Agent.""" neutron_config.register_agent_state_opts_helper(CONF) common_config.init(sys.argv[1:]) neutron_config.setup_logging() hyperv_agent = HyperVNeutronAgent() # Start everything. LOG.info("Agent initialized successfully, now runni...
python
def main(): """The entry point for the Hyper-V Neutron Agent.""" neutron_config.register_agent_state_opts_helper(CONF) common_config.init(sys.argv[1:]) neutron_config.setup_logging() hyperv_agent = HyperVNeutronAgent() # Start everything. LOG.info("Agent initialized successfully, now runni...
[ "def", "main", "(", ")", ":", "neutron_config", ".", "register_agent_state_opts_helper", "(", "CONF", ")", "common_config", ".", "init", "(", "sys", ".", "argv", "[", "1", ":", "]", ")", "neutron_config", ".", "setup_logging", "(", ")", "hyperv_agent", "=", ...
The entry point for the Hyper-V Neutron Agent.
[ "The", "entry", "point", "for", "the", "Hyper", "-", "V", "Neutron", "Agent", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L291-L301
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
HyperVNeutronAgent._setup
def _setup(self): """Setup the layer two agent.""" super(HyperVNeutronAgent, self)._setup() self._sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self._sec_groups_agent = HyperVSecurityAgent(self._context, self._sg_plu...
python
def _setup(self): """Setup the layer two agent.""" super(HyperVNeutronAgent, self)._setup() self._sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self._sec_groups_agent = HyperVSecurityAgent(self._context, self._sg_plu...
[ "def", "_setup", "(", "self", ")", ":", "super", "(", "HyperVNeutronAgent", ",", "self", ")", ".", "_setup", "(", ")", "self", ".", "_sg_plugin_rpc", "=", "sg_rpc", ".", "SecurityGroupServerRpcApi", "(", "topics", ".", "PLUGIN", ")", "self", ".", "_sec_gro...
Setup the layer two agent.
[ "Setup", "the", "layer", "two", "agent", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L114-L124
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
HyperVNeutronAgent._setup_qos_extension
def _setup_qos_extension(self): """Setup the QOS extension if it is required.""" if not CONF.AGENT.enable_qos_extension: return self._qos_ext = qos_extension.QosAgentExtension() self._qos_ext.consume_api(self) self._qos_ext.initialize(self._connection, 'hyperv')
python
def _setup_qos_extension(self): """Setup the QOS extension if it is required.""" if not CONF.AGENT.enable_qos_extension: return self._qos_ext = qos_extension.QosAgentExtension() self._qos_ext.consume_api(self) self._qos_ext.initialize(self._connection, 'hyperv')
[ "def", "_setup_qos_extension", "(", "self", ")", ":", "if", "not", "CONF", ".", "AGENT", ".", "enable_qos_extension", ":", "return", "self", ".", "_qos_ext", "=", "qos_extension", ".", "QosAgentExtension", "(", ")", "self", ".", "_qos_ext", ".", "consume_api",...
Setup the QOS extension if it is required.
[ "Setup", "the", "QOS", "extension", "if", "it", "is", "required", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L126-L132
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
HyperVNeutronAgent._provision_network
def _provision_network(self, port_id, net_uuid, network_type, physical_network, segmentation_id): """Provision the network with the received information.""" LOG.info("Provisioning network %s", net_uuid) vswitch_name = self._get_vswitch_name(network_type, physical_netw...
python
def _provision_network(self, port_id, net_uuid, network_type, physical_network, segmentation_id): """Provision the network with the received information.""" LOG.info("Provisioning network %s", net_uuid) vswitch_name = self._get_vswitch_name(network_type, physical_netw...
[ "def", "_provision_network", "(", "self", ",", "port_id", ",", "net_uuid", ",", "network_type", ",", "physical_network", ",", "segmentation_id", ")", ":", "LOG", ".", "info", "(", "\"Provisioning network %s\"", ",", "net_uuid", ")", "vswitch_name", "=", "self", ...
Provision the network with the received information.
[ "Provision", "the", "network", "with", "the", "received", "information", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L156-L186
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
HyperVNeutronAgent._port_bound
def _port_bound(self, port_id, network_id, network_type, physical_network, segmentation_id, port_security_enabled, set_port_sriov): """Bind the port to the recived network.""" super(HyperVNeutronAgent, self)._port_bound( port_id, network_id, network_type, physical_network...
python
def _port_bound(self, port_id, network_id, network_type, physical_network, segmentation_id, port_security_enabled, set_port_sriov): """Bind the port to the recived network.""" super(HyperVNeutronAgent, self)._port_bound( port_id, network_id, network_type, physical_network...
[ "def", "_port_bound", "(", "self", ",", "port_id", ",", "network_id", ",", "network_type", ",", "physical_network", ",", "segmentation_id", ",", "port_security_enabled", ",", "set_port_sriov", ")", ":", "super", "(", "HyperVNeutronAgent", ",", "self", ")", ".", ...
Bind the port to the recived network.
[ "Bind", "the", "port", "to", "the", "recived", "network", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L188-L221
openstack/networking-hyperv
networking_hyperv/neutron/agent/hyperv_neutron_agent.py
HyperVNeutronAgent._work
def _work(self): """Process the information regarding the available ports.""" super(HyperVNeutronAgent, self)._work() if self._nvgre_enabled: self._nvgre_ops.refresh_nvgre_records() self._port_enable_control_metrics()
python
def _work(self): """Process the information regarding the available ports.""" super(HyperVNeutronAgent, self)._work() if self._nvgre_enabled: self._nvgre_ops.refresh_nvgre_records() self._port_enable_control_metrics()
[ "def", "_work", "(", "self", ")", ":", "super", "(", "HyperVNeutronAgent", ",", "self", ")", ".", "_work", "(", ")", "if", "self", ".", "_nvgre_enabled", ":", "self", ".", "_nvgre_ops", ".", "refresh_nvgre_records", "(", ")", "self", ".", "_port_enable_con...
Process the information regarding the available ports.
[ "Process", "the", "information", "regarding", "the", "available", "ports", "." ]
train
https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hyperv_neutron_agent.py#L269-L274
Metatab/metapack
metapack/jupyter/script.py
ScriptIPython.run_cell_magic
def run_cell_magic(self, magic_name, line, cell): """Run a limited number of magics from scripts, without IPython""" if magic_name == 'bash': self.shebang("bash", cell) elif magic_name == 'metatab': self.mm.metatab(line, cell)
python
def run_cell_magic(self, magic_name, line, cell): """Run a limited number of magics from scripts, without IPython""" if magic_name == 'bash': self.shebang("bash", cell) elif magic_name == 'metatab': self.mm.metatab(line, cell)
[ "def", "run_cell_magic", "(", "self", ",", "magic_name", ",", "line", ",", "cell", ")", ":", "if", "magic_name", "==", "'bash'", ":", "self", ".", "shebang", "(", "\"bash\"", ",", "cell", ")", "elif", "magic_name", "==", "'metatab'", ":", "self", ".", ...
Run a limited number of magics from scripts, without IPython
[ "Run", "a", "limited", "number", "of", "magics", "from", "scripts", "without", "IPython" ]
train
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/script.py#L51-L57