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
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L1479-L1487
def max_pulse_sp(self): """ Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the maximum (clockwise) position_sp. Default value is 2400. Valid values are 2300 to 2700. You must write to the position_sp attribute for changes to this attrib...
[ "def", "max_pulse_sp", "(", "self", ")", ":", "self", ".", "_max_pulse_sp", ",", "value", "=", "self", ".", "get_attr_int", "(", "self", ".", "_max_pulse_sp", ",", "'max_pulse_sp'", ")", "return", "value" ]
Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the maximum (clockwise) position_sp. Default value is 2400. Valid values are 2300 to 2700. You must write to the position_sp attribute for changes to this attribute to take effect.
[ "Used", "to", "set", "the", "pulse", "size", "in", "milliseconds", "for", "the", "signal", "that", "tells", "the", "servo", "to", "drive", "to", "the", "maximum", "(", "clockwise", ")", "position_sp", ".", "Default", "value", "is", "2400", ".", "Valid", ...
python
train
pantsbuild/pants
src/python/pants/util/contextutil.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/contextutil.py#L210-L233
def temporary_file(root_dir=None, cleanup=True, suffix='', permissions=None, binary_mode=True): """ A with-context that creates a temporary file and returns a writeable file descriptor to it. You may specify the following keyword args: :param str root_dir: The parent directory to create the temporary fil...
[ "def", "temporary_file", "(", "root_dir", "=", "None", ",", "cleanup", "=", "True", ",", "suffix", "=", "''", ",", "permissions", "=", "None", ",", "binary_mode", "=", "True", ")", ":", "mode", "=", "'w+b'", "if", "binary_mode", "else", "'w+'", "# tempfi...
A with-context that creates a temporary file and returns a writeable file descriptor to it. You may specify the following keyword args: :param str root_dir: The parent directory to create the temporary file. :param bool cleanup: Whether or not to clean up the temporary file. :param str suffix: If suffi...
[ "A", "with", "-", "context", "that", "creates", "a", "temporary", "file", "and", "returns", "a", "writeable", "file", "descriptor", "to", "it", "." ]
python
train
geoadmin/lib-gatilegrid
gatilegrid/tilegrids.py
https://github.com/geoadmin/lib-gatilegrid/blob/28e39cba22451f6ef0ddcb93cbc0838f06815505/gatilegrid/tilegrids.py#L298-L301
def getZoom(self, resolution): "Return the zoom level for a given resolution" assert resolution in self.RESOLUTIONS return self.RESOLUTIONS.index(resolution)
[ "def", "getZoom", "(", "self", ",", "resolution", ")", ":", "assert", "resolution", "in", "self", ".", "RESOLUTIONS", "return", "self", ".", "RESOLUTIONS", ".", "index", "(", "resolution", ")" ]
Return the zoom level for a given resolution
[ "Return", "the", "zoom", "level", "for", "a", "given", "resolution" ]
python
train
aloetesting/aloe_webdriver
aloe_webdriver/css.py
https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L64-L98
def load_jquery(func): """ A decorator to ensure a function is run with jQuery available. If an exception from a function indicates jQuery is missing, it is loaded and the function re-executed. The browser to load jQuery into must be the first argument of the function. """ @wraps(func) ...
[ "def", "load_jquery", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "browser", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Run the function, loading jQuery if needed.\"\"\"", "try", ":", "return", "func", "(", ...
A decorator to ensure a function is run with jQuery available. If an exception from a function indicates jQuery is missing, it is loaded and the function re-executed. The browser to load jQuery into must be the first argument of the function.
[ "A", "decorator", "to", "ensure", "a", "function", "is", "run", "with", "jQuery", "available", "." ]
python
train
awslabs/serverless-application-model
samtranslator/sdk/parameter.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/parameter.py#L61-L67
def add_pseudo_parameter_values(self): """ Add pseudo parameter values :return: parameter values that have pseudo parameter in it """ if 'AWS::Region' not in self.parameter_values: self.parameter_values['AWS::Region'] = boto3.session.Session().region_name
[ "def", "add_pseudo_parameter_values", "(", "self", ")", ":", "if", "'AWS::Region'", "not", "in", "self", ".", "parameter_values", ":", "self", ".", "parameter_values", "[", "'AWS::Region'", "]", "=", "boto3", ".", "session", ".", "Session", "(", ")", ".", "r...
Add pseudo parameter values :return: parameter values that have pseudo parameter in it
[ "Add", "pseudo", "parameter", "values", ":", "return", ":", "parameter", "values", "that", "have", "pseudo", "parameter", "in", "it" ]
python
train
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_applicationmanagement.py
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L317-L325
def get_capability(self, capability_name): """ Return the desired capability value by desired capability name """ try: capability = self._current_application().capabilities[capability_name] except Exception as e: raise e return capability
[ "def", "get_capability", "(", "self", ",", "capability_name", ")", ":", "try", ":", "capability", "=", "self", ".", "_current_application", "(", ")", ".", "capabilities", "[", "capability_name", "]", "except", "Exception", "as", "e", ":", "raise", "e", "retu...
Return the desired capability value by desired capability name
[ "Return", "the", "desired", "capability", "value", "by", "desired", "capability", "name" ]
python
train
mcs07/ChemDataExtractor
chemdataextractor/cli/evaluate.py
https://github.com/mcs07/ChemDataExtractor/blob/349a3bea965f2073141d62043b89319222e46af1/chemdataextractor/cli/evaluate.py#L83-L88
def get_labels(cs): """Return list of every label.""" records = [] for c in cs: records.extend(c.get('labels', [])) return records
[ "def", "get_labels", "(", "cs", ")", ":", "records", "=", "[", "]", "for", "c", "in", "cs", ":", "records", ".", "extend", "(", "c", ".", "get", "(", "'labels'", ",", "[", "]", ")", ")", "return", "records" ]
Return list of every label.
[ "Return", "list", "of", "every", "label", "." ]
python
train
woolfson-group/isambard
isambard/ampal/base_ampal.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/base_ampal.py#L543-L555
def relabel_atoms(self, start=1): """Relabels all `Atoms` in numerical order. Parameters ---------- start : int, optional Offset the labelling by `start` residues. """ counter = start for atom in self.get_atoms(): atom.id = counter ...
[ "def", "relabel_atoms", "(", "self", ",", "start", "=", "1", ")", ":", "counter", "=", "start", "for", "atom", "in", "self", ".", "get_atoms", "(", ")", ":", "atom", ".", "id", "=", "counter", "counter", "+=", "1", "return" ]
Relabels all `Atoms` in numerical order. Parameters ---------- start : int, optional Offset the labelling by `start` residues.
[ "Relabels", "all", "Atoms", "in", "numerical", "order", "." ]
python
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1477-L1495
def get_values(self): """ Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods. """ # if w...
[ "def", "get_values", "(", "self", ")", ":", "# if we are a datetime and period index, return Index to keep metadata", "if", "is_datetimelike", "(", "self", ".", "categories", ")", ":", "return", "self", ".", "categories", ".", "take", "(", "self", ".", "_codes", ","...
Return the values. For internal compatibility with pandas formatting. Returns ------- numpy.array A numpy array of the same dtype as categorical.categories.dtype or Index if datetime / periods.
[ "Return", "the", "values", "." ]
python
train
Clinical-Genomics/scout
scout/server/blueprints/institutes/views.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/institutes/views.py#L17-L41
def institutes(): """Display a list of all user institutes.""" institute_objs = user_institutes(store, current_user) institutes = [] for ins_obj in institute_objs: sanger_recipients = [] for user_mail in ins_obj.get('sanger_recipients',[]): user_obj = store.user(user_mail) ...
[ "def", "institutes", "(", ")", ":", "institute_objs", "=", "user_institutes", "(", "store", ",", "current_user", ")", "institutes", "=", "[", "]", "for", "ins_obj", "in", "institute_objs", ":", "sanger_recipients", "=", "[", "]", "for", "user_mail", "in", "i...
Display a list of all user institutes.
[ "Display", "a", "list", "of", "all", "user", "institutes", "." ]
python
test
rigetti/quantumflow
quantumflow/qaoa.py
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/qaoa.py#L22-L64
def qubo_circuit( graph: nx.Graph, steps: int, beta: Sequence, gamma: Sequence) -> Circuit: """ A QAOA circuit for the Quadratic Unconstrained Binary Optimization problem (i.e. an Ising model). Args: graph : a networkx graph instance with optional edge and node w...
[ "def", "qubo_circuit", "(", "graph", ":", "nx", ".", "Graph", ",", "steps", ":", "int", ",", "beta", ":", "Sequence", ",", "gamma", ":", "Sequence", ")", "->", "Circuit", ":", "qubits", "=", "list", "(", "graph", ".", "nodes", "(", ")", ")", "# Ini...
A QAOA circuit for the Quadratic Unconstrained Binary Optimization problem (i.e. an Ising model). Args: graph : a networkx graph instance with optional edge and node weights steps : number of QAOA steps beta : driver parameters (One per step) gamma : cost parameters (One per st...
[ "A", "QAOA", "circuit", "for", "the", "Quadratic", "Unconstrained", "Binary", "Optimization", "problem", "(", "i", ".", "e", ".", "an", "Ising", "model", ")", "." ]
python
train
bootphon/h5features
h5features/properties.py
https://github.com/bootphon/h5features/blob/d5f95db0f1cee58ac1ba4575d1212e796c39e1f9/h5features/properties.py#L57-L72
def _eq_dicts(d1, d2): """Returns True if d1 == d2, False otherwise""" if not d1.keys() == d2.keys(): return False for k, v1 in d1.items(): v2 = d2[k] if not type(v1) == type(v2): return False if isinstance(v1, np.ndarray): ...
[ "def", "_eq_dicts", "(", "d1", ",", "d2", ")", ":", "if", "not", "d1", ".", "keys", "(", ")", "==", "d2", ".", "keys", "(", ")", ":", "return", "False", "for", "k", ",", "v1", "in", "d1", ".", "items", "(", ")", ":", "v2", "=", "d2", "[", ...
Returns True if d1 == d2, False otherwise
[ "Returns", "True", "if", "d1", "==", "d2", "False", "otherwise" ]
python
train
christophertbrown/bioscripts
ctbBio/rax.py
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L205-L241
def rax(a, boot, threads, \ fast = False, run_rax = False, run_iq = False, model = False, cluster = False, node = False): """ run raxml on 'a' (alignment) with 'boot' (bootstraps) and 'threads' (threads) store all files in raxml_a_b 1. give every sequence a short identifier 2. convert fa...
[ "def", "rax", "(", "a", ",", "boot", ",", "threads", ",", "fast", "=", "False", ",", "run_rax", "=", "False", ",", "run_iq", "=", "False", ",", "model", "=", "False", ",", "cluster", "=", "False", ",", "node", "=", "False", ")", ":", "a", "=", ...
run raxml on 'a' (alignment) with 'boot' (bootstraps) and 'threads' (threads) store all files in raxml_a_b 1. give every sequence a short identifier 2. convert fasta to phylip 3. run raxml 4. convert ids in raxml tree to original names
[ "run", "raxml", "on", "a", "(", "alignment", ")", "with", "boot", "(", "bootstraps", ")", "and", "threads", "(", "threads", ")", "store", "all", "files", "in", "raxml_a_b", "1", ".", "give", "every", "sequence", "a", "short", "identifier", "2", ".", "c...
python
train
googleapis/google-cloud-python
api_core/google/api_core/path_template.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/path_template.py#L131-L159
def _replace_variable_with_pattern(match): """Replace a variable match with a pattern that can be used to validate it. Args: match (re.Match): A regular expression match Returns: str: A regular expression pattern that can be used to validate the variable in an expanded path. ...
[ "def", "_replace_variable_with_pattern", "(", "match", ")", ":", "positional", "=", "match", ".", "group", "(", "\"positional\"", ")", "name", "=", "match", ".", "group", "(", "\"name\"", ")", "template", "=", "match", ".", "group", "(", "\"template\"", ")",...
Replace a variable match with a pattern that can be used to validate it. Args: match (re.Match): A regular expression match Returns: str: A regular expression pattern that can be used to validate the variable in an expanded path. Raises: ValueError: If an unexpected te...
[ "Replace", "a", "variable", "match", "with", "a", "pattern", "that", "can", "be", "used", "to", "validate", "it", "." ]
python
train
pypa/pipenv
pipenv/vendor/parse.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/parse.py#L1201-L1228
def parse(format, string, extra_types=None, evaluate_result=True, case_sensitive=False): '''Using "format" attempt to pull values from "string". The format must match the string contents exactly. If the value you're looking for is instead just a part of the string use search(). If ``evaluate_resul...
[ "def", "parse", "(", "format", ",", "string", ",", "extra_types", "=", "None", ",", "evaluate_result", "=", "True", ",", "case_sensitive", "=", "False", ")", ":", "p", "=", "Parser", "(", "format", ",", "extra_types", "=", "extra_types", ",", "case_sensiti...
Using "format" attempt to pull values from "string". The format must match the string contents exactly. If the value you're looking for is instead just a part of the string use search(). If ``evaluate_result`` is True the return value will be an Result instance with two attributes: .fixed - tupl...
[ "Using", "format", "attempt", "to", "pull", "values", "from", "string", "." ]
python
train
lvjiyong/configreset
configreset/__init__.py
https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L90-L108
def load(items, default_section=_DEFAULT_SECTION): """ 从混合类型组中读取配置 :param default_section: :param items: :return: """ settings = [] assert isinstance(items, list), 'items必须为list' logger.debug(items) for item in items: if _is_conf(item): settings.append(load_...
[ "def", "load", "(", "items", ",", "default_section", "=", "_DEFAULT_SECTION", ")", ":", "settings", "=", "[", "]", "assert", "isinstance", "(", "items", ",", "list", ")", ",", "'items必须为list'", "logger", ".", "debug", "(", "items", ")", "for", "item", "i...
从混合类型组中读取配置 :param default_section: :param items: :return:
[ "从混合类型组中读取配置", ":", "param", "default_section", ":", ":", "param", "items", ":", ":", "return", ":" ]
python
train
pymc-devs/pymc
pymc/StepMethods.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L303-L312
def logp_plus_loglike(self): ''' The summed log-probability of all stochastic variables that depend on self.stochastics, and self.stochastics. ''' sum = logp_of_set(self.markov_blanket) if self.verbose > 2: print_('\t' + self._id + ' Current...
[ "def", "logp_plus_loglike", "(", "self", ")", ":", "sum", "=", "logp_of_set", "(", "self", ".", "markov_blanket", ")", "if", "self", ".", "verbose", ">", "2", ":", "print_", "(", "'\\t'", "+", "self", ".", "_id", "+", "' Current log-likelihood plus current l...
The summed log-probability of all stochastic variables that depend on self.stochastics, and self.stochastics.
[ "The", "summed", "log", "-", "probability", "of", "all", "stochastic", "variables", "that", "depend", "on", "self", ".", "stochastics", "and", "self", ".", "stochastics", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/autobuild.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/autobuild.py#L152-L176
def autobuild_arm_program(elfname, test_dir=os.path.join('firmware', 'test'), patch=True): """ Build the an ARM module for all targets and build all unit tests. If pcb files are given, also build those. """ try: #Build for all targets family = utilities.get_family('module_settings.json'...
[ "def", "autobuild_arm_program", "(", "elfname", ",", "test_dir", "=", "os", ".", "path", ".", "join", "(", "'firmware'", ",", "'test'", ")", ",", "patch", "=", "True", ")", ":", "try", ":", "#Build for all targets", "family", "=", "utilities", ".", "get_fa...
Build the an ARM module for all targets and build all unit tests. If pcb files are given, also build those.
[ "Build", "the", "an", "ARM", "module", "for", "all", "targets", "and", "build", "all", "unit", "tests", ".", "If", "pcb", "files", "are", "given", "also", "build", "those", "." ]
python
train
pokerregion/poker
poker/room/pokerstars.py
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L372-L375
def prepend_note(self, player, text): """Prepend text to an already existing note.""" note = self._find_note(player) note.text = text + note.text
[ "def", "prepend_note", "(", "self", ",", "player", ",", "text", ")", ":", "note", "=", "self", ".", "_find_note", "(", "player", ")", "note", ".", "text", "=", "text", "+", "note", ".", "text" ]
Prepend text to an already existing note.
[ "Prepend", "text", "to", "an", "already", "existing", "note", "." ]
python
train
LEMS/pylems
lems/model/structure.py
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L86-L95
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Tunnel name="{0}"'.format(self.name) + \ ' endA="{0}"'.format(self.end_a) + \ ' endB="{0}"'.format(self.end_b) + \ ' componentA="{0}"'.format(self.component_a) + \ ...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Tunnel name=\"{0}\"'", ".", "format", "(", "self", ".", "name", ")", "+", "' endA=\"{0}\"'", ".", "format", "(", "self", ".", "end_a", ")", "+", "' endB=\"{0}\"'", ".", "format", "(", "self", ".", "end_...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
python
train
google/grr
grr/server/grr_response_server/flow.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L795-L810
def NotifyAboutEnd(self): """Send out a final notification about the end of this flow.""" flow_ref = None if self.runner_args.client_id: flow_ref = rdf_objects.FlowReference( client_id=self.client_id, flow_id=self.urn.Basename()) num_results = len(self.ResultCollection()) notificati...
[ "def", "NotifyAboutEnd", "(", "self", ")", ":", "flow_ref", "=", "None", "if", "self", ".", "runner_args", ".", "client_id", ":", "flow_ref", "=", "rdf_objects", ".", "FlowReference", "(", "client_id", "=", "self", ".", "client_id", ",", "flow_id", "=", "s...
Send out a final notification about the end of this flow.
[ "Send", "out", "a", "final", "notification", "about", "the", "end", "of", "this", "flow", "." ]
python
train
pypa/pipenv
pipenv/patched/notpip/_vendor/cachecontrol/caches/redis_cache.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/cachecontrol/caches/redis_cache.py#L25-L29
def clear(self): """Helper for clearing all the keys in a database. Use with caution!""" for key in self.conn.keys(): self.conn.delete(key)
[ "def", "clear", "(", "self", ")", ":", "for", "key", "in", "self", ".", "conn", ".", "keys", "(", ")", ":", "self", ".", "conn", ".", "delete", "(", "key", ")" ]
Helper for clearing all the keys in a database. Use with caution!
[ "Helper", "for", "clearing", "all", "the", "keys", "in", "a", "database", ".", "Use", "with", "caution!" ]
python
train
openstax/cnx-publishing
cnxpublishing/session.py
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/session.py#L5-L9
def includeme(config): """Configures the session manager""" settings = config.registry.settings session_factory = SignedCookieSessionFactory(settings['session_key']) config.set_session_factory(session_factory)
[ "def", "includeme", "(", "config", ")", ":", "settings", "=", "config", ".", "registry", ".", "settings", "session_factory", "=", "SignedCookieSessionFactory", "(", "settings", "[", "'session_key'", "]", ")", "config", ".", "set_session_factory", "(", "session_fac...
Configures the session manager
[ "Configures", "the", "session", "manager" ]
python
valid
Kitware/tangelo
tangelo/tangelo/util.py
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/util.py#L170-L214
def module_cache_get(cache, module): """ Import a module with an optional yaml config file, but only if we haven't imported it already. :param cache: object which holds information on which modules and config files have been loaded and whether config files should be ...
[ "def", "module_cache_get", "(", "cache", ",", "module", ")", ":", "if", "getattr", "(", "cache", ",", "\"config\"", ",", "False", ")", ":", "config_file", "=", "module", "[", ":", "-", "2", "]", "+", "\"yaml\"", "if", "config_file", "not", "in", "cache...
Import a module with an optional yaml config file, but only if we haven't imported it already. :param cache: object which holds information on which modules and config files have been loaded and whether config files should be loaded. :param module: the path of the module...
[ "Import", "a", "module", "with", "an", "optional", "yaml", "config", "file", "but", "only", "if", "we", "haven", "t", "imported", "it", "already", "." ]
python
train
tornadoweb/tornado
tornado/web.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1424-L1448
def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]: """Read or generate the xsrf token in its raw form. The raw_xsrf_token is a tuple containing: * version: the version of the cookie from which this token was read, or None if we generated a new token in this request....
[ "def", "_get_raw_xsrf_token", "(", "self", ")", "->", "Tuple", "[", "Optional", "[", "int", "]", ",", "bytes", ",", "float", "]", ":", "if", "not", "hasattr", "(", "self", ",", "\"_raw_xsrf_token\"", ")", ":", "cookie", "=", "self", ".", "get_cookie", ...
Read or generate the xsrf token in its raw form. The raw_xsrf_token is a tuple containing: * version: the version of the cookie from which this token was read, or None if we generated a new token in this request. * token: the raw token data; random (non-ascii) bytes. * timest...
[ "Read", "or", "generate", "the", "xsrf", "token", "in", "its", "raw", "form", "." ]
python
train
BlackEarth/bxml
bxml/xml.py
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xml.py#L476-L480
def tag_name(cls, tag): """return the name of the tag, with the namespace removed""" while isinstance(tag, etree._Element): tag = tag.tag return tag.split('}')[-1]
[ "def", "tag_name", "(", "cls", ",", "tag", ")", ":", "while", "isinstance", "(", "tag", ",", "etree", ".", "_Element", ")", ":", "tag", "=", "tag", ".", "tag", "return", "tag", ".", "split", "(", "'}'", ")", "[", "-", "1", "]" ]
return the name of the tag, with the namespace removed
[ "return", "the", "name", "of", "the", "tag", "with", "the", "namespace", "removed" ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10750-L10771
def mag_cal_report_encode(self, compass_id, cal_mask, cal_status, autosaved, fitness, ofs_x, ofs_y, ofs_z, diag_x, diag_y, diag_z, offdiag_x, offdiag_y, offdiag_z): ''' Reports results of completed compass calibration. Sent until MAG_CAL_ACK received. com...
[ "def", "mag_cal_report_encode", "(", "self", ",", "compass_id", ",", "cal_mask", ",", "cal_status", ",", "autosaved", ",", "fitness", ",", "ofs_x", ",", "ofs_y", ",", "ofs_z", ",", "diag_x", ",", "diag_y", ",", "diag_z", ",", "offdiag_x", ",", "offdiag_y", ...
Reports results of completed compass calibration. Sent until MAG_CAL_ACK received. compass_id : Compass being calibrated (uint8_t) cal_mask : Bitmask of compasses being calibrated (uint8_t) cal_status : Statu...
[ "Reports", "results", "of", "completed", "compass", "calibration", ".", "Sent", "until", "MAG_CAL_ACK", "received", "." ]
python
train
apache/spark
python/pyspark/heapq3.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L595-L673
def merge(iterables, key=None, reverse=False): '''Merge multiple sorted inputs into a single sorted output. Similar to sorted(itertools.chain(*iterables)) but returns a generator, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to l...
[ "def", "merge", "(", "iterables", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "h", "=", "[", "]", "h_append", "=", "h", ".", "append", "if", "reverse", ":", "_heapify", "=", "_heapify_max", "_heappop", "=", "_heappop_max", "_heapre...
Merge multiple sorted inputs into a single sorted output. Similar to sorted(itertools.chain(*iterables)) but returns a generator, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to largest). >>> list(merge([1,3,5,7], [0,2,4,8], [5,...
[ "Merge", "multiple", "sorted", "inputs", "into", "a", "single", "sorted", "output", "." ]
python
train
pantsbuild/pants
src/python/pants/base/exception_sink.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/exception_sink.py#L377-L404
def _log_unhandled_exception_and_exit(cls, exc_class=None, exc=None, tb=None, add_newline=False): """A sys.excepthook implementation which logs the error and exits with failure.""" exc_class = exc_class or sys.exc_info()[0] exc = exc or sys.exc_info()[1] tb = tb or sys.exc_info()[2] # This exceptio...
[ "def", "_log_unhandled_exception_and_exit", "(", "cls", ",", "exc_class", "=", "None", ",", "exc", "=", "None", ",", "tb", "=", "None", ",", "add_newline", "=", "False", ")", ":", "exc_class", "=", "exc_class", "or", "sys", ".", "exc_info", "(", ")", "["...
A sys.excepthook implementation which logs the error and exits with failure.
[ "A", "sys", ".", "excepthook", "implementation", "which", "logs", "the", "error", "and", "exits", "with", "failure", "." ]
python
train
blockstack/virtualchain
virtualchain/lib/config.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L64-L91
def get_logger(name=None): """ Get virtualchain's logger """ level = logging.CRITICAL if DEBUG: logging.disable(logging.NOTSET) level = logging.DEBUG if name is None: name = "<unknown>" log = logging.getLogger(name=name) log.setLevel( level ) console = logg...
[ "def", "get_logger", "(", "name", "=", "None", ")", ":", "level", "=", "logging", ".", "CRITICAL", "if", "DEBUG", ":", "logging", ".", "disable", "(", "logging", ".", "NOTSET", ")", "level", "=", "logging", ".", "DEBUG", "if", "name", "is", "None", "...
Get virtualchain's logger
[ "Get", "virtualchain", "s", "logger" ]
python
train
rigetti/pyquil
pyquil/reference_simulator.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/reference_simulator.py#L198-L209
def do_gate_matrix(self, matrix: np.ndarray, qubits: Sequence[int]) -> 'AbstractQuantumSimulator': """ Apply an arbitrary unitary; not necessarily a named gate. :param matrix: The unitary matrix to apply. No checks are done :param qubits: A list of qubits to apply...
[ "def", "do_gate_matrix", "(", "self", ",", "matrix", ":", "np", ".", "ndarray", ",", "qubits", ":", "Sequence", "[", "int", "]", ")", "->", "'AbstractQuantumSimulator'", ":", "unitary", "=", "lifted_gate_matrix", "(", "matrix", "=", "matrix", ",", "qubit_ind...
Apply an arbitrary unitary; not necessarily a named gate. :param matrix: The unitary matrix to apply. No checks are done :param qubits: A list of qubits to apply the unitary to. :return: ``self`` to support method chaining.
[ "Apply", "an", "arbitrary", "unitary", ";", "not", "necessarily", "a", "named", "gate", "." ]
python
train
juju/charm-helpers
charmhelpers/contrib/openstack/ip.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/ip.py#L117-L187
def resolve_address(endpoint_type=PUBLIC, override=True): """Return unit address depending on net config. If unit is clustered with vip(s) and has net splits defined, return vip on correct network. If clustered with no nets defined, return primary vip. If not clustered, return unit address ensuring ad...
[ "def", "resolve_address", "(", "endpoint_type", "=", "PUBLIC", ",", "override", "=", "True", ")", ":", "resolved_address", "=", "None", "if", "override", ":", "resolved_address", "=", "_get_address_override", "(", "endpoint_type", ")", "if", "resolved_address", ":...
Return unit address depending on net config. If unit is clustered with vip(s) and has net splits defined, return vip on correct network. If clustered with no nets defined, return primary vip. If not clustered, return unit address ensuring address is on configured net split if one is configured, or a J...
[ "Return", "unit", "address", "depending", "on", "net", "config", "." ]
python
train
yatiml/yatiml
yatiml/constructors.py
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L206-L231
def __check_no_missing_attributes(self, node: yaml.Node, mapping: CommentedMap) -> None: """Checks that all required attributes are present. Also checks that they're of the correct type. Args: mapping: The mapping with subobjects of this object...
[ "def", "__check_no_missing_attributes", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "mapping", ":", "CommentedMap", ")", "->", "None", ":", "logger", ".", "debug", "(", "'Checking presence of required attributes'", ")", "for", "name", ",", "type_", ...
Checks that all required attributes are present. Also checks that they're of the correct type. Args: mapping: The mapping with subobjects of this object. Raises: RecognitionError: if an attribute is missing or the type \ is incorrect.
[ "Checks", "that", "all", "required", "attributes", "are", "present", "." ]
python
train
liamw9534/bt-manager
bt_manager/codecs.py
https://github.com/liamw9534/bt-manager/blob/51be2919394ce8134c698359649bfad09eedf4ec/bt_manager/codecs.py#L111-L157
def _init_sbc_config(self, config): """ Translator from namedtuple config representation to the sbc_t type. :param namedtuple config: See :py:class:`.SBCCodecConfig` :returns: """ if (config.channel_mode == SBCChannelMode.CHANNEL_MODE_MONO): self.conf...
[ "def", "_init_sbc_config", "(", "self", ",", "config", ")", ":", "if", "(", "config", ".", "channel_mode", "==", "SBCChannelMode", ".", "CHANNEL_MODE_MONO", ")", ":", "self", ".", "config", ".", "mode", "=", "self", ".", "codec", ".", "SBC_MODE_MONO", "eli...
Translator from namedtuple config representation to the sbc_t type. :param namedtuple config: See :py:class:`.SBCCodecConfig` :returns:
[ "Translator", "from", "namedtuple", "config", "representation", "to", "the", "sbc_t", "type", "." ]
python
train
raphaelvallat/pingouin
pingouin/correlation.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/correlation.py#L15-L107
def skipped(x, y, method='spearman'): """ Skipped correlation (Rousselet and Pernet 2012). Parameters ---------- x, y : array_like First and second set of observations. x and y must be independent. method : str Method used to compute the correlation after outlier removal. Can be...
[ "def", "skipped", "(", "x", ",", "y", ",", "method", "=", "'spearman'", ")", ":", "# Check that sklearn is installed", "from", "pingouin", ".", "utils", "import", "_is_sklearn_installed", "_is_sklearn_installed", "(", "raise_error", "=", "True", ")", "from", "scip...
Skipped correlation (Rousselet and Pernet 2012). Parameters ---------- x, y : array_like First and second set of observations. x and y must be independent. method : str Method used to compute the correlation after outlier removal. Can be either 'spearman' (default) or 'pearson'....
[ "Skipped", "correlation", "(", "Rousselet", "and", "Pernet", "2012", ")", "." ]
python
train
IdentityPython/SATOSA
src/satosa/util.py
https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/util.py#L81-L93
def rndstr(size=16, alphabet=""): """ Returns a string of random ascii characters or digits :type size: int :type alphabet: str :param size: The length of the string :param alphabet: A string with characters. :return: string """ rng = random.SystemRandom() if not alphabet: ...
[ "def", "rndstr", "(", "size", "=", "16", ",", "alphabet", "=", "\"\"", ")", ":", "rng", "=", "random", ".", "SystemRandom", "(", ")", "if", "not", "alphabet", ":", "alphabet", "=", "string", ".", "ascii_letters", "[", "0", ":", "52", "]", "+", "str...
Returns a string of random ascii characters or digits :type size: int :type alphabet: str :param size: The length of the string :param alphabet: A string with characters. :return: string
[ "Returns", "a", "string", "of", "random", "ascii", "characters", "or", "digits", ":", "type", "size", ":", "int", ":", "type", "alphabet", ":", "str", ":", "param", "size", ":", "The", "length", "of", "the", "string", ":", "param", "alphabet", ":", "A"...
python
train
the01/paps-settings
setup.py
https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/setup.py#L29-L42
def get_version(): """ Parse the version information from the init file """ version_file = os.path.join("paps_settings", "__init__.py") initfile_lines = open(version_file, 'rt').readlines() version_reg = r"^__version__ = ['\"]([^'\"]*)['\"]" for line in initfile_lines: mo = re.search...
[ "def", "get_version", "(", ")", ":", "version_file", "=", "os", ".", "path", ".", "join", "(", "\"paps_settings\"", ",", "\"__init__.py\"", ")", "initfile_lines", "=", "open", "(", "version_file", ",", "'rt'", ")", ".", "readlines", "(", ")", "version_reg", ...
Parse the version information from the init file
[ "Parse", "the", "version", "information", "from", "the", "init", "file" ]
python
train
vertexproject/synapse
synapse/cryotank.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/cryotank.py#L285-L312
async def init(self, name, conf=None): ''' Generate a new CryoTank with a given name or get an reference to an existing CryoTank. Args: name (str): Name of the CryoTank. Returns: CryoTank: A CryoTank instance. ''' tank = self.tanks.get(name) ...
[ "async", "def", "init", "(", "self", ",", "name", ",", "conf", "=", "None", ")", ":", "tank", "=", "self", ".", "tanks", ".", "get", "(", "name", ")", "if", "tank", "is", "not", "None", ":", "return", "tank", "iden", "=", "s_common", ".", "guid",...
Generate a new CryoTank with a given name or get an reference to an existing CryoTank. Args: name (str): Name of the CryoTank. Returns: CryoTank: A CryoTank instance.
[ "Generate", "a", "new", "CryoTank", "with", "a", "given", "name", "or", "get", "an", "reference", "to", "an", "existing", "CryoTank", "." ]
python
train
CivicSpleen/ambry
ambry/run.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/run.py#L90-L129
def find_config_file(file_name, extra_path=None, load_user=True): """ Find a configuration file in one of these directories, tried in this order: - A path provided as an argument - A path specified by the AMBRY_CONFIG environmenal variable - ambry in a path specified by the VIRTUAL_ENV environmenta...
[ "def", "find_config_file", "(", "file_name", ",", "extra_path", "=", "None", ",", "load_user", "=", "True", ")", ":", "paths", "=", "[", "]", "if", "extra_path", "is", "not", "None", ":", "paths", ".", "append", "(", "extra_path", ")", "if", "os", ".",...
Find a configuration file in one of these directories, tried in this order: - A path provided as an argument - A path specified by the AMBRY_CONFIG environmenal variable - ambry in a path specified by the VIRTUAL_ENV environmental variable - ~/ambry - /etc/ambry :param file_name: :param ex...
[ "Find", "a", "configuration", "file", "in", "one", "of", "these", "directories", "tried", "in", "this", "order", ":" ]
python
train
openego/ding0
ding0/examples/example_parallel_multiple_grid_districts.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/examples/example_parallel_multiple_grid_districts.py#L191-L217
def process_metadata(meta): """ Merge metadata of run on multiple grid districts Parameters ---------- meta: list of dict Metadata of run of each MV grid district Returns ------- dict Single metadata dict including merge metadata """ mvgds = [] metadata = m...
[ "def", "process_metadata", "(", "meta", ")", ":", "mvgds", "=", "[", "]", "metadata", "=", "meta", "[", "0", "]", "for", "mvgd", "in", "meta", ":", "if", "isinstance", "(", "mvgd", "[", "'mv_grid_districts'", "]", ",", "list", ")", ":", "mvgds", ".",...
Merge metadata of run on multiple grid districts Parameters ---------- meta: list of dict Metadata of run of each MV grid district Returns ------- dict Single metadata dict including merge metadata
[ "Merge", "metadata", "of", "run", "on", "multiple", "grid", "districts" ]
python
train
spyder-ide/spyder
spyder/utils/stringmatching.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/stringmatching.py#L179-L230
def get_search_scores(query, choices, ignore_case=True, template='{}', valid_only=False, sort=False): """Search for query inside choices and return a list of tuples. Returns a list of tuples of text with the enriched text (if a template is provided) and a score for the match. Lower sc...
[ "def", "get_search_scores", "(", "query", ",", "choices", ",", "ignore_case", "=", "True", ",", "template", "=", "'{}'", ",", "valid_only", "=", "False", ",", "sort", "=", "False", ")", ":", "# First remove spaces from query", "query", "=", "query", ".", "re...
Search for query inside choices and return a list of tuples. Returns a list of tuples of text with the enriched text (if a template is provided) and a score for the match. Lower scores imply a better match. Parameters ---------- query : str String with letters to search in each choice (in ...
[ "Search", "for", "query", "inside", "choices", "and", "return", "a", "list", "of", "tuples", "." ]
python
train
planetlabs/datalake-common
datalake_common/record.py
https://github.com/planetlabs/datalake-common/blob/f0864732ac8cf26df4bea62600aee13b19321a93/datalake_common/record.py#L65-L71
def list_from_url(cls, url): '''return a list of DatalakeRecords for the specified url''' key = cls._get_key(url) metadata = cls._get_metadata_from_key(key) ct = cls._get_create_time(key) time_buckets = cls.get_time_buckets_from_metadata(metadata) return [cls(url, metadat...
[ "def", "list_from_url", "(", "cls", ",", "url", ")", ":", "key", "=", "cls", ".", "_get_key", "(", "url", ")", "metadata", "=", "cls", ".", "_get_metadata_from_key", "(", "key", ")", "ct", "=", "cls", ".", "_get_create_time", "(", "key", ")", "time_buc...
return a list of DatalakeRecords for the specified url
[ "return", "a", "list", "of", "DatalakeRecords", "for", "the", "specified", "url" ]
python
train
uw-it-aca/uw-restclients
restclients/r25/reservations.py
https://github.com/uw-it-aca/uw-restclients/blob/e12dcd32bf5296b6ebdf71798031594afb7852cb/restclients/r25/reservations.py#L12-L23
def get_reservations(**kwargs): """ Return a list of reservations matching the passed filter. Supported kwargs are listed at http://knowledge25.collegenet.com/display/WSW/reservations.xml """ kwargs["scope"] = "extended" url = "/r25ws/servlet/wrd/run/reservations.xml" if len(kwargs): ...
[ "def", "get_reservations", "(", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"scope\"", "]", "=", "\"extended\"", "url", "=", "\"/r25ws/servlet/wrd/run/reservations.xml\"", "if", "len", "(", "kwargs", ")", ":", "url", "+=", "\"?%s\"", "%", "urlencode", "(", ...
Return a list of reservations matching the passed filter. Supported kwargs are listed at http://knowledge25.collegenet.com/display/WSW/reservations.xml
[ "Return", "a", "list", "of", "reservations", "matching", "the", "passed", "filter", ".", "Supported", "kwargs", "are", "listed", "at", "http", ":", "//", "knowledge25", ".", "collegenet", ".", "com", "/", "display", "/", "WSW", "/", "reservations", ".", "x...
python
train
has2k1/plotnine
plotnine/utils.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/utils.py#L386-L395
def uniquecols(df): """ Return unique columns This is used for figuring out which columns are constant within a group """ bool_idx = df.apply(lambda col: len(np.unique(col)) == 1, axis=0) df = df.loc[:, bool_idx].iloc[0:1, :].reset_index(drop=True) return df
[ "def", "uniquecols", "(", "df", ")", ":", "bool_idx", "=", "df", ".", "apply", "(", "lambda", "col", ":", "len", "(", "np", ".", "unique", "(", "col", ")", ")", "==", "1", ",", "axis", "=", "0", ")", "df", "=", "df", ".", "loc", "[", ":", "...
Return unique columns This is used for figuring out which columns are constant within a group
[ "Return", "unique", "columns" ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/plugins.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/plugins.py#L369-L397
def load_plugin(self, p): """Load the specified plugin :param p: The plugin to load :type p: Subclass of JB_Plugin :returns: None :rtype: None :raises: errors.PluginInitError """ if p.is_loaded(): return # load required plugins first ...
[ "def", "load_plugin", "(", "self", ",", "p", ")", ":", "if", "p", ".", "is_loaded", "(", ")", ":", "return", "# load required plugins first", "reqnames", "=", "p", ".", "required", "reqplugins", "=", "[", "]", "for", "name", "in", "reqnames", ":", "try",...
Load the specified plugin :param p: The plugin to load :type p: Subclass of JB_Plugin :returns: None :rtype: None :raises: errors.PluginInitError
[ "Load", "the", "specified", "plugin" ]
python
train
ladybug-tools/ladybug
ladybug/sunpath.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/sunpath.py#L481-L488
def _calculate_solar_time(self, hour, eq_of_time, is_solar_time): """Calculate Solar time for an hour.""" if is_solar_time: return hour return ( (hour * 60 + eq_of_time + 4 * math.degrees(self._longitude) - 60 * self.time_zone) % 1440) / 60
[ "def", "_calculate_solar_time", "(", "self", ",", "hour", ",", "eq_of_time", ",", "is_solar_time", ")", ":", "if", "is_solar_time", ":", "return", "hour", "return", "(", "(", "hour", "*", "60", "+", "eq_of_time", "+", "4", "*", "math", ".", "degrees", "(...
Calculate Solar time for an hour.
[ "Calculate", "Solar", "time", "for", "an", "hour", "." ]
python
train
bokeh/bokeh
bokeh/embed/util.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/embed/util.py#L305-L315
def submodel_has_python_callbacks(models): ''' Traverses submodels to check for Python (event) callbacks ''' has_python_callback = False for model in collect_models(models): if len(model._callbacks) > 0 or len(model._event_callbacks) > 0: has_python_callback = True break...
[ "def", "submodel_has_python_callbacks", "(", "models", ")", ":", "has_python_callback", "=", "False", "for", "model", "in", "collect_models", "(", "models", ")", ":", "if", "len", "(", "model", ".", "_callbacks", ")", ">", "0", "or", "len", "(", "model", "...
Traverses submodels to check for Python (event) callbacks
[ "Traverses", "submodels", "to", "check", "for", "Python", "(", "event", ")", "callbacks" ]
python
train
MakerReduxCorp/PLOD
PLOD/internal.py
https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/internal.py#L204-L209
def get_member(row, key): ''' properly detects if a an attribute exists ''' (target, tkey, tvalue) = dict_crawl(row, key) if target: return tvalue return None
[ "def", "get_member", "(", "row", ",", "key", ")", ":", "(", "target", ",", "tkey", ",", "tvalue", ")", "=", "dict_crawl", "(", "row", ",", "key", ")", "if", "target", ":", "return", "tvalue", "return", "None" ]
properly detects if a an attribute exists
[ "properly", "detects", "if", "a", "an", "attribute", "exists" ]
python
train
paylogic/pip-accel
pip_accel/config.py
https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/config.py#L226-L237
def data_directory(self): """ The absolute pathname of the directory where pip-accel's data files are stored (a string). - Environment variable: ``$PIP_ACCEL_CACHE`` - Configuration option: ``data-directory`` - Default: ``/var/cache/pip-accel`` if running as ``root``, ``~/.pip-a...
[ "def", "data_directory", "(", "self", ")", ":", "return", "expand_path", "(", "self", ".", "get", "(", "property_name", "=", "'data_directory'", ",", "environment_variable", "=", "'PIP_ACCEL_CACHE'", ",", "configuration_option", "=", "'data-directory'", ",", "defaul...
The absolute pathname of the directory where pip-accel's data files are stored (a string). - Environment variable: ``$PIP_ACCEL_CACHE`` - Configuration option: ``data-directory`` - Default: ``/var/cache/pip-accel`` if running as ``root``, ``~/.pip-accel`` otherwise
[ "The", "absolute", "pathname", "of", "the", "directory", "where", "pip", "-", "accel", "s", "data", "files", "are", "stored", "(", "a", "string", ")", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1291-L1294
def p_negedgesig(self, p): 'edgesig : NEGEDGE edgesig_base' p[0] = Sens(p[2], 'negedge', lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_negedgesig", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "Sens", "(", "p", "[", "2", "]", ",", "'negedge'", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "p", ".", "set_lineno", "(", "0", ",", "p", ".",...
edgesig : NEGEDGE edgesig_base
[ "edgesig", ":", "NEGEDGE", "edgesig_base" ]
python
train
mozilla/treeherder
treeherder/auth/backends.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/auth/backends.py#L169-L182
def _calculate_session_expiry(self, request, user_info): """Returns the number of seconds after which the Django session should expire.""" access_token_expiry_timestamp = self._get_access_token_expiry(request) id_token_expiry_timestamp = self._get_id_token_expiry(user_info) now_in_second...
[ "def", "_calculate_session_expiry", "(", "self", ",", "request", ",", "user_info", ")", ":", "access_token_expiry_timestamp", "=", "self", ".", "_get_access_token_expiry", "(", "request", ")", "id_token_expiry_timestamp", "=", "self", ".", "_get_id_token_expiry", "(", ...
Returns the number of seconds after which the Django session should expire.
[ "Returns", "the", "number", "of", "seconds", "after", "which", "the", "Django", "session", "should", "expire", "." ]
python
train
wuher/devil
devil/resource.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L173-L186
def _format_response(self, request, response): """ Format response using appropriate datamapper. Take the devil response and turn it into django response, ready to be returned to the client. """ res = datamapper.format(request, response, self) # data is now formatted, l...
[ "def", "_format_response", "(", "self", ",", "request", ",", "response", ")", ":", "res", "=", "datamapper", ".", "format", "(", "request", ",", "response", ",", "self", ")", "# data is now formatted, let's check if the status_code is set", "if", "res", ".", "stat...
Format response using appropriate datamapper. Take the devil response and turn it into django response, ready to be returned to the client.
[ "Format", "response", "using", "appropriate", "datamapper", "." ]
python
train
ga4gh/ga4gh-server
ga4gh/server/datamodel/genotype_phenotype.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/genotype_phenotype.py#L102-L113
def _extractAssociationsDetails(self, associations): """ Given a set of results from our search query, return the `details` (feature,environment,phenotype) """ detailedURIRef = [] for row in associations.bindings: if 'feature' in row: detailedU...
[ "def", "_extractAssociationsDetails", "(", "self", ",", "associations", ")", ":", "detailedURIRef", "=", "[", "]", "for", "row", "in", "associations", ".", "bindings", ":", "if", "'feature'", "in", "row", ":", "detailedURIRef", ".", "append", "(", "row", "["...
Given a set of results from our search query, return the `details` (feature,environment,phenotype)
[ "Given", "a", "set", "of", "results", "from", "our", "search", "query", "return", "the", "details", "(", "feature", "environment", "phenotype", ")" ]
python
train
ianmiell/shutit
shutit_pexpect.py
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L2159-L2241
def multisend(self, sendspec): """Multisend. Same as send, except it takes multiple sends and expects in a dict that are processed while waiting for the end "expect" argument supplied. @param send: See send() @param send_dict: See ShutItSendSpec @param expect: See sen...
[ "def", "multisend", "(", "self", ",", "sendspec", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "sendspec", ".", "note", ")", "expect", "=", "sendspec", ".", "expect", "or", "self", ".", "default_expect", "send_iteratio...
Multisend. Same as send, except it takes multiple sends and expects in a dict that are processed while waiting for the end "expect" argument supplied. @param send: See send() @param send_dict: See ShutItSendSpec @param expect: See send() @param timeout: S...
[ "Multisend", ".", "Same", "as", "send", "except", "it", "takes", "multiple", "sends", "and", "expects", "in", "a", "dict", "that", "are", "processed", "while", "waiting", "for", "the", "end", "expect", "argument", "supplied", "." ]
python
train
dangunter/smoqe
smoqe/query.py
https://github.com/dangunter/smoqe/blob/70aa8ec1e9df875b9d21c71cbded95c595fe2aad/smoqe/query.py#L472-L481
def get_conflicts(self): """Get conflicts in constraints, if any. :return: Description of each conflict, empty if none. :rtype: list(str) """ conflicts = [] if self._array and self._range: conflicts.append('cannot use range expressions on arrays') ret...
[ "def", "get_conflicts", "(", "self", ")", ":", "conflicts", "=", "[", "]", "if", "self", ".", "_array", "and", "self", ".", "_range", ":", "conflicts", ".", "append", "(", "'cannot use range expressions on arrays'", ")", "return", "conflicts" ]
Get conflicts in constraints, if any. :return: Description of each conflict, empty if none. :rtype: list(str)
[ "Get", "conflicts", "in", "constraints", "if", "any", "." ]
python
train
sirfoga/pyhal
hal/streams/user.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L116-L151
def get_number(self, question, min_i=float("-inf"), max_i=float("inf"), just_these=None): """Parses answer and gets number :param question: Question: to ask user :param min_i: min acceptable number :param max_i: max acceptable number :param just_these: Accept ...
[ "def", "get_number", "(", "self", ",", "question", ",", "min_i", "=", "float", "(", "\"-inf\"", ")", ",", "max_i", "=", "float", "(", "\"inf\"", ")", ",", "just_these", "=", "None", ")", ":", "try", ":", "user_answer", "=", "self", ".", "get_answer", ...
Parses answer and gets number :param question: Question: to ask user :param min_i: min acceptable number :param max_i: max acceptable number :param just_these: Accept only these numbers :return: User answer
[ "Parses", "answer", "and", "gets", "number" ]
python
train
IdentityPython/fedoidcmsg
src/fedoidcmsg/file_system.py
https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/file_system.py#L170-L188
def sync(self): """ Goes through the directory and builds a local cache based on the content of the directory. """ if not os.path.isdir(self.fdir): os.makedirs(self.fdir) for f in os.listdir(self.fdir): fname = os.path.join(self.fdir, f) ...
[ "def", "sync", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "fdir", ")", ":", "os", ".", "makedirs", "(", "self", ".", "fdir", ")", "for", "f", "in", "os", ".", "listdir", "(", "self", ".", "fdir", ")...
Goes through the directory and builds a local cache based on the content of the directory.
[ "Goes", "through", "the", "directory", "and", "builds", "a", "local", "cache", "based", "on", "the", "content", "of", "the", "directory", "." ]
python
test
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L313-L327
def worker_stop(obj, worker_ids): """ Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all. """ if len(worker_ids) == 0: msg = 'Would you like to stop all workers?' else: msg = '\n{}\n\n{}'.format('\n'.join(worker_ids), ...
[ "def", "worker_stop", "(", "obj", ",", "worker_ids", ")", ":", "if", "len", "(", "worker_ids", ")", "==", "0", ":", "msg", "=", "'Would you like to stop all workers?'", "else", ":", "msg", "=", "'\\n{}\\n\\n{}'", ".", "format", "(", "'\\n'", ".", "join", "...
Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all.
[ "Stop", "running", "workers", "." ]
python
train
mwouts/jupytext
demo/Matplotlib example.py
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L84-L178
def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func=None, labels=None, plot_func=None, plot_kwargs=None): """ ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated...
[ "def", "stack_hist", "(", "ax", ",", "stacked_data", ",", "sty_cycle", ",", "bottoms", "=", "None", ",", "hist_func", "=", "None", ",", "labels", "=", "None", ",", "plot_func", "=", "None", ",", "plot_kwargs", "=", "None", ")", ":", "# deal with default bi...
ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated over to compute histograms row-wise sty_cycle : Cycler or operable of dict Style to apply to each set bottoms : array, optional T...
[ "ax", ":", "axes", ".", "Axes", "The", "axes", "to", "add", "artists", "too" ]
python
train
twisted/mantissa
xmantissa/people.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/people.py#L514-L522
def getEmailAddresses(self): """ Return an iterator of all email addresses associated with this person. @return: an iterator of unicode strings in RFC2822 address format. """ return self.store.query( EmailAddress, EmailAddress.person == self).getColumn('a...
[ "def", "getEmailAddresses", "(", "self", ")", ":", "return", "self", ".", "store", ".", "query", "(", "EmailAddress", ",", "EmailAddress", ".", "person", "==", "self", ")", ".", "getColumn", "(", "'address'", ")" ]
Return an iterator of all email addresses associated with this person. @return: an iterator of unicode strings in RFC2822 address format.
[ "Return", "an", "iterator", "of", "all", "email", "addresses", "associated", "with", "this", "person", "." ]
python
train
olitheolix/qtmacs
qtmacs/qtmacsmain_macros.py
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain_macros.py#L293-L307
def qteReplayKeysequenceHook(self, msgObj): """ Replay the macro sequence. """ # Quit if there is nothing to replay. if self.recorded_keysequence.toString() == '': return # Stop the recording before the replay, if necessary. if self.qteRecording: ...
[ "def", "qteReplayKeysequenceHook", "(", "self", ",", "msgObj", ")", ":", "# Quit if there is nothing to replay.", "if", "self", ".", "recorded_keysequence", ".", "toString", "(", ")", "==", "''", ":", "return", "# Stop the recording before the replay, if necessary.", "if"...
Replay the macro sequence.
[ "Replay", "the", "macro", "sequence", "." ]
python
train
lago-project/lago
lago/templates.py
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/templates.py#L325-L352
def from_url(cls, path): """ Instantiate a :class:`TemplateRepository` instance from the data in a file or url Args: path (str): Path or url to the json file to load Returns: TemplateRepository: A new instance """ if os.path.isfile(path):...
[ "def", "from_url", "(", "cls", ",", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "with", "open", "(", "path", ")", "as", "fd", ":", "data", "=", "fd", ".", "read", "(", ")", "else", ":", "try", ":", "respon...
Instantiate a :class:`TemplateRepository` instance from the data in a file or url Args: path (str): Path or url to the json file to load Returns: TemplateRepository: A new instance
[ "Instantiate", "a", ":", "class", ":", "TemplateRepository", "instance", "from", "the", "data", "in", "a", "file", "or", "url" ]
python
train
bunq/sdk_python
bunq/sdk/exception_factory.py
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/exception_factory.py#L101-L119
def _generate_message_error(cls, response_code, messages, response_id): """ :type response_code: int :type messages: list[str] :type response_id: str :rtype: str """ line_response_code = cls._FORMAT_RESPONSE_CODE_LINE \ .format(response_code) ...
[ "def", "_generate_message_error", "(", "cls", ",", "response_code", ",", "messages", ",", "response_id", ")", ":", "line_response_code", "=", "cls", ".", "_FORMAT_RESPONSE_CODE_LINE", ".", "format", "(", "response_code", ")", "line_response_id", "=", "cls", ".", "...
:type response_code: int :type messages: list[str] :type response_id: str :rtype: str
[ ":", "type", "response_code", ":", "int", ":", "type", "messages", ":", "list", "[", "str", "]", ":", "type", "response_id", ":", "str" ]
python
train
prompt-toolkit/pyvim
pyvim/window_arrangement.py
https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/window_arrangement.py#L254-L261
def get_editor_buffer_for_buffer_name(self, buffer_name): """ Return the `EditorBuffer` for this buffer_name. When not found, return None """ for eb in self.editor_buffers: if eb.buffer_name == buffer_name: return eb
[ "def", "get_editor_buffer_for_buffer_name", "(", "self", ",", "buffer_name", ")", ":", "for", "eb", "in", "self", ".", "editor_buffers", ":", "if", "eb", ".", "buffer_name", "==", "buffer_name", ":", "return", "eb" ]
Return the `EditorBuffer` for this buffer_name. When not found, return None
[ "Return", "the", "EditorBuffer", "for", "this", "buffer_name", ".", "When", "not", "found", "return", "None" ]
python
train
flatangle/flatlib
flatlib/ephem/tools.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L56-L73
def syzygyJD(jd): """ Finds the latest new or full moon and returns the julian date of that event. """ sun = swe.sweObjectLon(const.SUN, jd) moon = swe.sweObjectLon(const.MOON, jd) dist = angle.distance(sun, moon) # Offset represents the Syzygy type. # Zero is conjunction and...
[ "def", "syzygyJD", "(", "jd", ")", ":", "sun", "=", "swe", ".", "sweObjectLon", "(", "const", ".", "SUN", ",", "jd", ")", "moon", "=", "swe", ".", "sweObjectLon", "(", "const", ".", "MOON", ",", "jd", ")", "dist", "=", "angle", ".", "distance", "...
Finds the latest new or full moon and returns the julian date of that event.
[ "Finds", "the", "latest", "new", "or", "full", "moon", "and", "returns", "the", "julian", "date", "of", "that", "event", "." ]
python
train
facelessuser/wcmatch
wcmatch/glob.py
https://github.com/facelessuser/wcmatch/blob/d153e7007cc73b994ae1ba553dc4584039f5c212/wcmatch/glob.py#L235-L315
def _glob(self, curdir, this, rest): """ Handle glob flow. There are really only a couple of cases: - File name. - File name pattern (magic). - Directory. - Directory name pattern (magic). - Extra slashes `////`. - `globstar` `**`. """ ...
[ "def", "_glob", "(", "self", ",", "curdir", ",", "this", ",", "rest", ")", ":", "is_magic", "=", "this", ".", "is_magic", "dir_only", "=", "this", ".", "dir_only", "target", "=", "this", ".", "pattern", "is_globstar", "=", "this", ".", "is_globstar", "...
Handle glob flow. There are really only a couple of cases: - File name. - File name pattern (magic). - Directory. - Directory name pattern (magic). - Extra slashes `////`. - `globstar` `**`.
[ "Handle", "glob", "flow", "." ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/fetching.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fetching.py#L113-L153
def update(self, cur_value, mesg=None): """Update progressbar with current value of process Parameters ---------- cur_value : number Current value of process. Should be <= max_value (but this is not enforced). The percent of the progressbar will be computed as ...
[ "def", "update", "(", "self", ",", "cur_value", ",", "mesg", "=", "None", ")", ":", "# Ensure floating-point division so we can get fractions of a percent", "# for the progressbar.", "self", ".", "cur_value", "=", "cur_value", "progress", "=", "float", "(", "self", "....
Update progressbar with current value of process Parameters ---------- cur_value : number Current value of process. Should be <= max_value (but this is not enforced). The percent of the progressbar will be computed as (cur_value / max_value) * 100 m...
[ "Update", "progressbar", "with", "current", "value", "of", "process" ]
python
train
peri-source/peri
peri/opt/optimize.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2408-L2435
def do_levmarq_n_directions(s, directions, max_iter=2, run_length=2, damping=1e-3, collect_stats=False, marquardt_damping=True, **kwargs): """ Optimization of a state along a specific set of directions in parameter space. Parameters ---------- s : :class:`peri.states.State` ...
[ "def", "do_levmarq_n_directions", "(", "s", ",", "directions", ",", "max_iter", "=", "2", ",", "run_length", "=", "2", ",", "damping", "=", "1e-3", ",", "collect_stats", "=", "False", ",", "marquardt_damping", "=", "True", ",", "*", "*", "kwargs", ")", "...
Optimization of a state along a specific set of directions in parameter space. Parameters ---------- s : :class:`peri.states.State` The state to optimize directions : np.ndarray [n,d] element numpy.ndarray of the n directions in the d- dimensional space t...
[ "Optimization", "of", "a", "state", "along", "a", "specific", "set", "of", "directions", "in", "parameter", "space", "." ]
python
valid
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1087-L1113
def pre_message(self): '''read timestamp if needed''' # read the timestamp if self.filesize != 0: self.percent = (100.0 * self.f.tell()) / self.filesize if self.notimestamps: return if self.planner_format: tbuf = self.f.read(21) if ...
[ "def", "pre_message", "(", "self", ")", ":", "# read the timestamp", "if", "self", ".", "filesize", "!=", "0", ":", "self", ".", "percent", "=", "(", "100.0", "*", "self", ".", "f", ".", "tell", "(", ")", ")", "/", "self", ".", "filesize", "if", "s...
read timestamp if needed
[ "read", "timestamp", "if", "needed" ]
python
train
estnltk/estnltk
estnltk/syntax/utils.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L669-L743
def get_children( self, **kwargs ): ''' Recursively collects and returns all subtrees of given tree (if no arguments are given), or, alternatively, collects and returns subtrees satisfying some specific criteria (pre-specified in the arguments); Parameters ...
[ "def", "get_children", "(", "self", ",", "*", "*", "kwargs", ")", ":", "depth_limit", "=", "kwargs", ".", "get", "(", "'depth_limit'", ",", "922337203685477580", ")", "# Just a nice big number to", "# assure that by default, ", "# there is no depth limit ...", "include_...
Recursively collects and returns all subtrees of given tree (if no arguments are given), or, alternatively, collects and returns subtrees satisfying some specific criteria (pre-specified in the arguments); Parameters ----------- depth_limit : in...
[ "Recursively", "collects", "and", "returns", "all", "subtrees", "of", "given", "tree", "(", "if", "no", "arguments", "are", "given", ")", "or", "alternatively", "collects", "and", "returns", "subtrees", "satisfying", "some", "specific", "criteria", "(", "pre", ...
python
train
jantman/pypi-download-stats
pypi_download_stats/outputgenerator.py
https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/outputgenerator.py#L197-L223
def _generate_graph(self, name, title, stats_data, y_name): """ Generate a downloads graph; append it to ``self._graphs``. :param name: HTML name of the graph, also used in ``self.GRAPH_KEYS`` :type name: str :param title: human-readable title for the graph :type title: ...
[ "def", "_generate_graph", "(", "self", ",", "name", ",", "title", ",", "stats_data", ",", "y_name", ")", ":", "logger", ".", "debug", "(", "'Generating chart data for %s graph'", ",", "name", ")", "orig_data", ",", "labels", "=", "self", ".", "_data_dict_to_bo...
Generate a downloads graph; append it to ``self._graphs``. :param name: HTML name of the graph, also used in ``self.GRAPH_KEYS`` :type name: str :param title: human-readable title for the graph :type title: str :param stats_data: data dict from ``self._stats`` :type stat...
[ "Generate", "a", "downloads", "graph", ";", "append", "it", "to", "self", ".", "_graphs", "." ]
python
train
svartalf/python-2gis
dgis/__init__.py
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L144-L158
def geo_search(self, **kwargs): """Geo search http://api.2gis.ru/doc/geo/search/ """ if 'types' in kwargs: kwargs['types'] = ','.join(kwargs['types']) bound = kwargs.pop('bound', False) if bound: kwargs['bound[point1]'] = bound[0] kw...
[ "def", "geo_search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'types'", "in", "kwargs", ":", "kwargs", "[", "'types'", "]", "=", "','", ".", "join", "(", "kwargs", "[", "'types'", "]", ")", "bound", "=", "kwargs", ".", "pop", "(", "...
Geo search http://api.2gis.ru/doc/geo/search/
[ "Geo", "search" ]
python
train
globus/globus-cli
globus_cli/parsing/detect_and_decorate.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/parsing/detect_and_decorate.py#L1-L27
def detect_and_decorate(decorator, args, kwargs): """ Helper for applying a decorator when it is applied directly, and also applying it when it is given arguments and then applied to a function. """ # special behavior when invoked with only one non-keyword argument: act as # a normal decorator, ...
[ "def", "detect_and_decorate", "(", "decorator", ",", "args", ",", "kwargs", ")", ":", "# special behavior when invoked with only one non-keyword argument: act as", "# a normal decorator, decorating and returning that argument with", "# click.option", "if", "len", "(", "args", ")", ...
Helper for applying a decorator when it is applied directly, and also applying it when it is given arguments and then applied to a function.
[ "Helper", "for", "applying", "a", "decorator", "when", "it", "is", "applied", "directly", "and", "also", "applying", "it", "when", "it", "is", "given", "arguments", "and", "then", "applied", "to", "a", "function", "." ]
python
train
MisterY/gnucash-portfolio
gnucash_portfolio/accounts.py
https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/accounts.py#L244-L256
def find_by_name(self, term: str, include_placeholders: bool = False) -> List[Account]: """ Search for account by part of the name """ query = ( self.query .filter(Account.name.like('%' + term + '%')) .order_by(Account.name) ) # Exclude placeholder acc...
[ "def", "find_by_name", "(", "self", ",", "term", ":", "str", ",", "include_placeholders", ":", "bool", "=", "False", ")", "->", "List", "[", "Account", "]", ":", "query", "=", "(", "self", ".", "query", ".", "filter", "(", "Account", ".", "name", "."...
Search for account by part of the name
[ "Search", "for", "account", "by", "part", "of", "the", "name" ]
python
train
saltstack/salt
salt/utils/data.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L557-L596
def traverse_dict_and_list(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict or list using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:0' will return data['foo']['bar'][0] if this value exists, and will otherwise ...
[ "def", "traverse_dict_and_list", "(", "data", ",", "key", ",", "default", "=", "None", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "ptr", "=", "data", "for", "each", "in", "key", ".", "split", "(", "delimiter", ")", ":", "if", "isinstance", ...
Traverse a dict or list using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:0' will return data['foo']['bar'][0] if this value exists, and will otherwise return the dict in the default argument. Function will automatically determine the target...
[ "Traverse", "a", "dict", "or", "list", "using", "a", "colon", "-", "delimited", "(", "or", "otherwise", "delimited", "using", "the", "delimiter", "param", ")", "target", "string", ".", "The", "target", "foo", ":", "bar", ":", "0", "will", "return", "data...
python
train
gwastro/pycbc-glue
pycbc_glue/iterutils.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/iterutils.py#L252-L325
def inorder(*iterables, **kwargs): """ A generator that yields the values from several ordered iterables in order. Example: >>> x = [0, 1, 2, 3] >>> y = [1.5, 2.5, 3.5, 4.5] >>> z = [1.75, 2.25, 3.75, 4.25] >>> list(inorder(x, y, z)) [0, 1, 1.5, 1.75, 2, 2.25, 2.5, 3, 3.5, 3.75, 4.25, 4.5] >>> list(inorder(...
[ "def", "inorder", "(", "*", "iterables", ",", "*", "*", "kwargs", ")", ":", "reverse", "=", "kwargs", ".", "pop", "(", "\"reverse\"", ",", "False", ")", "keyfunc", "=", "kwargs", ".", "pop", "(", "\"key\"", ",", "lambda", "x", ":", "x", ")", "# def...
A generator that yields the values from several ordered iterables in order. Example: >>> x = [0, 1, 2, 3] >>> y = [1.5, 2.5, 3.5, 4.5] >>> z = [1.75, 2.25, 3.75, 4.25] >>> list(inorder(x, y, z)) [0, 1, 1.5, 1.75, 2, 2.25, 2.5, 3, 3.5, 3.75, 4.25, 4.5] >>> list(inorder(x, y, z, key=lambda x: x * x)) [0, 1, 1....
[ "A", "generator", "that", "yields", "the", "values", "from", "several", "ordered", "iterables", "in", "order", "." ]
python
train
gijzelaerr/python-snap7
snap7/common.py
https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/common.py#L68-L87
def error_text(error, context="client"): """Returns a textual explanation of a given error number :param error: an error integer :param context: server, client or partner :returns: the error string """ assert context in ("client", "server", "partner") logger.debug("error text for %s" % hex(...
[ "def", "error_text", "(", "error", ",", "context", "=", "\"client\"", ")", ":", "assert", "context", "in", "(", "\"client\"", ",", "\"server\"", ",", "\"partner\"", ")", "logger", ".", "debug", "(", "\"error text for %s\"", "%", "hex", "(", "error", ")", "...
Returns a textual explanation of a given error number :param error: an error integer :param context: server, client or partner :returns: the error string
[ "Returns", "a", "textual", "explanation", "of", "a", "given", "error", "number" ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isoline.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L14-L91
def iso_mesh_line(vertices, tris, vertex_data, levels): """Generate an isocurve from vertex data in a surface mesh. Parameters ---------- vertices : ndarray, shape (Nv, 3) Vertex coordinates. tris : ndarray, shape (Nf, 3) Indices of triangular element into the vertices array. ve...
[ "def", "iso_mesh_line", "(", "vertices", ",", "tris", ",", "vertex_data", ",", "levels", ")", ":", "lines", "=", "None", "connects", "=", "None", "vertex_level", "=", "None", "level_index", "=", "None", "if", "not", "all", "(", "[", "isinstance", "(", "x...
Generate an isocurve from vertex data in a surface mesh. Parameters ---------- vertices : ndarray, shape (Nv, 3) Vertex coordinates. tris : ndarray, shape (Nf, 3) Indices of triangular element into the vertices array. vertex_data : ndarray, shape (Nv,) data at vertex. le...
[ "Generate", "an", "isocurve", "from", "vertex", "data", "in", "a", "surface", "mesh", "." ]
python
train
espressif/esptool
esptool.py
https://github.com/espressif/esptool/blob/c583756c118039cfcfe256f7a3285618914d16a5/esptool.py#L1185-L1199
def get_flash_crypt_config(self): """ bit 3 in efuse_rd_disable[3:0] is mapped to flash_crypt_config this bit is at position 19 in EFUSE_BLK0_RDATA0_REG """ word0 = self.read_efuse(0) rd_disable = (word0 >> 19) & 0x1 if rd_disable == 0: """ we can read the flash_cryp...
[ "def", "get_flash_crypt_config", "(", "self", ")", ":", "word0", "=", "self", ".", "read_efuse", "(", "0", ")", "rd_disable", "=", "(", "word0", ">>", "19", ")", "&", "0x1", "if", "rd_disable", "==", "0", ":", "\"\"\" we can read the flash_crypt_config efuse v...
bit 3 in efuse_rd_disable[3:0] is mapped to flash_crypt_config this bit is at position 19 in EFUSE_BLK0_RDATA0_REG
[ "bit", "3", "in", "efuse_rd_disable", "[", "3", ":", "0", "]", "is", "mapped", "to", "flash_crypt_config", "this", "bit", "is", "at", "position", "19", "in", "EFUSE_BLK0_RDATA0_REG" ]
python
train
tBuLi/symfit
symfit/core/support.py
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L108-L160
def sympy_to_py(func, args): """ Turn a symbolic expression into a Python lambda function, which has the names of the variables and parameters as it's argument names. :param func: sympy expression :param args: variables and parameters in this model :return: lambda function to be used for numeri...
[ "def", "sympy_to_py", "(", "func", ",", "args", ")", ":", "# replace the derivatives with printable variables.", "derivatives", "=", "{", "var", ":", "Variable", "(", "var", ".", "name", ")", "for", "var", "in", "args", "if", "isinstance", "(", "var", ",", "...
Turn a symbolic expression into a Python lambda function, which has the names of the variables and parameters as it's argument names. :param func: sympy expression :param args: variables and parameters in this model :return: lambda function to be used for numerical evaluation of the model.
[ "Turn", "a", "symbolic", "expression", "into", "a", "Python", "lambda", "function", "which", "has", "the", "names", "of", "the", "variables", "and", "parameters", "as", "it", "s", "argument", "names", "." ]
python
train
inveniosoftware-contrib/json-merger
json_merger/conflict.py
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/conflict.py#L95-L97
def with_prefix(self, root_path): """Returns a new conflict with a prepended prefix as a path.""" return Conflict(self.conflict_type, root_path + self.path, self.body)
[ "def", "with_prefix", "(", "self", ",", "root_path", ")", ":", "return", "Conflict", "(", "self", ".", "conflict_type", ",", "root_path", "+", "self", ".", "path", ",", "self", ".", "body", ")" ]
Returns a new conflict with a prepended prefix as a path.
[ "Returns", "a", "new", "conflict", "with", "a", "prepended", "prefix", "as", "a", "path", "." ]
python
train
AndrewIngram/django-extra-views
extra_views/formsets.py
https://github.com/AndrewIngram/django-extra-views/blob/188e1bf1f15a44d9a599028d020083af9fb43ea7/extra_views/formsets.py#L206-L219
def get_formset_kwargs(self): """ Returns the keyword arguments for instantiating the formset. """ # Perform deprecation check if hasattr(self, 'save_as_new'): klass = type(self).__name__ raise DeprecationWarning( 'Setting `{0}.save_as_new`...
[ "def", "get_formset_kwargs", "(", "self", ")", ":", "# Perform deprecation check", "if", "hasattr", "(", "self", ",", "'save_as_new'", ")", ":", "klass", "=", "type", "(", "self", ")", ".", "__name__", "raise", "DeprecationWarning", "(", "'Setting `{0}.save_as_new...
Returns the keyword arguments for instantiating the formset.
[ "Returns", "the", "keyword", "arguments", "for", "instantiating", "the", "formset", "." ]
python
valid
BD2KGenomics/protect
src/protect/pipeline/ProTECT.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/pipeline/ProTECT.py#L151-L180
def _add_default_entries(input_dict, defaults_dict): """ Add the entries in defaults dict into input_dict if they don't exist in input_dict This is based on the accepted answer at http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth :param dict input_dict...
[ "def", "_add_default_entries", "(", "input_dict", ",", "defaults_dict", ")", ":", "for", "key", ",", "value", "in", "defaults_dict", ".", "iteritems", "(", ")", ":", "if", "key", "==", "'patients'", ":", "print", "(", "'Cannot default `patients`.'", ")", "cont...
Add the entries in defaults dict into input_dict if they don't exist in input_dict This is based on the accepted answer at http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth :param dict input_dict: The dict to be updated :param dict defaults_dict: Dict cont...
[ "Add", "the", "entries", "in", "defaults", "dict", "into", "input_dict", "if", "they", "don", "t", "exist", "in", "input_dict" ]
python
train
LLNL/scraper
scraper/util.py
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/util.py#L161-L196
def compute_labor_hours(sloc, month_hours='cocomo_book'): """ Compute the labor hours, given a count of source lines of code The intention is to use the COCOMO II model to compute this value. References: - http://csse.usc.edu/tools/cocomoii.php - http://docs.python-guide.org/en/latest/scenario...
[ "def", "compute_labor_hours", "(", "sloc", ",", "month_hours", "=", "'cocomo_book'", ")", ":", "# Calculation of hours in a month", "if", "month_hours", "==", "'hours_per_year'", ":", "# Use number of working hours in a year:", "# (40 Hours / week) * (52 weeks / year) / (12 months ...
Compute the labor hours, given a count of source lines of code The intention is to use the COCOMO II model to compute this value. References: - http://csse.usc.edu/tools/cocomoii.php - http://docs.python-guide.org/en/latest/scenarios/scrape/
[ "Compute", "the", "labor", "hours", "given", "a", "count", "of", "source", "lines", "of", "code" ]
python
test
CivicSpleen/ambry
ambry/orm/database.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L470-L474
def root_dataset(self): """Return the root dataset, which hold configuration values for the library""" ds = self.dataset(ROOT_CONFIG_NAME_V) ds._database = self return ds
[ "def", "root_dataset", "(", "self", ")", ":", "ds", "=", "self", ".", "dataset", "(", "ROOT_CONFIG_NAME_V", ")", "ds", ".", "_database", "=", "self", "return", "ds" ]
Return the root dataset, which hold configuration values for the library
[ "Return", "the", "root", "dataset", "which", "hold", "configuration", "values", "for", "the", "library" ]
python
train
pvlib/pvlib-python
pvlib/spa.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/spa.py#L1263-L1294
def earthsun_distance(unixtime, delta_t, numthreads): """ Calculates the distance from the earth to the sun using the NREL SPA algorithm described in [1]. Parameters ---------- unixtime : numpy array Array of unix/epoch timestamps to calculate solar position for. Unixtime is the...
[ "def", "earthsun_distance", "(", "unixtime", ",", "delta_t", ",", "numthreads", ")", ":", "R", "=", "solar_position", "(", "unixtime", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "delta_t", ",", "0", ",", "numthreads", ",", "esd", "=", "...
Calculates the distance from the earth to the sun using the NREL SPA algorithm described in [1]. Parameters ---------- unixtime : numpy array Array of unix/epoch timestamps to calculate solar position for. Unixtime is the number of seconds since Jan. 1, 1970 00:00:00 UTC. A pand...
[ "Calculates", "the", "distance", "from", "the", "earth", "to", "the", "sun", "using", "the", "NREL", "SPA", "algorithm", "described", "in", "[", "1", "]", "." ]
python
train
PythonCharmers/python-future
src/future/backports/http/cookiejar.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/cookiejar.py#L618-L627
def eff_request_host(request): """Return a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased. """ erhn = req_host = request_host(request) if req_host.find(".") == -1 and not IPV4_RE.search(req_host): erhn = req_host + ".local" return ...
[ "def", "eff_request_host", "(", "request", ")", ":", "erhn", "=", "req_host", "=", "request_host", "(", "request", ")", "if", "req_host", ".", "find", "(", "\".\"", ")", "==", "-", "1", "and", "not", "IPV4_RE", ".", "search", "(", "req_host", ")", ":",...
Return a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased.
[ "Return", "a", "tuple", "(", "request", "-", "host", "effective", "request", "-", "host", "name", ")", "." ]
python
train
quantmind/pulsar-cloud
cloud/pusher.py
https://github.com/quantmind/pulsar-cloud/blob/dc2ff8ab5c9a1c2cfb1270581d30454d1a606cf9/cloud/pusher.py#L149-L175
def on_message(self, websocket, message): '''Handle websocket incoming messages ''' waiter = self._waiter self._waiter = None encoded = json.loads(message) event = encoded.get('event') channel = encoded.get('channel') data = json.loads(encoded.get('data'))...
[ "def", "on_message", "(", "self", ",", "websocket", ",", "message", ")", ":", "waiter", "=", "self", ".", "_waiter", "self", ".", "_waiter", "=", "None", "encoded", "=", "json", ".", "loads", "(", "message", ")", "event", "=", "encoded", ".", "get", ...
Handle websocket incoming messages
[ "Handle", "websocket", "incoming", "messages" ]
python
valid
gbowerman/azurerm
azurerm/amsrp.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L600-L629
def create_streaming_endpoint(access_token, name, description="New Streaming Endpoint", \ scale_units="1"): '''Create Media Service Streaming Endpoint. Args: access_token (str): A valid Azure authentication token. name (str): A Media Service Streaming Endpoint Name. description (str): A...
[ "def", "create_streaming_endpoint", "(", "access_token", ",", "name", ",", "description", "=", "\"New Streaming Endpoint\"", ",", "scale_units", "=", "\"1\"", ")", ":", "path", "=", "'/StreamingEndpoints'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_e...
Create Media Service Streaming Endpoint. Args: access_token (str): A valid Azure authentication token. name (str): A Media Service Streaming Endpoint Name. description (str): A Media Service Streaming Endpoint Description. scale_units (str): A Media Service Scale Units Number. ...
[ "Create", "Media", "Service", "Streaming", "Endpoint", "." ]
python
train
mitsei/dlkit
dlkit/json_/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L5183-L5206
def assign_proficiency_to_objective_bank(self, proficiency_id, objective_bank_id): """Adds an existing ``Proficiency`` to a ``ObjectiveBank``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ...
[ "def", "assign_proficiency_to_objective_bank", "(", "self", ",", "proficiency_id", ",", "objective_bank_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinAssignmentSession.assign_resource_to_bin", "mgr", "=", "self", ".", "_get_provider_manager", "(", ...
Adds an existing ``Proficiency`` to a ``ObjectiveBank``. arg: proficiency_id (osid.id.Id): the ``Id`` of the ``Proficiency`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: AlreadyExists - ``proficiency_id`` is already mappe...
[ "Adds", "an", "existing", "Proficiency", "to", "a", "ObjectiveBank", "." ]
python
train
rfk/tnetstring
tnetstring/__init__.py
https://github.com/rfk/tnetstring/blob/146381498a07d6053e044375562be08ef16017c2/tnetstring/__init__.py#L86-L171
def _rdumpq(q,size,value,encoding=None): """Dump value as a tnetstring, to a deque instance, last chunks first. This function generates the tnetstring representation of the given value, pushing chunks of the output onto the given deque instance. It pushes the last chunk first, then recursively generat...
[ "def", "_rdumpq", "(", "q", ",", "size", ",", "value", ",", "encoding", "=", "None", ")", ":", "write", "=", "q", ".", "appendleft", "if", "value", "is", "None", ":", "write", "(", "\"0:~\"", ")", "return", "size", "+", "3", "if", "value", "is", ...
Dump value as a tnetstring, to a deque instance, last chunks first. This function generates the tnetstring representation of the given value, pushing chunks of the output onto the given deque instance. It pushes the last chunk first, then recursively generates more chunks. When passed in the current ...
[ "Dump", "value", "as", "a", "tnetstring", "to", "a", "deque", "instance", "last", "chunks", "first", "." ]
python
train
ska-sa/purr
Purr/Editors.py
https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/Editors.py#L259-L328
def _makeDPItem(self, parent, dp, after=None): """Creates listview item for data product 'dp', inserts it after item 'after'""" if parent: item = QTreeWidgetItem(parent, after) else: item = QTreeWidgetItem() item.setTextAlignment(self.ColAction, Qt.AlignRight | Qt...
[ "def", "_makeDPItem", "(", "self", ",", "parent", ",", "dp", ",", "after", "=", "None", ")", ":", "if", "parent", ":", "item", "=", "QTreeWidgetItem", "(", "parent", ",", "after", ")", "else", ":", "item", "=", "QTreeWidgetItem", "(", ")", "item", "....
Creates listview item for data product 'dp', inserts it after item 'after
[ "Creates", "listview", "item", "for", "data", "product", "dp", "inserts", "it", "after", "item", "after" ]
python
train
mongodb/mongo-python-driver
pymongo/common.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/common.py#L459-L465
def validate_is_document_type(option, value): """Validate the type of method arguments that expect a MongoDB document.""" if not isinstance(value, (abc.MutableMapping, RawBSONDocument)): raise TypeError("%s must be an instance of dict, bson.son.SON, " "bson.raw_bson.RawBSONDocume...
[ "def", "validate_is_document_type", "(", "option", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "abc", ".", "MutableMapping", ",", "RawBSONDocument", ")", ")", ":", "raise", "TypeError", "(", "\"%s must be an instance of dict, bson.so...
Validate the type of method arguments that expect a MongoDB document.
[ "Validate", "the", "type", "of", "method", "arguments", "that", "expect", "a", "MongoDB", "document", "." ]
python
train
aws/aws-iot-device-sdk-python
AWSIoTPythonSDK/core/protocol/paho/client.py
https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1164-L1188
def loop_write(self, max_packets=1): """Process read network events. Use in place of calling loop() if you wish to handle your client reads as part of your own application. Use socket() to obtain the client socket to call select() or equivalent on. Use want_write() to determine...
[ "def", "loop_write", "(", "self", ",", "max_packets", "=", "1", ")", ":", "if", "self", ".", "_sock", "is", "None", "and", "self", ".", "_ssl", "is", "None", ":", "return", "MQTT_ERR_NO_CONN", "max_packets", "=", "len", "(", "self", ".", "_out_packet", ...
Process read network events. Use in place of calling loop() if you wish to handle your client reads as part of your own application. Use socket() to obtain the client socket to call select() or equivalent on. Use want_write() to determine if there is data waiting to be written. ...
[ "Process", "read", "network", "events", ".", "Use", "in", "place", "of", "calling", "loop", "()", "if", "you", "wish", "to", "handle", "your", "client", "reads", "as", "part", "of", "your", "own", "application", "." ]
python
train
CitrineInformatics/pif-dft
dfttopif/drivers.py
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L216-L233
def convert(files, **kwargs): """ Wrap directory to pif as a dice extension :param files: a list of files, which must be non-empty :param kwargs: any additional keyword arguments :return: the created pif """ if len(files) < 1: raise ValueError("Files needs to be a non-empty list") ...
[ "def", "convert", "(", "files", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "files", ")", "<", "1", ":", "raise", "ValueError", "(", "\"Files needs to be a non-empty list\"", ")", "if", "len", "(", "files", ")", "==", "1", ":", "if", "os", "...
Wrap directory to pif as a dice extension :param files: a list of files, which must be non-empty :param kwargs: any additional keyword arguments :return: the created pif
[ "Wrap", "directory", "to", "pif", "as", "a", "dice", "extension", ":", "param", "files", ":", "a", "list", "of", "files", "which", "must", "be", "non", "-", "empty", ":", "param", "kwargs", ":", "any", "additional", "keyword", "arguments", ":", "return",...
python
train
Azure/azure-storage-python
azure-storage-file/azure/storage/file/fileservice.py
https://github.com/Azure/azure-storage-python/blob/52327354b192cbcf6b7905118ec6b5d57fa46275/azure-storage-file/azure/storage/file/fileservice.py#L2336-L2391
def update_range(self, share_name, directory_name, file_name, data, start_range, end_range, validate_content=False, timeout=None): ''' Writes the bytes specified by the request body into the specified range. :param str share_name: Name of existing share...
[ "def", "update_range", "(", "self", ",", "share_name", ",", "directory_name", ",", "file_name", ",", "data", ",", "start_range", ",", "end_range", ",", "validate_content", "=", "False", ",", "timeout", "=", "None", ")", ":", "_validate_not_none", "(", "'share_...
Writes the bytes specified by the request body into the specified range. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param bytes data: ...
[ "Writes", "the", "bytes", "specified", "by", "the", "request", "body", "into", "the", "specified", "range", ".", ":", "param", "str", "share_name", ":", "Name", "of", "existing", "share", ".", ":", "param", "str", "directory_name", ":", "The", "path", "to"...
python
train
kwikteam/phy
phy/cluster/views/trace.py
https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/cluster/views/trace.py#L246-L300
def set_interval(self, interval=None, change_status=True, force_update=False): """Display the traces and spikes in a given interval.""" if interval is None: interval = self._interval interval = self._restrict_interval(interval) if not force_update and int...
[ "def", "set_interval", "(", "self", ",", "interval", "=", "None", ",", "change_status", "=", "True", ",", "force_update", "=", "False", ")", ":", "if", "interval", "is", "None", ":", "interval", "=", "self", ".", "_interval", "interval", "=", "self", "."...
Display the traces and spikes in a given interval.
[ "Display", "the", "traces", "and", "spikes", "in", "a", "given", "interval", "." ]
python
train
etal/biofrills
biofrills/pairutils.py
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/pairutils.py#L119-L124
def identity_abs(aseq, bseq): """Compute absolute identity (# matching sites) between sequence strings.""" assert len(aseq) == len(bseq) return sum(a == b for a, b in zip(aseq, bseq) if not (a in '-.' and b in '-.'))
[ "def", "identity_abs", "(", "aseq", ",", "bseq", ")", ":", "assert", "len", "(", "aseq", ")", "==", "len", "(", "bseq", ")", "return", "sum", "(", "a", "==", "b", "for", "a", ",", "b", "in", "zip", "(", "aseq", ",", "bseq", ")", "if", "not", ...
Compute absolute identity (# matching sites) between sequence strings.
[ "Compute", "absolute", "identity", "(", "#", "matching", "sites", ")", "between", "sequence", "strings", "." ]
python
train
annoviko/pyclustering
pyclustering/nnet/legion.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/legion.py#L305-L320
def __create_stimulus(self, stimulus): """! @brief Create stimulus for oscillators in line with stimulus map and parameters. @param[in] stimulus (list): Stimulus for oscillators that is represented by list, number of stimulus should be equal number of oscillators. ...
[ "def", "__create_stimulus", "(", "self", ",", "stimulus", ")", ":", "if", "(", "len", "(", "stimulus", ")", "!=", "self", ".", "_num_osc", ")", ":", "raise", "NameError", "(", "\"Number of stimulus should be equal number of oscillators in the network.\"", ")", "else...
! @brief Create stimulus for oscillators in line with stimulus map and parameters. @param[in] stimulus (list): Stimulus for oscillators that is represented by list, number of stimulus should be equal number of oscillators.
[ "!" ]
python
valid
readbeyond/aeneas
aeneas/audiofile.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L466-L499
def preallocate_memory(self, capacity): """ Preallocate memory to store audio samples, to avoid repeated new allocations and copies while performing several consecutive append operations. If ``self.__samples`` is not initialized, it will become an array of ``capacity`` z...
[ "def", "preallocate_memory", "(", "self", ",", "capacity", ")", ":", "if", "capacity", "<", "0", ":", "raise", "ValueError", "(", "u\"The capacity value cannot be negative\"", ")", "if", "self", ".", "__samples", "is", "None", ":", "self", ".", "log", "(", "...
Preallocate memory to store audio samples, to avoid repeated new allocations and copies while performing several consecutive append operations. If ``self.__samples`` is not initialized, it will become an array of ``capacity`` zeros. If ``capacity`` is larger than the current ca...
[ "Preallocate", "memory", "to", "store", "audio", "samples", "to", "avoid", "repeated", "new", "allocations", "and", "copies", "while", "performing", "several", "consecutive", "append", "operations", "." ]
python
train