repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
allianceauth/allianceauth
allianceauth/groupmanagement/managers.py
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/groupmanagement/managers.py#L31-L42
def can_manage_groups(cls, user): """ For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for ...
[ "def", "can_manage_groups", "(", "cls", ",", "user", ")", ":", "if", "user", ".", "is_authenticated", ":", "return", "cls", ".", "has_management_permission", "(", "user", ")", "or", "user", ".", "leads_groups", ".", "all", "(", ")", "return", "False" ]
For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for the request :return: bool True if user can man...
[ "For", "use", "with", "user_passes_test", "decorator", ".", "Check", "if", "the", "user", "can", "manage", "groups", ".", "Either", "has", "the", "auth", ".", "group_management", "permission", "or", "is", "a", "leader", "of", "at", "least", "one", "group", ...
python
train
mdickinson/bigfloat
bigfloat/core.py
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L1831-L1841
def tanh(x, context=None): """ Return the hyperbolic tangent of x. """ return _apply_function_in_current_context( BigFloat, mpfr.mpfr_tanh, (BigFloat._implicit_convert(x),), context, )
[ "def", "tanh", "(", "x", ",", "context", "=", "None", ")", ":", "return", "_apply_function_in_current_context", "(", "BigFloat", ",", "mpfr", ".", "mpfr_tanh", ",", "(", "BigFloat", ".", "_implicit_convert", "(", "x", ")", ",", ")", ",", "context", ",", ...
Return the hyperbolic tangent of x.
[ "Return", "the", "hyperbolic", "tangent", "of", "x", "." ]
python
train
lltk/lltk
lltk/de/scrapers/pons.py
https://github.com/lltk/lltk/blob/d171de55c1b97695fddedf4b02401ae27bf1d634/lltk/de/scrapers/pons.py#L20-L27
def _normalize(self, string): ''' Returns a sanitized string. ''' string = string.replace(u'\xb7', '') string = string.replace(u'\u0331', '') string = string.replace(u'\u0323', '') string = string.strip(' \n\rI.') return string
[ "def", "_normalize", "(", "self", ",", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "u'\\xb7'", ",", "''", ")", "string", "=", "string", ".", "replace", "(", "u'\\u0331'", ",", "''", ")", "string", "=", "string", ".", "replace", ...
Returns a sanitized string.
[ "Returns", "a", "sanitized", "string", "." ]
python
train
tonybaloney/retox
retox/ui.py
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L281-L288
def reset(self): ''' Reset the frame between jobs ''' self.palette['title'] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLUE) self._completed_view.options = [] self._task_view.options = [] self.refresh()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "palette", "[", "'title'", "]", "=", "(", "Screen", ".", "COLOUR_WHITE", ",", "Screen", ".", "A_BOLD", ",", "Screen", ".", "COLOUR_BLUE", ")", "self", ".", "_completed_view", ".", "options", "=", "[",...
Reset the frame between jobs
[ "Reset", "the", "frame", "between", "jobs" ]
python
train
cltk/cltk
cltk/prosody/latin/metrical_validator.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/latin/metrical_validator.py#L157-L167
def closest_hexameter_patterns(self, scansion: str) -> List[str]: """ Find the closest group of matching valid hexameter patterns. :return: list of the closest valid hexameter patterns; only candidates with a matching length/number of syllables are considered. >>> print(Metrica...
[ "def", "closest_hexameter_patterns", "(", "self", ",", "scansion", ":", "str", ")", "->", "List", "[", "str", "]", ":", "return", "self", ".", "_closest_patterns", "(", "self", ".", "VALID_HEXAMETERS", ",", "scansion", ")" ]
Find the closest group of matching valid hexameter patterns. :return: list of the closest valid hexameter patterns; only candidates with a matching length/number of syllables are considered. >>> print(MetricalValidator().closest_hexameter_patterns('-UUUUU-----UU--')) ['-UU-UU-----UU--'...
[ "Find", "the", "closest", "group", "of", "matching", "valid", "hexameter", "patterns", "." ]
python
train
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/key_jar.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L735-L848
def init_key_jar(public_path='', private_path='', key_defs='', owner='', read_only=True): """ A number of cases here: 1. A private path is given a. The file exists and a JWKS is found there. From that JWKS a KeyJar instance is built. b. If the private pat...
[ "def", "init_key_jar", "(", "public_path", "=", "''", ",", "private_path", "=", "''", ",", "key_defs", "=", "''", ",", "owner", "=", "''", ",", "read_only", "=", "True", ")", ":", "if", "private_path", ":", "if", "os", ".", "path", ".", "isfile", "("...
A number of cases here: 1. A private path is given a. The file exists and a JWKS is found there. From that JWKS a KeyJar instance is built. b. If the private path file doesn't exit the key definitions are used to build a KeyJar instance. A JWKS with the private keys are...
[ "A", "number", "of", "cases", "here", ":" ]
python
train
hyperledger/indy-plenum
stp_core/crypto/nacl_wrappers.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L357-L388
def encrypt(self, plaintext, nonce, encoder=encoding.RawEncoder): """ Encrypts the plaintext message using the given `nonce` and returns the ciphertext encoded with the encoder. .. warning:: It is **VITALLY** important that the nonce is a nonce, i.e. it is a number used only...
[ "def", "encrypt", "(", "self", ",", "plaintext", ",", "nonce", ",", "encoder", "=", "encoding", ".", "RawEncoder", ")", ":", "if", "len", "(", "nonce", ")", "!=", "self", ".", "NONCE_SIZE", ":", "raise", "ValueError", "(", "\"The nonce must be exactly %s byt...
Encrypts the plaintext message using the given `nonce` and returns the ciphertext encoded with the encoder. .. warning:: It is **VITALLY** important that the nonce is a nonce, i.e. it is a number used only once for any given key. If you fail to do this, you compromise the privac...
[ "Encrypts", "the", "plaintext", "message", "using", "the", "given", "nonce", "and", "returns", "the", "ciphertext", "encoded", "with", "the", "encoder", "." ]
python
train
rosenbrockc/ci
pyci/server.py
https://github.com/rosenbrockc/ci/blob/4d5a60291424a83124d1d962d17fb4c7718cde2b/pyci/server.py#L509-L530
def _fields_common(self): """Returns a dictionary of fields and values that are common to all events for which fields dictionaries are created. """ result = {} if not self.testmode: result["__reponame__"] = self.repo.repo.full_name result["__repodesc__"] =...
[ "def", "_fields_common", "(", "self", ")", ":", "result", "=", "{", "}", "if", "not", "self", ".", "testmode", ":", "result", "[", "\"__reponame__\"", "]", "=", "self", ".", "repo", ".", "repo", ".", "full_name", "result", "[", "\"__repodesc__\"", "]", ...
Returns a dictionary of fields and values that are common to all events for which fields dictionaries are created.
[ "Returns", "a", "dictionary", "of", "fields", "and", "values", "that", "are", "common", "to", "all", "events", "for", "which", "fields", "dictionaries", "are", "created", "." ]
python
train
pgmpy/pgmpy
pgmpy/inference/mplp.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L270-L289
def find_triangles(self): """ Finds all the triangles present in the given model Examples -------- >>> from pgmpy.models import MarkovModel >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.inference import Mplp >>> mm = MarkovModel() ...
[ "def", "find_triangles", "(", "self", ")", ":", "return", "list", "(", "filter", "(", "lambda", "x", ":", "len", "(", "x", ")", "==", "3", ",", "nx", ".", "find_cliques", "(", "self", ".", "model", ")", ")", ")" ]
Finds all the triangles present in the given model Examples -------- >>> from pgmpy.models import MarkovModel >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.inference import Mplp >>> mm = MarkovModel() >>> mm.add_nodes_from(['x1', 'x2', 'x3'...
[ "Finds", "all", "the", "triangles", "present", "in", "the", "given", "model" ]
python
train
gwastro/pycbc
pycbc/inference/models/base.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/base.py#L166-L183
def apply(self, samples, inverse=False): """Applies the sampling transforms to the given samples. Parameters ---------- samples : dict or FieldArray The samples to apply the transforms to. inverse : bool, optional Whether to apply the inverse transforms (...
[ "def", "apply", "(", "self", ",", "samples", ",", "inverse", "=", "False", ")", ":", "return", "transforms", ".", "apply_transforms", "(", "samples", ",", "self", ".", "sampling_transforms", ",", "inverse", "=", "inverse", ")" ]
Applies the sampling transforms to the given samples. Parameters ---------- samples : dict or FieldArray The samples to apply the transforms to. inverse : bool, optional Whether to apply the inverse transforms (i.e., go from the sampling args to the `...
[ "Applies", "the", "sampling", "transforms", "to", "the", "given", "samples", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex_logger.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_logger.py#L53-L58
def emit(self, record): """Emit the log record.""" self.entries.append(self.format(record)) if len(self.entries) > self.flush_limit and not self.session.auth.renewing: self.log_to_api() self.entries = []
[ "def", "emit", "(", "self", ",", "record", ")", ":", "self", ".", "entries", ".", "append", "(", "self", ".", "format", "(", "record", ")", ")", "if", "len", "(", "self", ".", "entries", ")", ">", "self", ".", "flush_limit", "and", "not", "self", ...
Emit the log record.
[ "Emit", "the", "log", "record", "." ]
python
train
jurismarches/chopper
chopper/css/extractor.py
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L225-L236
def _selector_as_string(self, selector): """ Returns a selector as a CSS string :param selector: A list of tinycss Tokens :type selector: list :returns: The CSS string for the selector :rtype: str """ return ','.join( ''.join(token.as_css() fo...
[ "def", "_selector_as_string", "(", "self", ",", "selector", ")", ":", "return", "','", ".", "join", "(", "''", ".", "join", "(", "token", ".", "as_css", "(", ")", "for", "token", "in", "strip_whitespace", "(", "token_list", ")", ")", "for", "token_list",...
Returns a selector as a CSS string :param selector: A list of tinycss Tokens :type selector: list :returns: The CSS string for the selector :rtype: str
[ "Returns", "a", "selector", "as", "a", "CSS", "string" ]
python
train
workforce-data-initiative/skills-utils
skills_utils/metta.py
https://github.com/workforce-data-initiative/skills-utils/blob/4cf9b7c2938984f34bbcc33d45482d23c52c7539/skills_utils/metta.py#L27-L45
def metta_config(quarter, num_dimensions): """Returns metta metadata for a quarter's SOC code classifier matrix Args: quarter (str) quarter, in format '2015Q1' num_dimensions (int) Number of features in matrix Returns: (dict) metadata suitable for metta.archive_train_test """ first...
[ "def", "metta_config", "(", "quarter", ",", "num_dimensions", ")", ":", "first_day", ",", "last_day", "=", "quarter_boundaries", "(", "quarter", ")", "return", "{", "'start_time'", ":", "first_day", ",", "'end_time'", ":", "last_day", ",", "'prediction_window'", ...
Returns metta metadata for a quarter's SOC code classifier matrix Args: quarter (str) quarter, in format '2015Q1' num_dimensions (int) Number of features in matrix Returns: (dict) metadata suitable for metta.archive_train_test
[ "Returns", "metta", "metadata", "for", "a", "quarter", "s", "SOC", "code", "classifier", "matrix" ]
python
train
RedFantom/ttkwidgets
ttkwidgets/checkboxtreeview.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/checkboxtreeview.py#L104-L119
def change_state(self, item, state): """ Replace the current state of the item. i.e. replace the current state tag but keeps the other tags. :param item: item id :type item: str :param state: "checked", "unchecked" or "tristate": new state of the item :...
[ "def", "change_state", "(", "self", ",", "item", ",", "state", ")", ":", "tags", "=", "self", ".", "item", "(", "item", ",", "\"tags\"", ")", "states", "=", "(", "\"checked\"", ",", "\"unchecked\"", ",", "\"tristate\"", ")", "new_tags", "=", "[", "t", ...
Replace the current state of the item. i.e. replace the current state tag but keeps the other tags. :param item: item id :type item: str :param state: "checked", "unchecked" or "tristate": new state of the item :type state: str
[ "Replace", "the", "current", "state", "of", "the", "item", "." ]
python
train
MartinThoma/hwrt
bin/merge.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/bin/merge.py#L26-L34
def read_raw(data_path): """ Parameters ---------- data_path : str """ with open(data_path, 'rb') as f: data = pickle.load(f) return data
[ "def", "read_raw", "(", "data_path", ")", ":", "with", "open", "(", "data_path", ",", "'rb'", ")", "as", "f", ":", "data", "=", "pickle", ".", "load", "(", "f", ")", "return", "data" ]
Parameters ---------- data_path : str
[ "Parameters", "----------", "data_path", ":", "str" ]
python
train
trailofbits/manticore
manticore/native/memory.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/memory.py#L579-L614
def _search(self, size, start=None, counter=0): """ Recursively searches the address space for enough free space to allocate C{size} bytes. :param size: the size in bytes to allocate. :param start: an address from where to start the search. :param counter: internal parameter to ...
[ "def", "_search", "(", "self", ",", "size", ",", "start", "=", "None", ",", "counter", "=", "0", ")", ":", "assert", "size", "&", "self", ".", "page_mask", "==", "0", "if", "start", "is", "None", ":", "end", "=", "{", "32", ":", "0xf8000000", ","...
Recursively searches the address space for enough free space to allocate C{size} bytes. :param size: the size in bytes to allocate. :param start: an address from where to start the search. :param counter: internal parameter to know if all the memory was already scanned. :return: the add...
[ "Recursively", "searches", "the", "address", "space", "for", "enough", "free", "space", "to", "allocate", "C", "{", "size", "}", "bytes", "." ]
python
valid
JdeRobot/base
src/libs/comm_py/comm/ros/listenerLaser.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerLaser.py#L86-L97
def getLaserData(self): ''' Returns last LaserData. @return last JdeRobotTypes LaserData saved ''' self.lock.acquire() laser = self.data self.lock.release() return laser
[ "def", "getLaserData", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "laser", "=", "self", ".", "data", "self", ".", "lock", ".", "release", "(", ")", "return", "laser" ]
Returns last LaserData. @return last JdeRobotTypes LaserData saved
[ "Returns", "last", "LaserData", "." ]
python
train
Robpol86/libnl
libnl/list_.py
https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/list_.py#L101-L121
def nl_list_for_each_entry_safe(pos, n, head, member): """https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L84. Positional arguments: pos -- class instance holding an nl_list_head instance. n -- class instance holding an nl_list_head instance. head -- nl_list_head class inst...
[ "def", "nl_list_for_each_entry_safe", "(", "pos", ",", "n", ",", "head", ",", "member", ")", ":", "pos", "=", "nl_list_entry", "(", "head", ".", "next_", ",", "type", "(", "pos", ")", ",", "member", ")", "n", "=", "nl_list_entry", "(", "pos", ".", "m...
https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L84. Positional arguments: pos -- class instance holding an nl_list_head instance. n -- class instance holding an nl_list_head instance. head -- nl_list_head class instance. member -- attribute (string). Returns: Gene...
[ "https", ":", "//", "github", ".", "com", "/", "thom311", "/", "libnl", "/", "blob", "/", "libnl3_2_25", "/", "include", "/", "netlink", "/", "list", ".", "h#L84", "." ]
python
train
codelv/enaml-native
src/enamlnative/core/hotswap/autoreload.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/autoreload.py#L494-L528
def aimport(self, parameter_s='', stream=None): """%aimport => Import modules for automatic reloading. %aimport List modules to automatically import and not to import. %aimport foo Import module 'foo' and mark it to be autoreloaded for %autoreload 1 %aimport foo, bar ...
[ "def", "aimport", "(", "self", ",", "parameter_s", "=", "''", ",", "stream", "=", "None", ")", ":", "modname", "=", "parameter_s", "if", "not", "modname", ":", "to_reload", "=", "sorted", "(", "self", ".", "_reloader", ".", "modules", ".", "keys", "(",...
%aimport => Import modules for automatic reloading. %aimport List modules to automatically import and not to import. %aimport foo Import module 'foo' and mark it to be autoreloaded for %autoreload 1 %aimport foo, bar Import modules 'foo', 'bar' and mark them to be auto...
[ "%aimport", "=", ">", "Import", "modules", "for", "automatic", "reloading", "." ]
python
train
datastore/datastore
datastore/core/key.py
https://github.com/datastore/datastore/blob/7ccf0cd4748001d3dbf5e6dda369b0f63e0269d3/datastore/core/key.py#L115-L118
def instance(self, other): '''Returns an instance Key, by appending a name to the namespace.''' assert '/' not in str(other) return Key(str(self) + ':' + str(other))
[ "def", "instance", "(", "self", ",", "other", ")", ":", "assert", "'/'", "not", "in", "str", "(", "other", ")", "return", "Key", "(", "str", "(", "self", ")", "+", "':'", "+", "str", "(", "other", ")", ")" ]
Returns an instance Key, by appending a name to the namespace.
[ "Returns", "an", "instance", "Key", "by", "appending", "a", "name", "to", "the", "namespace", "." ]
python
train
cggh/scikit-allel
allel/chunked/core.py
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L65-L92
def copy_table(tbl, start=0, stop=None, blen=None, storage=None, create='table', **kwargs): """Copy `tbl` block-wise into a new table.""" # setup names, columns = _util.check_table_like(tbl) storage = _util.get_storage(storage) blen = _util.get_blen_table(tbl, blen) if stop is No...
[ "def", "copy_table", "(", "tbl", ",", "start", "=", "0", ",", "stop", "=", "None", ",", "blen", "=", "None", ",", "storage", "=", "None", ",", "create", "=", "'table'", ",", "*", "*", "kwargs", ")", ":", "# setup", "names", ",", "columns", "=", "...
Copy `tbl` block-wise into a new table.
[ "Copy", "tbl", "block", "-", "wise", "into", "a", "new", "table", "." ]
python
train
Dallinger/Dallinger
dallinger/deployment.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L570-L579
def notify(self, message): """Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete. """ if self.complete: return HerokuLocalWrappe...
[ "def", "notify", "(", "self", ",", "message", ")", ":", "if", "self", ".", "complete", ":", "return", "HerokuLocalWrapper", ".", "MONITOR_STOP", "return", "super", "(", "DebugDeployment", ",", "self", ")", ".", "notify", "(", "message", ")" ]
Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete.
[ "Monitor", "output", "from", "heroku", "process", "." ]
python
train
aio-libs/aioredis
aioredis/commands/streams.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/streams.py#L193-L200
def xclaim(self, stream, group_name, consumer_name, min_idle_time, id, *ids): """Claim a message for a given consumer""" fut = self.execute( b'XCLAIM', stream, group_name, consumer_name, min_idle_time, id, *ids ) return wait_convert(fut, parse_messa...
[ "def", "xclaim", "(", "self", ",", "stream", ",", "group_name", ",", "consumer_name", ",", "min_idle_time", ",", "id", ",", "*", "ids", ")", ":", "fut", "=", "self", ".", "execute", "(", "b'XCLAIM'", ",", "stream", ",", "group_name", ",", "consumer_name"...
Claim a message for a given consumer
[ "Claim", "a", "message", "for", "a", "given", "consumer" ]
python
train
aichaos/rivescript-python
rivescript/rivescript.py
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/rivescript.py#L926-L947
def reply(self, user, msg, errors_as_replies=True): """Fetch a reply from the RiveScript brain. Arguments: user (str): A unique user ID for the person requesting a reply. This could be e.g. a screen name or nickname. It's used internally to store user variabl...
[ "def", "reply", "(", "self", ",", "user", ",", "msg", ",", "errors_as_replies", "=", "True", ")", ":", "return", "self", ".", "_brain", ".", "reply", "(", "user", ",", "msg", ",", "errors_as_replies", ")" ]
Fetch a reply from the RiveScript brain. Arguments: user (str): A unique user ID for the person requesting a reply. This could be e.g. a screen name or nickname. It's used internally to store user variables (including topic and history), so if your bo...
[ "Fetch", "a", "reply", "from", "the", "RiveScript", "brain", "." ]
python
train
getnikola/coil
coil/tasks.py
https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/tasks.py#L122-L138
def orphans_single(default_exec=False): """Remove all orphans in the site, in the single user-mode.""" if not default_exec and executable.endswith('uwsgi'): # default_exec => rq => sys.executable is sane _executable = executable[:-5] + 'python' else: _executable = executable p = ...
[ "def", "orphans_single", "(", "default_exec", "=", "False", ")", ":", "if", "not", "default_exec", "and", "executable", ".", "endswith", "(", "'uwsgi'", ")", ":", "# default_exec => rq => sys.executable is sane", "_executable", "=", "executable", "[", ":", "-", "5...
Remove all orphans in the site, in the single user-mode.
[ "Remove", "all", "orphans", "in", "the", "site", "in", "the", "single", "user", "-", "mode", "." ]
python
train
spotify/gordon
gordon/metrics/log.py
https://github.com/spotify/gordon/blob/8dbf54a032cfaa8f003264682456236b6a69c039/gordon/metrics/log.py#L89-L98
def log(self, metric): """Format and output metric. Args: metric (dict): Complete metric. """ message = self.LOGFMT.format(**metric) if metric['context']: message += ' context: {context}'.format(context=metric['context']) self._logger.log(self.lev...
[ "def", "log", "(", "self", ",", "metric", ")", ":", "message", "=", "self", ".", "LOGFMT", ".", "format", "(", "*", "*", "metric", ")", "if", "metric", "[", "'context'", "]", ":", "message", "+=", "' context: {context}'", ".", "format", "(", "context",...
Format and output metric. Args: metric (dict): Complete metric.
[ "Format", "and", "output", "metric", "." ]
python
train
recurly/recurly-client-python
recurly/__init__.py
https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/__init__.py#L1303-L1327
def refund(self, **kwargs): """Refund this transaction. Calling this method returns the refunded transaction (that is, ``self``) if the refund was successful, or raises a `ResponseError` if an error occurred requesting the refund. After a successful call to `refund()`, to retrie...
[ "def", "refund", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Find the URL and method to refund the transaction.", "try", ":", "selfnode", "=", "self", ".", "_elem", "except", "AttributeError", ":", "raise", "AttributeError", "(", "'refund'", ")", "url", "...
Refund this transaction. Calling this method returns the refunded transaction (that is, ``self``) if the refund was successful, or raises a `ResponseError` if an error occurred requesting the refund. After a successful call to `refund()`, to retrieve the new transaction representing the...
[ "Refund", "this", "transaction", "." ]
python
train
pyviz/holoviews
holoviews/core/io.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/io.py#L417-L466
def collect(self_or_cls, files, drop=[], metadata=True): """ Given a list or NdMapping type containing file paths return a Layout of Collators, which can be called to load a given set of files using the current Importer. If supplied as a list each file is expected to disambiguat...
[ "def", "collect", "(", "self_or_cls", ",", "files", ",", "drop", "=", "[", "]", ",", "metadata", "=", "True", ")", ":", "aslist", "=", "not", "isinstance", "(", "files", ",", "(", "NdMapping", ",", "Element", ")", ")", "if", "isinstance", "(", "files...
Given a list or NdMapping type containing file paths return a Layout of Collators, which can be called to load a given set of files using the current Importer. If supplied as a list each file is expected to disambiguate itself with contained metadata. If an NdMapping type is sup...
[ "Given", "a", "list", "or", "NdMapping", "type", "containing", "file", "paths", "return", "a", "Layout", "of", "Collators", "which", "can", "be", "called", "to", "load", "a", "given", "set", "of", "files", "using", "the", "current", "Importer", "." ]
python
train
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py#L418-L450
def _update_servers(self): """Sync our Servers from TopologyDescription.server_descriptions. Hold the lock while calling this. """ for address, sd in self._description.server_descriptions().items(): if address not in self._servers: monitor = self._settings.mo...
[ "def", "_update_servers", "(", "self", ")", ":", "for", "address", ",", "sd", "in", "self", ".", "_description", ".", "server_descriptions", "(", ")", ".", "items", "(", ")", ":", "if", "address", "not", "in", "self", ".", "_servers", ":", "monitor", "...
Sync our Servers from TopologyDescription.server_descriptions. Hold the lock while calling this.
[ "Sync", "our", "Servers", "from", "TopologyDescription", ".", "server_descriptions", "." ]
python
train
limodou/uliweb
uliweb/orm/__init__.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L916-L932
def set_model_config(model_name, config, replace=False): """ This function should be only used in initialization phrase :param model_name: model name it's should be string :param config: config should be dict. e.g. {'__mapping_only__', '__tablename__', '__ext_model__'} :param replace: if Tru...
[ "def", "set_model_config", "(", "model_name", ",", "config", ",", "replace", "=", "False", ")", ":", "assert", "isinstance", "(", "model_name", ",", "str", ")", "assert", "isinstance", "(", "config", ",", "dict", ")", "d", "=", "__models__", ".", "setdefau...
This function should be only used in initialization phrase :param model_name: model name it's should be string :param config: config should be dict. e.g. {'__mapping_only__', '__tablename__', '__ext_model__'} :param replace: if True, then replace original config, False will update
[ "This", "function", "should", "be", "only", "used", "in", "initialization", "phrase", ":", "param", "model_name", ":", "model", "name", "it", "s", "should", "be", "string", ":", "param", "config", ":", "config", "should", "be", "dict", ".", "e", ".", "g"...
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data_post_request.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data_post_request.py#L441-L452
def firmware_checksum(self, firmware_checksum): """ Sets the firmware_checksum of this DeviceDataPostRequest. The SHA256 checksum of the current firmware image. :param firmware_checksum: The firmware_checksum of this DeviceDataPostRequest. :type: str """ if firmw...
[ "def", "firmware_checksum", "(", "self", ",", "firmware_checksum", ")", ":", "if", "firmware_checksum", "is", "not", "None", "and", "len", "(", "firmware_checksum", ")", ">", "64", ":", "raise", "ValueError", "(", "\"Invalid value for `firmware_checksum`, length must ...
Sets the firmware_checksum of this DeviceDataPostRequest. The SHA256 checksum of the current firmware image. :param firmware_checksum: The firmware_checksum of this DeviceDataPostRequest. :type: str
[ "Sets", "the", "firmware_checksum", "of", "this", "DeviceDataPostRequest", ".", "The", "SHA256", "checksum", "of", "the", "current", "firmware", "image", "." ]
python
train
CellProfiler/centrosome
centrosome/cpmorphology.py
https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L2117-L2149
def ellipse_from_second_moments(image, labels, indexes, wants_compactness = False): """Calculate measurements of ellipses equivalent to the second moments of labels image - the intensity at each point labels - for each labeled object, derive an ellipse indexes - sequence of indexes to process ...
[ "def", "ellipse_from_second_moments", "(", "image", ",", "labels", ",", "indexes", ",", "wants_compactness", "=", "False", ")", ":", "if", "len", "(", "indexes", ")", "==", "0", ":", "return", "(", "np", ".", "zeros", "(", "(", "0", ",", "2", ")", ")...
Calculate measurements of ellipses equivalent to the second moments of labels image - the intensity at each point labels - for each labeled object, derive an ellipse indexes - sequence of indexes to process returns the following arrays: coordinates of the center of the ellipse e...
[ "Calculate", "measurements", "of", "ellipses", "equivalent", "to", "the", "second", "moments", "of", "labels", "image", "-", "the", "intensity", "at", "each", "point", "labels", "-", "for", "each", "labeled", "object", "derive", "an", "ellipse", "indexes", "-"...
python
train
ambitioninc/django-query-builder
querybuilder/tables.py
https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L213-L230
def remove_field(self, field): """ Removes a field from this table :param field: This can be a string of a field name, a dict of {'alias': field}, or a ``Field`` instance :type field: str or dict or :class:`Field <querybuilder.fields.Field>` """ new_field = F...
[ "def", "remove_field", "(", "self", ",", "field", ")", ":", "new_field", "=", "FieldFactory", "(", "field", ",", ")", "new_field", ".", "set_table", "(", "self", ")", "new_field_identifier", "=", "new_field", ".", "get_identifier", "(", ")", "for", "field", ...
Removes a field from this table :param field: This can be a string of a field name, a dict of {'alias': field}, or a ``Field`` instance :type field: str or dict or :class:`Field <querybuilder.fields.Field>`
[ "Removes", "a", "field", "from", "this", "table" ]
python
train
liip/requests_gpgauthlib
requests_gpgauthlib/gpgauth_session.py
https://github.com/liip/requests_gpgauthlib/blob/017711dfff6cc74cc4cb78ee05dec5e38564987e/requests_gpgauthlib/gpgauth_session.py#L208-L222
def is_authenticated_with_token(self): """ GPGAuth Stage 2 """ """ Send back the token to the server to get auth cookie """ server_login_response = post_log_in( self, keyid=self.user_fingerprint, user_token_result=self.user_auth_token ) if no...
[ "def", "is_authenticated_with_token", "(", "self", ")", ":", "\"\"\" Send back the token to the server to get auth cookie \"\"\"", "server_login_response", "=", "post_log_in", "(", "self", ",", "keyid", "=", "self", ".", "user_fingerprint", ",", "user_token_result", "=", "s...
GPGAuth Stage 2
[ "GPGAuth", "Stage", "2" ]
python
train
pyannote/pyannote-metrics
pyannote/metrics/base.py
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L296-L319
def confidence_interval(self, alpha=0.9): """Compute confidence interval on accumulated metric values Parameters ---------- alpha : float, optional Probability that the returned confidence interval contains the true metric value. Returns ------- ...
[ "def", "confidence_interval", "(", "self", ",", "alpha", "=", "0.9", ")", ":", "m", ",", "_", ",", "_", "=", "scipy", ".", "stats", ".", "bayes_mvs", "(", "[", "r", "[", "self", ".", "metric_name_", "]", "for", "_", ",", "r", "in", "self", ".", ...
Compute confidence interval on accumulated metric values Parameters ---------- alpha : float, optional Probability that the returned confidence interval contains the true metric value. Returns ------- (center, (lower, upper)) with cen...
[ "Compute", "confidence", "interval", "on", "accumulated", "metric", "values" ]
python
train
gwastro/pycbc
pycbc/transforms.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/transforms.py#L219-L239
def _copytoscratch(self, maps): """Copies the data in maps to the scratch space. If the maps contain arrays that are not the same shape as the scratch space, a new scratch space will be created. """ try: for p in self.inputs: self._scratch[p][:] = map...
[ "def", "_copytoscratch", "(", "self", ",", "maps", ")", ":", "try", ":", "for", "p", "in", "self", ".", "inputs", ":", "self", ".", "_scratch", "[", "p", "]", "[", ":", "]", "=", "maps", "[", "p", "]", "except", "ValueError", ":", "# we'll get a Va...
Copies the data in maps to the scratch space. If the maps contain arrays that are not the same shape as the scratch space, a new scratch space will be created.
[ "Copies", "the", "data", "in", "maps", "to", "the", "scratch", "space", "." ]
python
train
pytorch/text
torchtext/data/dataset.py
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L201-L214
def filter_examples(self, field_names): """Remove unknown words from dataset examples with respect to given field. Arguments: field_names (list(str)): Within example only the parts with field names in field_names will have their unknown words deleted. """ for...
[ "def", "filter_examples", "(", "self", ",", "field_names", ")", ":", "for", "i", ",", "example", "in", "enumerate", "(", "self", ".", "examples", ")", ":", "for", "field_name", "in", "field_names", ":", "vocab", "=", "set", "(", "self", ".", "fields", ...
Remove unknown words from dataset examples with respect to given field. Arguments: field_names (list(str)): Within example only the parts with field names in field_names will have their unknown words deleted.
[ "Remove", "unknown", "words", "from", "dataset", "examples", "with", "respect", "to", "given", "field", "." ]
python
train
saulpw/visidata
visidata/clipboard.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/clipboard.py#L92-L104
def save(self, vs, filetype): 'Copy rows to the system clipboard.' # use NTF to generate filename and delete file on context exit with tempfile.NamedTemporaryFile(suffix='.'+filetype) as temp: saveSheets(temp.name, vs) sync(1) p = subprocess.Popen( ...
[ "def", "save", "(", "self", ",", "vs", ",", "filetype", ")", ":", "# use NTF to generate filename and delete file on context exit", "with", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.'", "+", "filetype", ")", "as", "temp", ":", "saveSheets", "("...
Copy rows to the system clipboard.
[ "Copy", "rows", "to", "the", "system", "clipboard", "." ]
python
train
pyviz/holoviews
holoviews/core/spaces.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/spaces.py#L669-L683
def clone(self, callable=None, **overrides): """Clones the Callable optionally with new settings Args: callable: New callable function to wrap **overrides: Parameter overrides to apply Returns: Cloned Callable object """ old = {k: v for k, v ...
[ "def", "clone", "(", "self", ",", "callable", "=", "None", ",", "*", "*", "overrides", ")", ":", "old", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "get_param_values", "(", ")", "if", "k", "not", "in", "[", "'callable'", "...
Clones the Callable optionally with new settings Args: callable: New callable function to wrap **overrides: Parameter overrides to apply Returns: Cloned Callable object
[ "Clones", "the", "Callable", "optionally", "with", "new", "settings" ]
python
train
apache/airflow
airflow/hooks/dbapi_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L256-L272
def _serialize_cell(cell, conn=None): """ Returns the SQL literal of the cell as a string. :param cell: The cell to insert into the table :type cell: object :param conn: The database connection :type conn: connection object :return: The serialized cell :r...
[ "def", "_serialize_cell", "(", "cell", ",", "conn", "=", "None", ")", ":", "if", "cell", "is", "None", ":", "return", "None", "if", "isinstance", "(", "cell", ",", "datetime", ")", ":", "return", "cell", ".", "isoformat", "(", ")", "return", "str", "...
Returns the SQL literal of the cell as a string. :param cell: The cell to insert into the table :type cell: object :param conn: The database connection :type conn: connection object :return: The serialized cell :rtype: str
[ "Returns", "the", "SQL", "literal", "of", "the", "cell", "as", "a", "string", "." ]
python
test
inveniosoftware/invenio-files-rest
invenio_files_rest/views.py
https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/views.py#L529-L566
def create_object(self, bucket, key): """Create a new object. :param bucket: The bucket (instance or id) to get the object from. :param key: The file key. :returns: A Flask response. """ # Initial validation of size based on Content-Length. # User can tamper with...
[ "def", "create_object", "(", "self", ",", "bucket", ",", "key", ")", ":", "# Initial validation of size based on Content-Length.", "# User can tamper with Content-Length, so this is just an initial up", "# front check. The storage subsystem must validate the size limit as", "# well.", "s...
Create a new object. :param bucket: The bucket (instance or id) to get the object from. :param key: The file key. :returns: A Flask response.
[ "Create", "a", "new", "object", "." ]
python
train
f3at/feat
src/feat/extern/log/log.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/extern/log/log.py#L422-L452
def stderrHandler(level, object, category, file, line, message): """ A log handler that writes to stderr. @type level: string @type object: string (or None) @type category: string @type message: string """ o = "" if object: o = '"' + object + '"' where = "(%s:%d)...
[ "def", "stderrHandler", "(", "level", ",", "object", ",", "category", ",", "file", ",", "line", ",", "message", ")", ":", "o", "=", "\"\"", "if", "object", ":", "o", "=", "'\"'", "+", "object", "+", "'\"'", "where", "=", "\"(%s:%d)\"", "%", "(", "f...
A log handler that writes to stderr. @type level: string @type object: string (or None) @type category: string @type message: string
[ "A", "log", "handler", "that", "writes", "to", "stderr", "." ]
python
train
wright-group/WrightTools
WrightTools/kit/_timestamp.py
https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/kit/_timestamp.py#L147-L174
def RFC3339(self): """RFC3339. `Link to RFC3339.`__ __ https://www.ietf.org/rfc/rfc3339.txt """ # get timezone offset delta_sec = time.timezone m, s = divmod(delta_sec, 60) h, m = divmod(m, 60) # timestamp format_string = "%Y-%m-%dT%H:%M:...
[ "def", "RFC3339", "(", "self", ")", ":", "# get timezone offset", "delta_sec", "=", "time", ".", "timezone", "m", ",", "s", "=", "divmod", "(", "delta_sec", ",", "60", ")", "h", ",", "m", "=", "divmod", "(", "m", ",", "60", ")", "# timestamp", "forma...
RFC3339. `Link to RFC3339.`__ __ https://www.ietf.org/rfc/rfc3339.txt
[ "RFC3339", "." ]
python
train
openego/eDisGo
edisgo/grid/network.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/network.py#L562-L651
def analyze(self, mode=None, timesteps=None): """Analyzes the grid by power flow analysis Analyze the grid for violations of hosting capacity. Means, perform a power flow analysis and obtain voltages at nodes (load, generator, stations/transformers and branch tees) and active/reactive p...
[ "def", "analyze", "(", "self", ",", "mode", "=", "None", ",", "timesteps", "=", "None", ")", ":", "if", "timesteps", "is", "None", ":", "timesteps", "=", "self", ".", "network", ".", "timeseries", ".", "timeindex", "# check if timesteps is array-like, otherwis...
Analyzes the grid by power flow analysis Analyze the grid for violations of hosting capacity. Means, perform a power flow analysis and obtain voltages at nodes (load, generator, stations/transformers and branch tees) and active/reactive power at lines. The power flow analysis c...
[ "Analyzes", "the", "grid", "by", "power", "flow", "analysis" ]
python
train
mcieslik-mctp/papy
src/papy/util/func.py
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/func.py#L379-L478
def load_item(inbox, type="string", remove=True, buffer=None): """ Loads data from a file. Determines the file type automatically ``"file"``, ``"fifo"``, ``"socket"``, but allows to specify the representation type ``"string"`` or ``"mmap"`` for memory mapped access to the file. Returns the loaded...
[ "def", "load_item", "(", "inbox", ",", "type", "=", "\"string\"", ",", "remove", "=", "True", ",", "buffer", "=", "None", ")", ":", "is_file", ",", "is_fifo", ",", "is_socket", "=", "False", ",", "False", ",", "False", "file", "=", "inbox", "[", "0",...
Loads data from a file. Determines the file type automatically ``"file"``, ``"fifo"``, ``"socket"``, but allows to specify the representation type ``"string"`` or ``"mmap"`` for memory mapped access to the file. Returns the loaded item as a ``str`` or ``mmap`` object. Internally creates an item from ...
[ "Loads", "data", "from", "a", "file", ".", "Determines", "the", "file", "type", "automatically", "file", "fifo", "socket", "but", "allows", "to", "specify", "the", "representation", "type", "string", "or", "mmap", "for", "memory", "mapped", "access", "to", "...
python
train
inveniosoftware/invenio-access
invenio_access/utils.py
https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/invenio_access/utils.py#L16-L30
def get_identity(user): """Create an identity for a given user instance. Primarily useful for testing. """ identity = Identity(user.id) if hasattr(user, 'id'): identity.provides.add(UserNeed(user.id)) for role in getattr(user, 'roles', []): identity.provides.add(RoleNeed(role....
[ "def", "get_identity", "(", "user", ")", ":", "identity", "=", "Identity", "(", "user", ".", "id", ")", "if", "hasattr", "(", "user", ",", "'id'", ")", ":", "identity", ".", "provides", ".", "add", "(", "UserNeed", "(", "user", ".", "id", ")", ")",...
Create an identity for a given user instance. Primarily useful for testing.
[ "Create", "an", "identity", "for", "a", "given", "user", "instance", "." ]
python
train
tobgu/pyrsistent
pyrsistent/_helpers.py
https://github.com/tobgu/pyrsistent/blob/c84dab0daaa44973cbe83830d14888827b307632/pyrsistent/_helpers.py#L8-L39
def freeze(o): """ Recursively convert simple Python containers into pyrsistent versions of those containers. - list is converted to pvector, recursively - dict is converted to pmap, recursively on values (but not keys) - set is converted to pset, but not recursively - tuple is converted to...
[ "def", "freeze", "(", "o", ")", ":", "typ", "=", "type", "(", "o", ")", "if", "typ", "is", "dict", ":", "return", "pmap", "(", "dict", "(", "(", "k", ",", "freeze", "(", "v", ")", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(...
Recursively convert simple Python containers into pyrsistent versions of those containers. - list is converted to pvector, recursively - dict is converted to pmap, recursively on values (but not keys) - set is converted to pset, but not recursively - tuple is converted to tuple, recursively. S...
[ "Recursively", "convert", "simple", "Python", "containers", "into", "pyrsistent", "versions", "of", "those", "containers", "." ]
python
train
wandb/client
wandb/vendor/prompt_toolkit/layout/controls.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/layout/controls.py#L324-L360
def mouse_handler(self, cli, mouse_event): """ Handle mouse events. (When the token list contained mouse handlers and the user clicked on on any of these, the matching handler is called. This handler can still return `NotImplemented` in case we want the `Window` to handle this ...
[ "def", "mouse_handler", "(", "self", ",", "cli", ",", "mouse_event", ")", ":", "if", "self", ".", "_tokens", ":", "# Read the generator.", "tokens_for_line", "=", "list", "(", "split_lines", "(", "self", ".", "_tokens", ")", ")", "try", ":", "tokens", "=",...
Handle mouse events. (When the token list contained mouse handlers and the user clicked on on any of these, the matching handler is called. This handler can still return `NotImplemented` in case we want the `Window` to handle this particular event.)
[ "Handle", "mouse", "events", "." ]
python
train
pypa/pipenv
pipenv/vendor/click_didyoumean/__init__.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click_didyoumean/__init__.py#L25-L42
def resolve_command(self, ctx, args): """ Overrides clicks ``resolve_command`` method and appends *Did you mean ...* suggestions to the raised exception message. """ original_cmd_name = click.utils.make_str(args[0]) try: return super(DYMMixin, self).r...
[ "def", "resolve_command", "(", "self", ",", "ctx", ",", "args", ")", ":", "original_cmd_name", "=", "click", ".", "utils", ".", "make_str", "(", "args", "[", "0", "]", ")", "try", ":", "return", "super", "(", "DYMMixin", ",", "self", ")", ".", "resol...
Overrides clicks ``resolve_command`` method and appends *Did you mean ...* suggestions to the raised exception message.
[ "Overrides", "clicks", "resolve_command", "method", "and", "appends", "*", "Did", "you", "mean", "...", "*", "suggestions", "to", "the", "raised", "exception", "message", "." ]
python
train
Oneiroe/PySimpleAutomata
PySimpleAutomata/AFW.py
https://github.com/Oneiroe/PySimpleAutomata/blob/0f9f2705fd8ddd5d8118bc31552a640f5d00c359/PySimpleAutomata/AFW.py#L106-L120
def afw_word_acceptance(afw: dict, word: list) -> bool: """ Checks if a **word** is accepted by input AFW, returning True/False. The word w is accepted by a AFW if exists at least an accepting run on w. A run for AFWs is a tree and an alternating automaton can have multiple runs on a given inpu...
[ "def", "afw_word_acceptance", "(", "afw", ":", "dict", ",", "word", ":", "list", ")", "->", "bool", ":", "return", "__recursive_acceptance", "(", "afw", ",", "afw", "[", "'initial_state'", "]", ",", "word", ")" ]
Checks if a **word** is accepted by input AFW, returning True/False. The word w is accepted by a AFW if exists at least an accepting run on w. A run for AFWs is a tree and an alternating automaton can have multiple runs on a given input. A run is accepting if all the leaf nodes are accepting st...
[ "Checks", "if", "a", "**", "word", "**", "is", "accepted", "by", "input", "AFW", "returning", "True", "/", "False", "." ]
python
train
mdickinson/bigfloat
bigfloat/core.py
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L200-L225
def next_up(x, context=None): """next_up(x): return the least representable float that's strictly greater than x. This operation is quiet: flags are not affected. """ x = BigFloat._implicit_convert(x) # make sure we don't alter any flags with _saved_flags(): with (context if conte...
[ "def", "next_up", "(", "x", ",", "context", "=", "None", ")", ":", "x", "=", "BigFloat", ".", "_implicit_convert", "(", "x", ")", "# make sure we don't alter any flags", "with", "_saved_flags", "(", ")", ":", "with", "(", "context", "if", "context", "is", ...
next_up(x): return the least representable float that's strictly greater than x. This operation is quiet: flags are not affected.
[ "next_up", "(", "x", ")", ":", "return", "the", "least", "representable", "float", "that", "s", "strictly", "greater", "than", "x", "." ]
python
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L271-L285
def build_hypo_depth_dist(hdd): """ Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ hdds = [] ...
[ "def", "build_hypo_depth_dist", "(", "hdd", ")", ":", "hdds", "=", "[", "]", "for", "(", "prob", ",", "depth", ")", "in", "hdd", ".", "data", ":", "hdds", ".", "append", "(", "Node", "(", "\"hypoDepth\"", ",", "{", "\"depth\"", ":", "depth", ",", "...
Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Returns", "the", "hypocentral", "depth", "distribution", "as", "a", "Node", "instance" ]
python
train
FujiMakoto/AgentML
agentml/__init__.py
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L546-L561
def interpreter(self): """ Launch an AML interpreter session for testing """ while True: message = input('[#] ') if message.lower().strip() == 'exit': break reply = self.get_reply('#interpreter#', message) if not reply: ...
[ "def", "interpreter", "(", "self", ")", ":", "while", "True", ":", "message", "=", "input", "(", "'[#] '", ")", "if", "message", ".", "lower", "(", ")", ".", "strip", "(", ")", "==", "'exit'", ":", "break", "reply", "=", "self", ".", "get_reply", "...
Launch an AML interpreter session for testing
[ "Launch", "an", "AML", "interpreter", "session", "for", "testing" ]
python
train
CxAalto/gtfspy
gtfspy/routing/node_profile_analyzer_time.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L196-L206
def mean_temporal_distance(self): """ Get mean temporal distance (in seconds) to the target. Returns ------- mean_temporal_distance : float """ total_width = self.end_time_dep - self.start_time_dep total_area = sum([block.area() for block in self._profile...
[ "def", "mean_temporal_distance", "(", "self", ")", ":", "total_width", "=", "self", ".", "end_time_dep", "-", "self", ".", "start_time_dep", "total_area", "=", "sum", "(", "[", "block", ".", "area", "(", ")", "for", "block", "in", "self", ".", "_profile_bl...
Get mean temporal distance (in seconds) to the target. Returns ------- mean_temporal_distance : float
[ "Get", "mean", "temporal", "distance", "(", "in", "seconds", ")", "to", "the", "target", "." ]
python
valid
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L2432-L2457
def wallet_frontiers(self, wallet): """ Returns a list of pairs of account and block hash representing the head block starting for accounts from **wallet** :param wallet: Wallet to return frontiers for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` ...
[ "def", "wallet_frontiers", "(", "self", ",", "wallet", ")", ":", "wallet", "=", "self", ".", "_process_value", "(", "wallet", ",", "'wallet'", ")", "payload", "=", "{", "\"wallet\"", ":", "wallet", "}", "resp", "=", "self", ".", "call", "(", "'wallet_fro...
Returns a list of pairs of account and block hash representing the head block starting for accounts from **wallet** :param wallet: Wallet to return frontiers for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.wallet_frontiers( ... wallet="000D1B...
[ "Returns", "a", "list", "of", "pairs", "of", "account", "and", "block", "hash", "representing", "the", "head", "block", "starting", "for", "accounts", "from", "**", "wallet", "**" ]
python
train
zarr-developers/zarr
zarr/util.py
https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/util.py#L69-L112
def guess_chunks(shape, typesize): """ Guess an appropriate chunk layout for a dataset, given its shape and the size of each element in bytes. Will allocate chunks only as large as MAX_SIZE. Chunks are generally close to some power-of-2 fraction of each axis, slightly favoring bigger values for th...
[ "def", "guess_chunks", "(", "shape", ",", "typesize", ")", ":", "ndims", "=", "len", "(", "shape", ")", "# require chunks to have non-zero length for all dimensions", "chunks", "=", "np", ".", "maximum", "(", "np", ".", "array", "(", "shape", ",", "dtype", "="...
Guess an appropriate chunk layout for a dataset, given its shape and the size of each element in bytes. Will allocate chunks only as large as MAX_SIZE. Chunks are generally close to some power-of-2 fraction of each axis, slightly favoring bigger values for the last index. Undocumented and subject to c...
[ "Guess", "an", "appropriate", "chunk", "layout", "for", "a", "dataset", "given", "its", "shape", "and", "the", "size", "of", "each", "element", "in", "bytes", ".", "Will", "allocate", "chunks", "only", "as", "large", "as", "MAX_SIZE", ".", "Chunks", "are",...
python
train
cltrudeau/django-awl
awl/context_processors.py
https://github.com/cltrudeau/django-awl/blob/70d469ef9a161c1170b53aa017cf02d7c15eb90c/awl/context_processors.py#L4-L19
def extra_context(request): """Adds useful global items to the context for use in templates. * *request*: the request object * *HOST*: host name of server * *IN_ADMIN*: True if you are in the django admin area """ host = os.environ.get('DJANGO_LIVE_TEST_SERVER_ADDRESS', None) \ or reque...
[ "def", "extra_context", "(", "request", ")", ":", "host", "=", "os", ".", "environ", ".", "get", "(", "'DJANGO_LIVE_TEST_SERVER_ADDRESS'", ",", "None", ")", "or", "request", ".", "get_host", "(", ")", "d", "=", "{", "'request'", ":", "request", ",", "'HO...
Adds useful global items to the context for use in templates. * *request*: the request object * *HOST*: host name of server * *IN_ADMIN*: True if you are in the django admin area
[ "Adds", "useful", "global", "items", "to", "the", "context", "for", "use", "in", "templates", "." ]
python
valid
adewes/blitzdb
blitzdb/backends/base.py
https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/base.py#L190-L300
def serialize(self, obj, convert_keys_to_str=False, embed_level=0, encoders=None, autosave=True, for_query=False,path = None): """ Serializes a given object, i.e. converts it to a representation that can be stored in the database. ...
[ "def", "serialize", "(", "self", ",", "obj", ",", "convert_keys_to_str", "=", "False", ",", "embed_level", "=", "0", ",", "encoders", "=", "None", ",", "autosave", "=", "True", ",", "for_query", "=", "False", ",", "path", "=", "None", ")", ":", "if", ...
Serializes a given object, i.e. converts it to a representation that can be stored in the database. This usually involves replacing all `Document` instances by database references to them. :param obj: The object to serialize. :param convert_keys_to_str: If `True`, converts all dictionary keys t...
[ "Serializes", "a", "given", "object", "i", ".", "e", ".", "converts", "it", "to", "a", "representation", "that", "can", "be", "stored", "in", "the", "database", ".", "This", "usually", "involves", "replacing", "all", "Document", "instances", "by", "database"...
python
train
NLeSC/noodles
noodles/tutorial.py
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/tutorial.py#L167-L192
def run_and_print_log(workflow, highlight=None): """Run workflow on multi-threaded worker cached with Sqlite3. :param workflow: workflow to evaluate. :param highlight: highlight these lines. """ from noodles.run.threading.sqlite3 import run_parallel from noodles import serial import io ...
[ "def", "run_and_print_log", "(", "workflow", ",", "highlight", "=", "None", ")", ":", "from", "noodles", ".", "run", ".", "threading", ".", "sqlite3", "import", "run_parallel", "from", "noodles", "import", "serial", "import", "io", "import", "logging", "log", ...
Run workflow on multi-threaded worker cached with Sqlite3. :param workflow: workflow to evaluate. :param highlight: highlight these lines.
[ "Run", "workflow", "on", "multi", "-", "threaded", "worker", "cached", "with", "Sqlite3", "." ]
python
train
trp07/messages
messages/cli.py
https://github.com/trp07/messages/blob/7789ebc960335a59ea5d319fceed3dd349023648/messages/cli.py#L20-L24
def get_body_from_file(kwds): """Reads message body if specified via filepath.""" if kwds["file"] and os.path.isfile(kwds["file"]): kwds["body"] = open(kwds["file"], "r").read() kwds["file"] = None
[ "def", "get_body_from_file", "(", "kwds", ")", ":", "if", "kwds", "[", "\"file\"", "]", "and", "os", ".", "path", ".", "isfile", "(", "kwds", "[", "\"file\"", "]", ")", ":", "kwds", "[", "\"body\"", "]", "=", "open", "(", "kwds", "[", "\"file\"", "...
Reads message body if specified via filepath.
[ "Reads", "message", "body", "if", "specified", "via", "filepath", "." ]
python
test
sdispater/poetry
poetry/utils/shell.py
https://github.com/sdispater/poetry/blob/2d27acd76c165dd49f11934520a7973de7a3762a/poetry/utils/shell.py#L27-L41
def get(cls): # type: () -> Shell """ Retrieve the current shell. """ if cls._shell is not None: return cls._shell try: name, path = detect_shell(os.getpid()) except (RuntimeError, ShellDetectionFailure): raise RuntimeError("Unable to...
[ "def", "get", "(", "cls", ")", ":", "# type: () -> Shell", "if", "cls", ".", "_shell", "is", "not", "None", ":", "return", "cls", ".", "_shell", "try", ":", "name", ",", "path", "=", "detect_shell", "(", "os", ".", "getpid", "(", ")", ")", "except", ...
Retrieve the current shell.
[ "Retrieve", "the", "current", "shell", "." ]
python
train
BDNYC/astrodbkit
astrodbkit/astrocat.py
https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrocat.py#L246-L281
def SDSS_spectra_query(self, cat_name, ra, dec, radius, group=True, **kwargs): """ Use astroquery to search SDSS for sources within a search cone Parameters ---------- cat_name: str A name for the imported catalog (e.g. '2MASS') ra: astropy.units.quan...
[ "def", "SDSS_spectra_query", "(", "self", ",", "cat_name", ",", "ra", ",", "dec", ",", "radius", ",", "group", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Verify the cat_name", "if", "self", ".", "_catalog_check", "(", "cat_name", ")", ":", "# Pre...
Use astroquery to search SDSS for sources within a search cone Parameters ---------- cat_name: str A name for the imported catalog (e.g. '2MASS') ra: astropy.units.quantity.Quantity The RA of the center of the cone search dec: astropy.units.quanti...
[ "Use", "astroquery", "to", "search", "SDSS", "for", "sources", "within", "a", "search", "cone", "Parameters", "----------", "cat_name", ":", "str", "A", "name", "for", "the", "imported", "catalog", "(", "e", ".", "g", ".", "2MASS", ")", "ra", ":", "astro...
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/core_v1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L5347-L5370
def create_namespace(self, body, **kwargs): # noqa: E501 """create_namespace # noqa: E501 create a Namespace # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_namespac...
[ "def", "create_namespace", "(", "self", ",", "body", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "create_na...
create_namespace # noqa: E501 create a Namespace # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_namespace(body, async_req=True) >>> result = thread.get() :p...
[ "create_namespace", "#", "noqa", ":", "E501" ]
python
train
ggravlingen/pytradfri
pytradfri/command.py
https://github.com/ggravlingen/pytradfri/blob/63750fa8fb27158c013d24865cdaa7fb82b3ab53/pytradfri/command.py#L65-L70
def result(self, value): """The result of the command.""" if self._process_result: self._result = self._process_result(value) self._raw_result = value
[ "def", "result", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_process_result", ":", "self", ".", "_result", "=", "self", ".", "_process_result", "(", "value", ")", "self", ".", "_raw_result", "=", "value" ]
The result of the command.
[ "The", "result", "of", "the", "command", "." ]
python
train
mikedh/trimesh
trimesh/voxel.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/voxel.py#L669-L696
def indices_to_points(indices, pitch, origin): """ Convert indices of an (n,m,p) matrix into a set of voxel center points. Parameters ---------- indices: (q, 3) int, index of voxel matrix (n,m,p) pitch: float, what pitch was the voxel matrix computed with origin: (3,) float, what is the ori...
[ "def", "indices_to_points", "(", "indices", ",", "pitch", ",", "origin", ")", ":", "indices", "=", "np", ".", "asanyarray", "(", "indices", ",", "dtype", "=", "np", ".", "float64", ")", "origin", "=", "np", ".", "asanyarray", "(", "origin", ",", "dtype...
Convert indices of an (n,m,p) matrix into a set of voxel center points. Parameters ---------- indices: (q, 3) int, index of voxel matrix (n,m,p) pitch: float, what pitch was the voxel matrix computed with origin: (3,) float, what is the origin of the voxel matrix Returns ---------- poi...
[ "Convert", "indices", "of", "an", "(", "n", "m", "p", ")", "matrix", "into", "a", "set", "of", "voxel", "center", "points", "." ]
python
train
pzs741/TEDT
TEDT/release_time.py
https://github.com/pzs741/TEDT/blob/6b6663227b755005fe1a1e3e807a05bdb521e066/TEDT/release_time.py#L173-L185
def check_time_extrator(self): """将抽取得时间转换为date标准时间格式 Keyword arguments: string -- 含有时间的文本,str类型 Return: release_time -- 新闻发布时间 """ if self.year_check and self.month_check and self.day_check: time = str(self.year) + '-' + ...
[ "def", "check_time_extrator", "(", "self", ")", ":", "if", "self", ".", "year_check", "and", "self", ".", "month_check", "and", "self", ".", "day_check", ":", "time", "=", "str", "(", "self", ".", "year", ")", "+", "'-'", "+", "str", "(", "self", "."...
将抽取得时间转换为date标准时间格式 Keyword arguments: string -- 含有时间的文本,str类型 Return: release_time -- 新闻发布时间
[ "将抽取得时间转换为date标准时间格式" ]
python
train
manns/pyspread
pyspread/src/model/model.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/model/model.py#L568-L603
def _set_shape(self, shape): """Deletes all cells beyond new shape and sets dict_grid shape Parameters ---------- shape: 3-tuple of Integer \tTarget shape for grid """ # Delete each cell that is beyond new borders old_shape = self.shape deleted...
[ "def", "_set_shape", "(", "self", ",", "shape", ")", ":", "# Delete each cell that is beyond new borders", "old_shape", "=", "self", ".", "shape", "deleted_cells", "=", "{", "}", "if", "any", "(", "new_axis", "<", "old_axis", "for", "new_axis", ",", "old_axis", ...
Deletes all cells beyond new shape and sets dict_grid shape Parameters ---------- shape: 3-tuple of Integer \tTarget shape for grid
[ "Deletes", "all", "cells", "beyond", "new", "shape", "and", "sets", "dict_grid", "shape" ]
python
train
nerdvegas/rez
src/rez/vendor/pygraph/algorithms/accessibility.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/accessibility.py#L143-L163
def _dfs(graph, visited, count, node): """ Depth-first search subfunction adapted for accessibility algorithms. @type graph: graph, digraph, hypergraph @param graph: Graph. @type visited: dictionary @param visited: List of nodes (visited nodes are marked non-zero). @type count: num...
[ "def", "_dfs", "(", "graph", ",", "visited", ",", "count", ",", "node", ")", ":", "visited", "[", "node", "]", "=", "count", "# Explore recursively the connected component", "for", "each", "in", "graph", "[", "node", "]", ":", "if", "(", "each", "not", "...
Depth-first search subfunction adapted for accessibility algorithms. @type graph: graph, digraph, hypergraph @param graph: Graph. @type visited: dictionary @param visited: List of nodes (visited nodes are marked non-zero). @type count: number @param count: Counter of connected componen...
[ "Depth", "-", "first", "search", "subfunction", "adapted", "for", "accessibility", "algorithms", ".", "@type", "graph", ":", "graph", "digraph", "hypergraph", "@param", "graph", ":", "Graph", "." ]
python
train
trendels/gevent_inotifyx
example.py
https://github.com/trendels/gevent_inotifyx/blob/b1e531616d150e86b13aeca450a61c66f9bbc855/example.py#L16-L25
def watch_for_events(): """Wait for events and print them to stdout.""" fd = inotify.init() try: wd = inotify.add_watch(fd, '/tmp', inotify.IN_CLOSE_WRITE) while True: for event in inotify.get_events(fd): print("event:", event.name, event.get_mask_description()) ...
[ "def", "watch_for_events", "(", ")", ":", "fd", "=", "inotify", ".", "init", "(", ")", "try", ":", "wd", "=", "inotify", ".", "add_watch", "(", "fd", ",", "'/tmp'", ",", "inotify", ".", "IN_CLOSE_WRITE", ")", "while", "True", ":", "for", "event", "in...
Wait for events and print them to stdout.
[ "Wait", "for", "events", "and", "print", "them", "to", "stdout", "." ]
python
train
RetailMeNotSandbox/acky
acky/s3.py
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L113-L125
def copy(self, src_url, dst_url): """Copy an S3 object to another S3 location.""" src_bucket, src_key = _parse_url(src_url) dst_bucket, dst_key = _parse_url(dst_url) if not dst_bucket: dst_bucket = src_bucket params = { 'copy_source': '/'.join((src_bucket...
[ "def", "copy", "(", "self", ",", "src_url", ",", "dst_url", ")", ":", "src_bucket", ",", "src_key", "=", "_parse_url", "(", "src_url", ")", "dst_bucket", ",", "dst_key", "=", "_parse_url", "(", "dst_url", ")", "if", "not", "dst_bucket", ":", "dst_bucket", ...
Copy an S3 object to another S3 location.
[ "Copy", "an", "S3", "object", "to", "another", "S3", "location", "." ]
python
train
romanz/trezor-agent
libagent/gpg/decode.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/gpg/decode.py#L284-L300
def load_by_keygrip(pubkey_bytes, keygrip): """Return public key and first user ID for specified keygrip.""" stream = io.BytesIO(pubkey_bytes) packets = list(parse_packets(stream)) packets_per_pubkey = [] for p in packets: if p['type'] == 'pubkey': # Add a new packet list for eac...
[ "def", "load_by_keygrip", "(", "pubkey_bytes", ",", "keygrip", ")", ":", "stream", "=", "io", ".", "BytesIO", "(", "pubkey_bytes", ")", "packets", "=", "list", "(", "parse_packets", "(", "stream", ")", ")", "packets_per_pubkey", "=", "[", "]", "for", "p", ...
Return public key and first user ID for specified keygrip.
[ "Return", "public", "key", "and", "first", "user", "ID", "for", "specified", "keygrip", "." ]
python
train
sebdah/dynamic-dynamodb
dynamic_dynamodb/calculators.py
https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/calculators.py#L342-L358
def is_consumed_over_proposed( current_provisioning, proposed_provisioning, consumed_units_percent): """ Determines if the currently consumed capacity is over the proposed capacity for this table :type current_provisioning: int :param current_provisioning: The current provisioning :type...
[ "def", "is_consumed_over_proposed", "(", "current_provisioning", ",", "proposed_provisioning", ",", "consumed_units_percent", ")", ":", "consumption_based_current_provisioning", "=", "int", "(", "math", ".", "ceil", "(", "current_provisioning", "*", "(", "consumed_units_per...
Determines if the currently consumed capacity is over the proposed capacity for this table :type current_provisioning: int :param current_provisioning: The current provisioning :type proposed_provisioning: int :param proposed_provisioning: New provisioning :type consumed_units_percent: float ...
[ "Determines", "if", "the", "currently", "consumed", "capacity", "is", "over", "the", "proposed", "capacity", "for", "this", "table" ]
python
train
dhermes/bezier
src/bezier/_curve_helpers.py
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L388-L408
def de_casteljau_one_round(nodes, lambda1, lambda2): """Perform one round of de Casteljau's algorithm. .. note:: This is a helper for :func:`_specialize_curve`. It does not have a Fortran speedup because it is **only** used by a function which has a Fortran speedup. The weights ar...
[ "def", "de_casteljau_one_round", "(", "nodes", ",", "lambda1", ",", "lambda2", ")", ":", "return", "np", ".", "asfortranarray", "(", "lambda1", "*", "nodes", "[", ":", ",", ":", "-", "1", "]", "+", "lambda2", "*", "nodes", "[", ":", ",", "1", ":", ...
Perform one round of de Casteljau's algorithm. .. note:: This is a helper for :func:`_specialize_curve`. It does not have a Fortran speedup because it is **only** used by a function which has a Fortran speedup. The weights are assumed to sum to one. Args: nodes (numpy.nda...
[ "Perform", "one", "round", "of", "de", "Casteljau", "s", "algorithm", "." ]
python
train
pkkid/python-plexapi
plexapi/utils.py
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/utils.py#L129-L143
def searchType(libtype): """ Returns the integer value of the library string type. Parameters: libtype (str): LibType to lookup (movie, show, season, episode, artist, album, track, collection) Raises: :class:`plexapi.exceptions.N...
[ "def", "searchType", "(", "libtype", ")", ":", "libtype", "=", "compat", ".", "ustr", "(", "libtype", ")", "if", "libtype", "in", "[", "compat", ".", "ustr", "(", "v", ")", "for", "v", "in", "SEARCHTYPES", ".", "values", "(", ")", "]", ":", "return...
Returns the integer value of the library string type. Parameters: libtype (str): LibType to lookup (movie, show, season, episode, artist, album, track, collection) Raises: :class:`plexapi.exceptions.NotFound`: Unknown libtype
[ "Returns", "the", "integer", "value", "of", "the", "library", "string", "type", "." ]
python
train
allenai/allennlp
allennlp/state_machines/transition_functions/transition_function.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/state_machines/transition_functions/transition_function.py#L23-L82
def take_step(self, state: StateType, max_actions: int = None, allowed_actions: List[Set] = None) -> List[StateType]: """ The main method in the ``TransitionFunction`` API. This function defines the computation done at each step of decoding ...
[ "def", "take_step", "(", "self", ",", "state", ":", "StateType", ",", "max_actions", ":", "int", "=", "None", ",", "allowed_actions", ":", "List", "[", "Set", "]", "=", "None", ")", "->", "List", "[", "StateType", "]", ":", "raise", "NotImplementedError"...
The main method in the ``TransitionFunction`` API. This function defines the computation done at each step of decoding and returns a ranked list of next states. The input state is `grouped`, to allow for efficient computation, but the output states should all have a ``group_size`` of 1, to mak...
[ "The", "main", "method", "in", "the", "TransitionFunction", "API", ".", "This", "function", "defines", "the", "computation", "done", "at", "each", "step", "of", "decoding", "and", "returns", "a", "ranked", "list", "of", "next", "states", "." ]
python
train
googleapis/oauth2client
oauth2client/client.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1358-L1379
def _get_well_known_file(): """Get the well known file produced by command 'gcloud auth login'.""" # TODO(orestica): Revisit this method once gcloud provides a better way # of pinpointing the exact location of the file. default_config_dir = os.getenv(_CLOUDSDK_CONFIG_ENV_VAR) if default_config_dir i...
[ "def", "_get_well_known_file", "(", ")", ":", "# TODO(orestica): Revisit this method once gcloud provides a better way", "# of pinpointing the exact location of the file.", "default_config_dir", "=", "os", ".", "getenv", "(", "_CLOUDSDK_CONFIG_ENV_VAR", ")", "if", "default_config_dir...
Get the well known file produced by command 'gcloud auth login'.
[ "Get", "the", "well", "known", "file", "produced", "by", "command", "gcloud", "auth", "login", "." ]
python
valid
pecan/pecan
pecan/commands/shell.py
https://github.com/pecan/pecan/blob/833d0653fa0e6bbfb52545b091c30182105f4a82/pecan/commands/shell.py#L41-L66
def invoke(cls, ns, banner): # pragma: nocover """ :param ns: local namespace :param banner: interactive shell startup banner Embed an interactive ipython shell. Try the InteractiveShellEmbed API first, fall back on IPShellEmbed for older IPython versions. """ ...
[ "def", "invoke", "(", "cls", ",", "ns", ",", "banner", ")", ":", "# pragma: nocover", "try", ":", "from", "IPython", ".", "frontend", ".", "terminal", ".", "embed", "import", "(", "InteractiveShellEmbed", ")", "# try and load their default profile", "from", "IPy...
:param ns: local namespace :param banner: interactive shell startup banner Embed an interactive ipython shell. Try the InteractiveShellEmbed API first, fall back on IPShellEmbed for older IPython versions.
[ ":", "param", "ns", ":", "local", "namespace", ":", "param", "banner", ":", "interactive", "shell", "startup", "banner" ]
python
train
PythonCharmers/python-future
src/future/backports/urllib/request.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/urllib/request.py#L1878-L1892
def http_error(self, url, fp, errcode, errmsg, headers, data=None): """Handle http errors. Derived class can override this, or provide specific handlers named http_error_DDD where DDD is the 3-digit error code.""" # First check if there's a specific handler for this error name =...
[ "def", "http_error", "(", "self", ",", "url", ",", "fp", ",", "errcode", ",", "errmsg", ",", "headers", ",", "data", "=", "None", ")", ":", "# First check if there's a specific handler for this error", "name", "=", "'http_error_%d'", "%", "errcode", "if", "hasat...
Handle http errors. Derived class can override this, or provide specific handlers named http_error_DDD where DDD is the 3-digit error code.
[ "Handle", "http", "errors", "." ]
python
train
getsentry/sentry-python
sentry_sdk/utils.py
https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L182-L189
def store_api_url(self): """Returns the API url for storing events.""" return "%s://%s%sapi/%s/store/" % ( self.scheme, self.host, self.path, self.project_id, )
[ "def", "store_api_url", "(", "self", ")", ":", "return", "\"%s://%s%sapi/%s/store/\"", "%", "(", "self", ".", "scheme", ",", "self", ".", "host", ",", "self", ".", "path", ",", "self", ".", "project_id", ",", ")" ]
Returns the API url for storing events.
[ "Returns", "the", "API", "url", "for", "storing", "events", "." ]
python
train
fabioz/PyDev.Debugger
_pydev_bundle/pydev_override.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_override.py#L1-L21
def overrides(method): ''' Meant to be used as class B: @overrides(A.m1) def m1(self): pass ''' def wrapper(func): if func.__name__ != method.__name__: msg = "Wrong @override: %r expected, but overwriting %r." msg = msg % (func.__name_...
[ "def", "overrides", "(", "method", ")", ":", "def", "wrapper", "(", "func", ")", ":", "if", "func", ".", "__name__", "!=", "method", ".", "__name__", ":", "msg", "=", "\"Wrong @override: %r expected, but overwriting %r.\"", "msg", "=", "msg", "%", "(", "func...
Meant to be used as class B: @overrides(A.m1) def m1(self): pass
[ "Meant", "to", "be", "used", "as", "class", "B", ":" ]
python
train
ff0000/scarlet
scarlet/cms/sites.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L126-L140
def unregister(self, slug): """ Unregisters the given url. If a slug isn't already registered, this will raise NotRegistered. """ if slug not in self._registry: raise NotRegistered('The slug %s is not registered' % slug) bundle = self._registry[slug] ...
[ "def", "unregister", "(", "self", ",", "slug", ")", ":", "if", "slug", "not", "in", "self", ".", "_registry", ":", "raise", "NotRegistered", "(", "'The slug %s is not registered'", "%", "slug", ")", "bundle", "=", "self", ".", "_registry", "[", "slug", "]"...
Unregisters the given url. If a slug isn't already registered, this will raise NotRegistered.
[ "Unregisters", "the", "given", "url", "." ]
python
train
Unidata/MetPy
metpy/calc/tools.py
https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/calc/tools.py#L1366-L1377
def _abbrieviate_direction(ext_dir_str): """Convert extended (non-abbrievated) directions to abbrieviation.""" return (ext_dir_str .upper() .replace('_', '') .replace('-', '') .replace(' ', '') .replace('NORTH', 'N') .replace('EAST', 'E') ...
[ "def", "_abbrieviate_direction", "(", "ext_dir_str", ")", ":", "return", "(", "ext_dir_str", ".", "upper", "(", ")", ".", "replace", "(", "'_'", ",", "''", ")", ".", "replace", "(", "'-'", ",", "''", ")", ".", "replace", "(", "' '", ",", "''", ")", ...
Convert extended (non-abbrievated) directions to abbrieviation.
[ "Convert", "extended", "(", "non", "-", "abbrievated", ")", "directions", "to", "abbrieviation", "." ]
python
train
fumitoh/modelx
modelx/core/cells.py
https://github.com/fumitoh/modelx/blob/0180da34d052c44fb94dab9e115e218bbebfc9c3/modelx/core/cells.py#L28-L47
def convert_args(args, kwargs): """If args and kwargs contains Cells, Convert them to their values.""" found = False for arg in args: if isinstance(arg, Cells): found = True break if found: args = tuple( arg.value if isinstance(arg, Cells) else arg f...
[ "def", "convert_args", "(", "args", ",", "kwargs", ")", ":", "found", "=", "False", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "Cells", ")", ":", "found", "=", "True", "break", "if", "found", ":", "args", "=", "tuple", "(...
If args and kwargs contains Cells, Convert them to their values.
[ "If", "args", "and", "kwargs", "contains", "Cells", "Convert", "them", "to", "their", "values", "." ]
python
valid
kubernetes-client/python
kubernetes/client/apis/rbac_authorization_v1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/rbac_authorization_v1_api.py#L845-L871
def delete_collection_cluster_role_binding(self, **kwargs): """ delete collection of ClusterRoleBinding This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_collection_cluster_role_bindin...
[ "def", "delete_collection_cluster_role_binding", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "delete_collection_clus...
delete collection of ClusterRoleBinding This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_collection_cluster_role_binding(async_req=True) >>> result = thread.get() :param async_req bo...
[ "delete", "collection", "of", "ClusterRoleBinding", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread", "=", ...
python
train
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L735-L740
def simxReadCollision(clientID, collisionObjectHandle, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' collisionState = ct.c_ubyte() return c_ReadCollision(clientID, collisionObjectHandle, ct.byref(collisionState), operationMode), bool(co...
[ "def", "simxReadCollision", "(", "clientID", ",", "collisionObjectHandle", ",", "operationMode", ")", ":", "collisionState", "=", "ct", ".", "c_ubyte", "(", ")", "return", "c_ReadCollision", "(", "clientID", ",", "collisionObjectHandle", ",", "ct", ".", "byref", ...
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
treycucco/pyebnf
pyebnf/compiler.py
https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/compiler.py#L175-L196
def _get_rule_definition(self, rule): """Generates the source code for a rule.""" fmt = """def {rule_fxn_name}(self, text): {indent}\"\"\"{rule_source}\"\"\" {indent}self._attempting(text) {indent}return {rule_definition}(text){transform} """ fmt = self._clea...
[ "def", "_get_rule_definition", "(", "self", ",", "rule", ")", ":", "fmt", "=", "\"\"\"def {rule_fxn_name}(self, text):\n {indent}\\\"\\\"\\\"{rule_source}\\\"\\\"\\\"\n {indent}self._attempting(text)\n {indent}return {rule_definition}(text){transform}\n ...
Generates the source code for a rule.
[ "Generates", "the", "source", "code", "for", "a", "rule", "." ]
python
test
wakatime/wakatime
wakatime/packages/pygments/lexers/__init__.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/lexers/__init__.py#L152-L192
def find_lexer_class_for_filename(_fn, code=None): """Get a lexer for a filename. If multiple lexers match the filename pattern, use ``analyse_text()`` to figure out which one is more appropriate. Returns None if not found. """ matches = [] fn = basename(_fn) for modname, name, _, file...
[ "def", "find_lexer_class_for_filename", "(", "_fn", ",", "code", "=", "None", ")", ":", "matches", "=", "[", "]", "fn", "=", "basename", "(", "_fn", ")", "for", "modname", ",", "name", ",", "_", ",", "filenames", ",", "_", "in", "itervalues", "(", "L...
Get a lexer for a filename. If multiple lexers match the filename pattern, use ``analyse_text()`` to figure out which one is more appropriate. Returns None if not found.
[ "Get", "a", "lexer", "for", "a", "filename", "." ]
python
train
swimlane/swimlane-python
swimlane/core/fields/reference.py
https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/fields/reference.py#L138-L149
def get_swimlane(self): """Return list of record ids""" value = super(ReferenceField, self).get_swimlane() if value: ids = list(value.keys()) if self.multiselect: return ids return ids[0] return None
[ "def", "get_swimlane", "(", "self", ")", ":", "value", "=", "super", "(", "ReferenceField", ",", "self", ")", ".", "get_swimlane", "(", ")", "if", "value", ":", "ids", "=", "list", "(", "value", ".", "keys", "(", ")", ")", "if", "self", ".", "multi...
Return list of record ids
[ "Return", "list", "of", "record", "ids" ]
python
train
fhs/pyhdf
pyhdf/SD.py
https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1499-L1515
def nametoindex(self, sds_name): """Return the index number of a dataset given the dataset name. Args:: sds_name : dataset name Returns:: index number of the dataset C library equivalent : SDnametoindex """ ...
[ "def", "nametoindex", "(", "self", ",", "sds_name", ")", ":", "sds_idx", "=", "_C", ".", "SDnametoindex", "(", "self", ".", "_id", ",", "sds_name", ")", "_checkErr", "(", "'nametoindex'", ",", "sds_idx", ",", "'non existent SDS'", ")", "return", "sds_idx" ]
Return the index number of a dataset given the dataset name. Args:: sds_name : dataset name Returns:: index number of the dataset C library equivalent : SDnametoindex
[ "Return", "the", "index", "number", "of", "a", "dataset", "given", "the", "dataset", "name", "." ]
python
train
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/external.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L530-L541
def post_generate_identifier(request): """MNStorage.generateIdentifier(session, scheme[, fragment]) → Identifier.""" d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('field', 'scheme'),)) if request.POST['scheme'] != 'UUID': raise d1_common.types.exceptions.InvalidRequest( 0, 'O...
[ "def", "post_generate_identifier", "(", "request", ")", ":", "d1_gmn", ".", "app", ".", "views", ".", "assert_db", ".", "post_has_mime_parts", "(", "request", ",", "(", "(", "'field'", ",", "'scheme'", ")", ",", ")", ")", "if", "request", ".", "POST", "[...
MNStorage.generateIdentifier(session, scheme[, fragment]) → Identifier.
[ "MNStorage", ".", "generateIdentifier", "(", "session", "scheme", "[", "fragment", "]", ")", "→", "Identifier", "." ]
python
train
CityOfZion/neo-python-rpc
neorpc/Client.py
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L90-L101
def get_block(self, height_or_hash, id=None, endpoint=None): """ Look up a block by the height or hash of the block. Args: height_or_hash: (int or str) either the height of the desired block or its hash in the form '1e67372c158a4cfbb17b9ad3aaae77001a4247a00318e354c62e53b56af4006f' ...
[ "def", "get_block", "(", "self", ",", "height_or_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK", ",", "params", "=", "[", "height_or_hash", ",", "1", "]", ",", "id", "=",...
Look up a block by the height or hash of the block. Args: height_or_hash: (int or str) either the height of the desired block or its hash in the form '1e67372c158a4cfbb17b9ad3aaae77001a4247a00318e354c62e53b56af4006f' id: (int, optional) id to use for response tracking endpoin...
[ "Look", "up", "a", "block", "by", "the", "height", "or", "hash", "of", "the", "block", ".", "Args", ":", "height_or_hash", ":", "(", "int", "or", "str", ")", "either", "the", "height", "of", "the", "desired", "block", "or", "its", "hash", "in", "the"...
python
train
push-things/django-th
th_trello/my_trello.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/th_trello/my_trello.py#L171-L192
def auth(self, request): """ let's auth the user to the Service :param request: request object :return: callback url :rtype: string that contains the url to redirect after auth """ request_token = super(ServiceTrello, self).auth(request) ca...
[ "def", "auth", "(", "self", ",", "request", ")", ":", "request_token", "=", "super", "(", "ServiceTrello", ",", "self", ")", ".", "auth", "(", "request", ")", "callback_url", "=", "self", ".", "callback_url", "(", "request", ")", "# URL to redirect user to, ...
let's auth the user to the Service :param request: request object :return: callback url :rtype: string that contains the url to redirect after auth
[ "let", "s", "auth", "the", "user", "to", "the", "Service", ":", "param", "request", ":", "request", "object", ":", "return", ":", "callback", "url", ":", "rtype", ":", "string", "that", "contains", "the", "url", "to", "redirect", "after", "auth" ]
python
train
ArabellaTech/django-basic-cms
basic_cms/placeholders.py
https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/placeholders.py#L156-L188
def save(self, page, language, data, change, extra_data=None): """Actually save the placeholder data into the Content object.""" # if this placeholder is untranslated, we save everything # in the default language if self.untranslated: language = settings.PAGE_DEFAULT_LANGUAGE...
[ "def", "save", "(", "self", ",", "page", ",", "language", ",", "data", ",", "change", ",", "extra_data", "=", "None", ")", ":", "# if this placeholder is untranslated, we save everything", "# in the default language", "if", "self", ".", "untranslated", ":", "languag...
Actually save the placeholder data into the Content object.
[ "Actually", "save", "the", "placeholder", "data", "into", "the", "Content", "object", "." ]
python
train
edx/bok-choy
bok_choy/query.py
https://github.com/edx/bok-choy/blob/cdd0d423419fc0c49d56a9226533aa1490b60afc/bok_choy/query.py#L282-L309
def nth(self, index): """ Return a query that selects the element at `index` (starts from 0). If no elements are available, returns a query with no results. Example usage: .. code:: python >> q = Query(lambda: list(range(5))) >> q.nth(2).results ...
[ "def", "nth", "(", "self", ",", "index", ")", ":", "def", "_transform", "(", "xs", ")", ":", "# pylint: disable=missing-docstring, invalid-name", "try", ":", "return", "[", "next", "(", "islice", "(", "iter", "(", "xs", ")", ",", "index", ",", "None", ")...
Return a query that selects the element at `index` (starts from 0). If no elements are available, returns a query with no results. Example usage: .. code:: python >> q = Query(lambda: list(range(5))) >> q.nth(2).results [2] Args: index ...
[ "Return", "a", "query", "that", "selects", "the", "element", "at", "index", "(", "starts", "from", "0", ")", ".", "If", "no", "elements", "are", "available", "returns", "a", "query", "with", "no", "results", "." ]
python
train
nsavch/python-dpcolors
dpcolors/__init__.py
https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L328-L341
def to_irc(self, preserve_original=True): """ Convert to mIRC format :param preserve_original: if the current ColorString instance was created from mIRC text, then just return the original string :return: """ if preserve_original and self.original_type == '...
[ "def", "to_irc", "(", "self", ",", "preserve_original", "=", "True", ")", ":", "if", "preserve_original", "and", "self", ".", "original_type", "==", "'irc'", ":", "return", "self", ".", "original_bytes", "res", "=", "[", "]", "for", "i", "in", "self", "....
Convert to mIRC format :param preserve_original: if the current ColorString instance was created from mIRC text, then just return the original string :return:
[ "Convert", "to", "mIRC", "format", ":", "param", "preserve_original", ":", "if", "the", "current", "ColorString", "instance", "was", "created", "from", "mIRC", "text", "then", "just", "return", "the", "original", "string", ":", "return", ":" ]
python
train
PyCQA/astroid
astroid/node_classes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L1898-L1917
def postinit(self, target, annotation, simple, value=None): """Do some setup after initialisation. :param target: What is being assigned to. :type target: NodeNG :param annotation: The type annotation of what is being assigned to. :type: NodeNG :param simple: Whether :...
[ "def", "postinit", "(", "self", ",", "target", ",", "annotation", ",", "simple", ",", "value", "=", "None", ")", ":", "self", ".", "target", "=", "target", "self", ".", "annotation", "=", "annotation", "self", ".", "value", "=", "value", "self", ".", ...
Do some setup after initialisation. :param target: What is being assigned to. :type target: NodeNG :param annotation: The type annotation of what is being assigned to. :type: NodeNG :param simple: Whether :attr:`target` is a pure name or a complex statement. ...
[ "Do", "some", "setup", "after", "initialisation", "." ]
python
train
DavidMStraub/pylha
pylha/parse.py
https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L6-L13
def numval(token): """Return the numerical value of token.value if it is a number""" if token.type == 'INTEGER': return int(token.value) elif token.type == 'FLOAT': return float(token.value) else: return token.value
[ "def", "numval", "(", "token", ")", ":", "if", "token", ".", "type", "==", "'INTEGER'", ":", "return", "int", "(", "token", ".", "value", ")", "elif", "token", ".", "type", "==", "'FLOAT'", ":", "return", "float", "(", "token", ".", "value", ")", "...
Return the numerical value of token.value if it is a number
[ "Return", "the", "numerical", "value", "of", "token", ".", "value", "if", "it", "is", "a", "number" ]
python
train
ArchiveTeam/wpull
wpull/processor/coprocessor/phantomjs.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/processor/coprocessor/phantomjs.py#L247-L268
def _add_warc_action_log(self, path, url): '''Add the action log to the WARC file.''' _logger.debug('Adding action log record.') actions = [] with open(path, 'r', encoding='utf-8', errors='replace') as file: for line in file: actions.append(json.loads(line)) ...
[ "def", "_add_warc_action_log", "(", "self", ",", "path", ",", "url", ")", ":", "_logger", ".", "debug", "(", "'Adding action log record.'", ")", "actions", "=", "[", "]", "with", "open", "(", "path", ",", "'r'", ",", "encoding", "=", "'utf-8'", ",", "err...
Add the action log to the WARC file.
[ "Add", "the", "action", "log", "to", "the", "WARC", "file", "." ]
python
train
aliyun/aliyun-odps-python-sdk
odps/df/expr/merge.py
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/df/expr/merge.py#L897-L931
def concat(left, rights, distinct=False, axis=0): """ Concat collections. :param left: left collection :param rights: right collections, can be a DataFrame object or a list of DataFrames :param distinct: whether to remove duplicate entries. only available when axis == 0 :param axis: when axis =...
[ "def", "concat", "(", "left", ",", "rights", ",", "distinct", "=", "False", ",", "axis", "=", "0", ")", ":", "from", ".", ".", "utils", "import", "to_collection", "if", "isinstance", "(", "rights", ",", "Node", ")", ":", "rights", "=", "[", "rights",...
Concat collections. :param left: left collection :param rights: right collections, can be a DataFrame object or a list of DataFrames :param distinct: whether to remove duplicate entries. only available when axis == 0 :param axis: when axis == 0, the DataFrames are merged vertically, otherwise horizonta...
[ "Concat", "collections", "." ]
python
train
OpenKMIP/PyKMIP
kmip/services/kmip_client.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/services/kmip_client.py#L423-L503
def derive_key(self, object_type, unique_identifiers, derivation_method, derivation_parameters, template_attribute, credential=None): """ Derive a new key or secret data from an existing man...
[ "def", "derive_key", "(", "self", ",", "object_type", ",", "unique_identifiers", ",", "derivation_method", ",", "derivation_parameters", ",", "template_attribute", ",", "credential", "=", "None", ")", ":", "operation", "=", "Operation", "(", "OperationEnum", ".", ...
Derive a new key or secret data from an existing managed object. Args: object_type (ObjectType): An ObjectType enumeration specifying what type of object to create. Required. unique_identifiers (list): A list of strings specifying the unique IDs of the ex...
[ "Derive", "a", "new", "key", "or", "secret", "data", "from", "an", "existing", "managed", "object", "." ]
python
test