repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
Valuehorizon/valuehorizon-people
people/models.py
https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L102-L115
def save(self, *args, **kwargs): """ If date of death is specified, set is_deceased to true """ if self.date_of_death != None: self.is_deceased = True # Since we often copy and paste names from strange sources, do some basic cleanup self.first_nam...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "date_of_death", "!=", "None", ":", "self", ".", "is_deceased", "=", "True", "# Since we often copy and paste names from strange sources, do some basic cleanup", "s...
If date of death is specified, set is_deceased to true
[ "If", "date", "of", "death", "is", "specified", "set", "is_deceased", "to", "true" ]
python
train
marcinmiklitz/pywindow
pywindow/utilities.py
https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L720-L732
def lattice_array_to_unit_cell(lattice_array): """Return crystallographic param. from unit cell lattice matrix.""" cell_lengths = np.sqrt(np.sum(lattice_array**2, axis=0)) gamma_r = np.arccos(lattice_array[0][1] / cell_lengths[1]) beta_r = np.arccos(lattice_array[0][2] / cell_lengths[2]) alpha_r = n...
[ "def", "lattice_array_to_unit_cell", "(", "lattice_array", ")", ":", "cell_lengths", "=", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "lattice_array", "**", "2", ",", "axis", "=", "0", ")", ")", "gamma_r", "=", "np", ".", "arccos", "(", "lattice_array...
Return crystallographic param. from unit cell lattice matrix.
[ "Return", "crystallographic", "param", ".", "from", "unit", "cell", "lattice", "matrix", "." ]
python
train
havardgulldahl/jottalib
src/jottalib/JFS.py
https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/JFS.py#L698-L700
def updated(self): 'return datetime.datetime' return dateutil.parser.parse(str(self.f.currentRevision.updated))
[ "def", "updated", "(", "self", ")", ":", "return", "dateutil", ".", "parser", ".", "parse", "(", "str", "(", "self", ".", "f", ".", "currentRevision", ".", "updated", ")", ")" ]
return datetime.datetime
[ "return", "datetime", ".", "datetime" ]
python
train
alejandroautalan/pygubu
pygubu/stockimage.py
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L124-L136
def get(cls, rkey): """Get image previously registered with key rkey. If key not exist, raise StockImageException """ if rkey in cls._cached: logger.info('Resource %s is in cache.' % rkey) return cls._cached[rkey] if rkey in cls._stock: img = ...
[ "def", "get", "(", "cls", ",", "rkey", ")", ":", "if", "rkey", "in", "cls", ".", "_cached", ":", "logger", ".", "info", "(", "'Resource %s is in cache.'", "%", "rkey", ")", "return", "cls", ".", "_cached", "[", "rkey", "]", "if", "rkey", "in", "cls",...
Get image previously registered with key rkey. If key not exist, raise StockImageException
[ "Get", "image", "previously", "registered", "with", "key", "rkey", ".", "If", "key", "not", "exist", "raise", "StockImageException" ]
python
train
wummel/linkchecker
linkcheck/lc_cgi.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/lc_cgi.py#L105-L111
def write (self, data): """Write given unicode data to buffer.""" assert isinstance(data, unicode) if self.closed: raise IOError("Write on closed I/O object") if data: self.buf.append(data)
[ "def", "write", "(", "self", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "unicode", ")", "if", "self", ".", "closed", ":", "raise", "IOError", "(", "\"Write on closed I/O object\"", ")", "if", "data", ":", "self", ".", "buf", ".", ...
Write given unicode data to buffer.
[ "Write", "given", "unicode", "data", "to", "buffer", "." ]
python
train
invisibleroads/socketIO-client
socketIO_client/namespaces.py
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/namespaces.py#L22-L25
def once(self, event, callback): 'Define a callback to handle the first event emitted by the server' self._once_events.add(event) self.on(event, callback)
[ "def", "once", "(", "self", ",", "event", ",", "callback", ")", ":", "self", ".", "_once_events", ".", "add", "(", "event", ")", "self", ".", "on", "(", "event", ",", "callback", ")" ]
Define a callback to handle the first event emitted by the server
[ "Define", "a", "callback", "to", "handle", "the", "first", "event", "emitted", "by", "the", "server" ]
python
train
getsentry/rb
rb/ketama.py
https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/ketama.py#L45-L58
def _get_node_pos(self, key): """Return node position(integer) for a given key or None.""" if not self._hashring: return k = md5_bytes(key) key = (k[3] << 24) | (k[2] << 16) | (k[1] << 8) | k[0] nodes = self._sorted_keys pos = bisect(nodes, key) if ...
[ "def", "_get_node_pos", "(", "self", ",", "key", ")", ":", "if", "not", "self", ".", "_hashring", ":", "return", "k", "=", "md5_bytes", "(", "key", ")", "key", "=", "(", "k", "[", "3", "]", "<<", "24", ")", "|", "(", "k", "[", "2", "]", "<<",...
Return node position(integer) for a given key or None.
[ "Return", "node", "position", "(", "integer", ")", "for", "a", "given", "key", "or", "None", "." ]
python
train
baverman/supplement
supplement/remote.py
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/remote.py#L114-L123
def assist(self, project_path, source, position, filename): """Return completion match and list of completion proposals :param project_path: absolute project path :param source: unicode or byte string code source :param position: character or byte cursor position :param filename...
[ "def", "assist", "(", "self", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")", ":", "return", "self", ".", "_call", "(", "'assist'", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")" ]
Return completion match and list of completion proposals :param project_path: absolute project path :param source: unicode or byte string code source :param position: character or byte cursor position :param filename: absolute path of file with source code :returns: tuple (compl...
[ "Return", "completion", "match", "and", "list", "of", "completion", "proposals" ]
python
train
upsight/doctor
doctor/parsers.py
https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/parsers.py#L213-L268
def parse_form_and_query_params(req_params: dict, sig_params: dict) -> dict: """Uses the parameter annotations to coerce string params. This is used for HTTP requests, in which the form parameters are all strings, but need to be converted to the appropriate types before validating them. :param dic...
[ "def", "parse_form_and_query_params", "(", "req_params", ":", "dict", ",", "sig_params", ":", "dict", ")", "->", "dict", ":", "# Importing here to prevent circular dependencies.", "from", "doctor", ".", "types", "import", "SuperType", ",", "UnionType", "errors", "=", ...
Uses the parameter annotations to coerce string params. This is used for HTTP requests, in which the form parameters are all strings, but need to be converted to the appropriate types before validating them. :param dict req_params: The parameters specified in the request. :param dict sig_params: T...
[ "Uses", "the", "parameter", "annotations", "to", "coerce", "string", "params", "." ]
python
train
yjzhang/uncurl_python
uncurl/ensemble.py
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L150-L177
def nmf_tsne(data, k, n_runs=10, init='enhanced', **params): """ runs tsne-consensus-NMF 1. run a bunch of NMFs, get W and H 2. run tsne + km on all WH matrices 3. run consensus clustering on all km results 4. use consensus clustering as initialization for a new run of NMF 5. return the W a...
[ "def", "nmf_tsne", "(", "data", ",", "k", ",", "n_runs", "=", "10", ",", "init", "=", "'enhanced'", ",", "*", "*", "params", ")", ":", "clusters", "=", "[", "]", "nmf", "=", "NMF", "(", "k", ")", "tsne", "=", "TSNE", "(", "2", ")", "km", "=",...
runs tsne-consensus-NMF 1. run a bunch of NMFs, get W and H 2. run tsne + km on all WH matrices 3. run consensus clustering on all km results 4. use consensus clustering as initialization for a new run of NMF 5. return the W and H from the resulting NMF run
[ "runs", "tsne", "-", "consensus", "-", "NMF" ]
python
train
aestrivex/bctpy
bct/algorithms/centrality.py
https://github.com/aestrivex/bctpy/blob/4cb0e759eb4a038750b07e23bd29958c400684b8/bct/algorithms/centrality.py#L183-L248
def edge_betweenness_bin(G): ''' Edge betweenness centrality is the fraction of all shortest paths in the network that contain a given edge. Edges with high values of betweenness centrality participate in a large number of shortest paths. Parameters ---------- A : NxN np.ndarray bin...
[ "def", "edge_betweenness_bin", "(", "G", ")", ":", "n", "=", "len", "(", "G", ")", "BC", "=", "np", ".", "zeros", "(", "(", "n", ",", ")", ")", "# vertex betweenness", "EBC", "=", "np", ".", "zeros", "(", "(", "n", ",", "n", ")", ")", "# edge b...
Edge betweenness centrality is the fraction of all shortest paths in the network that contain a given edge. Edges with high values of betweenness centrality participate in a large number of shortest paths. Parameters ---------- A : NxN np.ndarray binary directed/undirected connection matrix...
[ "Edge", "betweenness", "centrality", "is", "the", "fraction", "of", "all", "shortest", "paths", "in", "the", "network", "that", "contain", "a", "given", "edge", ".", "Edges", "with", "high", "values", "of", "betweenness", "centrality", "participate", "in", "a"...
python
train
inasafe/inasafe
safe/gui/tools/multi_buffer_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/multi_buffer_dialog.py#L178-L185
def get_output_from_input(self): """Populate output form with default output path based on input layer. """ input_path = self.layer.currentLayer().source() output_path = ( os.path.splitext(input_path)[0] + '_multi_buffer' + os.path.splitext(input_path)[1]) ...
[ "def", "get_output_from_input", "(", "self", ")", ":", "input_path", "=", "self", ".", "layer", ".", "currentLayer", "(", ")", ".", "source", "(", ")", "output_path", "=", "(", "os", ".", "path", ".", "splitext", "(", "input_path", ")", "[", "0", "]", ...
Populate output form with default output path based on input layer.
[ "Populate", "output", "form", "with", "default", "output", "path", "based", "on", "input", "layer", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/utils/text.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/text.py#L275-L300
def qw(words,flat=0,sep=None,maxsplit=-1): """Similar to Perl's qw() operator, but with some more options. qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) words can also be a list itself, and with flat=1, the output will be recursively flattened. Examples: >>> qw('1 2') ...
[ "def", "qw", "(", "words", ",", "flat", "=", "0", ",", "sep", "=", "None", ",", "maxsplit", "=", "-", "1", ")", ":", "if", "isinstance", "(", "words", ",", "basestring", ")", ":", "return", "[", "word", ".", "strip", "(", ")", "for", "word", "i...
Similar to Perl's qw() operator, but with some more options. qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) words can also be a list itself, and with flat=1, the output will be recursively flattened. Examples: >>> qw('1 2') ['1', '2'] >>> qw(['a b','1 2',['m n','p q']...
[ "Similar", "to", "Perl", "s", "qw", "()", "operator", "but", "with", "some", "more", "options", "." ]
python
test
brocade/pynos
pynos/versions/base/yang/ietf_netconf.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/ietf_netconf.py#L42-L55
def get_config_input_source_config_source_startup_startup(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_config = ET.Element("get_config") config = get_config input = ET.SubElement(get_config, "input") source = ET.SubElement(input, "...
[ "def", "get_config_input_source_config_source_startup_startup", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_config", "=", "ET", ".", "Element", "(", "\"get_config\"", ")", "config", "=", "ge...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
MycroftAI/adapt
adapt/engine.py
https://github.com/MycroftAI/adapt/blob/334f23248b8e09fb9d84a88398424ec5bd3bae4c/adapt/engine.py#L258-L270
def _regex_strings(self): """ A property to link into IntentEngine's _regex_strings. Warning: this is only for backwards compatiblility and should not be used if you intend on using domains. Returns: the domains _regex_strings from its IntentEngine """ domai...
[ "def", "_regex_strings", "(", "self", ")", ":", "domain", "=", "0", "if", "domain", "not", "in", "self", ".", "domains", ":", "self", ".", "register_domain", "(", "domain", "=", "domain", ")", "return", "self", ".", "domains", "[", "domain", "]", ".", ...
A property to link into IntentEngine's _regex_strings. Warning: this is only for backwards compatiblility and should not be used if you intend on using domains. Returns: the domains _regex_strings from its IntentEngine
[ "A", "property", "to", "link", "into", "IntentEngine", "s", "_regex_strings", "." ]
python
train
ttroy50/pyephember
pyephember/pyephember.py
https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L77-L109
def _login(self): """ Login using username / password and get the first auth token """ headers = { "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json" } url = self.api_base_url + "account/directlogin" data = ...
[ "def", "_login", "(", "self", ")", ":", "headers", "=", "{", "\"Content-Type\"", ":", "\"application/x-www-form-urlencoded\"", ",", "\"Accept\"", ":", "\"application/json\"", "}", "url", "=", "self", ".", "api_base_url", "+", "\"account/directlogin\"", "data", "=", ...
Login using username / password and get the first auth token
[ "Login", "using", "username", "/", "password", "and", "get", "the", "first", "auth", "token" ]
python
train
johnwlockwood/stream_tap
stream_tap/__init__.py
https://github.com/johnwlockwood/stream_tap/blob/068f6427c39202991a1db2be842b0fa43c6c5b91/stream_tap/__init__.py#L40-L54
def stream_tap(callables, stream): """ Calls each callable with each item in the stream. Use with Buckets. Make a Bucket with a callable and then pass a tuple of those buckets in as the callables. After iterating over this generator, get contents from each Spigot. :param callables: collecti...
[ "def", "stream_tap", "(", "callables", ",", "stream", ")", ":", "for", "item", "in", "stream", ":", "for", "caller", "in", "callables", ":", "caller", "(", "item", ")", "yield", "item" ]
Calls each callable with each item in the stream. Use with Buckets. Make a Bucket with a callable and then pass a tuple of those buckets in as the callables. After iterating over this generator, get contents from each Spigot. :param callables: collection of callable. :param stream: Iterator if ...
[ "Calls", "each", "callable", "with", "each", "item", "in", "the", "stream", ".", "Use", "with", "Buckets", ".", "Make", "a", "Bucket", "with", "a", "callable", "and", "then", "pass", "a", "tuple", "of", "those", "buckets", "in", "as", "the", "callables",...
python
train
peergradeio/flask-mongo-profiler
flask_mongo_profiler/contrib/flask_admin/helpers.py
https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/helpers.py#L12-L63
def get_list_url_filtered_by_field_value(view, model, name, reverse=False): """Get the URL if a filter of model[name] value was appended. This allows programatically adding filters. This is used in the specialized case of filtering deeper into a list by a field's value. For instance, since there can b...
[ "def", "get_list_url_filtered_by_field_value", "(", "view", ",", "model", ",", "name", ",", "reverse", "=", "False", ")", ":", "view_args", "=", "view", ".", "_get_list_extra_args", "(", ")", "def", "create_filter_arg", "(", "field_name", ",", "value", ")", ":...
Get the URL if a filter of model[name] value was appended. This allows programatically adding filters. This is used in the specialized case of filtering deeper into a list by a field's value. For instance, since there can be multiple assignments in a list of handins. The assignment column can have a U...
[ "Get", "the", "URL", "if", "a", "filter", "of", "model", "[", "name", "]", "value", "was", "appended", "." ]
python
train
NiklasRosenstein-Python/nr-deprecated
nr/strex.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/strex.py#L218-L242
def match(self, regex, flags=0): """ Matches the specified *regex* from the current character of the *scanner* and returns the result. The Scanners column and line numbers are updated respectively. # Arguments regex (str, Pattern): The regex to match. flags (int): The flags to use when comp...
[ "def", "match", "(", "self", ",", "regex", ",", "flags", "=", "0", ")", ":", "if", "isinstance", "(", "regex", ",", "str", ")", ":", "regex", "=", "re", ".", "compile", "(", "regex", ",", "flags", ")", "match", "=", "regex", ".", "match", "(", ...
Matches the specified *regex* from the current character of the *scanner* and returns the result. The Scanners column and line numbers are updated respectively. # Arguments regex (str, Pattern): The regex to match. flags (int): The flags to use when compiling the pattern.
[ "Matches", "the", "specified", "*", "regex", "*", "from", "the", "current", "character", "of", "the", "*", "scanner", "*", "and", "returns", "the", "result", ".", "The", "Scanners", "column", "and", "line", "numbers", "are", "updated", "respectively", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L739-L763
def find_deadlocks(self): """ This function detects deadlocks Return: named tuple with the tasks grouped in: deadlocks, runnables, running """ # Find jobs that can be submitted and and the jobs that are already in the queue. runnables = [] for work in...
[ "def", "find_deadlocks", "(", "self", ")", ":", "# Find jobs that can be submitted and and the jobs that are already in the queue.", "runnables", "=", "[", "]", "for", "work", "in", "self", ":", "runnables", ".", "extend", "(", "work", ".", "fetch_alltasks_to_run", "(",...
This function detects deadlocks Return: named tuple with the tasks grouped in: deadlocks, runnables, running
[ "This", "function", "detects", "deadlocks" ]
python
train
djaodjin/djaodjin-deployutils
src/djd.py
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/src/djd.py#L106-L131
def main(args): """ Main Entry Point """ try: import __main__ parser = argparse.ArgumentParser( usage='%(prog)s [options] command\n\nVersion\n %(prog)s version ' + str(__version__), formatter_class=argparse.RawTextHelpFormatter) parser.add_arg...
[ "def", "main", "(", "args", ")", ":", "try", ":", "import", "__main__", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "'%(prog)s [options] command\\n\\nVersion\\n %(prog)s version '", "+", "str", "(", "__version__", ")", ",", "formatter_class...
Main Entry Point
[ "Main", "Entry", "Point" ]
python
train
monarch-initiative/dipper
dipper/sources/FlyBase.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1324-L1389
def _process_cvterm(self): """ CVterms are the internal identifiers for any controlled vocab or ontology term. Many are xrefd to actual ontologies. The actual external id is stored in the dbxref table, which we place into the internal hashmap for lookup with the cvterm id. The...
[ "def", "_process_cvterm", "(", "self", ")", ":", "line_counter", "=", "0", "raw", "=", "'/'", ".", "join", "(", "(", "self", ".", "rawdir", ",", "'cvterm'", ")", ")", "LOG", ".", "info", "(", "\"processing cvterms\"", ")", "with", "open", "(", "raw", ...
CVterms are the internal identifiers for any controlled vocab or ontology term. Many are xrefd to actual ontologies. The actual external id is stored in the dbxref table, which we place into the internal hashmap for lookup with the cvterm id. The name of the external term is stored in...
[ "CVterms", "are", "the", "internal", "identifiers", "for", "any", "controlled", "vocab", "or", "ontology", "term", ".", "Many", "are", "xrefd", "to", "actual", "ontologies", ".", "The", "actual", "external", "id", "is", "stored", "in", "the", "dbxref", "tabl...
python
train
Josef-Friedrich/phrydy
phrydy/mediafile.py
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L117-L139
def mutagen_call(action, path, func, *args, **kwargs): """Call a Mutagen function with appropriate error handling. `action` is a string describing what the function is trying to do, and `path` is the relevant filename. The rest of the arguments describe the callable to invoke. We require at least ...
[ "def", "mutagen_call", "(", "action", ",", "path", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "mutagen", ".", "MutagenError", "as", "exc"...
Call a Mutagen function with appropriate error handling. `action` is a string describing what the function is trying to do, and `path` is the relevant filename. The rest of the arguments describe the callable to invoke. We require at least Mutagen 1.33, where `IOError` is *never* used, neither for...
[ "Call", "a", "Mutagen", "function", "with", "appropriate", "error", "handling", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xcombobox.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L395-L418
def setCheckable( self, state ): """ Sets whether or not this combobox stores checkable items. :param state | <bool> """ self._checkable = state # need to be editable to be checkable edit = self.lineEdit() if state: self....
[ "def", "setCheckable", "(", "self", ",", "state", ")", ":", "self", ".", "_checkable", "=", "state", "# need to be editable to be checkable", "edit", "=", "self", ".", "lineEdit", "(", ")", "if", "state", ":", "self", ".", "setEditable", "(", "True", ")", ...
Sets whether or not this combobox stores checkable items. :param state | <bool>
[ "Sets", "whether", "or", "not", "this", "combobox", "stores", "checkable", "items", ".", ":", "param", "state", "|", "<bool", ">" ]
python
train
ethereum/py-evm
eth/chains/base.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L545-L551
def get_block_by_hash(self, block_hash: Hash32) -> BaseBlock: """ Returns the requested block as specified by block hash. """ validate_word(block_hash, title="Block Hash") block_header = self.get_block_header_by_hash(block_hash) return self.get_block_by_header(block_heade...
[ "def", "get_block_by_hash", "(", "self", ",", "block_hash", ":", "Hash32", ")", "->", "BaseBlock", ":", "validate_word", "(", "block_hash", ",", "title", "=", "\"Block Hash\"", ")", "block_header", "=", "self", ".", "get_block_header_by_hash", "(", "block_hash", ...
Returns the requested block as specified by block hash.
[ "Returns", "the", "requested", "block", "as", "specified", "by", "block", "hash", "." ]
python
train
ASMfreaK/habitipy
habitipy/api.py
https://github.com/ASMfreaK/habitipy/blob/555b8b20faf6d553353092614a8a0d612f0adbde/habitipy/api.py#L439-L446
def validate(self, obj): """check if obj has this api param""" if self.path: for i in self.path: obj = obj[i] obj = obj[self.field] raise NotImplementedError('Validation is not implemented yet')
[ "def", "validate", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "path", ":", "for", "i", "in", "self", ".", "path", ":", "obj", "=", "obj", "[", "i", "]", "obj", "=", "obj", "[", "self", ".", "field", "]", "raise", "NotImplementedError",...
check if obj has this api param
[ "check", "if", "obj", "has", "this", "api", "param" ]
python
train
opentok/Opentok-Python-SDK
opentok/opentok.py
https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L896-L934
def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None): """ Use this method to change the layout type of a live streaming broadcast :param String broadcast_id: The ID of the broadcast that will be updated :param String layout_type: The layout type for the broadcast....
[ "def", "set_broadcast_layout", "(", "self", ",", "broadcast_id", ",", "layout_type", ",", "stylesheet", "=", "None", ")", ":", "payload", "=", "{", "'type'", ":", "layout_type", ",", "}", "if", "layout_type", "==", "'custom'", ":", "if", "stylesheet", "is", ...
Use this method to change the layout type of a live streaming broadcast :param String broadcast_id: The ID of the broadcast that will be updated :param String layout_type: The layout type for the broadcast. Valid values are: 'bestFit', 'custom', 'horizontalPresentation', 'pip' and 'verticalPre...
[ "Use", "this", "method", "to", "change", "the", "layout", "type", "of", "a", "live", "streaming", "broadcast" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py#L155-L170
def nacm_rule_list_rule_module_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm") rule_list = ET.SubElement(nacm, "rule-list") name_key = ET.SubElement(r...
[ "def", "nacm_rule_list_rule_module_name", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "nacm", "=", "ET", ".", "SubElement", "(", "config", ",", "\"nacm\"", ",", "xmlns", "=", "\"urn:ietf:para...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
gtaylor/python-colormath
colormath/color_diff_matrix.py
https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff_matrix.py#L11-L17
def delta_e_cie1976(lab_color_vector, lab_color_matrix): """ Calculates the Delta E (CIE1976) between `lab_color_vector` and all colors in `lab_color_matrix`. """ return numpy.sqrt( numpy.sum(numpy.power(lab_color_vector - lab_color_matrix, 2), axis=1))
[ "def", "delta_e_cie1976", "(", "lab_color_vector", ",", "lab_color_matrix", ")", ":", "return", "numpy", ".", "sqrt", "(", "numpy", ".", "sum", "(", "numpy", ".", "power", "(", "lab_color_vector", "-", "lab_color_matrix", ",", "2", ")", ",", "axis", "=", "...
Calculates the Delta E (CIE1976) between `lab_color_vector` and all colors in `lab_color_matrix`.
[ "Calculates", "the", "Delta", "E", "(", "CIE1976", ")", "between", "lab_color_vector", "and", "all", "colors", "in", "lab_color_matrix", "." ]
python
train
dadadel/pyment
pyment/docstring.py
https://github.com/dadadel/pyment/blob/3d1bdf87d083ff56230bd0bf7c5252e20552b7b6/pyment/docstring.py#L190-L207
def get_return_list(self, data): """Get the list of returned values. The list contains tuples (name=None, desc, type=None) :param data: the data to proceed """ return_list = [] lst = self.get_list_key(data, 'return') for l in lst: name, desc, rtype =...
[ "def", "get_return_list", "(", "self", ",", "data", ")", ":", "return_list", "=", "[", "]", "lst", "=", "self", ".", "get_list_key", "(", "data", ",", "'return'", ")", "for", "l", "in", "lst", ":", "name", ",", "desc", ",", "rtype", "=", "l", "if",...
Get the list of returned values. The list contains tuples (name=None, desc, type=None) :param data: the data to proceed
[ "Get", "the", "list", "of", "returned", "values", ".", "The", "list", "contains", "tuples", "(", "name", "=", "None", "desc", "type", "=", "None", ")" ]
python
train
clalancette/pycdlib
pycdlib/pycdlib.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L3619-L3643
def _rm_joliet_dir(self, joliet_path): # type: (bytes) -> int ''' An internal method to remove a directory from the Joliet portion of the ISO. Parameters: joliet_path - The Joliet directory to remove. Returns: The number of bytes to remove from the ISO for this...
[ "def", "_rm_joliet_dir", "(", "self", ",", "joliet_path", ")", ":", "# type: (bytes) -> int", "if", "self", ".", "joliet_vd", "is", "None", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Tried to remove joliet dir from non-Joliet ISO'", ")", "log_...
An internal method to remove a directory from the Joliet portion of the ISO. Parameters: joliet_path - The Joliet directory to remove. Returns: The number of bytes to remove from the ISO for this Joliet directory.
[ "An", "internal", "method", "to", "remove", "a", "directory", "from", "the", "Joliet", "portion", "of", "the", "ISO", "." ]
python
train
tjcsl/ion
intranet/apps/announcements/views.py
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/views.py#L147-L184
def approve_announcement_view(request, req_id): """The approve announcement page. Teachers will be linked to this page from an email. req_id: The ID of the AnnouncementRequest """ req = get_object_or_404(AnnouncementRequest, id=req_id) requested_teachers = req.teachers_requested.all() logger....
[ "def", "approve_announcement_view", "(", "request", ",", "req_id", ")", ":", "req", "=", "get_object_or_404", "(", "AnnouncementRequest", ",", "id", "=", "req_id", ")", "requested_teachers", "=", "req", ".", "teachers_requested", ".", "all", "(", ")", "logger", ...
The approve announcement page. Teachers will be linked to this page from an email. req_id: The ID of the AnnouncementRequest
[ "The", "approve", "announcement", "page", ".", "Teachers", "will", "be", "linked", "to", "this", "page", "from", "an", "email", "." ]
python
train
Opentrons/opentrons
api/src/opentrons/protocol_api/labware.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/labware.py#L808-L827
def load_module_from_definition( definition: dict, parent: Location) -> \ Union[ModuleGeometry, ThermocyclerGeometry]: """ Return a :py:class:`ModuleGeometry` object from a specified definition :param definition: A dict representing all required data for a module's ...
[ "def", "load_module_from_definition", "(", "definition", ":", "dict", ",", "parent", ":", "Location", ")", "->", "Union", "[", "ModuleGeometry", ",", "ThermocyclerGeometry", "]", ":", "mod_name", "=", "definition", "[", "'loadName'", "]", "if", "mod_name", "==",...
Return a :py:class:`ModuleGeometry` object from a specified definition :param definition: A dict representing all required data for a module's geometry. :param parent: A :py:class:`.Location` representing the location where the front and left most point of the outside ...
[ "Return", "a", ":", "py", ":", "class", ":", "ModuleGeometry", "object", "from", "a", "specified", "definition" ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/gridmesh.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/gridmesh.py#L55-L99
def set_data(self, xs=None, ys=None, zs=None, colors=None): '''Update the mesh data. Parameters ---------- xs : ndarray | None A 2d array of x coordinates for the vertices of the mesh. ys : ndarray | None A 2d array of y coordinates for the vertices of th...
[ "def", "set_data", "(", "self", ",", "xs", "=", "None", ",", "ys", "=", "None", ",", "zs", "=", "None", ",", "colors", "=", "None", ")", ":", "if", "xs", "is", "None", ":", "xs", "=", "self", ".", "_xs", "self", ".", "__vertices", "=", "None", ...
Update the mesh data. Parameters ---------- xs : ndarray | None A 2d array of x coordinates for the vertices of the mesh. ys : ndarray | None A 2d array of y coordinates for the vertices of the mesh. zs : ndarray | None A 2d array of z coordin...
[ "Update", "the", "mesh", "data", "." ]
python
train
Nic30/hwt
hwt/synthesizer/param.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/param.py#L105-L115
def evalParam(p): """ Get value of parameter """ while isinstance(p, Param): p = p.get() if isinstance(p, RtlSignalBase): return p.staticEval() # use rather param inheritance instead of param as param value return toHVal(p)
[ "def", "evalParam", "(", "p", ")", ":", "while", "isinstance", "(", "p", ",", "Param", ")", ":", "p", "=", "p", ".", "get", "(", ")", "if", "isinstance", "(", "p", ",", "RtlSignalBase", ")", ":", "return", "p", ".", "staticEval", "(", ")", "# use...
Get value of parameter
[ "Get", "value", "of", "parameter" ]
python
test
hozn/stravalib
stravalib/attributes.py
https://github.com/hozn/stravalib/blob/5500ebc39e0bf4706bb1ca4c27b25e56becaaa5f/stravalib/attributes.py#L256-L274
def marshal(self, v): """ Turn this value into API format. Do a reverse dictionary lookup on choices to find the original value. If there are no keys or too many keys for now we raise a NotImplementedError as marshal is not used anywhere currently. In the future we will want to ...
[ "def", "marshal", "(", "self", ",", "v", ")", ":", "if", "v", ":", "orig", "=", "[", "i", "for", "i", "in", "self", ".", "choices", "if", "self", ".", "choices", "[", "i", "]", "==", "v", "]", "if", "len", "(", "orig", ")", "==", "1", ":", ...
Turn this value into API format. Do a reverse dictionary lookup on choices to find the original value. If there are no keys or too many keys for now we raise a NotImplementedError as marshal is not used anywhere currently. In the future we will want to fail gracefully.
[ "Turn", "this", "value", "into", "API", "format", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/internal/monte_carlo.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/monte_carlo.py#L30-L99
def expectation_importance_sampler(f, log_p, sampling_dist_q, z=None, n=None, seed=None, name='expectation_imp...
[ "def", "expectation_importance_sampler", "(", "f", ",", "log_p", ",", "sampling_dist_q", ",", "z", "=", "None", ",", "n", "=", "None", ",", "seed", "=", "None", ",", "name", "=", "'expectation_importance_sampler'", ")", ":", "q", "=", "sampling_dist_q", "wit...
r"""Monte Carlo estimate of \\(E_p[f(Z)] = E_q[f(Z) p(Z) / q(Z)]\\). With \\(p(z) := exp^{log_p(z)}\\), this `Op` returns \\(n^{-1} sum_{i=1}^n [ f(z_i) p(z_i) / q(z_i) ], z_i ~ q,\\) \\(\approx E_q[ f(Z) p(Z) / q(Z) ]\\) \\(= E_p[f(Z)]\\) This integral is done in log-space with max-subtraction to b...
[ "r", "Monte", "Carlo", "estimate", "of", "\\\\", "(", "E_p", "[", "f", "(", "Z", ")", "]", "=", "E_q", "[", "f", "(", "Z", ")", "p", "(", "Z", ")", "/", "q", "(", "Z", ")", "]", "\\\\", ")", "." ]
python
test
mitsei/dlkit
dlkit/json_/resource/searches.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/searches.py#L217-L228
def get_bins(self): """Gets the bin list resulting from the search. return: (osid.resource.BinList) - the bin list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.I...
[ "def", "get_bins", "(", "self", ")", ":", "if", "self", ".", "retrieved", ":", "raise", "errors", ".", "IllegalState", "(", "'List has already been retrieved.'", ")", "self", ".", "retrieved", "=", "True", "return", "objects", ".", "BinList", "(", "self", "....
Gets the bin list resulting from the search. return: (osid.resource.BinList) - the bin list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "bin", "list", "resulting", "from", "the", "search", "." ]
python
train
numenta/htmresearch
htmresearch/frameworks/location/path_integration_union_narrowing.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/location/path_integration_union_narrowing.py#L279-L291
def getLocationRepresentation(self): """ Get the full population representation of the location layer. """ activeCells = np.array([], dtype="uint32") totalPrevCells = 0 for module in self.L6aModules: activeCells = np.append(activeCells, module.getActiveCells(...
[ "def", "getLocationRepresentation", "(", "self", ")", ":", "activeCells", "=", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "\"uint32\"", ")", "totalPrevCells", "=", "0", "for", "module", "in", "self", ".", "L6aModules", ":", "activeCells", "=", ...
Get the full population representation of the location layer.
[ "Get", "the", "full", "population", "representation", "of", "the", "location", "layer", "." ]
python
train
sckott/pygbif
pygbif/occurrences/download.py
https://github.com/sckott/pygbif/blob/bf54f2920bc46d97d7e2e1b0c8059e5878f3c5ab/pygbif/occurrences/download.py#L361-L391
def download_get(key, path=".", **kwargs): """ Get a download from GBIF. :param key: [str] A key generated from a request, like that from ``download`` :param path: [str] Path to write zip file to. Default: ``"."``, with a ``.zip`` appended to the end. :param **kwargs**: Further named arguments pass...
[ "def", "download_get", "(", "key", ",", "path", "=", "\".\"", ",", "*", "*", "kwargs", ")", ":", "meta", "=", "pygbif", ".", "occurrences", ".", "download_meta", "(", "key", ")", "if", "meta", "[", "'status'", "]", "!=", "'SUCCEEDED'", ":", "raise", ...
Get a download from GBIF. :param key: [str] A key generated from a request, like that from ``download`` :param path: [str] Path to write zip file to. Default: ``"."``, with a ``.zip`` appended to the end. :param **kwargs**: Further named arguments passed on to ``requests.get`` Downloads the zip file t...
[ "Get", "a", "download", "from", "GBIF", "." ]
python
train
lingpy/sinopy
src/sinopy/sinopy.py
https://github.com/lingpy/sinopy/blob/59a47fcdfae3e0000ac6d2b3d7919bf875ec2056/src/sinopy/sinopy.py#L150-L164
def chars2gloss(chars): """ Get the TLS basic gloss for a characters. """ out = [] chars = gbk2big5(chars) for char in chars: tmp = [] if char in _cd.TLS: for entry in _cd.TLS[char]: baxter = _cd.TLS[char][entry]['UNIHAN_GLOSS'] if baxt...
[ "def", "chars2gloss", "(", "chars", ")", ":", "out", "=", "[", "]", "chars", "=", "gbk2big5", "(", "chars", ")", "for", "char", "in", "chars", ":", "tmp", "=", "[", "]", "if", "char", "in", "_cd", ".", "TLS", ":", "for", "entry", "in", "_cd", "...
Get the TLS basic gloss for a characters.
[ "Get", "the", "TLS", "basic", "gloss", "for", "a", "characters", "." ]
python
train
cassinyio/SwarmSpawner
cassinyspawner/swarmspawner.py
https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L260-L370
def start(self): """Start the single-user server in a docker service. You can specify the params for the service through jupyterhub_config.py or using the user_options """ # https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/user.py#L202 # By default jupyter...
[ "def", "start", "(", "self", ")", ":", "# https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/user.py#L202", "# By default jupyterhub calls the spawner passing user_options", "if", "self", ".", "use_user_options", ":", "user_options", "=", "self", ".", "user_options", ...
Start the single-user server in a docker service. You can specify the params for the service through jupyterhub_config.py or using the user_options
[ "Start", "the", "single", "-", "user", "server", "in", "a", "docker", "service", ".", "You", "can", "specify", "the", "params", "for", "the", "service", "through", "jupyterhub_config", ".", "py", "or", "using", "the", "user_options" ]
python
test
roaet/eh
eh/mdv/markdownviewer.py
https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L271-L298
def style_ansi(raw_code, lang=None): """ actual code hilite """ lexer = 0 if lang: try: lexer = get_lexer_by_name(lang) except ValueError: print col(R, 'Lexer for %s not found' % lang) lexer = None if not lexer: try: if guess_lexer: ...
[ "def", "style_ansi", "(", "raw_code", ",", "lang", "=", "None", ")", ":", "lexer", "=", "0", "if", "lang", ":", "try", ":", "lexer", "=", "get_lexer_by_name", "(", "lang", ")", "except", "ValueError", ":", "print", "col", "(", "R", ",", "'Lexer for %s ...
actual code hilite
[ "actual", "code", "hilite" ]
python
train
GetmeUK/MongoFrames
mongoframes/frames.py
https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/frames.py#L374-L394
def delete_many(cls, documents): """Delete multiple documents""" # Ensure all documents have been converted to frames frames = cls._ensure_frames(documents) all_count = len(documents) assert len([f for f in frames if '_id' in f._document]) == all_count, \ "Can't...
[ "def", "delete_many", "(", "cls", ",", "documents", ")", ":", "# Ensure all documents have been converted to frames", "frames", "=", "cls", ".", "_ensure_frames", "(", "documents", ")", "all_count", "=", "len", "(", "documents", ")", "assert", "len", "(", "[", "...
Delete multiple documents
[ "Delete", "multiple", "documents" ]
python
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L124-L129
def connect(self): """ Open a new telnet session on the remote server. """ self.client = BaitTelnetClient(self.options['server'], self.options['port']) self.client.set_option_negotiation_callback(self.process_options)
[ "def", "connect", "(", "self", ")", ":", "self", ".", "client", "=", "BaitTelnetClient", "(", "self", ".", "options", "[", "'server'", "]", ",", "self", ".", "options", "[", "'port'", "]", ")", "self", ".", "client", ".", "set_option_negotiation_callback",...
Open a new telnet session on the remote server.
[ "Open", "a", "new", "telnet", "session", "on", "the", "remote", "server", "." ]
python
train
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L185-L266
def signmsg(msg,priv,iscompressed,k=0): ''' Sign a message -- the message itself, not a hash -- with a given private key. Input private key must be hex, NOT WIF. Use wiftohex() found in .bitcoin in order to get the hex private key and whether it is (or rather, its public key is) compressed. ...
[ "def", "signmsg", "(", "msg", ",", "priv", ",", "iscompressed", ",", "k", "=", "0", ")", ":", "omsg", "=", "msg", "# Stripping carraige returns is standard practice in every", "# implementation I found, including Bitcoin Core", "msg", "=", "msg", ".", "replace", "(", ...
Sign a message -- the message itself, not a hash -- with a given private key. Input private key must be hex, NOT WIF. Use wiftohex() found in .bitcoin in order to get the hex private key and whether it is (or rather, its public key is) compressed. 'iscompressed' is True/False bool for whether or ...
[ "Sign", "a", "message", "--", "the", "message", "itself", "not", "a", "hash", "--", "with", "a", "given", "private", "key", "." ]
python
train
phoebe-project/phoebe2
phoebe/frontend/bundle.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L2183-L2408
def add_dataset(self, kind, component=None, **kwargs): """ Add a new dataset to the bundle. If not provided, 'dataset' (the name of the new dataset) will be created for you and can be accessed by the 'dataset' attribute of the returned ParameterSet. For light curves, th...
[ "def", "add_dataset", "(", "self", ",", "kind", ",", "component", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sing_plural", "=", "{", "}", "sing_plural", "[", "'time'", "]", "=", "'times'", "sing_plural", "[", "'flux'", "]", "=", "'fluxes'", "sing...
Add a new dataset to the bundle. If not provided, 'dataset' (the name of the new dataset) will be created for you and can be accessed by the 'dataset' attribute of the returned ParameterSet. For light curves, the light curve will be generated for the entire system. For radial ...
[ "Add", "a", "new", "dataset", "to", "the", "bundle", ".", "If", "not", "provided", "dataset", "(", "the", "name", "of", "the", "new", "dataset", ")", "will", "be", "created", "for", "you", "and", "can", "be", "accessed", "by", "the", "dataset", "attrib...
python
train
tilezen/tilequeue
tilequeue/rawr.py
https://github.com/tilezen/tilequeue/blob/d7b9484ab92e246eb2773949c784ebb37c731e28/tilequeue/rawr.py#L542-L561
def unpack_rawr_zip_payload(table_sources, payload): """unpack a zipfile and turn it into a callable "tables" object.""" # the io we get from S3 is streaming, so we can't seek on it, but zipfile # seems to require that. so we buffer it all in memory. RAWR tiles are # generally up to around 100MB in size...
[ "def", "unpack_rawr_zip_payload", "(", "table_sources", ",", "payload", ")", ":", "# the io we get from S3 is streaming, so we can't seek on it, but zipfile", "# seems to require that. so we buffer it all in memory. RAWR tiles are", "# generally up to around 100MB in size, which should be safe t...
unpack a zipfile and turn it into a callable "tables" object.
[ "unpack", "a", "zipfile", "and", "turn", "it", "into", "a", "callable", "tables", "object", "." ]
python
train
Yelp/threat_intel
threat_intel/util/api_cache.py
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L71-L80
def lookup_value(self, api_name, key): """Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. """ if api_name in self._cache: return s...
[ "def", "lookup_value", "(", "self", ",", "api_name", ",", "key", ")", ":", "if", "api_name", "in", "self", ".", "_cache", ":", "return", "self", ".", "_cache", "[", "api_name", "]", ".", "get", "(", "key", ",", "None", ")", "return", "None" ]
Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call.
[ "Add", "the", "value", "of", "an", "API", "call", "to", "the", "cache", "." ]
python
train
JoeVirtual/KonFoo
konfoo/options.py
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/options.py#L72-L87
def verbose_option(default=False): """ Attaches the option ``verbose`` with its *default* value to the keyword arguments when the option does not exist. All positional arguments and keyword arguments are forwarded unchanged. """ def decorator(method): @wraps(method) def wrapper(*arg...
[ "def", "verbose_option", "(", "default", "=", "False", ")", ":", "def", "decorator", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "option", "=", "Option", ".", "ve...
Attaches the option ``verbose`` with its *default* value to the keyword arguments when the option does not exist. All positional arguments and keyword arguments are forwarded unchanged.
[ "Attaches", "the", "option", "verbose", "with", "its", "*", "default", "*", "value", "to", "the", "keyword", "arguments", "when", "the", "option", "does", "not", "exist", ".", "All", "positional", "arguments", "and", "keyword", "arguments", "are", "forwarded",...
python
train
WebarchivCZ/WA-KAT
src/wa_kat/templates/static/js/Lib/site-packages/components/progressbar.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/progressbar.py#L69-L78
def reset(self): """ Reset the progressbar to 0, hide it and set original text message at background. """ self.hide() self.tag.class_name = "progress-bar progress-bar-striped active" self.tag.aria_valuemin = 0 self.tag.style.width = "{}%".format(0) ...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "hide", "(", ")", "self", ".", "tag", ".", "class_name", "=", "\"progress-bar progress-bar-striped active\"", "self", ".", "tag", ".", "aria_valuemin", "=", "0", "self", ".", "tag", ".", "style", ".", "...
Reset the progressbar to 0, hide it and set original text message at background.
[ "Reset", "the", "progressbar", "to", "0", "hide", "it", "and", "set", "original", "text", "message", "at", "background", "." ]
python
train
radjkarl/fancyWidgets
DUMP/pyqtgraphBased/parametertree/parameterTypes.py
https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/DUMP/pyqtgraphBased/parametertree/parameterTypes.py#L258-L266
def limitsChanged(self, param, limits): """Called when the parameter's limits have changed""" ParameterItem.limitsChanged(self, param, limits) t = self.param.opts['type'] if t == 'int' or t == 'float': self.widget.setOpts(bounds=limits) else: return
[ "def", "limitsChanged", "(", "self", ",", "param", ",", "limits", ")", ":", "ParameterItem", ".", "limitsChanged", "(", "self", ",", "param", ",", "limits", ")", "t", "=", "self", ".", "param", ".", "opts", "[", "'type'", "]", "if", "t", "==", "'int'...
Called when the parameter's limits have changed
[ "Called", "when", "the", "parameter", "s", "limits", "have", "changed" ]
python
train
EliotBerriot/django-dynamic-preferences
dynamic_preferences/managers.py
https://github.com/EliotBerriot/django-dynamic-preferences/blob/12eab4f17b960290525b215d954d1b5fb91199df/dynamic_preferences/managers.py#L122-L139
def get(self, key, no_cache=False): """Return the value of a single preference using a dotted path key :arg no_cache: if true, the cache is bypassed """ section, name = self.parse_lookup(key) preference = self.registry.get( section=section, name=name, fallback=False) ...
[ "def", "get", "(", "self", ",", "key", ",", "no_cache", "=", "False", ")", ":", "section", ",", "name", "=", "self", ".", "parse_lookup", "(", "key", ")", "preference", "=", "self", ".", "registry", ".", "get", "(", "section", "=", "section", ",", ...
Return the value of a single preference using a dotted path key :arg no_cache: if true, the cache is bypassed
[ "Return", "the", "value", "of", "a", "single", "preference", "using", "a", "dotted", "path", "key", ":", "arg", "no_cache", ":", "if", "true", "the", "cache", "is", "bypassed" ]
python
train
PSPC-SPAC-buyandsell/von_anchor
von_anchor/cache.py
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/cache.py#L596-L625
async def get_state_json( self, rr_state_builder: Callable[['Verifier', str, int], Awaitable[Tuple[str, int]]], fro: int, to: int) -> (str, int): """ Get rev reg state json, and its timestamp on the distributed ledger, from cached rev reg state fra...
[ "async", "def", "get_state_json", "(", "self", ",", "rr_state_builder", ":", "Callable", "[", "[", "'Verifier'", ",", "str", ",", "int", "]", ",", "Awaitable", "[", "Tuple", "[", "str", ",", "int", "]", "]", "]", ",", "fro", ":", "int", ",", "to", ...
Get rev reg state json, and its timestamp on the distributed ledger, from cached rev reg state frames list or distributed ledger, updating cache as necessary. Raise BadRevStateTime if caller asks for a state in the future. On return of any previously existing rev reg state frame, alway...
[ "Get", "rev", "reg", "state", "json", "and", "its", "timestamp", "on", "the", "distributed", "ledger", "from", "cached", "rev", "reg", "state", "frames", "list", "or", "distributed", "ledger", "updating", "cache", "as", "necessary", "." ]
python
train
radjkarl/imgProcessor
imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py#L24-L384
def simulateSytematicError(N_SAMPLES=5, N_IMAGES=10, SHOW_DETECTED_PATTERN=True, # GRAYSCALE=False, HEIGHT=500, PLOT_RESULTS=True, PLOT_ERROR_ARRAY=True, CAMERA_PARAM=None, PERSPECTIVE=True, ROTATION=True, R...
[ "def", "simulateSytematicError", "(", "N_SAMPLES", "=", "5", ",", "N_IMAGES", "=", "10", ",", "SHOW_DETECTED_PATTERN", "=", "True", ",", "# GRAYSCALE=False,\r", "HEIGHT", "=", "500", ",", "PLOT_RESULTS", "=", "True", ",", "PLOT_ERROR_ARRAY", "=", "True", ",", ...
Simulates a lens calibration using synthetic images * images are rendered under the given HEIGHT resolution * noise and smoothing is applied * perspective and position errors are applied * images are deformed using the given CAMERA_PARAM * the detected camera parameters are used to calculate ...
[ "Simulates", "a", "lens", "calibration", "using", "synthetic", "images", "*", "images", "are", "rendered", "under", "the", "given", "HEIGHT", "resolution", "*", "noise", "and", "smoothing", "is", "applied", "*", "perspective", "and", "position", "errors", "are",...
python
train
rwl/pylon
examples/pyreto/thesis/common.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/examples/pyreto/thesis/common.py#L107-L120
def get_case24_ieee_rts(): """ Returns the 24 bus IEEE Reliability Test System. """ path = os.path.dirname(pylon.__file__) path = os.path.join(path, "test", "data") path = os.path.join(path, "case24_ieee_rts", "case24_ieee_rts.pkl") case = pylon.Case.load(path) # FIXME: Correct generator n...
[ "def", "get_case24_ieee_rts", "(", ")", ":", "path", "=", "os", ".", "path", ".", "dirname", "(", "pylon", ".", "__file__", ")", "path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"test\"", ",", "\"data\"", ")", "path", "=", "os", "."...
Returns the 24 bus IEEE Reliability Test System.
[ "Returns", "the", "24", "bus", "IEEE", "Reliability", "Test", "System", "." ]
python
train
saltstack/salt
salt/modules/sensehat.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L140-L189
def show_message(message, msg_type=None, text_color=None, back_color=None, scroll_speed=0.1): ''' Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: ...
[ "def", "show_message", "(", "message", ",", "msg_type", "=", "None", ",", "text_color", "=", "None", ",", "back_color", "=", "None", ",", "scroll_speed", "=", "0.1", ")", ":", "text_color", "=", "text_color", "or", "[", "255", ",", "255", ",", "255", "...
Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: error: red text warning: orange text success: green text info:...
[ "Displays", "a", "message", "on", "the", "LED", "matrix", "." ]
python
train
Azure/blobxfer
blobxfer/models/synccopy.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/models/synccopy.py#L329-L389
def _resume(self): # type: (Descriptor) -> int """Resume a download, if possible :param Descriptor self: this :rtype: int or None :return: verified download offset """ if self._resume_mgr is None or self._offset > 0: return None # check if path...
[ "def", "_resume", "(", "self", ")", ":", "# type: (Descriptor) -> int", "if", "self", ".", "_resume_mgr", "is", "None", "or", "self", ".", "_offset", ">", "0", ":", "return", "None", "# check if path exists in resume db", "rr", "=", "self", ".", "_resume_mgr", ...
Resume a download, if possible :param Descriptor self: this :rtype: int or None :return: verified download offset
[ "Resume", "a", "download", "if", "possible", ":", "param", "Descriptor", "self", ":", "this", ":", "rtype", ":", "int", "or", "None", ":", "return", ":", "verified", "download", "offset" ]
python
train
dropbox/stone
stone/backends/python_types.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_types.py#L327-L363
def _generate_struct_class(self, ns, data_type): # type: (ApiNamespace, Struct) -> None """Defines a Python class that represents a struct in Stone.""" self.emit(self._class_declaration_for_type(ns, data_type)) with self.indent(): if data_type.has_documented_type_or_fields():...
[ "def", "_generate_struct_class", "(", "self", ",", "ns", ",", "data_type", ")", ":", "# type: (ApiNamespace, Struct) -> None", "self", ".", "emit", "(", "self", ".", "_class_declaration_for_type", "(", "ns", ",", "data_type", ")", ")", "with", "self", ".", "inde...
Defines a Python class that represents a struct in Stone.
[ "Defines", "a", "Python", "class", "that", "represents", "a", "struct", "in", "Stone", "." ]
python
train
ariebovenberg/valuable
valuable/xml.py
https://github.com/ariebovenberg/valuable/blob/72ac98b5a044233f13d14a9b9f273ce3a237d9ae/valuable/xml.py#L15-L20
def elemgetter(path: str) -> t.Callable[[Element], Element]: """shortcut making an XML element getter""" return compose( partial(_raise_if_none, exc=LookupError(path)), methodcaller('find', path) )
[ "def", "elemgetter", "(", "path", ":", "str", ")", "->", "t", ".", "Callable", "[", "[", "Element", "]", ",", "Element", "]", ":", "return", "compose", "(", "partial", "(", "_raise_if_none", ",", "exc", "=", "LookupError", "(", "path", ")", ")", ",",...
shortcut making an XML element getter
[ "shortcut", "making", "an", "XML", "element", "getter" ]
python
train
KelSolaar/Umbra
umbra/components/factory/script_editor/script_editor.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/script_editor/script_editor.py#L847-L858
def script_editor_file(self, value): """ Setter for **self.__script_editor_file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( ...
[ "def", "script_editor_file", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "unicode", ",", "\"'{0}' attribute: '{1}' type is not 'unicode'!\"", ".", "format", "(", "\"script_editor_file\"",...
Setter for **self.__script_editor_file** attribute. :param value: Attribute value. :type value: unicode
[ "Setter", "for", "**", "self", ".", "__script_editor_file", "**", "attribute", "." ]
python
train
iotile/coretools
iotilecore/iotile/core/utilities/schema_verify/string_verify.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/schema_verify/string_verify.py#L33-L41
def format(self, indent_level, indent_size=4): """Format this verifier Returns: string: A formatted string """ desc = self.format_name('String') return self.wrap_lines(desc, indent_level, indent_size=indent_size)
[ "def", "format", "(", "self", ",", "indent_level", ",", "indent_size", "=", "4", ")", ":", "desc", "=", "self", ".", "format_name", "(", "'String'", ")", "return", "self", ".", "wrap_lines", "(", "desc", ",", "indent_level", ",", "indent_size", "=", "ind...
Format this verifier Returns: string: A formatted string
[ "Format", "this", "verifier" ]
python
train
nschloe/matplotlib2tikz
matplotlib2tikz/util.py
https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/util.py#L11-L26
def get_legend_text(obj): """Check if line is in legend. """ leg = obj.axes.get_legend() if leg is None: return None keys = [l.get_label() for l in leg.legendHandles if l is not None] values = [l.get_text() for l in leg.texts] label = obj.get_label() d = dict(zip(keys, values))...
[ "def", "get_legend_text", "(", "obj", ")", ":", "leg", "=", "obj", ".", "axes", ".", "get_legend", "(", ")", "if", "leg", "is", "None", ":", "return", "None", "keys", "=", "[", "l", ".", "get_label", "(", ")", "for", "l", "in", "leg", ".", "legen...
Check if line is in legend.
[ "Check", "if", "line", "is", "in", "legend", "." ]
python
train
openstack/networking-cisco
networking_cisco/apps/saf/agent/vdp/lldpad.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/agent/vdp/lldpad.py#L644-L683
def send_vdp_assoc(self, vsiid=None, mgrid=None, typeid=None, typeid_ver=None, vsiid_frmt=vdp_const.VDP_VSIFRMT_UUID, filter_frmt=vdp_const.VDP_FILTER_GIDMACVID, gid=0, mac="", vlan=0, oui_id="", oui_data="", sw_resp=False): """Sends the VDP A...
[ "def", "send_vdp_assoc", "(", "self", ",", "vsiid", "=", "None", ",", "mgrid", "=", "None", ",", "typeid", "=", "None", ",", "typeid_ver", "=", "None", ",", "vsiid_frmt", "=", "vdp_const", ".", "VDP_VSIFRMT_UUID", ",", "filter_frmt", "=", "vdp_const", ".",...
Sends the VDP Associate Message. Please refer http://www.ieee802.org/1/pages/802.1bg.html VDP Section for more detailed information :param vsiid: VSI value, Only UUID supported for now :param mgrid: MGR ID :param typeid: Type ID :param typeid_ver: Version of the Type ID ...
[ "Sends", "the", "VDP", "Associate", "Message", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xtreewidget/xtreewidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidget.py#L675-L696
def edit(self, index, trigger, event): """ Prompts the edit for the inputed index given a trigger and event. :param index | <QModelIndex> trigger | <EditTrigger> event | <QEvent> """ # disable right-click editing ...
[ "def", "edit", "(", "self", ",", "index", ",", "trigger", ",", "event", ")", ":", "# disable right-click editing\r", "if", "trigger", "in", "(", "self", ".", "SelectedClicked", ",", "self", ".", "DoubleClicked", ")", "and", "event", ".", "button", "(", ")"...
Prompts the edit for the inputed index given a trigger and event. :param index | <QModelIndex> trigger | <EditTrigger> event | <QEvent>
[ "Prompts", "the", "edit", "for", "the", "inputed", "index", "given", "a", "trigger", "and", "event", ".", ":", "param", "index", "|", "<QModelIndex", ">", "trigger", "|", "<EditTrigger", ">", "event", "|", "<QEvent", ">" ]
python
train
grabbles/grabbit
grabbit/core.py
https://github.com/grabbles/grabbit/blob/83ff93df36019eaaee9d4e31f816a518e46cae07/grabbit/core.py#L666-L697
def add_entity(self, domain, **kwargs): ''' Add a new Entity to tracking. ''' # Set the entity's mapping func if one was specified map_func = kwargs.get('map_func', None) if map_func is not None and not callable(kwargs['map_func']): if self.entity_mapper is None: ...
[ "def", "add_entity", "(", "self", ",", "domain", ",", "*", "*", "kwargs", ")", ":", "# Set the entity's mapping func if one was specified", "map_func", "=", "kwargs", ".", "get", "(", "'map_func'", ",", "None", ")", "if", "map_func", "is", "not", "None", "and"...
Add a new Entity to tracking.
[ "Add", "a", "new", "Entity", "to", "tracking", "." ]
python
train
artefactual-labs/agentarchives
agentarchives/archivists_toolkit/client.py
https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivists_toolkit/client.py#L334-L353
def find_resource_id_for_component(self, component_id): """ Given the ID of a component, returns the parent resource ID. If the immediate parent of the component is itself a component, this method will progress up the tree until a resource is found. :param long component_id: The ID of ...
[ "def", "find_resource_id_for_component", "(", "self", ",", "component_id", ")", ":", "cursor", "=", "self", ".", "db", ".", "cursor", "(", ")", "sql", "=", "\"SELECT resourceId, parentResourceComponentId FROM ResourcesComponents WHERE resourceComponentId=%s\"", "cursor", "....
Given the ID of a component, returns the parent resource ID. If the immediate parent of the component is itself a component, this method will progress up the tree until a resource is found. :param long component_id: The ID of the ResourceComponent. :return: The ID of the component's parent res...
[ "Given", "the", "ID", "of", "a", "component", "returns", "the", "parent", "resource", "ID", "." ]
python
train
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L155-L163
def _get_measures(self, et): """ Get a list of measures in <continuous> or <SurveyOptions> section """ list_of_measures = [] for tag in et.findall("option"): if tag.attrib.get("value", "true") == "true": list_of_measures.append(tag.attrib["name"]) ...
[ "def", "_get_measures", "(", "self", ",", "et", ")", ":", "list_of_measures", "=", "[", "]", "for", "tag", "in", "et", ".", "findall", "(", "\"option\"", ")", ":", "if", "tag", ".", "attrib", ".", "get", "(", "\"value\"", ",", "\"true\"", ")", "==", ...
Get a list of measures in <continuous> or <SurveyOptions> section
[ "Get", "a", "list", "of", "measures", "in", "<continuous", ">", "or", "<SurveyOptions", ">", "section" ]
python
train
serge-sans-paille/pythran
pythran/spec.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/spec.py#L382-L392
def p_array_index(self, p): '''array_index : | NUM | COLUMN | COLUMN COLUMN''' if len(p) == 3: p[0] = slice(0, -1, -1) elif len(p) == 1 or p[1] == ':': p[0] = slice(0, -1, 1) else: p[...
[ "def", "p_array_index", "(", "self", ",", "p", ")", ":", "if", "len", "(", "p", ")", "==", "3", ":", "p", "[", "0", "]", "=", "slice", "(", "0", ",", "-", "1", ",", "-", "1", ")", "elif", "len", "(", "p", ")", "==", "1", "or", "p", "[",...
array_index : | NUM | COLUMN | COLUMN COLUMN
[ "array_index", ":", "|", "NUM", "|", "COLUMN", "|", "COLUMN", "COLUMN" ]
python
train
openego/ding0
ding0/grid/mv_grid/mv_connect.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/mv_connect.py#L901-L1008
def mv_connect_generators(mv_grid_district, graph, debug=False): """Connect MV generators to MV grid Args ---- mv_grid_district: MVGridDistrictDing0 MVGridDistrictDing0 object for which the connection process has to be done graph: :networkx:`NetworkX Graph Obj< >` NetworkX g...
[ "def", "mv_connect_generators", "(", "mv_grid_district", ",", "graph", ",", "debug", "=", "False", ")", ":", "generator_buffer_radius", "=", "cfg_ding0", ".", "get", "(", "'mv_connect'", ",", "'generator_buffer_radius'", ")", "generator_buffer_radius_inc", "=", "cfg_d...
Connect MV generators to MV grid Args ---- mv_grid_district: MVGridDistrictDing0 MVGridDistrictDing0 object for which the connection process has to be done graph: :networkx:`NetworkX Graph Obj< >` NetworkX graph object with nodes debug: bool, defaults to False If Tru...
[ "Connect", "MV", "generators", "to", "MV", "grid" ]
python
train
awslabs/serverless-application-model
samtranslator/validator/validator.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/validator/validator.py#L12-L35
def validate(template_dict, schema=None): """ Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optional, dictionary containing JSON Schema representing SAM template :return: Empty string if there are no validation errors...
[ "def", "validate", "(", "template_dict", ",", "schema", "=", "None", ")", ":", "if", "not", "schema", ":", "schema", "=", "SamTemplateValidator", ".", "_read_schema", "(", ")", "validation_errors", "=", "\"\"", "try", ":", "jsonschema", ".", "validate", "(",...
Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optional, dictionary containing JSON Schema representing SAM template :return: Empty string if there are no validation errors in template
[ "Is", "this", "a", "valid", "SAM", "template", "dictionary" ]
python
train
python-wink/python-wink
src/pywink/api.py
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/api.py#L464-L483
def post_session(): """ This endpoint appears to be required in order to keep pubnub updates flowing for some user. This just posts a random nonce to the /users/me/session endpoint and returns the result. """ url_string = "{}/users/me/session".format(WinkApiInterface.BASE_URL) nonce = ''.join...
[ "def", "post_session", "(", ")", ":", "url_string", "=", "\"{}/users/me/session\"", ".", "format", "(", "WinkApiInterface", ".", "BASE_URL", ")", "nonce", "=", "''", ".", "join", "(", "[", "str", "(", "random", ".", "randint", "(", "0", ",", "9", ")", ...
This endpoint appears to be required in order to keep pubnub updates flowing for some user. This just posts a random nonce to the /users/me/session endpoint and returns the result.
[ "This", "endpoint", "appears", "to", "be", "required", "in", "order", "to", "keep", "pubnub", "updates", "flowing", "for", "some", "user", "." ]
python
train
gem/oq-engine
openquake/calculators/extract.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L139-L150
def extract_(dstore, dspath): """ Extracts an HDF5 path object from the datastore, for instance extract(dstore, 'sitecol'). """ obj = dstore[dspath] if isinstance(obj, Dataset): return ArrayWrapper(obj.value, obj.attrs) elif isinstance(obj, Group): return ArrayWrapper(numpy.a...
[ "def", "extract_", "(", "dstore", ",", "dspath", ")", ":", "obj", "=", "dstore", "[", "dspath", "]", "if", "isinstance", "(", "obj", ",", "Dataset", ")", ":", "return", "ArrayWrapper", "(", "obj", ".", "value", ",", "obj", ".", "attrs", ")", "elif", ...
Extracts an HDF5 path object from the datastore, for instance extract(dstore, 'sitecol').
[ "Extracts", "an", "HDF5", "path", "object", "from", "the", "datastore", "for", "instance", "extract", "(", "dstore", "sitecol", ")", "." ]
python
train
librosa/librosa
librosa/util/utils.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/util/utils.py#L111-L172
def valid_audio(y, mono=True): '''Validate whether a variable contains valid, mono audio data. Parameters ---------- y : np.ndarray The input data to validate mono : bool Whether or not to force monophonic audio Returns ------- valid : bool True if all tests pass ...
[ "def", "valid_audio", "(", "y", ",", "mono", "=", "True", ")", ":", "if", "not", "isinstance", "(", "y", ",", "np", ".", "ndarray", ")", ":", "raise", "ParameterError", "(", "'data must be of type numpy.ndarray'", ")", "if", "not", "np", ".", "issubdtype",...
Validate whether a variable contains valid, mono audio data. Parameters ---------- y : np.ndarray The input data to validate mono : bool Whether or not to force monophonic audio Returns ------- valid : bool True if all tests pass Raises ------ ParameterEr...
[ "Validate", "whether", "a", "variable", "contains", "valid", "mono", "audio", "data", "." ]
python
test
kennell/schiene
schiene/schiene.py
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L40-L46
def parse_stations(html): """ Strips JS code, loads JSON """ html = html.replace('SLs.sls=', '').replace(';SLs.showSuggestion();', '') html = json.loads(html) return html['suggestions']
[ "def", "parse_stations", "(", "html", ")", ":", "html", "=", "html", ".", "replace", "(", "'SLs.sls='", ",", "''", ")", ".", "replace", "(", "';SLs.showSuggestion();'", ",", "''", ")", "html", "=", "json", ".", "loads", "(", "html", ")", "return", "htm...
Strips JS code, loads JSON
[ "Strips", "JS", "code", "loads", "JSON" ]
python
train
codebynumbers/ftpretty
ftpretty.py
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L196-L203
def cd(self, remote): """ Change working directory on server """ try: self.conn.cwd(remote) except Exception: return False else: return self.pwd()
[ "def", "cd", "(", "self", ",", "remote", ")", ":", "try", ":", "self", ".", "conn", ".", "cwd", "(", "remote", ")", "except", "Exception", ":", "return", "False", "else", ":", "return", "self", ".", "pwd", "(", ")" ]
Change working directory on server
[ "Change", "working", "directory", "on", "server" ]
python
train
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L5129-L5135
def decodeEntities(self, len, what, end, end2, end3): """This function is deprecated, we now always process entities content through xmlStringDecodeEntities TODO: remove it in next major release. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';' """ ...
[ "def", "decodeEntities", "(", "self", ",", "len", ",", "what", ",", "end", ",", "end2", ",", "end3", ")", ":", "ret", "=", "libxml2mod", ".", "xmlDecodeEntities", "(", "self", ".", "_o", ",", "len", ",", "what", ",", "end", ",", "end2", ",", "end3"...
This function is deprecated, we now always process entities content through xmlStringDecodeEntities TODO: remove it in next major release. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'
[ "This", "function", "is", "deprecated", "we", "now", "always", "process", "entities", "content", "through", "xmlStringDecodeEntities", "TODO", ":", "remove", "it", "in", "next", "major", "release", ".", "[", "67", "]", "Reference", "::", "=", "EntityRef", "|",...
python
train
napalm-automation/napalm
napalm/junos/junos.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/junos/junos.py#L1399-L1425
def get_arp_table(self, vrf=""): """Return the ARP table.""" # could use ArpTable # from jnpr.junos.op.phyport import ArpTable # and simply use it # but # we need: # - filters # - group by VLAN ID # - hostname & TTE fields as well if ...
[ "def", "get_arp_table", "(", "self", ",", "vrf", "=", "\"\"", ")", ":", "# could use ArpTable", "# from jnpr.junos.op.phyport import ArpTable", "# and simply use it", "# but", "# we need:", "# - filters", "# - group by VLAN ID", "# - hostname & TTE fields as well", "if", ...
Return the ARP table.
[ "Return", "the", "ARP", "table", "." ]
python
train
i3visio/osrframework
osrframework/thirdparties/pipl_com/lib/containers.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/containers.py#L232-L245
def unsearchable_fields(self): """A list of all the fields that can't be searched by. For example: names/usernames that are too short, emails that are invalid etc. """ filter_func = lambda field: not field.is_searchable return filter(filter_func, self.n...
[ "def", "unsearchable_fields", "(", "self", ")", ":", "filter_func", "=", "lambda", "field", ":", "not", "field", ".", "is_searchable", "return", "filter", "(", "filter_func", ",", "self", ".", "names", ")", "+", "filter", "(", "filter_func", ",", "self", "...
A list of all the fields that can't be searched by. For example: names/usernames that are too short, emails that are invalid etc.
[ "A", "list", "of", "all", "the", "fields", "that", "can", "t", "be", "searched", "by", ".", "For", "example", ":", "names", "/", "usernames", "that", "are", "too", "short", "emails", "that", "are", "invalid", "etc", "." ]
python
train
pydron/anycall
anycall/bytequeue.py
https://github.com/pydron/anycall/blob/43add96660258a14b24aa8e8413dffb1741b72d7/anycall/bytequeue.py#L19-L30
def enqueue(self, s): """ Append `s` to the queue. Equivalent to:: queue += s if `queue` where a regular string. """ self._parts.append(s) self._len += len(s)
[ "def", "enqueue", "(", "self", ",", "s", ")", ":", "self", ".", "_parts", ".", "append", "(", "s", ")", "self", ".", "_len", "+=", "len", "(", "s", ")" ]
Append `s` to the queue. Equivalent to:: queue += s if `queue` where a regular string.
[ "Append", "s", "to", "the", "queue", ".", "Equivalent", "to", "::", "queue", "+", "=", "s", "if", "queue", "where", "a", "regular", "string", "." ]
python
test
PyGithub/PyGithub
github/Branch.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Branch.py#L287-L296
def get_admin_enforcement(self): """ :calls: `GET /repos/:owner/:repo/branches/:branch/protection/enforce_admins <https://developer.github.com/v3/repos/branches>`_ :rtype: bool """ headers, data = self._requester.requestJsonAndCheck( "GET", self.protection...
[ "def", "get_admin_enforcement", "(", "self", ")", ":", "headers", ",", "data", "=", "self", ".", "_requester", ".", "requestJsonAndCheck", "(", "\"GET\"", ",", "self", ".", "protection_url", "+", "\"/enforce_admins\"", ")", "return", "data", "[", "\"enabled\"", ...
:calls: `GET /repos/:owner/:repo/branches/:branch/protection/enforce_admins <https://developer.github.com/v3/repos/branches>`_ :rtype: bool
[ ":", "calls", ":", "GET", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "branches", "/", ":", "branch", "/", "protection", "/", "enforce_admins", "<https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "repos", "/", "...
python
train
hyperledger/sawtooth-core
validator/sawtooth_validator/journal/block_info_injector.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_info_injector.py#L80-L102
def block_start(self, previous_block): """Returns an ordered list of batches to inject at the beginning of the block. Can also return None if no batches should be injected. Args: previous_block (Block): The previous block. Returns: A list of batches to inject. ...
[ "def", "block_start", "(", "self", ",", "previous_block", ")", ":", "previous_header_bytes", "=", "previous_block", ".", "header", "previous_header", "=", "BlockHeader", "(", ")", "previous_header", ".", "ParseFromString", "(", "previous_header_bytes", ")", "block_inf...
Returns an ordered list of batches to inject at the beginning of the block. Can also return None if no batches should be injected. Args: previous_block (Block): The previous block. Returns: A list of batches to inject.
[ "Returns", "an", "ordered", "list", "of", "batches", "to", "inject", "at", "the", "beginning", "of", "the", "block", ".", "Can", "also", "return", "None", "if", "no", "batches", "should", "be", "injected", "." ]
python
train
dhondta/tinyscript
tinyscript/report/__init__.py
https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/report/__init__.py#L133-L143
def html(self, text=TEXT): """ Generate an HTML file from the report data. """ self.logger.debug("Generating the HTML report{}..." .format(["", " (text only)"][text])) html = [] for piece in self._pieces: if isinstance(piece, string_types): ...
[ "def", "html", "(", "self", ",", "text", "=", "TEXT", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Generating the HTML report{}...\"", ".", "format", "(", "[", "\"\"", ",", "\" (text only)\"", "]", "[", "text", "]", ")", ")", "html", "=", "["...
Generate an HTML file from the report data.
[ "Generate", "an", "HTML", "file", "from", "the", "report", "data", "." ]
python
train
marcomusy/vtkplotter
vtkplotter/utils.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/utils.py#L90-L97
def vector(x, y=None, z=0.0): """Return a 3D numpy array representing a vector (of type `numpy.float64`). If `y` is ``None``, assume input is already in the form `[x,y,z]`. """ if y is None: # assume x is already [x,y,z] return np.array(x, dtype=np.float64) return np.array([x, y, z], dtype...
[ "def", "vector", "(", "x", ",", "y", "=", "None", ",", "z", "=", "0.0", ")", ":", "if", "y", "is", "None", ":", "# assume x is already [x,y,z]", "return", "np", ".", "array", "(", "x", ",", "dtype", "=", "np", ".", "float64", ")", "return", "np", ...
Return a 3D numpy array representing a vector (of type `numpy.float64`). If `y` is ``None``, assume input is already in the form `[x,y,z]`.
[ "Return", "a", "3D", "numpy", "array", "representing", "a", "vector", "(", "of", "type", "numpy", ".", "float64", ")", "." ]
python
train
darvid/biome
src/biome/__init__.py
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L204-L230
def get_path(self, name, default=None): """Retrieves an environment variable as a filesystem path. Requires the `pathlib`_ library if using Python <= 3.4. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be ret...
[ "def", "get_path", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".",...
Retrieves an environment variable as a filesystem path. Requires the `pathlib`_ library if using Python <= 3.4. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``Environ...
[ "Retrieves", "an", "environment", "variable", "as", "a", "filesystem", "path", "." ]
python
train
mikedh/trimesh
trimesh/poses.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/poses.py#L158-L187
def _orient3dfast(plane, pd): """ Performs a fast 3D orientation test. Parameters ---------- plane: (3,3) float, three points in space that define a plane pd: (3,) float, a single point Returns ------- result: float, if greater than zero then pd is above the plane through ...
[ "def", "_orient3dfast", "(", "plane", ",", "pd", ")", ":", "pa", ",", "pb", ",", "pc", "=", "plane", "adx", "=", "pa", "[", "0", "]", "-", "pd", "[", "0", "]", "bdx", "=", "pb", "[", "0", "]", "-", "pd", "[", "0", "]", "cdx", "=", "pc", ...
Performs a fast 3D orientation test. Parameters ---------- plane: (3,3) float, three points in space that define a plane pd: (3,) float, a single point Returns ------- result: float, if greater than zero then pd is above the plane through the given three points, if l...
[ "Performs", "a", "fast", "3D", "orientation", "test", "." ]
python
train
ethan92429/onshapepy
onshapepy/core/utils.py
https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/utils.py#L77-L101
def parse_quantity(q): """ Parse an OnShape units definition Args: q: Returns: a string that can be converted to any other unit engine. >>> from onshapepy.core.utils import parse_quantity >>> d = {'value': 0.1414213562373095, 'unitToPower': [{'value': 1, 'key': 'METER'}], 'type...
[ "def", "parse_quantity", "(", "q", ")", ":", "units_s", "=", "str", "(", "q", "[", "'value'", "]", ")", "for", "u", "in", "q", "[", "'unitToPower'", "]", ":", "units_s", "=", "units_s", "+", "\"*\"", "+", "u", "[", "'key'", "]", ".", "lower", "("...
Parse an OnShape units definition Args: q: Returns: a string that can be converted to any other unit engine. >>> from onshapepy.core.utils import parse_quantity >>> d = {'value': 0.1414213562373095, 'unitToPower': [{'value': 1, 'key': 'METER'}], 'typeTag': ''} >>> parse_quantity(d)...
[ "Parse", "an", "OnShape", "units", "definition", "Args", ":", "q", ":" ]
python
train
6809/MC6809
MC6809/components/mc6809_base.py
https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/mc6809_base.py#L888-L911
def instruction_SUB(self, opcode, m, register): """ Subtracts the value in memory location M from the contents of a register. The C (carry) bit represents a borrow and is set to the inverse of the resulting binary carry. source code forms: SUBA P; SUBB P; SUBD P CC bits...
[ "def", "instruction_SUB", "(", "self", ",", "opcode", ",", "m", ",", "register", ")", ":", "r", "=", "register", ".", "value", "r_new", "=", "r", "-", "m", "register", ".", "set", "(", "r_new", ")", "# log.debug(\"$%x SUB8 %s: $%x - $%x = $%x (dez.: %i ...
Subtracts the value in memory location M from the contents of a register. The C (carry) bit represents a borrow and is set to the inverse of the resulting binary carry. source code forms: SUBA P; SUBB P; SUBD P CC bits "HNZVC": uaaaa
[ "Subtracts", "the", "value", "in", "memory", "location", "M", "from", "the", "contents", "of", "a", "register", ".", "The", "C", "(", "carry", ")", "bit", "represents", "a", "borrow", "and", "is", "set", "to", "the", "inverse", "of", "the", "resulting", ...
python
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/autocompletion.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/autocompletion.py#L125-L152
def auto_complete_paths(current, completion_type): """If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``. :param current: The word to be completed :param completion_type: path co...
[ "def", "auto_complete_paths", "(", "current", ",", "completion_type", ")", ":", "directory", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "current", ")", "current_path", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "# Don't...
If ``completion_type`` is ``file`` or ``path``, list all regular files and directories starting with ``current``; otherwise only list directories starting with ``current``. :param current: The word to be completed :param completion_type: path completion type(`file`, `path` or `dir`)i :return: A gen...
[ "If", "completion_type", "is", "file", "or", "path", "list", "all", "regular", "files", "and", "directories", "starting", "with", "current", ";", "otherwise", "only", "list", "directories", "starting", "with", "current", "." ]
python
train
tgbugs/ontquery
ontquery/plugins/interlex_client.py
https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L81-L89
def get(self, url: str) -> List[dict]: """ Requests data from database """ response = requests.get( url, headers = {'Content-type': 'application/json'}, auth = ('scicrunch', 'perl22(query)') # for test2.scicrunch.org ) output = self.process_response(re...
[ "def", "get", "(", "self", ",", "url", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "{", "'Content-type'", ":", "'application/json'", "}", ",", "auth", "=", "(", "'s...
Requests data from database
[ "Requests", "data", "from", "database" ]
python
train
opendatateam/udata
udata/theme/__init__.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/theme/__init__.py#L141-L148
def render(template, **context): ''' Render a template with uData frontend specifics * Theme ''' theme = current_app.config['THEME'] return render_theme_template(get_theme(theme), template, **context)
[ "def", "render", "(", "template", ",", "*", "*", "context", ")", ":", "theme", "=", "current_app", ".", "config", "[", "'THEME'", "]", "return", "render_theme_template", "(", "get_theme", "(", "theme", ")", ",", "template", ",", "*", "*", "context", ")" ...
Render a template with uData frontend specifics * Theme
[ "Render", "a", "template", "with", "uData", "frontend", "specifics" ]
python
train
CEA-COSMIC/ModOpt
modopt/opt/proximity.py
https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/opt/proximity.py#L356-L395
def _check_operators(self, operators): """ Check Inputs This method cheks that the input operators and weights are correctly formatted Parameters ---------- operators : list, tuple or np.ndarray List of linear operator class instances Returns ...
[ "def", "_check_operators", "(", "self", ",", "operators", ")", ":", "if", "not", "isinstance", "(", "operators", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "raise", "TypeError", "(", "'Invalid input type, operators must be a list...
Check Inputs This method cheks that the input operators and weights are correctly formatted Parameters ---------- operators : list, tuple or np.ndarray List of linear operator class instances Returns ------- np.array operators Raise...
[ "Check", "Inputs" ]
python
train
saltstack/salt
salt/modules/file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L6580-L6657
def open_files(by_pid=False): ''' Return a list of all physical open files on the system. CLI Examples: .. code-block:: bash salt '*' file.open_files salt '*' file.open_files by_pid=True ''' # First we collect valid PIDs pids = {} procfs = os.listdir('/proc/') for ...
[ "def", "open_files", "(", "by_pid", "=", "False", ")", ":", "# First we collect valid PIDs", "pids", "=", "{", "}", "procfs", "=", "os", ".", "listdir", "(", "'/proc/'", ")", "for", "pfile", "in", "procfs", ":", "try", ":", "pids", "[", "int", "(", "pf...
Return a list of all physical open files on the system. CLI Examples: .. code-block:: bash salt '*' file.open_files salt '*' file.open_files by_pid=True
[ "Return", "a", "list", "of", "all", "physical", "open", "files", "on", "the", "system", "." ]
python
train
koordinates/python-client
koordinates/base.py
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L146-L153
def _update_range(self, response): """ Update the query count property from the `X-Resource-Range` response header """ header_value = response.headers.get('x-resource-range', '') m = re.match(r'\d+-\d+/(\d+)$', header_value) if m: self._count = int(m.group(1)) else: ...
[ "def", "_update_range", "(", "self", ",", "response", ")", ":", "header_value", "=", "response", ".", "headers", ".", "get", "(", "'x-resource-range'", ",", "''", ")", "m", "=", "re", ".", "match", "(", "r'\\d+-\\d+/(\\d+)$'", ",", "header_value", ")", "if...
Update the query count property from the `X-Resource-Range` response header
[ "Update", "the", "query", "count", "property", "from", "the", "X", "-", "Resource", "-", "Range", "response", "header" ]
python
train
CityOfZion/neo-python
neo/Core/TX/EnrollmentTransaction.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/TX/EnrollmentTransaction.py#L29-L42
def DeserializeExclusiveData(self, reader): """ Deserialize full object. Args: reader (neo.IO.BinaryReader): Raises: Exception: If the version read is incorrect. """ if self.Version is not 0: raise Exception('Invalid format') ...
[ "def", "DeserializeExclusiveData", "(", "self", ",", "reader", ")", ":", "if", "self", ".", "Version", "is", "not", "0", ":", "raise", "Exception", "(", "'Invalid format'", ")", "self", ".", "PublicKey", "=", "ECDSA", ".", "Deserialize_Secp256r1", "(", "read...
Deserialize full object. Args: reader (neo.IO.BinaryReader): Raises: Exception: If the version read is incorrect.
[ "Deserialize", "full", "object", "." ]
python
train
python-wink/python-wink
src/pywink/devices/cloud_clock.py
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/cloud_clock.py#L99-L120
def _update_state_from_response(self, response_json): """ :param response_json: the json obj returned from query :return: """ if 'data' in response_json and response_json['data']['object_type'] == "cloud_clock": cloud_clock = response_json.get('data') ...
[ "def", "_update_state_from_response", "(", "self", ",", "response_json", ")", ":", "if", "'data'", "in", "response_json", "and", "response_json", "[", "'data'", "]", "[", "'object_type'", "]", "==", "\"cloud_clock\"", ":", "cloud_clock", "=", "response_json", ".",...
:param response_json: the json obj returned from query :return:
[ ":", "param", "response_json", ":", "the", "json", "obj", "returned", "from", "query", ":", "return", ":" ]
python
train
AnalogJ/lexicon
lexicon/providers/hetzner.py
https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/providers/hetzner.py#L438-L455
def _get_nameservers(domain): """ Looks for domain nameservers and returns the IPs of the nameservers as a list. The list is empty, if no nameservers were found. Needed associated domain zone name for lookup. """ nameservers = [] rdtypes_ns = ['SOA', 'NS'] ...
[ "def", "_get_nameservers", "(", "domain", ")", ":", "nameservers", "=", "[", "]", "rdtypes_ns", "=", "[", "'SOA'", ",", "'NS'", "]", "rdtypes_ip", "=", "[", "'A'", ",", "'AAAA'", "]", "for", "rdtype_ns", "in", "rdtypes_ns", ":", "for", "rdata_ns", "in", ...
Looks for domain nameservers and returns the IPs of the nameservers as a list. The list is empty, if no nameservers were found. Needed associated domain zone name for lookup.
[ "Looks", "for", "domain", "nameservers", "and", "returns", "the", "IPs", "of", "the", "nameservers", "as", "a", "list", ".", "The", "list", "is", "empty", "if", "no", "nameservers", "were", "found", ".", "Needed", "associated", "domain", "zone", "name", "f...
python
train
niolabs/python-xbee
examples/alarm.py
https://github.com/niolabs/python-xbee/blob/b91be3d0ee7ccaa1990120b5b5490999d8e6cbc7/examples/alarm.py#L177-L195
def bed_occupied(self): """ bed_occupied: None -> boolean Determines whether the bed is currently occupied by requesting data from the remote XBee and comparing the analog value with a threshold. """ # Receive samples from the remote device self._set_sen...
[ "def", "bed_occupied", "(", "self", ")", ":", "# Receive samples from the remote device", "self", ".", "_set_send_samples", "(", "True", ")", "while", "True", ":", "packet", "=", "self", ".", "hw", ".", "wait_read_frame", "(", ")", "if", "'adc-0'", "in", "pack...
bed_occupied: None -> boolean Determines whether the bed is currently occupied by requesting data from the remote XBee and comparing the analog value with a threshold.
[ "bed_occupied", ":", "None", "-", ">", "boolean" ]
python
train
aequitas/python-rflink
rflink/protocol.py
https://github.com/aequitas/python-rflink/blob/46759ce8daf95cfc7cdb608ae17bc5501be9f6d8/rflink/protocol.py#L215-L231
def _handle_packet(self, packet): """Event specific packet handling logic. Break packet into events and fires configured event callback or nicely prints events for console. """ events = packet_events(packet) for event in events: if self.ignore_event(event['i...
[ "def", "_handle_packet", "(", "self", ",", "packet", ")", ":", "events", "=", "packet_events", "(", "packet", ")", "for", "event", "in", "events", ":", "if", "self", ".", "ignore_event", "(", "event", "[", "'id'", "]", ")", ":", "log", ".", "debug", ...
Event specific packet handling logic. Break packet into events and fires configured event callback or nicely prints events for console.
[ "Event", "specific", "packet", "handling", "logic", "." ]
python
train
ev3dev/ev3dev-lang-python
ev3dev2/sensor/lego.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/sensor/lego.py#L976-L981
def reflected_light_intensity(self): """ A measurement of the reflected light intensity, as a percentage. """ self._ensure_mode(self.MODE_REFLECT) return self.value(0) * self._scale('REFLECT')
[ "def", "reflected_light_intensity", "(", "self", ")", ":", "self", ".", "_ensure_mode", "(", "self", ".", "MODE_REFLECT", ")", "return", "self", ".", "value", "(", "0", ")", "*", "self", ".", "_scale", "(", "'REFLECT'", ")" ]
A measurement of the reflected light intensity, as a percentage.
[ "A", "measurement", "of", "the", "reflected", "light", "intensity", "as", "a", "percentage", "." ]
python
train