repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
csparpa/pyowm
pyowm/weatherapi25/forecast.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/forecast.py#L206-L223
def _to_DOM(self): """ Dumps object data to a fully traversable DOM representation of the object. :returns: a ``xml.etree.Element`` object """ root_node = ET.Element("forecast") interval_node = ET.SubElement(root_node, "interval") interval_node.text = se...
[ "def", "_to_DOM", "(", "self", ")", ":", "root_node", "=", "ET", ".", "Element", "(", "\"forecast\"", ")", "interval_node", "=", "ET", ".", "SubElement", "(", "root_node", ",", "\"interval\"", ")", "interval_node", ".", "text", "=", "self", ".", "_interval...
Dumps object data to a fully traversable DOM representation of the object. :returns: a ``xml.etree.Element`` object
[ "Dumps", "object", "data", "to", "a", "fully", "traversable", "DOM", "representation", "of", "the", "object", "." ]
python
train
37.055556
FujiMakoto/AgentML
agentml/parser/tags/condition.py
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/tags/condition.py#L37-L41
def value(self): """ Return the current evaluation of a condition statement """ return ''.join(map(str, self.evaluate(self.trigger.user)))
[ "def", "value", "(", "self", ")", ":", "return", "''", ".", "join", "(", "map", "(", "str", ",", "self", ".", "evaluate", "(", "self", ".", "trigger", ".", "user", ")", ")", ")" ]
Return the current evaluation of a condition statement
[ "Return", "the", "current", "evaluation", "of", "a", "condition", "statement" ]
python
train
33.2
eaton-lab/toytree
toytree/etemini.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1942-L1964
def get_monophyletic(self, values, target_attr): """ Returns a list of nodes matching the provided monophyly criteria. For a node to be considered a match, all `target_attr` values within and node, and exclusively them, should be grouped. :param values: a set of values f...
[ "def", "get_monophyletic", "(", "self", ",", "values", ",", "target_attr", ")", ":", "if", "type", "(", "values", ")", "!=", "set", ":", "values", "=", "set", "(", "values", ")", "n2values", "=", "self", ".", "get_cached_content", "(", "store_attr", "=",...
Returns a list of nodes matching the provided monophyly criteria. For a node to be considered a match, all `target_attr` values within and node, and exclusively them, should be grouped. :param values: a set of values for which monophyly is expected. :param target_at...
[ "Returns", "a", "list", "of", "nodes", "matching", "the", "provided", "monophyly", "criteria", ".", "For", "a", "node", "to", "be", "considered", "a", "match", "all", "target_attr", "values", "within", "and", "node", "and", "exclusively", "them", "should", "...
python
train
36.782609
insightindustry/validator-collection
validator_collection/checkers.py
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L927-L960
def is_fraction(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater tha...
[ "def", "is_fraction", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "fraction", "(", "value", ",", "minimum", "=", "minimum", ",", "maximum", "=...
Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. :type minimum: numeric :param maximum: If supplied, will make sure that ``value`...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "Fraction", "<python", ":", "fractions", ".", "Fraction", ">", "." ]
python
train
31.529412
chuck1/codemach
codemach/machine.py
https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L433-L464
def call_function(self, c, i): """ Implement the CALL_FUNCTION_ operation. .. _CALL_FUNCTION: https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION """ callable_ = self.__stack[-1-i.arg] args = tuple(self.__stack[len(self.__stack) - i.arg:]) ...
[ "def", "call_function", "(", "self", ",", "c", ",", "i", ")", ":", "callable_", "=", "self", ".", "__stack", "[", "-", "1", "-", "i", ".", "arg", "]", "args", "=", "tuple", "(", "self", ".", "__stack", "[", "len", "(", "self", ".", "__stack", "...
Implement the CALL_FUNCTION_ operation. .. _CALL_FUNCTION: https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION
[ "Implement", "the", "CALL_FUNCTION_", "operation", "." ]
python
test
28.4375
theislab/scanpy
scanpy/tools/_rank_genes_groups.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/tools/_rank_genes_groups.py#L425-L532
def filter_rank_genes_groups(adata, key=None, groupby=None, use_raw=True, log=True, key_added='rank_genes_groups_filtered', min_in_group_fraction=0.25, min_fold_change=2, max_out_group_fraction=0.5): """Filters out genes based on...
[ "def", "filter_rank_genes_groups", "(", "adata", ",", "key", "=", "None", ",", "groupby", "=", "None", ",", "use_raw", "=", "True", ",", "log", "=", "True", ",", "key_added", "=", "'rank_genes_groups_filtered'", ",", "min_in_group_fraction", "=", "0.25", ",", ...
Filters out genes based on fold change and fraction of genes expressing the gene within and outside the `groupby` categories. See :func:`~scanpy.tl.rank_genes_groups`. Results are stored in `adata.uns[key_added]` (default: 'rank_genes_groups_filtered'). To preserve the original structure of adata.uns['ra...
[ "Filters", "out", "genes", "based", "on", "fold", "change", "and", "fraction", "of", "genes", "expressing", "the", "gene", "within", "and", "outside", "the", "groupby", "categories", "." ]
python
train
46.277778
honzajavorek/redis-collections
redis_collections/sets.py
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L78-L83
def add(self, value): """Add element *value* to the set.""" # Raise TypeError if value is not hashable hash(value) self.redis.sadd(self.key, self._pickle(value))
[ "def", "add", "(", "self", ",", "value", ")", ":", "# Raise TypeError if value is not hashable", "hash", "(", "value", ")", "self", ".", "redis", ".", "sadd", "(", "self", ".", "key", ",", "self", ".", "_pickle", "(", "value", ")", ")" ]
Add element *value* to the set.
[ "Add", "element", "*", "value", "*", "to", "the", "set", "." ]
python
train
31.5
soravux/scoop
scoop/launch/workerLaunch.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L61-L74
def setWorker(self, *args, **kwargs): """Add a worker assignation Arguments and order to pass are defined in LAUNCHING_ARGUMENTS Using named args is advised. """ try: la = self.LAUNCHING_ARGUMENTS(*args, **kwargs) except TypeError as e: sco...
[ "def", "setWorker", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "la", "=", "self", ".", "LAUNCHING_ARGUMENTS", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "TypeError", "as", "e", ":", "scoop", ".", ...
Add a worker assignation Arguments and order to pass are defined in LAUNCHING_ARGUMENTS Using named args is advised.
[ "Add", "a", "worker", "assignation", "Arguments", "and", "order", "to", "pass", "are", "defined", "in", "LAUNCHING_ARGUMENTS", "Using", "named", "args", "is", "advised", "." ]
python
train
45.642857
neuropsychology/NeuroKit.py
neurokit/bio/bio_emg.py
https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/neurokit/bio/bio_emg.py#L185-L234
def emg_linear_envelope(emg, sampling_rate=1000, freqs=[10, 400], lfreq=4): r"""Calculate the linear envelope of a signal. Parameters ---------- emg : array raw EMG signal. sampling_rate : int Sampling rate (samples/second). freqs : list [fc_h, fc_l], optional cutoff...
[ "def", "emg_linear_envelope", "(", "emg", ",", "sampling_rate", "=", "1000", ",", "freqs", "=", "[", "10", ",", "400", "]", ",", "lfreq", "=", "4", ")", ":", "emg", "=", "emg_tkeo", "(", "emg", ")", "if", "np", ".", "size", "(", "freqs", ")", "==...
r"""Calculate the linear envelope of a signal. Parameters ---------- emg : array raw EMG signal. sampling_rate : int Sampling rate (samples/second). freqs : list [fc_h, fc_l], optional cutoff frequencies for the band-pass filter (in Hz). lfreq : number, optional ...
[ "r", "Calculate", "the", "linear", "envelope", "of", "a", "signal", "." ]
python
train
24.8
ashmastaflash/kal-wrapper
kalibrate/fn.py
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L103-L118
def extract_value_from_output(canary, split_offset, kal_out): """Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal. """ retval = "" while re...
[ "def", "extract_value_from_output", "(", "canary", ",", "split_offset", ",", "kal_out", ")", ":", "retval", "=", "\"\"", "while", "retval", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "canary", "in", "line", ...
Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal.
[ "Return", "value", "parsed", "from", "output", "." ]
python
train
32.1875
spdx/tools-python
spdx/parsers/rdfbuilders.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/rdfbuilders.py#L140-L149
def set_chksum(self, doc, chk_sum): """ Sets the external document reference's check sum, if not already set. chk_sum - The checksum value in the form of a string. """ if chk_sum: doc.ext_document_references[-1].check_sum = checksum.Algorithm( 'SHA1', ...
[ "def", "set_chksum", "(", "self", ",", "doc", ",", "chk_sum", ")", ":", "if", "chk_sum", ":", "doc", ".", "ext_document_references", "[", "-", "1", "]", ".", "check_sum", "=", "checksum", ".", "Algorithm", "(", "'SHA1'", ",", "chk_sum", ")", "else", ":...
Sets the external document reference's check sum, if not already set. chk_sum - The checksum value in the form of a string.
[ "Sets", "the", "external", "document", "reference", "s", "check", "sum", "if", "not", "already", "set", ".", "chk_sum", "-", "The", "checksum", "value", "in", "the", "form", "of", "a", "string", "." ]
python
valid
39.9
bcbio/bcbio-nextgen
bcbio/variation/varscan.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/varscan.py#L167-L271
def fix_varscan_output(line, normal_name="", tumor_name=""): """Fix a varscan VCF line. Fixes the ALT column and also fixes floating point values output as strings to by Floats: FREQ, SSC. This function was contributed by Sean Davis <sdavis2@mail.nih.gov>, with minor modifications by Luca Beltrame...
[ "def", "fix_varscan_output", "(", "line", ",", "normal_name", "=", "\"\"", ",", "tumor_name", "=", "\"\"", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "tofix", "=", "(", "\"##INFO=<ID=SSC\"", ",", "\"##FORMAT=<ID=FREQ\"", ")", "if", "(", "line",...
Fix a varscan VCF line. Fixes the ALT column and also fixes floating point values output as strings to by Floats: FREQ, SSC. This function was contributed by Sean Davis <sdavis2@mail.nih.gov>, with minor modifications by Luca Beltrame <luca.beltrame@marionegri.it>.
[ "Fix", "a", "varscan", "VCF", "line", "." ]
python
train
33.571429
Yelp/threat_intel
threat_intel/util/http.py
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L382-L397
def _convert_to_json(self, response): """Converts response to JSON. If the response cannot be converted to JSON then `None` is returned. Args: response - An object of type `requests.models.Response` Returns: Response in JSON format if the response can be converte...
[ "def", "_convert_to_json", "(", "self", ",", "response", ")", ":", "try", ":", "return", "response", ".", "json", "(", ")", "except", "ValueError", ":", "logging", ".", "warning", "(", "'Expected response in JSON format from {0} but the actual response text is: {1}'", ...
Converts response to JSON. If the response cannot be converted to JSON then `None` is returned. Args: response - An object of type `requests.models.Response` Returns: Response in JSON format if the response can be converted to JSON. `None` otherwise.
[ "Converts", "response", "to", "JSON", ".", "If", "the", "response", "cannot", "be", "converted", "to", "JSON", "then", "None", "is", "returned", "." ]
python
train
39.0625
log2timeline/dfvfs
dfvfs/vfs/cpio_file_entry.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/cpio_file_entry.py#L118-L138
def _GetLink(self): """Retrieves the link. Returns: str: full path of the linked file entry. """ if self._link is None: self._link = '' if self.entry_type != definitions.FILE_ENTRY_TYPE_LINK: return self._link cpio_archive_file = self._file_system.GetCPIOArchiveFile() ...
[ "def", "_GetLink", "(", "self", ")", ":", "if", "self", ".", "_link", "is", "None", ":", "self", ".", "_link", "=", "''", "if", "self", ".", "entry_type", "!=", "definitions", ".", "FILE_ENTRY_TYPE_LINK", ":", "return", "self", ".", "_link", "cpio_archiv...
Retrieves the link. Returns: str: full path of the linked file entry.
[ "Retrieves", "the", "link", "." ]
python
train
26.761905
BlueHack-Core/blueforge
blueforge/util/trans.py
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/util/trans.py#L6-L14
def download_file(save_path, file_url): """ Download file from http url link """ r = requests.get(file_url) # create HTTP response object with open(save_path, 'wb') as f: f.write(r.content) return save_path
[ "def", "download_file", "(", "save_path", ",", "file_url", ")", ":", "r", "=", "requests", ".", "get", "(", "file_url", ")", "# create HTTP response object", "with", "open", "(", "save_path", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "r",...
Download file from http url link
[ "Download", "file", "from", "http", "url", "link" ]
python
train
25.111111
yakupadakli/python-unsplash
unsplash/auth.py
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/auth.py#L83-L88
def refresh_token(self): """ Refreshing the current expired access token """ self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token()) self.access_token = self.token.get("access_token")
[ "def", "refresh_token", "(", "self", ")", ":", "self", ".", "token", "=", "self", ".", "oauth", ".", "refresh_token", "(", "self", ".", "access_token_url", ",", "refresh_token", "=", "self", ".", "get_refresh_token", "(", ")", ")", "self", ".", "access_tok...
Refreshing the current expired access token
[ "Refreshing", "the", "current", "expired", "access", "token" ]
python
train
43.833333
crunchyroll/ef-open
efopen/ef_cf_diff.py
https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L61-L78
def render_local_template(service_name, environment, repo_root, template_file): """ Render a given service's template for a given environment and return it """ cmd = 'cd {} && ef-cf {} {} --devel --verbose'.format(repo_root, template_file, environment) p = subprocess.Popen(cmd, shell=True, stdout=su...
[ "def", "render_local_template", "(", "service_name", ",", "environment", ",", "repo_root", ",", "template_file", ")", ":", "cmd", "=", "'cd {} && ef-cf {} {} --devel --verbose'", ".", "format", "(", "repo_root", ",", "template_file", ",", "environment", ")", "p", "=...
Render a given service's template for a given environment and return it
[ "Render", "a", "given", "service", "s", "template", "for", "a", "given", "environment", "and", "return", "it" ]
python
train
46.666667
fake-name/ChromeController
ChromeController/manager.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/manager.py#L165-L236
def get_cookies(self): ''' Retreive the cookies from the remote browser. Return value is a list of http.cookiejar.Cookie() instances. These can be directly used with the various http.cookiejar.XXXCookieJar cookie management classes. ''' ret = self.Network_getAllCookies() assert 'result' in ret, "No re...
[ "def", "get_cookies", "(", "self", ")", ":", "ret", "=", "self", ".", "Network_getAllCookies", "(", ")", "assert", "'result'", "in", "ret", ",", "\"No return value in function response!\"", "assert", "'cookies'", "in", "ret", "[", "'result'", "]", ",", "\"No 'co...
Retreive the cookies from the remote browser. Return value is a list of http.cookiejar.Cookie() instances. These can be directly used with the various http.cookiejar.XXXCookieJar cookie management classes.
[ "Retreive", "the", "cookies", "from", "the", "remote", "browser", "." ]
python
train
32.319444
ga4gh/ga4gh-server
oidc-provider/simple_op/src/provider/server/server.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L129-L137
def _webfinger(provider, request, **kwargs): """Handle webfinger requests.""" params = urlparse.parse_qs(request) if params["rel"][0] == OIC_ISSUER: wf = WebFinger() return Response(wf.response(params["resource"][0], provider.baseurl), headers=[("Content-Type", "appli...
[ "def", "_webfinger", "(", "provider", ",", "request", ",", "*", "*", "kwargs", ")", ":", "params", "=", "urlparse", ".", "parse_qs", "(", "request", ")", "if", "params", "[", "\"rel\"", "]", "[", "0", "]", "==", "OIC_ISSUER", ":", "wf", "=", "WebFing...
Handle webfinger requests.
[ "Handle", "webfinger", "requests", "." ]
python
train
43.444444
casacore/python-casacore
casacore/images/image.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/images/image.py#L492-L519
def tofits(self, filename, overwrite=True, velocity=True, optical=True, bitpix=-32, minpix=1, maxpix=-1): """Write the image to a file in FITS format. `filename` FITS file name `overwrite` If False, an exception is raised if the new image file already exists. ...
[ "def", "tofits", "(", "self", ",", "filename", ",", "overwrite", "=", "True", ",", "velocity", "=", "True", ",", "optical", "=", "True", ",", "bitpix", "=", "-", "32", ",", "minpix", "=", "1", ",", "maxpix", "=", "-", "1", ")", ":", "return", "se...
Write the image to a file in FITS format. `filename` FITS file name `overwrite` If False, an exception is raised if the new image file already exists. Default is True. `velocity` By default a velocity primary spectral axis is written if possible. ...
[ "Write", "the", "image", "to", "a", "file", "in", "FITS", "format", "." ]
python
train
46.035714
datastax/python-driver
cassandra/connection.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/connection.py#L667-L674
def register_watcher(self, event_type, callback, register_timeout=None): """ Register a callback for a given event type. """ self._push_watchers[event_type].add(callback) self.wait_for_response( RegisterMessage(event_list=[event_type]), timeout=register_ti...
[ "def", "register_watcher", "(", "self", ",", "event_type", ",", "callback", ",", "register_timeout", "=", "None", ")", ":", "self", ".", "_push_watchers", "[", "event_type", "]", ".", "add", "(", "callback", ")", "self", ".", "wait_for_response", "(", "Regis...
Register a callback for a given event type.
[ "Register", "a", "callback", "for", "a", "given", "event", "type", "." ]
python
train
39.875
MatterMiners/cobald
cobald/daemon/runners/trio_runner.py
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/trio_runner.py#L40-L46
async def _start_payloads(self, nursery): """Start all queued payloads""" with self._lock: for coroutine in self._payloads: nursery.start_soon(coroutine) self._payloads.clear() await trio.sleep(0)
[ "async", "def", "_start_payloads", "(", "self", ",", "nursery", ")", ":", "with", "self", ".", "_lock", ":", "for", "coroutine", "in", "self", ".", "_payloads", ":", "nursery", ".", "start_soon", "(", "coroutine", ")", "self", ".", "_payloads", ".", "cle...
Start all queued payloads
[ "Start", "all", "queued", "payloads" ]
python
train
36.285714
inveniosoftware/invenio-migrator
invenio_migrator/legacy/users.py
https://github.com/inveniosoftware/invenio-migrator/blob/6902c6968a39b747d15e32363f43b7dffe2622c2/invenio_migrator/legacy/users.py#L73-L91
def dump(u, *args, **kwargs): """Dump the users as a list of dictionaries. :param u: User to be dumped. :type u: `invenio.modules.accounts.models.User [Invenio2.x]` or namedtuple. :returns: User serialized to dictionary. :rtype: dict """ return dict( id=u.id, email=u.email, ...
[ "def", "dump", "(", "u", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "dict", "(", "id", "=", "u", ".", "id", ",", "email", "=", "u", ".", "email", ",", "password", "=", "u", ".", "password", ",", "password_salt", "=", "u", ...
Dump the users as a list of dictionaries. :param u: User to be dumped. :type u: `invenio.modules.accounts.models.User [Invenio2.x]` or namedtuple. :returns: User serialized to dictionary. :rtype: dict
[ "Dump", "the", "users", "as", "a", "list", "of", "dictionaries", "." ]
python
test
32.684211
ihabunek/toot
toot/utils.py
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/utils.py#L32-L42
def parse_html(html): """Attempt to convert html to plain text while keeping line breaks. Returns a list of paragraphs, each being a list of lines. """ paragraphs = re.split("</?p[^>]*>", html) # Convert <br>s to line breaks and remove empty paragraphs paragraphs = [re.split("<br */?>", p) for ...
[ "def", "parse_html", "(", "html", ")", ":", "paragraphs", "=", "re", ".", "split", "(", "\"</?p[^>]*>\"", ",", "html", ")", "# Convert <br>s to line breaks and remove empty paragraphs", "paragraphs", "=", "[", "re", ".", "split", "(", "\"<br */?>\"", ",", "p", "...
Attempt to convert html to plain text while keeping line breaks. Returns a list of paragraphs, each being a list of lines.
[ "Attempt", "to", "convert", "html", "to", "plain", "text", "while", "keeping", "line", "breaks", ".", "Returns", "a", "list", "of", "paragraphs", "each", "being", "a", "list", "of", "lines", "." ]
python
train
40.636364
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1177-L1221
def cwt_coefficients(x, param): """ Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the "Mexican hat wavelet" which is defined by .. math:: \\frac{2}{\\sqrt{3a} \\pi^{\\frac{1}{4}}} (1 - \\frac{x^2}{a^2}) exp(-\\frac{x^2}{2a^2}) where :math:`a` is the width ...
[ "def", "cwt_coefficients", "(", "x", ",", "param", ")", ":", "calculated_cwt", "=", "{", "}", "res", "=", "[", "]", "indices", "=", "[", "]", "for", "parameter_combination", "in", "param", ":", "widths", "=", "parameter_combination", "[", "\"widths\"", "]"...
Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the "Mexican hat wavelet" which is defined by .. math:: \\frac{2}{\\sqrt{3a} \\pi^{\\frac{1}{4}}} (1 - \\frac{x^2}{a^2}) exp(-\\frac{x^2}{2a^2}) where :math:`a` is the width parameter of the wavelet function. This...
[ "Calculates", "a", "Continuous", "wavelet", "transform", "for", "the", "Ricker", "wavelet", "also", "known", "as", "the", "Mexican", "hat", "wavelet", "which", "is", "defined", "by" ]
python
train
36.4
Cymmetria/honeycomb
honeycomb/cli.py
https://github.com/Cymmetria/honeycomb/blob/33ea91b5cf675000e4e85dd02efe580ea6e95c86/honeycomb/cli.py#L72-L88
def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None): """Override default logger to allow overriding of internal attributes.""" # See below commented section for a simple example of what the docstring refers to if six.PY2: rv = logging.Lo...
[ "def", "makeRecord", "(", "self", ",", "name", ",", "level", ",", "fn", ",", "lno", ",", "msg", ",", "args", ",", "exc_info", ",", "func", "=", "None", ",", "extra", "=", "None", ",", "sinfo", "=", "None", ")", ":", "# See below commented section for a...
Override default logger to allow overriding of internal attributes.
[ "Override", "default", "logger", "to", "allow", "overriding", "of", "internal", "attributes", "." ]
python
train
50.823529
frnsys/broca
broca/vectorize/dcs.py
https://github.com/frnsys/broca/blob/7236dcf54edc0a4a54a55eb93be30800910667e7/broca/vectorize/dcs.py#L133-L176
def _disambiguate_pos(self, terms, pos): """ Disambiguates a list of tokens of a given PoS. """ # Map the terms to candidate concepts # Consider only the top 3 most common senses candidate_map = {term: wn.synsets(term, pos=pos)[:3] for term in terms} # Filter to ...
[ "def", "_disambiguate_pos", "(", "self", ",", "terms", ",", "pos", ")", ":", "# Map the terms to candidate concepts", "# Consider only the top 3 most common senses", "candidate_map", "=", "{", "term", ":", "wn", ".", "synsets", "(", "term", ",", "pos", "=", "pos", ...
Disambiguates a list of tokens of a given PoS.
[ "Disambiguates", "a", "list", "of", "tokens", "of", "a", "given", "PoS", "." ]
python
train
38.840909
inveniosoftware/invenio-pidstore
invenio_pidstore/providers/datacite.py
https://github.com/inveniosoftware/invenio-pidstore/blob/8bf35f4e62d5dcaf1a2cfe5803245ba5220a9b78/invenio_pidstore/providers/datacite.py#L35-L49
def create(cls, pid_value, **kwargs): """Create a new record identifier. For more information about parameters, see :meth:`invenio_pidstore.providers.BaseProvider.create`. :param pid_value: Persistent identifier value. :params **kwargs: See :meth:`invenio_pidstore.p...
[ "def", "create", "(", "cls", ",", "pid_value", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "DataCiteProvider", ",", "cls", ")", ".", "create", "(", "pid_value", "=", "pid_value", ",", "*", "*", "kwargs", ")" ]
Create a new record identifier. For more information about parameters, see :meth:`invenio_pidstore.providers.BaseProvider.create`. :param pid_value: Persistent identifier value. :params **kwargs: See :meth:`invenio_pidstore.providers.base.BaseProvider.create` extra ...
[ "Create", "a", "new", "record", "identifier", "." ]
python
train
38.133333
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L2406-L2419
def disable_svc_freshness_check(self, service): """Disable freshness check for a service Format of the line that triggers function call:: DISABLE_SERVICE_FRESHNESS_CHECK;<host_name>;<service_description> :param service: service to edit :type service: alignak.objects.service.Ser...
[ "def", "disable_svc_freshness_check", "(", "self", ",", "service", ")", ":", "if", "service", ".", "check_freshness", ":", "service", ".", "modified_attributes", "|=", "DICT_MODATTR", "[", "\"MODATTR_FRESHNESS_CHECKS_ENABLED\"", "]", ".", "value", "service", ".", "c...
Disable freshness check for a service Format of the line that triggers function call:: DISABLE_SERVICE_FRESHNESS_CHECK;<host_name>;<service_description> :param service: service to edit :type service: alignak.objects.service.Service :return: None
[ "Disable", "freshness", "check", "for", "a", "service", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
42.142857
saltstack/salt
salt/modules/tomcat.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L268-L280
def _simple_cmd(cmd, app, url='http://localhost:8080/manager', timeout=180): ''' Simple command wrapper to commands that need only a path option ''' try: opts = { 'path': app, 'version': ls(url)[app]['version'] } return '\n'.join(_wget(cmd, opts, url, tim...
[ "def", "_simple_cmd", "(", "cmd", ",", "app", ",", "url", "=", "'http://localhost:8080/manager'", ",", "timeout", "=", "180", ")", ":", "try", ":", "opts", "=", "{", "'path'", ":", "app", ",", "'version'", ":", "ls", "(", "url", ")", "[", "app", "]",...
Simple command wrapper to commands that need only a path option
[ "Simple", "command", "wrapper", "to", "commands", "that", "need", "only", "a", "path", "option" ]
python
train
32.153846
roaet/wafflehaus.neutron
wafflehaus/neutron/last_ip_check/last_ip_check.py
https://github.com/roaet/wafflehaus.neutron/blob/01f6d69ae759ec2f24f2f7cf9dcfa4a4734f7e1c/wafflehaus/neutron/last_ip_check/last_ip_check.py#L135-L142
def filter_factory(global_conf, **local_conf): """Returns a WSGI filter app for use with paste.deploy.""" conf = global_conf.copy() conf.update(local_conf) def check_last_ip(app): return LastIpCheck(app, conf) return check_last_ip
[ "def", "filter_factory", "(", "global_conf", ",", "*", "*", "local_conf", ")", ":", "conf", "=", "global_conf", ".", "copy", "(", ")", "conf", ".", "update", "(", "local_conf", ")", "def", "check_last_ip", "(", "app", ")", ":", "return", "LastIpCheck", "...
Returns a WSGI filter app for use with paste.deploy.
[ "Returns", "a", "WSGI", "filter", "app", "for", "use", "with", "paste", ".", "deploy", "." ]
python
train
31.5
cloudmesh/cloudmesh-common
cloudmesh/common/BaseConfigDict.py
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/BaseConfigDict.py#L449-L477
def set(self, value, *keys): """ Sets the dict of the information as read from the yaml file. To access the file safely, you can use the keys in the order of the access. Example: set("{'project':{'fg82':[i0-i10]}}", "provisioner","policy") will set the value of config["provisione...
[ "def", "set", "(", "self", ",", "value", ",", "*", "keys", ")", ":", "element", "=", "self", "if", "keys", "is", "None", ":", "return", "self", "if", "'.'", "in", "keys", "[", "0", "]", ":", "keys", "=", "keys", "[", "0", "]", ".", "split", "...
Sets the dict of the information as read from the yaml file. To access the file safely, you can use the keys in the order of the access. Example: set("{'project':{'fg82':[i0-i10]}}", "provisioner","policy") will set the value of config["provisioner"]["policy"] in the yaml file if it does...
[ "Sets", "the", "dict", "of", "the", "information", "as", "read", "from", "the", "yaml", "file", ".", "To", "access", "the", "file", "safely", "you", "can", "use", "the", "keys", "in", "the", "order", "of", "the", "access", ".", "Example", ":", "set", ...
python
train
42.034483
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L962-L990
def update_status(self, progress): """ waits for a signal emitted from a thread and updates the gui Args: progress: Returns: """ # interval at which the gui will be updated, if requests come in faster than they will be ignored update_interval = 0.2 ...
[ "def", "update_status", "(", "self", ",", "progress", ")", ":", "# interval at which the gui will be updated, if requests come in faster than they will be ignored", "update_interval", "=", "0.2", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "not", ...
waits for a signal emitted from a thread and updates the gui Args: progress: Returns:
[ "waits", "for", "a", "signal", "emitted", "from", "a", "thread", "and", "updates", "the", "gui", "Args", ":", "progress", ":", "Returns", ":" ]
python
train
35.517241
Kozea/pygal
pygal/svg.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/svg.py#L470-L493
def render(self, is_unicode=False, pretty_print=False): """Last thing to do before rendering""" for f in self.graph.xml_filters: self.root = f(self.root) args = {'encoding': 'utf-8'} svg = b'' if etree.lxml: args['pretty_print'] = pretty_print if...
[ "def", "render", "(", "self", ",", "is_unicode", "=", "False", ",", "pretty_print", "=", "False", ")", ":", "for", "f", "in", "self", ".", "graph", ".", "xml_filters", ":", "self", ".", "root", "=", "f", "(", "self", ".", "root", ")", "args", "=", ...
Last thing to do before rendering
[ "Last", "thing", "to", "do", "before", "rendering" ]
python
train
31.875
inveniosoftware/invenio-migrator
invenio_migrator/legacy/cli.py
https://github.com/inveniosoftware/invenio-migrator/blob/6902c6968a39b747d15e32363f43b7dffe2622c2/invenio_migrator/legacy/cli.py#L57-L97
def dump(thing, query, from_date, file_prefix, chunk_size, limit, thing_flags): """Dump data from Invenio legacy.""" init_app_context() file_prefix = file_prefix if file_prefix else '{0}_dump'.format(thing) kwargs = dict((f.strip('-').replace('-', '_'), True) for f in thing_flags) try: th...
[ "def", "dump", "(", "thing", ",", "query", ",", "from_date", ",", "file_prefix", ",", "chunk_size", ",", "limit", ",", "thing_flags", ")", ":", "init_app_context", "(", ")", "file_prefix", "=", "file_prefix", "if", "file_prefix", "else", "'{0}_dump'", ".", "...
Dump data from Invenio legacy.
[ "Dump", "data", "from", "Invenio", "legacy", "." ]
python
test
39.536585
foremast/foremast
src/foremast/awslambda/cloudwatch_log_event/cloudwatch_log_event.py
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/cloudwatch_log_event/cloudwatch_log_event.py#L28-L75
def create_cloudwatch_log_event(app_name, env, region, rules): """Create cloudwatch log event for lambda from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): ...
[ "def", "create_cloudwatch_log_event", "(", "app_name", ",", "env", ",", "region", ",", "rules", ")", ":", "session", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ",", "region_name", "=", "region", ")", "cloudwatch_client", "=", "session", "...
Create cloudwatch log event for lambda from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): Trigger rules from the settings
[ "Create", "cloudwatch", "log", "event", "for", "lambda", "from", "rules", "." ]
python
train
42.583333
auth0/auth0-python
auth0/v3/management/guardian.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L36-L46
def update_factor(self, name, body): """Update Guardian factor Useful to enable / disable factor Args: name (str): Either push-notification or sms body (dict): Attributes to modify. See: https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name ...
[ "def", "update_factor", "(", "self", ",", "name", ",", "body", ")", ":", "url", "=", "self", ".", "_url", "(", "'factors/{}'", ".", "format", "(", "name", ")", ")", "return", "self", ".", "client", ".", "put", "(", "url", ",", "data", "=", "body", ...
Update Guardian factor Useful to enable / disable factor Args: name (str): Either push-notification or sms body (dict): Attributes to modify. See: https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name
[ "Update", "Guardian", "factor", "Useful", "to", "enable", "/", "disable", "factor" ]
python
train
38.090909
Erotemic/utool
utool/util_hash.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_hash.py#L65-L95
def make_hash(o): r""" Makes a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types (including any lists, tuples, sets, and dictionaries). In the case where other kinds of objects (like classes) need to be hashed, pass in a collection of object attributes ...
[ "def", "make_hash", "(", "o", ")", ":", "if", "type", "(", "o", ")", "==", "DictProxyType", ":", "o2", "=", "{", "}", "for", "k", ",", "v", "in", "o", ".", "items", "(", ")", ":", "if", "not", "k", ".", "startswith", "(", "\"__\"", ")", ":", ...
r""" Makes a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types (including any lists, tuples, sets, and dictionaries). In the case where other kinds of objects (like classes) need to be hashed, pass in a collection of object attributes that are pertinent. ...
[ "r", "Makes", "a", "hash", "from", "a", "dictionary", "list", "tuple", "or", "set", "to", "any", "level", "that", "contains", "only", "other", "hashable", "types", "(", "including", "any", "lists", "tuples", "sets", "and", "dictionaries", ")", ".", "In", ...
python
train
34.064516
profitbricks/profitbricks-sdk-python
profitbricks/client.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/profitbricks/client.py#L917-L935
def create_loadbalancer(self, datacenter_id, loadbalancer): """ Creates a load balancer within the specified data center. :param datacenter_id: The unique ID of the data center. :type datacenter_id: ``str`` :param loadbalancer: The load balancer object to be cre...
[ "def", "create_loadbalancer", "(", "self", ",", "datacenter_id", ",", "loadbalancer", ")", ":", "data", "=", "json", ".", "dumps", "(", "self", ".", "_create_loadbalancer_dict", "(", "loadbalancer", ")", ")", "response", "=", "self", ".", "_perform_request", "...
Creates a load balancer within the specified data center. :param datacenter_id: The unique ID of the data center. :type datacenter_id: ``str`` :param loadbalancer: The load balancer object to be created. :type loadbalancer: ``dict``
[ "Creates", "a", "load", "balancer", "within", "the", "specified", "data", "center", "." ]
python
valid
32.526316
pyca/pynacl
src/nacl/hash.py
https://github.com/pyca/pynacl/blob/0df0c2c7693fa5d316846111ce510702756f5feb/src/nacl/hash.py#L144-L160
def siphashx24(message, key=b'', encoder=nacl.encoding.HexEncoder): """ Computes a keyed MAC of ``message`` using the 128 bit variant of the siphash-2-4 construction. :param message: The message to hash. :type message: bytes :param key: the message authentication key for the siphash MAC constru...
[ "def", "siphashx24", "(", "message", ",", "key", "=", "b''", ",", "encoder", "=", "nacl", ".", "encoding", ".", "HexEncoder", ")", ":", "digest", "=", "_sip_hashx", "(", "message", ",", "key", ")", "return", "encoder", ".", "encode", "(", "digest", ")"...
Computes a keyed MAC of ``message`` using the 128 bit variant of the siphash-2-4 construction. :param message: The message to hash. :type message: bytes :param key: the message authentication key for the siphash MAC construct :type key: bytes(:const:`SIPHASHX_KEYBYTES`) :param encoder: A class ...
[ "Computes", "a", "keyed", "MAC", "of", "message", "using", "the", "128", "bit", "variant", "of", "the", "siphash", "-", "2", "-", "4", "construction", "." ]
python
train
35.882353
pescadores/pescador
examples/frameworks/keras_example.py
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/examples/frameworks/keras_example.py#L155-L178
def additive_noise(stream, key='X', scale=1e-1): '''Add noise to a data stream. Parameters ---------- stream : iterable A stream that yields data objects. key : string, default='X' Name of the field to add noise. scale : float, default=0.1 Scale factor for gaussian noi...
[ "def", "additive_noise", "(", "stream", ",", "key", "=", "'X'", ",", "scale", "=", "1e-1", ")", ":", "for", "data", "in", "stream", ":", "noise_shape", "=", "data", "[", "key", "]", ".", "shape", "noise", "=", "scale", "*", "np", ".", "random", "."...
Add noise to a data stream. Parameters ---------- stream : iterable A stream that yields data objects. key : string, default='X' Name of the field to add noise. scale : float, default=0.1 Scale factor for gaussian noise. Yields ------ data : dict Updat...
[ "Add", "noise", "to", "a", "data", "stream", "." ]
python
train
23.5
wright-group/WrightTools
WrightTools/kit/_path.py
https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/kit/_path.py#L20-L44
def get_path_matching(name): """Get path matching a name. Parameters ---------- name : string Name to search for. Returns ------- string Full filepath. """ # first try looking in the user folder p = os.path.join(os.path.expanduser("~"), name) # then try expa...
[ "def", "get_path_matching", "(", "name", ")", ":", "# first try looking in the user folder", "p", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "name", ")", "# then try expanding upwards from cwd", "if", ...
Get path matching a name. Parameters ---------- name : string Name to search for. Returns ------- string Full filepath.
[ "Get", "path", "matching", "a", "name", "." ]
python
train
27
BlueBrain/NeuroM
neurom/core/types.py
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/core/types.py#L66-L92
def tree_type_checker(*ref): '''Tree type checker functor Returns: Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref Ex: >>> from neurom.core.types import NeuriteType, tree_type_checker >>> tree_filter = tree_type_checker(NeuriteTyp...
[ "def", "tree_type_checker", "(", "*", "ref", ")", ":", "ref", "=", "tuple", "(", "ref", ")", "if", "NeuriteType", ".", "all", "in", "ref", ":", "def", "check_tree_type", "(", "_", ")", ":", "'''Always returns true'''", "return", "True", "else", ":", "def...
Tree type checker functor Returns: Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref Ex: >>> from neurom.core.types import NeuriteType, tree_type_checker >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) ...
[ "Tree", "type", "checker", "functor" ]
python
train
31.111111
cuihantao/andes
andes/variables/call.py
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L178-L188
def _compile_bus_injection(self): """Impose injections on buses""" string = '"""\n' for device, series in zip(self.devices, self.series): if series: string += 'system.' + device + '.gcall(system.dae)\n' string += '\n' string += 'system.dae.reset_small_...
[ "def", "_compile_bus_injection", "(", "self", ")", ":", "string", "=", "'\"\"\"\\n'", "for", "device", ",", "series", "in", "zip", "(", "self", ".", "devices", ",", "self", ".", "series", ")", ":", "if", "series", ":", "string", "+=", "'system.'", "+", ...
Impose injections on buses
[ "Impose", "injections", "on", "buses" ]
python
train
39.454545
log2timeline/dfwinreg
dfwinreg/interface.py
https://github.com/log2timeline/dfwinreg/blob/9d488bb1db562197dbfb48de9613d6b29dea056e/dfwinreg/interface.py#L291-L302
def DataIsInteger(self): """Determines, based on the data type, if the data is an integer. The data types considered strings are: REG_DWORD (REG_DWORD_LITTLE_ENDIAN), REG_DWORD_BIG_ENDIAN and REG_QWORD. Returns: bool: True if the data is an integer, False otherwise. """ return self.data_...
[ "def", "DataIsInteger", "(", "self", ")", ":", "return", "self", ".", "data_type", "in", "(", "definitions", ".", "REG_DWORD", ",", "definitions", ".", "REG_DWORD_BIG_ENDIAN", ",", "definitions", ".", "REG_QWORD", ")" ]
Determines, based on the data type, if the data is an integer. The data types considered strings are: REG_DWORD (REG_DWORD_LITTLE_ENDIAN), REG_DWORD_BIG_ENDIAN and REG_QWORD. Returns: bool: True if the data is an integer, False otherwise.
[ "Determines", "based", "on", "the", "data", "type", "if", "the", "data", "is", "an", "integer", "." ]
python
train
34.5
hyperledger/indy-sdk
vcx/wrappers/python3/vcx/api/credential.py
https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/vcx/wrappers/python3/vcx/api/credential.py#L186-L210
async def send_request(self, connection: Connection, payment_handle: int): """ Approves the credential offer and submits a credential request. The result will be a credential stored in the prover's wallet. :param connection: connection to submit request from :param payment_handle: curren...
[ "async", "def", "send_request", "(", "self", ",", "connection", ":", "Connection", ",", "payment_handle", ":", "int", ")", ":", "if", "not", "hasattr", "(", "Credential", ".", "send_request", ",", "\"cb\"", ")", ":", "self", ".", "logger", ".", "debug", ...
Approves the credential offer and submits a credential request. The result will be a credential stored in the prover's wallet. :param connection: connection to submit request from :param payment_handle: currently unused :return: Example: connection = await Connection.create(sourc...
[ "Approves", "the", "credential", "offer", "and", "submits", "a", "credential", "request", ".", "The", "result", "will", "be", "a", "credential", "stored", "in", "the", "prover", "s", "wallet", ".", ":", "param", "connection", ":", "connection", "to", "submit...
python
train
46.92
jaredLunde/vital-tools
vital/tools/strings.py
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L61-L72
def is_username(string, minlen=1, maxlen=15): """ Determines whether the @string pattern is username-like @string: #str being tested @minlen: minimum required username length @maxlen: maximum username length -> #bool """ if string: string = string.strip() ret...
[ "def", "is_username", "(", "string", ",", "minlen", "=", "1", ",", "maxlen", "=", "15", ")", ":", "if", "string", ":", "string", "=", "string", ".", "strip", "(", ")", "return", "username_re", ".", "match", "(", "string", ")", "and", "(", "minlen", ...
Determines whether the @string pattern is username-like @string: #str being tested @minlen: minimum required username length @maxlen: maximum username length -> #bool
[ "Determines", "whether", "the", "@string", "pattern", "is", "username", "-", "like", "@string", ":", "#str", "being", "tested", "@minlen", ":", "minimum", "required", "username", "length", "@maxlen", ":", "maximum", "username", "length" ]
python
train
32.75
mojaie/chorus
chorus/v2000reader.py
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L127-L144
def properties(lines): """Parse properties block Returns: dict: {property_type: (atom_index, value)} """ results = {} for i, line in enumerate(lines): type_ = line[3:6] if type_ not in ["CHG", "RAD", "ISO"]: continue # Other properties are not supported yet ...
[ "def", "properties", "(", "lines", ")", ":", "results", "=", "{", "}", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "type_", "=", "line", "[", "3", ":", "6", "]", "if", "type_", "not", "in", "[", "\"CHG\"", ",", "\"RAD\"", ...
Parse properties block Returns: dict: {property_type: (atom_index, value)}
[ "Parse", "properties", "block" ]
python
train
30.944444
browniebroke/deezer-python
deezer/client.py
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L150-L156
def get_album(self, object_id, relation=None, **kwargs): """ Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object """ return self.get_object("album", object_id, relation=relation, **kwargs)
[ "def", "get_album", "(", "self", ",", "object_id", ",", "relation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"album\"", ",", "object_id", ",", "relation", "=", "relation", ",", "*", "*", "kwargs", ")" ...
Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object
[ "Get", "the", "album", "with", "the", "provided", "id" ]
python
train
37
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L348-L360
def _tobinarray_really(self, start, end, pad, size): """Return binary array.""" if pad is None: pad = self.padding bin = array('B') if self._buf == {} and None in (start, end): return bin if size is not None and size <= 0: raise ValueError("tob...
[ "def", "_tobinarray_really", "(", "self", ",", "start", ",", "end", ",", "pad", ",", "size", ")", ":", "if", "pad", "is", "None", ":", "pad", "=", "self", ".", "padding", "bin", "=", "array", "(", "'B'", ")", "if", "self", ".", "_buf", "==", "{",...
Return binary array.
[ "Return", "binary", "array", "." ]
python
train
38.692308
praekeltfoundation/marathon-acme
marathon_acme/clients/_base.py
https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/_base.py#L12-L27
def get_single_header(headers, key): """ Get a single value for the given key out of the given set of headers. :param twisted.web.http_headers.Headers headers: The set of headers in which to look for the header value :param str key: The header key """ raw_headers = headers.getRa...
[ "def", "get_single_header", "(", "headers", ",", "key", ")", ":", "raw_headers", "=", "headers", ".", "getRawHeaders", "(", "key", ")", "if", "raw_headers", "is", "None", ":", "return", "None", "# Take the final header as the authorative", "header", ",", "_", "=...
Get a single value for the given key out of the given set of headers. :param twisted.web.http_headers.Headers headers: The set of headers in which to look for the header value :param str key: The header key
[ "Get", "a", "single", "value", "for", "the", "given", "key", "out", "of", "the", "given", "set", "of", "headers", "." ]
python
valid
30.125
pybluez/pybluez
bluetooth/bluez.py
https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/bluez.py#L119-L129
def get_l2cap_options (sock): """get_l2cap_options (sock, mtu) Gets L2CAP options for the specified L2CAP socket. Options are: omtu, imtu, flush_to, mode, fcs, max_tx, txwin_size. """ # TODO this should be in the C module, because it depends # directly on struct l2cap_options layout. s = so...
[ "def", "get_l2cap_options", "(", "sock", ")", ":", "# TODO this should be in the C module, because it depends", "# directly on struct l2cap_options layout.", "s", "=", "sock", ".", "getsockopt", "(", "SOL_L2CAP", ",", "L2CAP_OPTIONS", ",", "12", ")", "options", "=", "list...
get_l2cap_options (sock, mtu) Gets L2CAP options for the specified L2CAP socket. Options are: omtu, imtu, flush_to, mode, fcs, max_tx, txwin_size.
[ "get_l2cap_options", "(", "sock", "mtu", ")" ]
python
train
38.454545
KelSolaar/Foundations
foundations/trace.py
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/trace.py#L455-L482
def untracable(object): """ Marks decorated object as non tracable. :param object: Object to decorate. :type object: object :return: Object. :rtype: object """ @functools.wraps(object) def untracable_wrapper(*args, **kwargs): """ Marks decorated object as non tracab...
[ "def", "untracable", "(", "object", ")", ":", "@", "functools", ".", "wraps", "(", "object", ")", "def", "untracable_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Marks decorated object as non tracable.\n\n :param \\*args: Argu...
Marks decorated object as non tracable. :param object: Object to decorate. :type object: object :return: Object. :rtype: object
[ "Marks", "decorated", "object", "as", "non", "tracable", "." ]
python
train
21.607143
bastibe/SoundFile
soundfile.py
https://github.com/bastibe/SoundFile/blob/161e930da9c9ea76579b6ee18a131e10bca8a605/soundfile.py#L1262-L1271
def _check_frames(self, frames, fill_value): """Reduce frames to no more than are available in the file.""" if self.seekable(): remaining_frames = self.frames - self.tell() if frames < 0 or (frames > remaining_frames and fill_value is None): ...
[ "def", "_check_frames", "(", "self", ",", "frames", ",", "fill_value", ")", ":", "if", "self", ".", "seekable", "(", ")", ":", "remaining_frames", "=", "self", ".", "frames", "-", "self", ".", "tell", "(", ")", "if", "frames", "<", "0", "or", "(", ...
Reduce frames to no more than are available in the file.
[ "Reduce", "frames", "to", "no", "more", "than", "are", "available", "in", "the", "file", "." ]
python
train
47.1
sentinel-hub/sentinelhub-py
sentinelhub/aws.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L118-L133
def get_safe_type(self): """Determines the type of ESA product. In 2016 ESA changed structure and naming of data. Therefore the class must distinguish between old product type and compact (new) product type. :return: type of ESA product :rtype: constants.EsaSafeType :ra...
[ "def", "get_safe_type", "(", "self", ")", ":", "product_type", "=", "self", ".", "product_id", ".", "split", "(", "'_'", ")", "[", "1", "]", "if", "product_type", ".", "startswith", "(", "'MSI'", ")", ":", "return", "EsaSafeType", ".", "COMPACT_TYPE", "i...
Determines the type of ESA product. In 2016 ESA changed structure and naming of data. Therefore the class must distinguish between old product type and compact (new) product type. :return: type of ESA product :rtype: constants.EsaSafeType :raises: ValueError
[ "Determines", "the", "type", "of", "ESA", "product", "." ]
python
train
40.8125
ewels/MultiQC
multiqc/modules/fastp/fastp.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/fastp/fastp.py#L385-L401
def fastp_read_n_plot(self): """ Make the read N content plot for Fastp """ data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_n_content_data, 'Base Content Percent') pconfig = { 'id': 'fastp-seq-content-n-plot', 'title': 'Fastp: Read N Content', ...
[ "def", "fastp_read_n_plot", "(", "self", ")", ":", "data_labels", ",", "pdata", "=", "self", ".", "filter_pconfig_pdata_subplots", "(", "self", ".", "fastp_n_content_data", ",", "'Base Content Percent'", ")", "pconfig", "=", "{", "'id'", ":", "'fastp-seq-content-n-p...
Make the read N content plot for Fastp
[ "Make", "the", "read", "N", "content", "plot", "for", "Fastp" ]
python
train
40.941176
inasafe/inasafe
safe/gui/analysis_utilities.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/analysis_utilities.py#L219-L234
def add_layer_to_canvas(layer, name): """Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str """ if qgis_version() >= 21800: layer.setName(name) else: layer.setLayerName(name) QgsProject.in...
[ "def", "add_layer_to_canvas", "(", "layer", ",", "name", ")", ":", "if", "qgis_version", "(", ")", ">=", "21800", ":", "layer", ".", "setName", "(", "name", ")", "else", ":", "layer", ".", "setLayerName", "(", "name", ")", "QgsProject", ".", "instance", ...
Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str
[ "Helper", "method", "to", "add", "layer", "to", "QGIS", "." ]
python
train
21.1875
amoffat/sh
sh.py
https://github.com/amoffat/sh/blob/858adf0c682af4c40e41f34d6926696b7a5d3b12/sh.py#L1026-L1051
def bufsize_validator(kwargs): """ a validator to prevent a user from saying that they want custom buffering when they're using an in/out object that will be os.dup'd to the process, and has its own buffering. an example is a pipe or a tty. it doesn't make sense to tell them to have a custom buffering...
[ "def", "bufsize_validator", "(", "kwargs", ")", ":", "invalid", "=", "[", "]", "in_ob", "=", "kwargs", ".", "get", "(", "\"in\"", ",", "None", ")", "out_ob", "=", "kwargs", ".", "get", "(", "\"out\"", ",", "None", ")", "in_buf", "=", "kwargs", ".", ...
a validator to prevent a user from saying that they want custom buffering when they're using an in/out object that will be os.dup'd to the process, and has its own buffering. an example is a pipe or a tty. it doesn't make sense to tell them to have a custom buffering, since the os controls this.
[ "a", "validator", "to", "prevent", "a", "user", "from", "saying", "that", "they", "want", "custom", "buffering", "when", "they", "re", "using", "an", "in", "/", "out", "object", "that", "will", "be", "os", ".", "dup", "d", "to", "the", "process", "and"...
python
train
37.115385
kolypto/py-smsframework
smsframework/providers/forward/provider.py
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L162-L176
def send(self, message): """ Send a message by forwarding it to the server :param message: Message :type message: smsframework.data.OutgoingMessage :rtype: smsframework.data.OutgoingMessage :raise Exception: any exception reported by the other side :raise urllib2.URLError...
[ "def", "send", "(", "self", ",", "message", ")", ":", "res", "=", "jsonex_request", "(", "self", ".", "server_url", "+", "'/im'", ".", "lstrip", "(", "'/'", ")", ",", "{", "'message'", ":", "message", "}", ")", "msg", "=", "res", "[", "'message'", ...
Send a message by forwarding it to the server :param message: Message :type message: smsframework.data.OutgoingMessage :rtype: smsframework.data.OutgoingMessage :raise Exception: any exception reported by the other side :raise urllib2.URLError: Connection error
[ "Send", "a", "message", "by", "forwarding", "it", "to", "the", "server", ":", "param", "message", ":", "Message", ":", "type", "message", ":", "smsframework", ".", "data", ".", "OutgoingMessage", ":", "rtype", ":", "smsframework", ".", "data", ".", "Outgoi...
python
test
45.666667
ioam/lancet
lancet/core.py
https://github.com/ioam/lancet/blob/1fbbf88fa0e8974ff9ed462e3cb11722ddebdd6e/lancet/core.py#L65-L107
def _pprint(self, cycle=False, flat=False, annotate=False, onlychanged=True, level=1, tab = ' '): """ Pretty printer that prints only the modified keywords and generates flat representations (for repr) and optionally annotates the top of the repr with a comment. """ (kw...
[ "def", "_pprint", "(", "self", ",", "cycle", "=", "False", ",", "flat", "=", "False", ",", "annotate", "=", "False", ",", "onlychanged", "=", "True", ",", "level", "=", "1", ",", "tab", "=", "' '", ")", ":", "(", "kwargs", ",", "pos_args", ",", ...
Pretty printer that prints only the modified keywords and generates flat representations (for repr) and optionally annotates the top of the repr with a comment.
[ "Pretty", "printer", "that", "prints", "only", "the", "modified", "keywords", "and", "generates", "flat", "representations", "(", "for", "repr", ")", "and", "optionally", "annotates", "the", "top", "of", "the", "repr", "with", "a", "comment", "." ]
python
valid
50.255814
frejanordsiek/hdf5storage
hdf5storage/utilities.py
https://github.com/frejanordsiek/hdf5storage/blob/539275141dd3a4efbbbfd9bdb978f3ed59e3f05d/hdf5storage/utilities.py#L702-L743
def next_unused_name_in_group(grp, length): """ Gives a name that isn't used in a Group. Generates a name of the desired length that is not a Dataset or Group in the given group. Note, if length is not large enough and `grp` is full enough, there may be no available names meaning that this function...
[ "def", "next_unused_name_in_group", "(", "grp", ",", "length", ")", ":", "# While", "#", "# ltrs = string.ascii_letters + string.digits", "# name = ''.join([random.choice(ltrs) for i in range(length)])", "#", "# seems intuitive, its performance is abysmal compared to", "#", "# '%0{0}x'...
Gives a name that isn't used in a Group. Generates a name of the desired length that is not a Dataset or Group in the given group. Note, if length is not large enough and `grp` is full enough, there may be no available names meaning that this function will hang. Parameters ---------- grp :...
[ "Gives", "a", "name", "that", "isn", "t", "used", "in", "a", "Group", "." ]
python
train
31.071429
waqasbhatti/astrobase
astrobase/services/simbad.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/services/simbad.py#L861-L977
def objectnames_conesearch(racenter, declcenter, searchradiusarcsec, simbad_mirror='simbad', returnformat='csv', forcefetch=False, cachedir='~/.astrobase/simb...
[ "def", "objectnames_conesearch", "(", "racenter", ",", "declcenter", ",", "searchradiusarcsec", ",", "simbad_mirror", "=", "'simbad'", ",", "returnformat", "=", "'csv'", ",", "forcefetch", "=", "False", ",", "cachedir", "=", "'~/.astrobase/simbad-cache'", ",", "verb...
This queries the SIMBAD TAP service for a list of object names near the coords. This is effectively a "reverse" name resolver (i.e. this does the opposite of SESAME). Parameters ---------- racenter,declcenter : float The cone-search center coordinates in decimal degrees searchradiusar...
[ "This", "queries", "the", "SIMBAD", "TAP", "service", "for", "a", "list", "of", "object", "names", "near", "the", "coords", ".", "This", "is", "effectively", "a", "reverse", "name", "resolver", "(", "i", ".", "e", ".", "this", "does", "the", "opposite", ...
python
valid
40.282051
sorgerlab/indra
indra/sources/biopax/processor.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/processor.py#L1418-L1432
def _is_modification_or_activity(feature): """Return True if the feature is a modification""" if not (isinstance(feature, _bp('ModificationFeature')) or \ isinstance(feature, _bpimpl('ModificationFeature'))): return None mf_type = feature.getModificationType() if mf_type is None: ...
[ "def", "_is_modification_or_activity", "(", "feature", ")", ":", "if", "not", "(", "isinstance", "(", "feature", ",", "_bp", "(", "'ModificationFeature'", ")", ")", "or", "isinstance", "(", "feature", ",", "_bpimpl", "(", "'ModificationFeature'", ")", ")", ")"...
Return True if the feature is a modification
[ "Return", "True", "if", "the", "feature", "is", "a", "modification" ]
python
train
40.4
saltstack/salt
salt/states/boto_apigateway.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_apigateway.py#L1008-L1018
def _get_current_deployment_label(self): ''' Helper method to find the deployment label that the stage_name is currently associated with. ''' deploymentId = self._get_current_deployment_id() deployment = __salt__['boto_apigateway.describe_api_deployment'](restApiId=self.restApiId...
[ "def", "_get_current_deployment_label", "(", "self", ")", ":", "deploymentId", "=", "self", ".", "_get_current_deployment_id", "(", ")", "deployment", "=", "__salt__", "[", "'boto_apigateway.describe_api_deployment'", "]", "(", "restApiId", "=", "self", ".", "restApiI...
Helper method to find the deployment label that the stage_name is currently associated with.
[ "Helper", "method", "to", "find", "the", "deployment", "label", "that", "the", "stage_name", "is", "currently", "associated", "with", "." ]
python
train
56.272727
alefnula/tea
tea/process/wrapper.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/process/wrapper.py#L36-L59
def get_processes(sort_by_name=True): """Retrieve a list of processes sorted by name. Args: sort_by_name (bool): Sort the list by name or by process ID's. Returns: list of (int, str) or list of (int, str, str): List of process id, process name and optional cmdline tuple...
[ "def", "get_processes", "(", "sort_by_name", "=", "True", ")", ":", "if", "sort_by_name", ":", "return", "sorted", "(", "_list_processes", "(", ")", ",", "key", "=", "cmp_to_key", "(", "lambda", "p1", ",", "p2", ":", "(", "cmp", "(", "p1", ".", "name",...
Retrieve a list of processes sorted by name. Args: sort_by_name (bool): Sort the list by name or by process ID's. Returns: list of (int, str) or list of (int, str, str): List of process id, process name and optional cmdline tuples.
[ "Retrieve", "a", "list", "of", "processes", "sorted", "by", "name", ".", "Args", ":", "sort_by_name", "(", "bool", ")", ":", "Sort", "the", "list", "by", "name", "or", "by", "process", "ID", "s", ".", "Returns", ":", "list", "of", "(", "int", "str", ...
python
train
30.125
rogerhil/thegamesdb
thegamesdb/resources.py
https://github.com/rogerhil/thegamesdb/blob/795314215f9ee73697c7520dea4ddecfb23ca8e6/thegamesdb/resources.py#L38-L47
def list(self, name, platform='', genre=''): """ The name argument is required for this method as per the API server specification. This method also provides the platform and genre optional arguments as filters. """ data_list = self.db.get_data(self.list_path, name=name, ...
[ "def", "list", "(", "self", ",", "name", ",", "platform", "=", "''", ",", "genre", "=", "''", ")", ":", "data_list", "=", "self", ".", "db", ".", "get_data", "(", "self", ".", "list_path", ",", "name", "=", "name", ",", "platform", "=", "platform",...
The name argument is required for this method as per the API server specification. This method also provides the platform and genre optional arguments as filters.
[ "The", "name", "argument", "is", "required", "for", "this", "method", "as", "per", "the", "API", "server", "specification", ".", "This", "method", "also", "provides", "the", "platform", "and", "genre", "optional", "arguments", "as", "filters", "." ]
python
train
51.7
spotify/snakebite
snakebite/client.py
https://github.com/spotify/snakebite/blob/6a456e6100b0c1be66cc1f7f9d7f50494f369da3/snakebite/client.py#L881-L909
def tail(self, path, tail_length=1024, append=False): # Note: append is currently not implemented. ''' Show the end of the file - default 1KB, supports up to the Hadoop block size. :param path: Path to read :type path: string :param tail_length: The length to read from the end o...
[ "def", "tail", "(", "self", ",", "path", ",", "tail_length", "=", "1024", ",", "append", "=", "False", ")", ":", "# Note: append is currently not implemented.", "#TODO: Make tail support multiple files at a time, like most other methods do", "if", "not", "path", ":", "rai...
Show the end of the file - default 1KB, supports up to the Hadoop block size. :param path: Path to read :type path: string :param tail_length: The length to read from the end of the file - default 1KB, up to block size. :type tail_length: int :param append: Currently not impleme...
[ "Show", "the", "end", "of", "the", "file", "-", "default", "1KB", "supports", "up", "to", "the", "Hadoop", "block", "size", "." ]
python
train
45.137931
developmentseed/landsat-util
landsat/search.py
https://github.com/developmentseed/landsat-util/blob/92dc81771ddaa64a8a9124a89a6516b52485374b/landsat/search.py#L254-L273
def date_range_builder(self, start='2013-02-11', end=None): """ Builds date range query. :param start: Date string. format: YYYY-MM-DD :type start: String :param end: date string. format: YYYY-MM-DD :type end: String ...
[ "def", "date_range_builder", "(", "self", ",", "start", "=", "'2013-02-11'", ",", "end", "=", "None", ")", ":", "if", "not", "end", ":", "end", "=", "time", ".", "strftime", "(", "'%Y-%m-%d'", ")", "return", "'acquisitionDate:[%s+TO+%s]'", "%", "(", "start...
Builds date range query. :param start: Date string. format: YYYY-MM-DD :type start: String :param end: date string. format: YYYY-MM-DD :type end: String :returns: String
[ "Builds", "date", "range", "query", "." ]
python
train
23.4
iamteem/redisco
redisco/models/base.py
https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L447-L458
def _delete_from_indices(self, pipeline): """Deletes the object's id from the sets(indices) it has been added to and removes its list of indices (used for housekeeping). """ s = Set(self.key()['_indices']) z = Set(self.key()['_zindices']) for index in s.members: ...
[ "def", "_delete_from_indices", "(", "self", ",", "pipeline", ")", ":", "s", "=", "Set", "(", "self", ".", "key", "(", ")", "[", "'_indices'", "]", ")", "z", "=", "Set", "(", "self", ".", "key", "(", ")", "[", "'_zindices'", "]", ")", "for", "inde...
Deletes the object's id from the sets(indices) it has been added to and removes its list of indices (used for housekeeping).
[ "Deletes", "the", "object", "s", "id", "from", "the", "sets", "(", "indices", ")", "it", "has", "been", "added", "to", "and", "removes", "its", "list", "of", "indices", "(", "used", "for", "housekeeping", ")", "." ]
python
train
39.75
noahbenson/pimms
pimms/util.py
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L219-L249
def save(filename, obj, overwrite=False, create_directories=False): ''' pimms.save(filename, obj) attempts to pickle the given object obj in the filename (or stream, if given). An error is raised when this cannot be accomplished; the first argument is always returned; though if the argument is a fil...
[ "def", "save", "(", "filename", ",", "obj", ",", "overwrite", "=", "False", ",", "create_directories", "=", "False", ")", ":", "if", "isinstance", "(", "filename", ",", "six", ".", "string_types", ")", ":", "filename", "=", "os", ".", "path", ".", "exp...
pimms.save(filename, obj) attempts to pickle the given object obj in the filename (or stream, if given). An error is raised when this cannot be accomplished; the first argument is always returned; though if the argument is a filename, it may be a differet string that refers to the same file. The ...
[ "pimms", ".", "save", "(", "filename", "obj", ")", "attempts", "to", "pickle", "the", "given", "object", "obj", "in", "the", "filename", "(", "or", "stream", "if", "given", ")", ".", "An", "error", "is", "raised", "when", "this", "cannot", "be", "accom...
python
train
53.483871
jobovy/galpy
galpy/potential/KuzminKutuzovStaeckelPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/KuzminKutuzovStaeckelPotential.py#L113-L134
def _zforce(self,R,z,phi=0.,t=0.): """ NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: ...
[ "def", "_zforce", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "l", ",", "n", "=", "bovy_coords", ".", "Rz_to_lambdanu", "(", "R", ",", "z", ",", "ac", "=", "self", ".", "_ac", ",", "Delta", "=", "s...
NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the vertical force HISTORY: ...
[ "NAME", ":", "_zforce", "PURPOSE", ":", "evaluate", "the", "vertical", "force", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ...
python
train
31.909091
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11369-L11379
def file_transfer_protocol_send(self, target_network, target_system, target_component, payload, force_mavlink1=False): ''' File transfer message target_network : Network ID (0 for broadcast) (uint8_t) target_system : System ID (0 fo...
[ "def", "file_transfer_protocol_send", "(", "self", ",", "target_network", ",", "target_system", ",", "target_component", ",", "payload", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "file_transfer_protocol_encode", ...
File transfer message target_network : Network ID (0 for broadcast) (uint8_t) target_system : System ID (0 for broadcast) (uint8_t) target_component : Component ID (0 for broadcast) (uint8_t) payload : Var...
[ "File", "transfer", "message" ]
python
train
91
gabstopper/smc-python
smc/core/node.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/node.py#L517-L530
def ssh(self, enable=True, comment=None): """ Enable or disable SSH :param bool enable: enable or disable SSH daemon :param str comment: optional comment for audit :raises NodeCommandFailed: cannot enable SSH daemon :return: None """ self.make_request( ...
[ "def", "ssh", "(", "self", ",", "enable", "=", "True", ",", "comment", "=", "None", ")", ":", "self", ".", "make_request", "(", "NodeCommandFailed", ",", "method", "=", "'update'", ",", "resource", "=", "'ssh'", ",", "params", "=", "{", "'enable'", ":"...
Enable or disable SSH :param bool enable: enable or disable SSH daemon :param str comment: optional comment for audit :raises NodeCommandFailed: cannot enable SSH daemon :return: None
[ "Enable", "or", "disable", "SSH" ]
python
train
32.214286
Clinical-Genomics/scout
scout/adapter/mongo/clinvar.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/clinvar.py#L71-L92
def get_open_clinvar_submission(self, user_id, institute_id): """Retrieve the database id of an open clinvar submission for a user and institute, if none is available then create a new submission and return it Args: user_id(str): a user ID institute_id(str)...
[ "def", "get_open_clinvar_submission", "(", "self", ",", "user_id", ",", "institute_id", ")", ":", "LOG", ".", "info", "(", "\"Retrieving an open clinvar submission for user '%s' and institute %s\"", ",", "user_id", ",", "institute_id", ")", "query", "=", "dict", "(", ...
Retrieve the database id of an open clinvar submission for a user and institute, if none is available then create a new submission and return it Args: user_id(str): a user ID institute_id(str): an institute ID Returns: submission(obj) : ...
[ "Retrieve", "the", "database", "id", "of", "an", "open", "clinvar", "submission", "for", "a", "user", "and", "institute", "if", "none", "is", "available", "then", "create", "a", "new", "submission", "and", "return", "it" ]
python
test
44.909091
scanny/python-pptx
pptx/presentation.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/presentation.py#L108-L114
def slides(self): """ |Slides| object containing the slides in this presentation. """ sldIdLst = self._element.get_or_add_sldIdLst() self.part.rename_slide_parts([sldId.rId for sldId in sldIdLst]) return Slides(sldIdLst, self)
[ "def", "slides", "(", "self", ")", ":", "sldIdLst", "=", "self", ".", "_element", ".", "get_or_add_sldIdLst", "(", ")", "self", ".", "part", ".", "rename_slide_parts", "(", "[", "sldId", ".", "rId", "for", "sldId", "in", "sldIdLst", "]", ")", "return", ...
|Slides| object containing the slides in this presentation.
[ "|Slides|", "object", "containing", "the", "slides", "in", "this", "presentation", "." ]
python
train
38.285714
rainwoodman/sharedmem
sharedmem/sharedmem.py
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L186-L201
def total_memory(): """ Returns the the amount of memory available for use. The memory is obtained from MemTotal entry in /proc/meminfo. Notes ===== This function is not very useful and not very portable. """ with file('/proc/meminfo', 'r') as f: for line ...
[ "def", "total_memory", "(", ")", ":", "with", "file", "(", "'/proc/meminfo'", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ":", "words", "=", "line", ".", "split", "(", ")", "if", "words", "[", "0", "]", ".", "upper", "(", ")", "=...
Returns the the amount of memory available for use. The memory is obtained from MemTotal entry in /proc/meminfo. Notes ===== This function is not very useful and not very portable.
[ "Returns", "the", "the", "amount", "of", "memory", "available", "for", "use", "." ]
python
valid
29.0625
JoelBender/bacpypes
py25/bacpypes/iocb.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/iocb.py#L474-L503
def get(self, block=1, delay=None): """Get a request from a queue, optionally block until a request is available.""" if _debug: IOQueue._debug("get block=%r delay=%r", block, delay) # if the queue is empty and we do not block return None if not block and not self.notempty.isSet(...
[ "def", "get", "(", "self", ",", "block", "=", "1", ",", "delay", "=", "None", ")", ":", "if", "_debug", ":", "IOQueue", ".", "_debug", "(", "\"get block=%r delay=%r\"", ",", "block", ",", "delay", ")", "# if the queue is empty and we do not block return None", ...
Get a request from a queue, optionally block until a request is available.
[ "Get", "a", "request", "from", "a", "queue", "optionally", "block", "until", "a", "request", "is", "available", "." ]
python
train
30.833333
oasis-open/cti-pattern-validator
stix2patterns/validator.py
https://github.com/oasis-open/cti-pattern-validator/blob/753a6901120db25f0c8550607de1eab4440d59df/stix2patterns/validator.py#L77-L95
def validate(user_input, ret_errs=False, print_errs=False): """ Wrapper for run_validator function that returns True if the user_input contains a valid STIX pattern or False otherwise. The error messages may also be returned or printed based upon the ret_errs and print_errs arg values. """ ...
[ "def", "validate", "(", "user_input", ",", "ret_errs", "=", "False", ",", "print_errs", "=", "False", ")", ":", "errs", "=", "run_validator", "(", "user_input", ")", "passed", "=", "len", "(", "errs", ")", "==", "0", "if", "print_errs", ":", "for", "er...
Wrapper for run_validator function that returns True if the user_input contains a valid STIX pattern or False otherwise. The error messages may also be returned or printed based upon the ret_errs and print_errs arg values.
[ "Wrapper", "for", "run_validator", "function", "that", "returns", "True", "if", "the", "user_input", "contains", "a", "valid", "STIX", "pattern", "or", "False", "otherwise", ".", "The", "error", "messages", "may", "also", "be", "returned", "or", "printed", "ba...
python
train
26.052632
tanghaibao/jcvi
jcvi/formats/fastq.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/fastq.py#L826-L854
def size(args): """ %prog size fastqfile Find the total base pairs in a list of fastq files """ p = OptionParser(size.__doc__) opts, args = p.parse_args(args) if len(args) < 1: sys.exit(not p.print_help()) total_size = total_numrecords = 0 for f in args: cur_size =...
[ "def", "size", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "size", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", "(", "args", ")", "<", "1", ":", "sys", ".", "exit", "(", "not", ...
%prog size fastqfile Find the total base pairs in a list of fastq files
[ "%prog", "size", "fastqfile" ]
python
train
26.034483
Tanganelli/CoAPthon3
coapthon/layers/messagelayer.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/layers/messagelayer.py#L140-L190
def receive_empty(self, message): """ Pair ACKs with requests. :type message: Message :param message: the received message :rtype : Transaction :return: the transaction to which the message belongs to """ logger.debug("receive_empty - " + str(message)) ...
[ "def", "receive_empty", "(", "self", ",", "message", ")", ":", "logger", ".", "debug", "(", "\"receive_empty - \"", "+", "str", "(", "message", ")", ")", "try", ":", "host", ",", "port", "=", "message", ".", "source", "except", "AttributeError", ":", "re...
Pair ACKs with requests. :type message: Message :param message: the received message :rtype : Transaction :return: the transaction to which the message belongs to
[ "Pair", "ACKs", "with", "requests", "." ]
python
train
45.078431
github/octodns
octodns/record/geo.py
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/record/geo.py#L14-L37
def validate(cls, code, prefix): ''' Validates an octoDNS geo code making sure that it is a valid and corresponding: * continent * continent & country * continent, country, & province ''' reasons = [] pieces = code.split('-') n...
[ "def", "validate", "(", "cls", ",", "code", ",", "prefix", ")", ":", "reasons", "=", "[", "]", "pieces", "=", "code", ".", "split", "(", "'-'", ")", "n", "=", "len", "(", "pieces", ")", "if", "n", ">", "3", ":", "reasons", ".", "append", "(", ...
Validates an octoDNS geo code making sure that it is a valid and corresponding: * continent * continent & country * continent, country, & province
[ "Validates", "an", "octoDNS", "geo", "code", "making", "sure", "that", "it", "is", "a", "valid", "and", "corresponding", ":", "*", "continent", "*", "continent", "&", "country", "*", "continent", "country", "&", "province" ]
python
train
37.916667
sassoftware/saspy
saspy/sasdata.py
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasdata.py#L912-L927
def to_csv(self, file: str, opts: dict = None) -> str: """ This method will export a SAS Data Set to a file in CSV format. :param file: the OS filesystem path of the file to be created (exported from this SAS Data Set) :return: """ opts = opts if opts is not None else {}...
[ "def", "to_csv", "(", "self", ",", "file", ":", "str", ",", "opts", ":", "dict", "=", "None", ")", "->", "str", ":", "opts", "=", "opts", "if", "opts", "is", "not", "None", "else", "{", "}", "ll", "=", "self", ".", "_is_valid", "(", ")", "if", ...
This method will export a SAS Data Set to a file in CSV format. :param file: the OS filesystem path of the file to be created (exported from this SAS Data Set) :return:
[ "This", "method", "will", "export", "a", "SAS", "Data", "Set", "to", "a", "file", "in", "CSV", "format", "." ]
python
train
35.25
Alignak-monitoring/alignak
alignak/objects/item.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L816-L841
def add_items(self, items, index_items): """ Add items to template if is template, else add in item list :param items: items list to add :type items: alignak.objects.item.Items :param index_items: Flag indicating if the items should be indexed on the fly. :type index_ite...
[ "def", "add_items", "(", "self", ",", "items", ",", "index_items", ")", ":", "count_templates", "=", "0", "count_items", "=", "0", "generated_items", "=", "[", "]", "for", "item", "in", "items", ":", "if", "item", ".", "is_tpl", "(", ")", ":", "self", ...
Add items to template if is template, else add in item list :param items: items list to add :type items: alignak.objects.item.Items :param index_items: Flag indicating if the items should be indexed on the fly. :type index_items: bool :return: None
[ "Add", "items", "to", "template", "if", "is", "template", "else", "add", "in", "item", "list" ]
python
train
38.846154
tornadoweb/tornado
tornado/web.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L809-L839
def write(self, chunk: Union[str, bytes, dict]) -> None: """Writes the given chunk to the output buffer. To write the output to the network, use the `flush()` method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``applicat...
[ "def", "write", "(", "self", ",", "chunk", ":", "Union", "[", "str", ",", "bytes", ",", "dict", "]", ")", "->", "None", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"Cannot write() after finish()\"", ")", "if", "not", "isinst...
Writes the given chunk to the output buffer. To write the output to the network, use the `flush()` method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Conte...
[ "Writes", "the", "given", "chunk", "to", "the", "output", "buffer", "." ]
python
train
49.387097
dls-controls/pymalcolm
malcolm/core/serializable.py
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L200-L218
def lookup_subclass(cls, d): """Look up a class based on a serialized dictionary containing a typeid Args: d (dict): Dictionary with key "typeid" Returns: Serializable subclass """ try: typeid = d["typeid"] except KeyError: ...
[ "def", "lookup_subclass", "(", "cls", ",", "d", ")", ":", "try", ":", "typeid", "=", "d", "[", "\"typeid\"", "]", "except", "KeyError", ":", "raise", "FieldError", "(", "\"typeid not present in keys %s\"", "%", "list", "(", "d", ")", ")", "subclass", "=", ...
Look up a class based on a serialized dictionary containing a typeid Args: d (dict): Dictionary with key "typeid" Returns: Serializable subclass
[ "Look", "up", "a", "class", "based", "on", "a", "serialized", "dictionary", "containing", "a", "typeid" ]
python
train
29.052632
lmjohns3/theanets
theanets/losses.py
https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/losses.py#L517-L538
def accuracy(self, outputs): '''Build a Theano expression for computing the accuracy of graph output. Parameters ---------- outputs : dict of Theano expressions A dictionary mapping network output names to Theano expressions representing the outputs of a computat...
[ "def", "accuracy", "(", "self", ",", "outputs", ")", ":", "output", "=", "outputs", "[", "self", ".", "output_name", "]", "predict", "=", "TT", ".", "argmax", "(", "output", ",", "axis", "=", "-", "1", ")", "correct", "=", "TT", ".", "eq", "(", "...
Build a Theano expression for computing the accuracy of graph output. Parameters ---------- outputs : dict of Theano expressions A dictionary mapping network output names to Theano expressions representing the outputs of a computation graph. Returns ----...
[ "Build", "a", "Theano", "expression", "for", "computing", "the", "accuracy", "of", "graph", "output", "." ]
python
test
36
saxix/sample-data-utils
sample_data_utils/utils.py
https://github.com/saxix/sample-data-utils/blob/769f1b46e60def2675a14bd5872047af6d1ea398/sample_data_utils/utils.py#L53-L63
def memoize(func): """Decorator that stores function results in a dictionary to be used on the next time that the same arguments were informed.""" func._cache_dict = {} @wraps(func) def _inner(*args, **kwargs): return _get_memoized_value(func, args, kwargs) return _inner
[ "def", "memoize", "(", "func", ")", ":", "func", ".", "_cache_dict", "=", "{", "}", "@", "wraps", "(", "func", ")", "def", "_inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_get_memoized_value", "(", "func", ",", "args", ","...
Decorator that stores function results in a dictionary to be used on the next time that the same arguments were informed.
[ "Decorator", "that", "stores", "function", "results", "in", "a", "dictionary", "to", "be", "used", "on", "the", "next", "time", "that", "the", "same", "arguments", "were", "informed", "." ]
python
test
26.909091
robinagist/ezo
ezo/core/helpers.py
https://github.com/robinagist/ezo/blob/fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986/ezo/core/helpers.py#L63-L83
def get_topic_sha3(event_block): ''' takes an event block and returns a signature for sha3 hashing :param event_block: :return: ''' sig = "" sig += event_block["name"] if not event_block["inputs"]: sig += "()" return sig sig += "(" for input in event_block["inpu...
[ "def", "get_topic_sha3", "(", "event_block", ")", ":", "sig", "=", "\"\"", "sig", "+=", "event_block", "[", "\"name\"", "]", "if", "not", "event_block", "[", "\"inputs\"", "]", ":", "sig", "+=", "\"()\"", "return", "sig", "sig", "+=", "\"(\"", "for", "in...
takes an event block and returns a signature for sha3 hashing :param event_block: :return:
[ "takes", "an", "event", "block", "and", "returns", "a", "signature", "for", "sha3", "hashing", ":", "param", "event_block", ":", ":", "return", ":" ]
python
train
19.190476
heuer/segno
segno/utils.py
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/utils.py#L43-L65
def get_symbol_size(version, scale=1, border=None): """\ Returns the symbol size (width x height) with the provided border and scaling factor. :param int version: A version constant. :param scale: Indicates the size of a single module (default: 1). The size of a module depends on the us...
[ "def", "get_symbol_size", "(", "version", ",", "scale", "=", "1", ",", "border", "=", "None", ")", ":", "if", "border", "is", "None", ":", "border", "=", "get_default_border_size", "(", "version", ")", "# M4 = 0, M3 = -1 ...", "dim", "=", "version", "*", "...
\ Returns the symbol size (width x height) with the provided border and scaling factor. :param int version: A version constant. :param scale: Indicates the size of a single module (default: 1). The size of a module depends on the used output format; i.e. in a PNG context, a scal...
[ "\\", "Returns", "the", "symbol", "size", "(", "width", "x", "height", ")", "with", "the", "provided", "border", "and", "scaling", "factor", "." ]
python
train
42.608696
mwgielen/jackal
jackal/scripts/domaindump.py
https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/scripts/domaindump.py#L160-L195
def parse_domain_users(domain_users_file, domain_groups_file): """ Parses the domain users and groups files. """ with open(domain_users_file) as f: users = json.loads(f.read()) domain_groups = {} if domain_groups_file: with open(domain_groups_file) as f: groups =...
[ "def", "parse_domain_users", "(", "domain_users_file", ",", "domain_groups_file", ")", ":", "with", "open", "(", "domain_users_file", ")", "as", "f", ":", "users", "=", "json", ".", "loads", "(", "f", ".", "read", "(", ")", ")", "domain_groups", "=", "{", ...
Parses the domain users and groups files.
[ "Parses", "the", "domain", "users", "and", "groups", "files", "." ]
python
valid
33.777778
google/openhtf
examples/repeat.py
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/repeat.py#L41-L48
def run(self): """Increments counter and raises an exception for first two runs.""" self.count += 1 print('FailTwicePlug: Run number %s' % (self.count)) if self.count < 3: raise RuntimeError('Fails a couple times') return True
[ "def", "run", "(", "self", ")", ":", "self", ".", "count", "+=", "1", "print", "(", "'FailTwicePlug: Run number %s'", "%", "(", "self", ".", "count", ")", ")", "if", "self", ".", "count", "<", "3", ":", "raise", "RuntimeError", "(", "'Fails a couple time...
Increments counter and raises an exception for first two runs.
[ "Increments", "counter", "and", "raises", "an", "exception", "for", "first", "two", "runs", "." ]
python
train
30.75
fozzle/python-brotherprint
brotherprint/brotherprint.py
https://github.com/fozzle/python-brotherprint/blob/5fb92df11b599c30a7da3d6ac7ed60acff230044/brotherprint/brotherprint.py#L710-L728
def char_style(self, style): '''Sets the character style. Args: style: The desired character style. Choose from 'normal', 'outline', 'shadow', and 'outlineshadow' Returns: None Raises: RuntimeError: Invalid character style ''' ...
[ "def", "char_style", "(", "self", ",", "style", ")", ":", "styleset", "=", "{", "'normal'", ":", "0", ",", "'outline'", ":", "1", ",", "'shadow'", ":", "2", ",", "'outlineshadow'", ":", "3", "}", "if", "style", "in", "styleset", ":", "self", ".", "...
Sets the character style. Args: style: The desired character style. Choose from 'normal', 'outline', 'shadow', and 'outlineshadow' Returns: None Raises: RuntimeError: Invalid character style
[ "Sets", "the", "character", "style", ".", "Args", ":", "style", ":", "The", "desired", "character", "style", ".", "Choose", "from", "normal", "outline", "shadow", "and", "outlineshadow", "Returns", ":", "None", "Raises", ":", "RuntimeError", ":", "Invalid", ...
python
train
33.578947
baliame/http-hmac-python
httphmac/v2.py
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L111-L116
def get_response_signer(self): """Returns the response signer for this version of the signature. """ if not hasattr(self, "response_signer"): self.response_signer = V2ResponseSigner(self.digest, orig=self) return self.response_signer
[ "def", "get_response_signer", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"response_signer\"", ")", ":", "self", ".", "response_signer", "=", "V2ResponseSigner", "(", "self", ".", "digest", ",", "orig", "=", "self", ")", "return", "s...
Returns the response signer for this version of the signature.
[ "Returns", "the", "response", "signer", "for", "this", "version", "of", "the", "signature", "." ]
python
train
45.333333
NuGrid/NuGridPy
nugridpy/astronomy.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/astronomy.py#L81-L120
def visc_rad_kap_sc(T,rho,X): ''' Radiative viscosity (Thomas, 1930) for e- scattering opacity Parameters ---------- X : float H mass fraction T : float temperature in K rho : float density in cgs Returns ------- nu : float radiative diffusivity in [...
[ "def", "visc_rad_kap_sc", "(", "T", ",", "rho", ",", "X", ")", ":", "kappa", "=", "0.2", "*", "(", "1.", "+", "X", ")", "nu_rad", "=", "6.88e-26", "*", "(", "old_div", "(", "T", "**", "4", ",", "(", "kappa", "*", "rho", "**", "2", ")", ")", ...
Radiative viscosity (Thomas, 1930) for e- scattering opacity Parameters ---------- X : float H mass fraction T : float temperature in K rho : float density in cgs Returns ------- nu : float radiative diffusivity in [cm**2/s] Examples -------- >>...
[ "Radiative", "viscosity", "(", "Thomas", "1930", ")", "for", "e", "-", "scattering", "opacity" ]
python
train
24.275
spulec/moto
moto/ecr/models.py
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecr/models.py#L208-L228
def list_images(self, repository_name, registry_id=None): """ maxResults and filtering not implemented """ repository = None found = False if repository_name in self.repositories: repository = self.repositories[repository_name] if registry_id: ...
[ "def", "list_images", "(", "self", ",", "repository_name", ",", "registry_id", "=", "None", ")", ":", "repository", "=", "None", "found", "=", "False", "if", "repository_name", "in", "self", ".", "repositories", ":", "repository", "=", "self", ".", "reposito...
maxResults and filtering not implemented
[ "maxResults", "and", "filtering", "not", "implemented" ]
python
train
31.952381
SergeySatskiy/cdm-pythonparser
cdmpyparser.py
https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L26-L57
def trim_docstring(docstring): """Taken from http://www.python.org/dev/peps/pep-0257/""" if not docstring: return '' # Convert tabs to spaces (following the normal Python rules) # and split into a list of lines: lines = docstring.expandtabs().splitlines() # Determine minimum indentatio...
[ "def", "trim_docstring", "(", "docstring", ")", ":", "if", "not", "docstring", ":", "return", "''", "# Convert tabs to spaces (following the normal Python rules)", "# and split into a list of lines:", "lines", "=", "docstring", ".", "expandtabs", "(", ")", ".", "splitline...
Taken from http://www.python.org/dev/peps/pep-0257/
[ "Taken", "from", "http", ":", "//", "www", ".", "python", ".", "org", "/", "dev", "/", "peps", "/", "pep", "-", "0257", "/" ]
python
train
29.125
kubernetes-client/python
kubernetes/client/apis/core_v1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/core_v1_api.py#L12346-L12373
def list_namespaced_pod(self, namespace, **kwargs): """ list or watch objects of kind Pod This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_namespaced_pod(namespace, async_req=True) ...
[ "def", "list_namespaced_pod", "(", "self", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "list_namespaced_pod...
list or watch objects of kind Pod This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_namespaced_pod(namespace, async_req=True) >>> result = thread.get() :param async_req bool :pa...
[ "list", "or", "watch", "objects", "of", "kind", "Pod", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread",...
python
train
165.285714
sam-washington/requests-aws4auth
requests_aws4auth/aws4auth.py
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L368-L394
def get_request_date(cls, req): """ Try to pull a date from the request by looking first at the x-amz-date header, and if that's not present then the Date header. Return a datetime.date object, or None if neither date header is found or is in a recognisable format. req ...
[ "def", "get_request_date", "(", "cls", ",", "req", ")", ":", "date", "=", "None", "for", "header", "in", "[", "'x-amz-date'", ",", "'date'", "]", ":", "if", "header", "not", "in", "req", ".", "headers", ":", "continue", "try", ":", "date_str", "=", "...
Try to pull a date from the request by looking first at the x-amz-date header, and if that's not present then the Date header. Return a datetime.date object, or None if neither date header is found or is in a recognisable format. req -- a requests PreparedRequest object
[ "Try", "to", "pull", "a", "date", "from", "the", "request", "by", "looking", "first", "at", "the", "x", "-", "amz", "-", "date", "header", "and", "if", "that", "s", "not", "present", "then", "the", "Date", "header", "." ]
python
valid
30.740741
androguard/androguard
androguard/core/analysis/analysis.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/analysis/analysis.py#L1494-L1520
def find_methods(self, classname=".*", methodname=".*", descriptor=".*", accessflags=".*", no_external=False): """ Find a method by name using regular expression. This method will return all MethodClassAnalysis objects, which match the classname, methodname, descriptor and ac...
[ "def", "find_methods", "(", "self", ",", "classname", "=", "\".*\"", ",", "methodname", "=", "\".*\"", ",", "descriptor", "=", "\".*\"", ",", "accessflags", "=", "\".*\"", ",", "no_external", "=", "False", ")", ":", "for", "cname", ",", "c", "in", "self"...
Find a method by name using regular expression. This method will return all MethodClassAnalysis objects, which match the classname, methodname, descriptor and accessflags of the method. :param classname: regular expression for the classname :param methodname: regular expression for the ...
[ "Find", "a", "method", "by", "name", "using", "regular", "expression", ".", "This", "method", "will", "return", "all", "MethodClassAnalysis", "objects", "which", "match", "the", "classname", "methodname", "descriptor", "and", "accessflags", "of", "the", "method", ...
python
train
52.851852
scot-dev/scot
scot/ooapi.py
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L202-L221
def set_used_labels(self, labels): """ Specify which trials to use in subsequent analysis steps. This function masks trials based on their class labels. Parameters ---------- labels : list of class labels Marks all trials that have a label that is in the `labels` li...
[ "def", "set_used_labels", "(", "self", ",", "labels", ")", ":", "mask", "=", "np", ".", "zeros", "(", "self", ".", "cl_", ".", "size", ",", "dtype", "=", "bool", ")", "for", "l", "in", "labels", ":", "mask", "=", "np", ".", "logical_or", "(", "ma...
Specify which trials to use in subsequent analysis steps. This function masks trials based on their class labels. Parameters ---------- labels : list of class labels Marks all trials that have a label that is in the `labels` list for further processing. Returns ...
[ "Specify", "which", "trials", "to", "use", "in", "subsequent", "analysis", "steps", "." ]
python
train
30.65