repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
h2oai/h2o-3
h2o-py/h2o/backend/connection.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/backend/connection.py#L448-L459
def session_id(self): """ Return the session id of the current connection. The session id is issued (through an API request) the first time it is requested, but no sooner. This is because generating a session id puts it into the DKV on the server, which effectively locks the cluster. On...
[ "def", "session_id", "(", "self", ")", ":", "if", "self", ".", "_session_id", "is", "None", ":", "req", "=", "self", ".", "request", "(", "\"POST /4/sessions\"", ")", "self", ".", "_session_id", "=", "req", ".", "get", "(", "\"session_key\"", ")", "or", ...
Return the session id of the current connection. The session id is issued (through an API request) the first time it is requested, but no sooner. This is because generating a session id puts it into the DKV on the server, which effectively locks the cluster. Once issued, the session id will sta...
[ "Return", "the", "session", "id", "of", "the", "current", "connection", "." ]
python
test
51.666667
sighingnow/parsec.py
src/parsec/__init__.py
https://github.com/sighingnow/parsec.py/blob/ed50e1e259142757470b925f8d20dfe5ad223af0/src/parsec/__init__.py#L567-L575
def one_of(s): '''Parser a char from specified string.''' @Parser def one_of_parser(text, index=0): if index < len(text) and text[index] in s: return Value.success(index + 1, text[index]) else: return Value.failure(index, 'one of {}'.format(s)) return one_of_parse...
[ "def", "one_of", "(", "s", ")", ":", "@", "Parser", "def", "one_of_parser", "(", "text", ",", "index", "=", "0", ")", ":", "if", "index", "<", "len", "(", "text", ")", "and", "text", "[", "index", "]", "in", "s", ":", "return", "Value", ".", "s...
Parser a char from specified string.
[ "Parser", "a", "char", "from", "specified", "string", "." ]
python
train
34.777778
not-na/peng3d
peng3d/gui/slider.py
https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/gui/slider.py#L422-L428
def p(self): """ Helper property containing the percentage this slider is "filled". This property is read-only. """ return (self.n-self.nmin)/max((self.nmax-self.nmin),1)
[ "def", "p", "(", "self", ")", ":", "return", "(", "self", ".", "n", "-", "self", ".", "nmin", ")", "/", "max", "(", "(", "self", ".", "nmax", "-", "self", ".", "nmin", ")", ",", "1", ")" ]
Helper property containing the percentage this slider is "filled". This property is read-only.
[ "Helper", "property", "containing", "the", "percentage", "this", "slider", "is", "filled", ".", "This", "property", "is", "read", "-", "only", "." ]
python
test
30.428571
saltstack/salt
salt/modules/bigip.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bigip.py#L956-L1020
def replace_pool_members(hostname, username, password, name, members): ''' A function to connect to a bigip device and replace members of an existing pool with new members. hostname The host/address of the bigip device username The iControl REST username password The iContro...
[ "def", "replace_pool_members", "(", "hostname", ",", "username", ",", "password", ",", "name", ",", "members", ")", ":", "payload", "=", "{", "}", "payload", "[", "'name'", "]", "=", "name", "#specify members if provided", "if", "members", "is", "not", "None...
A function to connect to a bigip device and replace members of an existing pool with new members. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the pool to modify members ...
[ "A", "function", "to", "connect", "to", "a", "bigip", "device", "and", "replace", "members", "of", "an", "existing", "pool", "with", "new", "members", "." ]
python
train
31.4
bitesofcode/projex
projex/xbuild/builder.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L906-L918
def licenseFile(self): """ Returns the license file for this builder. :return <str> """ if self._licenseFile: return self._licenseFile elif self._license: f = projex.resources.find('licenses/{0}.txt'.format(self.license())) ...
[ "def", "licenseFile", "(", "self", ")", ":", "if", "self", ".", "_licenseFile", ":", "return", "self", ".", "_licenseFile", "elif", "self", ".", "_license", ":", "f", "=", "projex", ".", "resources", ".", "find", "(", "'licenses/{0}.txt'", ".", "format", ...
Returns the license file for this builder. :return <str>
[ "Returns", "the", "license", "file", "for", "this", "builder", ".", ":", "return", "<str", ">" ]
python
train
27.153846
xu2243051/easyui-menu
easyui/mixins/view_mixins.py
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L50-L56
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIUpdateView, self).get_template_names() names.append('easyui/form.html') return names
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "EasyUIUpdateView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/form.html'", ")", "return", "names" ]
datagrid的默认模板
[ "datagrid的默认模板" ]
python
valid
28.285714
ardydedase/apiwrapper
apiwrapper/apiwrapper.py
https://github.com/ardydedase/apiwrapper/blob/dd477e9f6fc5706b7a29c61a466cd63427d7c517/apiwrapper/apiwrapper.py#L89-L143
def make_request(self, url, method='get', headers=None, data=None, callback=None, errors=STRICT, verify=False, timeout=None, **params): """ Reusable method for performing requests. :param url - URL to request :param method - request method, default is 'get' :...
[ "def", "make_request", "(", "self", ",", "url", ",", "method", "=", "'get'", ",", "headers", "=", "None", ",", "data", "=", "None", ",", "callback", "=", "None", ",", "errors", "=", "STRICT", ",", "verify", "=", "False", ",", "timeout", "=", "None", ...
Reusable method for performing requests. :param url - URL to request :param method - request method, default is 'get' :param headers - request headers :param data - post data :param callback - callback to be applied to response, default callback will par...
[ "Reusable", "method", "for", "performing", "requests", ".", ":", "param", "url", "-", "URL", "to", "request", ":", "param", "method", "-", "request", "method", "default", "is", "get", ":", "param", "headers", "-", "request", "headers", ":", "param", "data"...
python
valid
46.618182
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxglobalworkflow.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxglobalworkflow.py#L275-L311
def run(self, workflow_input, *args, **kwargs): ''' :param workflow_input: Dictionary of the workflow's input arguments; see below for more details :type workflow_input: dict :param instance_type: Instance type on which all stages' jobs will be run, or a dict mapping function names to in...
[ "def", "run", "(", "self", ",", "workflow_input", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "DXGlobalWorkflow", ",", "self", ")", ".", "run", "(", "workflow_input", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
:param workflow_input: Dictionary of the workflow's input arguments; see below for more details :type workflow_input: dict :param instance_type: Instance type on which all stages' jobs will be run, or a dict mapping function names to instance types. These may be overridden on a per-stage basis if stage_...
[ ":", "param", "workflow_input", ":", "Dictionary", "of", "the", "workflow", "s", "input", "arguments", ";", "see", "below", "for", "more", "details", ":", "type", "workflow_input", ":", "dict", ":", "param", "instance_type", ":", "Instance", "type", "on", "w...
python
train
61.864865
tornadoweb/tornado
tornado/iostream.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L198-L226
def advance(self, size: int) -> None: """ Advance the current buffer position by ``size`` bytes. """ assert 0 < size <= self._size self._size -= size pos = self._first_pos buffers = self._buffers while buffers and size > 0: is_large, b = buffe...
[ "def", "advance", "(", "self", ",", "size", ":", "int", ")", "->", "None", ":", "assert", "0", "<", "size", "<=", "self", ".", "_size", "self", ".", "_size", "-=", "size", "pos", "=", "self", ".", "_first_pos", "buffers", "=", "self", ".", "_buffer...
Advance the current buffer position by ``size`` bytes.
[ "Advance", "the", "current", "buffer", "position", "by", "size", "bytes", "." ]
python
train
29.206897
pgmpy/pgmpy
pgmpy/models/FactorGraph.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/FactorGraph.py#L72-L93
def add_edge(self, u, v, **kwargs): """ Add an edge between variable_node and factor_node. Parameters ---------- u, v: nodes Nodes can be any hashable Python object. Examples -------- >>> from pgmpy.models import FactorGraph >>> G = F...
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "*", "*", "kwargs", ")", ":", "if", "u", "!=", "v", ":", "super", "(", "FactorGraph", ",", "self", ")", ".", "add_edge", "(", "u", ",", "v", ",", "*", "*", "kwargs", ")", "else", ":", ...
Add an edge between variable_node and factor_node. Parameters ---------- u, v: nodes Nodes can be any hashable Python object. Examples -------- >>> from pgmpy.models import FactorGraph >>> G = FactorGraph() >>> G.add_nodes_from(['a', 'b', 'c'...
[ "Add", "an", "edge", "between", "variable_node", "and", "factor_node", "." ]
python
train
30.590909
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L163-L181
def _chunk_filter(self, extensions): """ Create a filter from the extensions and ignore files """ if isinstance(extensions, six.string_types): extensions = extensions.split() def _filter(chunk): """ Exclusion filter """ name = chunk['name'] if ext...
[ "def", "_chunk_filter", "(", "self", ",", "extensions", ")", ":", "if", "isinstance", "(", "extensions", ",", "six", ".", "string_types", ")", ":", "extensions", "=", "extensions", ".", "split", "(", ")", "def", "_filter", "(", "chunk", ")", ":", "\"\"\"...
Create a filter from the extensions and ignore files
[ "Create", "a", "filter", "from", "the", "extensions", "and", "ignore", "files" ]
python
train
38.105263
ArchiveTeam/wpull
wpull/protocol/ftp/client.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/protocol/ftp/client.py#L385-L394
def _fetch_size(self, request: Request) -> int: '''Return size of file. Coroutine. ''' try: size = yield from self._commander.size(request.file_path) return size except FTPServerError: return
[ "def", "_fetch_size", "(", "self", ",", "request", ":", "Request", ")", "->", "int", ":", "try", ":", "size", "=", "yield", "from", "self", ".", "_commander", ".", "size", "(", "request", ".", "file_path", ")", "return", "size", "except", "FTPServerError...
Return size of file. Coroutine.
[ "Return", "size", "of", "file", "." ]
python
train
25.9
bapakode/OmMongo
ommongo/fields/fields.py
https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/fields/fields.py#L583-L586
def wrap(self, value): ''' Validates ``value`` and wraps it with ``ComputedField.computed_type``''' self.validate_wrap(value) return self.computed_type.wrap(value)
[ "def", "wrap", "(", "self", ",", "value", ")", ":", "self", ".", "validate_wrap", "(", "value", ")", "return", "self", ".", "computed_type", ".", "wrap", "(", "value", ")" ]
Validates ``value`` and wraps it with ``ComputedField.computed_type``
[ "Validates", "value", "and", "wraps", "it", "with", "ComputedField", ".", "computed_type" ]
python
train
46
dw/mitogen
ansible_mitogen/connection.py
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/connection.py#L571-L596
def _spec_from_via(self, proxied_inventory_name, via_spec): """ Produce a dict connection specifiction given a string `via_spec`, of the form `[[become_method:]become_user@]inventory_hostname`. """ become_user, _, inventory_name = via_spec.rpartition('@') become_method, _...
[ "def", "_spec_from_via", "(", "self", ",", "proxied_inventory_name", ",", "via_spec", ")", ":", "become_user", ",", "_", ",", "inventory_name", "=", "via_spec", ".", "rpartition", "(", "'@'", ")", "become_method", ",", "_", ",", "become_user", "=", "become_use...
Produce a dict connection specifiction given a string `via_spec`, of the form `[[become_method:]become_user@]inventory_hostname`.
[ "Produce", "a", "dict", "connection", "specifiction", "given", "a", "string", "via_spec", "of", "the", "form", "[[", "become_method", ":", "]", "become_user" ]
python
train
41.730769
Spinmob/spinmob
egg/_gui.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_gui.py#L1862-L1880
def unblock_user_signals(self, name, ignore_error=False): """ Reconnects the user-defined signals for the specified parameter name (blocked with "block_user_signal_changed") Note this only affects those connections made with connect_signal_changed(), and I do not recom...
[ "def", "unblock_user_signals", "(", "self", ",", "name", ",", "ignore_error", "=", "False", ")", ":", "x", "=", "self", ".", "_find_parameter", "(", "name", ".", "split", "(", "\"/\"", ")", ",", "quiet", "=", "ignore_error", ")", "# if it pooped.", "if", ...
Reconnects the user-defined signals for the specified parameter name (blocked with "block_user_signal_changed") Note this only affects those connections made with connect_signal_changed(), and I do not recommend adding new connections while they're blocked!
[ "Reconnects", "the", "user", "-", "defined", "signals", "for", "the", "specified", "parameter", "name", "(", "blocked", "with", "block_user_signal_changed", ")", "Note", "this", "only", "affects", "those", "connections", "made", "with", "connect_signal_changed", "()...
python
train
37.263158
gem/oq-engine
openquake/hazardlib/source/point.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/source/point.py#L29-L67
def _get_rupture_dimensions(src, mag, nodal_plane): """ Calculate and return the rupture length and width for given magnitude ``mag`` and nodal plane. :param src: a PointSource, AreaSource or MultiPointSource :param mag: a magnitude :param nodal_plane: Instance of :class...
[ "def", "_get_rupture_dimensions", "(", "src", ",", "mag", ",", "nodal_plane", ")", ":", "area", "=", "src", ".", "magnitude_scaling_relationship", ".", "get_median_area", "(", "mag", ",", "nodal_plane", ".", "rake", ")", "rup_length", "=", "math", ".", "sqrt",...
Calculate and return the rupture length and width for given magnitude ``mag`` and nodal plane. :param src: a PointSource, AreaSource or MultiPointSource :param mag: a magnitude :param nodal_plane: Instance of :class:`openquake.hazardlib.geo.nodalplane.NodalPlane`. :returns: ...
[ "Calculate", "and", "return", "the", "rupture", "length", "and", "width", "for", "given", "magnitude", "mag", "and", "nodal", "plane", "." ]
python
train
40.102564
MosesSymeonidis/aggregation_builder
aggregation_builder/operators/array.py
https://github.com/MosesSymeonidis/aggregation_builder/blob/a1f4b580401d400c53206e9c020e413166254274/aggregation_builder/operators/array.py#L146-L156
def SLICE(array, n, position=None): """ Returns a subset of an array. See https://docs.mongodb.com/manual/reference/operator/aggregation/slice/ for more details :param array: Any valid expression as long as it resolves to an array. :param n: Any valid expression as long as it resolves to an inte...
[ "def", "SLICE", "(", "array", ",", "n", ",", "position", "=", "None", ")", ":", "return", "{", "'$slice'", ":", "[", "array", ",", "position", ",", "n", "]", "}", "if", "position", "is", "not", "None", "else", "{", "'$slice'", ":", "[", "array", ...
Returns a subset of an array. See https://docs.mongodb.com/manual/reference/operator/aggregation/slice/ for more details :param array: Any valid expression as long as it resolves to an array. :param n: Any valid expression as long as it resolves to an integer. :param position: Optional. Any valid ex...
[ "Returns", "a", "subset", "of", "an", "array", ".", "See", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", "/", "reference", "/", "operator", "/", "aggregation", "/", "slice", "/", "for", "more", "details", ":", "param", "array",...
python
train
49.272727
pgmpy/pgmpy
pgmpy/sampling/Sampling.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L305-L337
def _get_kernel_from_markov_model(self, model): """ Computes the Gibbs transition models from a Markov Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: MarkovModel ...
[ "def", "_get_kernel_from_markov_model", "(", "self", ",", "model", ")", ":", "self", ".", "variables", "=", "np", ".", "array", "(", "model", ".", "nodes", "(", ")", ")", "factors_dict", "=", "{", "var", ":", "[", "]", "for", "var", "in", "self", "."...
Computes the Gibbs transition models from a Markov Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: MarkovModel The model from which probabilities will be computed.
[ "Computes", "the", "Gibbs", "transition", "models", "from", "a", "Markov", "Network", ".", "Probabilistic", "Graphical", "Model", "Principles", "and", "Techniques", "Koller", "and", "Friedman", "Section", "12", ".", "3", ".", "3", "pp", "512", "-", "513", "....
python
train
47.363636
ampl/amplpy
amplpy/errorhandler.py
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/errorhandler.py#L26-L31
def warning(self, amplexception): """ Receives notification of a warning. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Warning:\n{:s}'.format(msg))
[ "def", "warning", "(", "self", ",", "amplexception", ")", ":", "msg", "=", "'\\t'", "+", "str", "(", "amplexception", ")", ".", "replace", "(", "'\\n'", ",", "'\\n\\t'", ")", "print", "(", "'Warning:\\n{:s}'", ".", "format", "(", "msg", ")", ")" ]
Receives notification of a warning.
[ "Receives", "notification", "of", "a", "warning", "." ]
python
train
33.333333
wilson-eft/wilson
wilson/translate/wet.py
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L987-L1013
def Fierz_to_JMS_lep(C, ddll): """From Fierz to semileptonic JMS basis for Class V. `ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc.""" if ddll[:2] == 'uc': s = str(uflav[ddll[0]] + 1) b = str(uflav[ddll[1]] + 1) q = 'u' else: s = str(dflav[ddll[0]] + 1) ...
[ "def", "Fierz_to_JMS_lep", "(", "C", ",", "ddll", ")", ":", "if", "ddll", "[", ":", "2", "]", "==", "'uc'", ":", "s", "=", "str", "(", "uflav", "[", "ddll", "[", "0", "]", "]", "+", "1", ")", "b", "=", "str", "(", "uflav", "[", "ddll", "[",...
From Fierz to semileptonic JMS basis for Class V. `ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc.
[ "From", "Fierz", "to", "semileptonic", "JMS", "basis", "for", "Class", "V", ".", "ddll", "should", "be", "of", "the", "form", "sbl_enu_tau", "dbl_munu_e", "etc", "." ]
python
train
57
mitsei/dlkit
dlkit/records/assessment/qti/extended_text_interaction.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/qti/extended_text_interaction.py#L29-L37
def _init_map(self): """stub""" self.my_osid_object_form._my_map['maxStrings'] = \ self._max_strings_metadata['default_integer_values'][0] self.my_osid_object_form._my_map['expectedLength'] = \ self._expected_length_metadata['default_integer_values'][0] self.my_os...
[ "def", "_init_map", "(", "self", ")", ":", "self", ".", "my_osid_object_form", ".", "_my_map", "[", "'maxStrings'", "]", "=", "self", ".", "_max_strings_metadata", "[", "'default_integer_values'", "]", "[", "0", "]", "self", ".", "my_osid_object_form", ".", "_...
stub
[ "stub" ]
python
train
55.444444
merll/docker-map
dockermap/map/client.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L276-L292
def restart(self, container, instances=None, map_name=None, **kwargs): """ Restarts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to stop. If not specified, will restart all instances as...
[ "def", "restart", "(", "self", ",", "container", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "run_actions", "(", "'restart'", ",", "container", ",", "instances", "=", "instances",...
Restarts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to stop. If not specified, will restart all instances as specified in the configuration (or just one default instance). :type inst...
[ "Restarts", "instances", "for", "a", "container", "configuration", "." ]
python
train
56.764706
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/quaternion.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L87-L103
def exp(self): """ Returns the exponent of the quaternion. (not tested) """ # Init vecNorm = self.x**2 + self.y**2 + self.z**2 wPart = np.exp(self.w) q = Quaternion() # Calculate q.w = wPart * np.cos(vecNorm) q.x ...
[ "def", "exp", "(", "self", ")", ":", "# Init", "vecNorm", "=", "self", ".", "x", "**", "2", "+", "self", ".", "y", "**", "2", "+", "self", ".", "z", "**", "2", "wPart", "=", "np", ".", "exp", "(", "self", ".", "w", ")", "q", "=", "Quaternio...
Returns the exponent of the quaternion. (not tested)
[ "Returns", "the", "exponent", "of", "the", "quaternion", ".", "(", "not", "tested", ")" ]
python
train
28.705882
limodou/uliweb
uliweb/orm/__init__.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L2959-L2967
def clear(self, *objs): """ Clear the third relationship table, but not the ModelA or ModelB """ if objs: keys = get_objs_columns(objs) self.do_(self.model.table.delete(self.condition & self.model.table.c[self.model._primary_field].in_(keys))) else: ...
[ "def", "clear", "(", "self", ",", "*", "objs", ")", ":", "if", "objs", ":", "keys", "=", "get_objs_columns", "(", "objs", ")", "self", ".", "do_", "(", "self", ".", "model", ".", "table", ".", "delete", "(", "self", ".", "condition", "&", "self", ...
Clear the third relationship table, but not the ModelA or ModelB
[ "Clear", "the", "third", "relationship", "table", "but", "not", "the", "ModelA", "or", "ModelB" ]
python
train
40.777778
seatgeek/businesstime
businesstime/__init__.py
https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L80-L94
def iterbusinessdays(self, d1, d2): """ Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays """ assert d2 >= d1 if d1.date() == d2.date() and d2.time() < self.business_hours[0]: return first = True for dt in self.iterdays(d1,...
[ "def", "iterbusinessdays", "(", "self", ",", "d1", ",", "d2", ")", ":", "assert", "d2", ">=", "d1", "if", "d1", ".", "date", "(", ")", "==", "d2", ".", "date", "(", ")", "and", "d2", ".", "time", "(", ")", "<", "self", ".", "business_hours", "[...
Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays
[ "Date", "iterator", "returning", "dates", "in", "d1", "<", "=", "x", "<", "d2", "excluding", "weekends", "and", "holidays" ]
python
train
36.266667
skyfielders/python-skyfield
skyfield/timelib.py
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L425-L462
def utc_datetime_and_leap_second(self): """Convert to a Python ``datetime`` in UTC, plus a leap second value. Convert this time to a `datetime`_ object and a leap second:: dt, leap_second = t.utc_datetime_and_leap_second() If the third-party `pytz`_ package is available, then its ...
[ "def", "utc_datetime_and_leap_second", "(", "self", ")", ":", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", "=", "self", ".", "_utc_tuple", "(", "_half_millisecond", ")", "second", ",", "fraction", "=", "divmod", "(", "second...
Convert to a Python ``datetime`` in UTC, plus a leap second value. Convert this time to a `datetime`_ object and a leap second:: dt, leap_second = t.utc_datetime_and_leap_second() If the third-party `pytz`_ package is available, then its ``utc`` timezone will be used as the timezo...
[ "Convert", "to", "a", "Python", "datetime", "in", "UTC", "plus", "a", "leap", "second", "value", "." ]
python
train
44.289474
christophertbrown/bioscripts
ctbBio/genome_variation.py
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L186-L213
def parse_gbk(gbks): """ parse gbk file """ for gbk in gbks: for record in SeqIO.parse(open(gbk), 'genbank'): for feature in record.features: if feature.type == 'gene': try: locus = feature.qualifiers['locus_tag'][0] ...
[ "def", "parse_gbk", "(", "gbks", ")", ":", "for", "gbk", "in", "gbks", ":", "for", "record", "in", "SeqIO", ".", "parse", "(", "open", "(", "gbk", ")", ",", "'genbank'", ")", ":", "for", "feature", "in", "record", ".", "features", ":", "if", "featu...
parse gbk file
[ "parse", "gbk", "file" ]
python
train
39.25
marteinn/AtomicPress
atomicpress/utils/files.py
https://github.com/marteinn/AtomicPress/blob/b8a0ca9c9c327f062833fc4a401a8ac0baccf6d1/atomicpress/utils/files.py#L16-L36
def generate_image_from_url(url=None, timeout=30): """ Downloads and saves a image from url into a file. """ file_name = posixpath.basename(url) img_tmp = NamedTemporaryFile(delete=True) try: response = requests.get(url, timeout=timeout) response.raise_for_status() except E...
[ "def", "generate_image_from_url", "(", "url", "=", "None", ",", "timeout", "=", "30", ")", ":", "file_name", "=", "posixpath", ".", "basename", "(", "url", ")", "img_tmp", "=", "NamedTemporaryFile", "(", "delete", "=", "True", ")", "try", ":", "response", ...
Downloads and saves a image from url into a file.
[ "Downloads", "and", "saves", "a", "image", "from", "url", "into", "a", "file", "." ]
python
train
22.809524
librosa/librosa
librosa/core/pitch.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/pitch.py#L17-L93
def estimate_tuning(y=None, sr=22050, S=None, n_fft=2048, resolution=0.01, bins_per_octave=12, **kwargs): '''Estimate the tuning of an audio time series or spectrogram input. Parameters ---------- y: np.ndarray [shape=(n,)] or None audio signal sr : number > 0 [scalar] ...
[ "def", "estimate_tuning", "(", "y", "=", "None", ",", "sr", "=", "22050", ",", "S", "=", "None", ",", "n_fft", "=", "2048", ",", "resolution", "=", "0.01", ",", "bins_per_octave", "=", "12", ",", "*", "*", "kwargs", ")", ":", "pitch", ",", "mag", ...
Estimate the tuning of an audio time series or spectrogram input. Parameters ---------- y: np.ndarray [shape=(n,)] or None audio signal sr : number > 0 [scalar] audio sampling rate of `y` S: np.ndarray [shape=(d, t)] or None magnitude or power spectrogram n_fft : int ...
[ "Estimate", "the", "tuning", "of", "an", "audio", "time", "series", "or", "spectrogram", "input", "." ]
python
test
29.311688
kytos/python-openflow
pyof/foundation/network_types.py
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/network_types.py#L580-L615
def unpack(self, buff, offset=0): """Unpack a binary struct into this object's attributes. Return the values instead of the lib's basic types. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.Unpa...
[ "def", "unpack", "(", "self", ",", "buff", ",", "offset", "=", "0", ")", ":", "super", "(", ")", ".", "unpack", "(", "buff", ",", "offset", ")", "self", ".", "version", "=", "self", ".", "_version_ihl", ".", "value", ">>", "4", "self", ".", "ihl"...
Unpack a binary struct into this object's attributes. Return the values instead of the lib's basic types. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: If unpack fails.
[ "Unpack", "a", "binary", "struct", "into", "this", "object", "s", "attributes", "." ]
python
train
34.694444
lrgar/scope
scope/scope.py
https://github.com/lrgar/scope/blob/f1c5815b0efd6be75ce54370d69e9b7eca854844/scope/scope.py#L112-L116
def set_children(self, value, defined): """Set the children of the object.""" self.children = value self.children_defined = defined return self
[ "def", "set_children", "(", "self", ",", "value", ",", "defined", ")", ":", "self", ".", "children", "=", "value", "self", ".", "children_defined", "=", "defined", "return", "self" ]
Set the children of the object.
[ "Set", "the", "children", "of", "the", "object", "." ]
python
train
34.2
gwastro/pycbc-glue
pycbc_glue/ligolw/dbtables.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/dbtables.py#L325-L386
def put_connection_filename(filename, working_filename, verbose = False): """ This function reverses the effect of a previous call to get_connection_filename(), restoring the working copy to its original location if the two are different. This function should always be called after calling get_connection_filename...
[ "def", "put_connection_filename", "(", "filename", ",", "working_filename", ",", "verbose", "=", "False", ")", ":", "if", "working_filename", "!=", "filename", ":", "# initialize SIGTERM and SIGTSTP trap", "deferred_signals", "=", "[", "]", "def", "newsigterm", "(", ...
This function reverses the effect of a previous call to get_connection_filename(), restoring the working copy to its original location if the two are different. This function should always be called after calling get_connection_filename() when the file is no longer in use. During the move operation, this functio...
[ "This", "function", "reverses", "the", "effect", "of", "a", "previous", "call", "to", "get_connection_filename", "()", "restoring", "the", "working", "copy", "to", "its", "original", "location", "if", "the", "two", "are", "different", ".", "This", "function", ...
python
train
38.5
michaelbrooks/twitter-monitor
twitter_monitor/checker.py
https://github.com/michaelbrooks/twitter-monitor/blob/3f99cea8492d3bdaa16f28a038bc8cf6022222ba/twitter_monitor/checker.py#L33-L57
def check(self): """ Checks if the list of tracked terms has changed. Returns True if changed, otherwise False. """ new_tracking_terms = self.update_tracking_terms() terms_changed = False # any deleted terms? if self._tracking_terms_set > new_tracking_t...
[ "def", "check", "(", "self", ")", ":", "new_tracking_terms", "=", "self", ".", "update_tracking_terms", "(", ")", "terms_changed", "=", "False", "# any deleted terms?", "if", "self", ".", "_tracking_terms_set", ">", "new_tracking_terms", ":", "logging", ".", "debu...
Checks if the list of tracked terms has changed. Returns True if changed, otherwise False.
[ "Checks", "if", "the", "list", "of", "tracked", "terms", "has", "changed", ".", "Returns", "True", "if", "changed", "otherwise", "False", "." ]
python
train
30.12
Telefonica/toolium
toolium/behave/env_utils.py
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/behave/env_utils.py#L249-L260
def execute_after_scenario_steps(self, context): """ actions after each scenario :param context: It’s a clever place where you and behave can store information to share around, automatically managed by behave. """ if not self.feature_error and not self.scenario_error: ...
[ "def", "execute_after_scenario_steps", "(", "self", ",", "context", ")", ":", "if", "not", "self", ".", "feature_error", "and", "not", "self", ".", "scenario_error", ":", "self", ".", "__execute_steps_by_action", "(", "context", ",", "ACTIONS_AFTER_SCENARIO", ")",...
actions after each scenario :param context: It’s a clever place where you and behave can store information to share around, automatically managed by behave.
[ "actions", "after", "each", "scenario", ":", "param", "context", ":", "It’s", "a", "clever", "place", "where", "you", "and", "behave", "can", "store", "information", "to", "share", "around", "automatically", "managed", "by", "behave", "." ]
python
train
52.416667
charlierguo/gmail
gmail/utf.py
https://github.com/charlierguo/gmail/blob/4626823d3fbf159d242a50b33251576aeddbd9ad/gmail/utf.py#L60-L89
def decode(s): """Decode a folder name from IMAP modified UTF-7 encoding to unicode. Despite the function's name, the input may still be a unicode string. If the input is bytes, it's first decoded to unicode. """ if isinstance(s, binary_type): s = s.decode('latin-1') if not isinstance(s...
[ "def", "decode", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "binary_type", ")", ":", "s", "=", "s", ".", "decode", "(", "'latin-1'", ")", "if", "not", "isinstance", "(", "s", ",", "text_type", ")", ":", "return", "s", "r", "=", "[", ...
Decode a folder name from IMAP modified UTF-7 encoding to unicode. Despite the function's name, the input may still be a unicode string. If the input is bytes, it's first decoded to unicode.
[ "Decode", "a", "folder", "name", "from", "IMAP", "modified", "UTF", "-", "7", "encoding", "to", "unicode", "." ]
python
train
26.066667
saltstack/salt
salt/modules/zpool.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zpool.py#L1151-L1193
def export(*pools, **kwargs): ''' .. versionadded:: 2015.5.0 Export storage pools pools : string One or more storage pools to export force : boolean Force export of storage pools CLI Example: .. code-block:: bash salt '*' zpool.export myzpool ... [force=True|Fal...
[ "def", "export", "(", "*", "pools", ",", "*", "*", "kwargs", ")", ":", "## Configure pool", "# NOTE: initialize the defaults", "flags", "=", "[", "]", "targets", "=", "[", "]", "# NOTE: set extra config based on kwargs", "if", "kwargs", ".", "get", "(", "'force'...
.. versionadded:: 2015.5.0 Export storage pools pools : string One or more storage pools to export force : boolean Force export of storage pools CLI Example: .. code-block:: bash salt '*' zpool.export myzpool ... [force=True|False] salt '*' zpool.export myzpool2...
[ "..", "versionadded", "::", "2015", ".", "5", ".", "0" ]
python
train
21.604651
cosven/feeluown-core
fuocore/utils.py
https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/utils.py#L43-L69
def find_previous(element, l): """ find previous element in a sorted list >>> find_previous(0, [0]) 0 >>> find_previous(2, [1, 1, 3]) 1 >>> find_previous(0, [1, 2]) >>> find_previous(1.5, [1, 2]) 1 >>> find_previous(3, [1, 2]) 2 """ length = len(l) for index, cur...
[ "def", "find_previous", "(", "element", ",", "l", ")", ":", "length", "=", "len", "(", "l", ")", "for", "index", ",", "current", "in", "enumerate", "(", "l", ")", ":", "# current is the last element", "if", "length", "-", "1", "==", "index", ":", "retu...
find previous element in a sorted list >>> find_previous(0, [0]) 0 >>> find_previous(2, [1, 1, 3]) 1 >>> find_previous(0, [1, 2]) >>> find_previous(1.5, [1, 2]) 1 >>> find_previous(3, [1, 2]) 2
[ "find", "previous", "element", "in", "a", "sorted", "list" ]
python
train
22.555556
ThreatConnect-Inc/tcex
tcex/tcex_bin.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin.py#L135-L151
def install_json_params(self, ij=None): """Return install.json params in a dict with name param as key. Args: ij (dict, optional): Defaults to None. The install.json contents. Returns: dict: A dictionary containing the install.json input params with name as key. ...
[ "def", "install_json_params", "(", "self", ",", "ij", "=", "None", ")", ":", "if", "self", ".", "_install_json_params", "is", "None", "or", "ij", "is", "not", "None", ":", "self", ".", "_install_json_params", "=", "{", "}", "# TODO: support for projects with m...
Return install.json params in a dict with name param as key. Args: ij (dict, optional): Defaults to None. The install.json contents. Returns: dict: A dictionary containing the install.json input params with name as key.
[ "Return", "install", ".", "json", "params", "in", "a", "dict", "with", "name", "param", "as", "key", "." ]
python
train
42.882353
trevisanj/a99
a99/textinterface.py
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/textinterface.py#L267-L281
def format_box(title, ch="*"): """ Encloses title in a box. Result is a list >>> for line in format_box("Today's TODO list"): ... print(line) ************************* *** Today's TODO list *** ************************* """ lt = len(title) return [(ch * (lt + 8)),...
[ "def", "format_box", "(", "title", ",", "ch", "=", "\"*\"", ")", ":", "lt", "=", "len", "(", "title", ")", "return", "[", "(", "ch", "*", "(", "lt", "+", "8", ")", ")", ",", "(", "ch", "*", "3", "+", "\" \"", "+", "title", "+", "\" \"", "+"...
Encloses title in a box. Result is a list >>> for line in format_box("Today's TODO list"): ... print(line) ************************* *** Today's TODO list *** *************************
[ "Encloses", "title", "in", "a", "box", ".", "Result", "is", "a", "list", ">>>", "for", "line", "in", "format_box", "(", "Today", "s", "TODO", "list", ")", ":", "...", "print", "(", "line", ")", "*************************", "***", "Today", "s", "TODO", ...
python
train
26.733333
quantumlib/Cirq
cirq/linalg/decompositions.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L101-L145
def _perp_eigendecompose(matrix: np.ndarray, rtol: float = 1e-5, atol: float = 1e-8, ) -> Tuple[np.array, List[np.ndarray]]: """An eigendecomposition that ensures eigenvectors are perpendicular. numpy.linalg.eig doesn't guarantee that e...
[ "def", "_perp_eigendecompose", "(", "matrix", ":", "np", ".", "ndarray", ",", "rtol", ":", "float", "=", "1e-5", ",", "atol", ":", "float", "=", "1e-8", ",", ")", "->", "Tuple", "[", "np", ".", "array", ",", "List", "[", "np", ".", "ndarray", "]", ...
An eigendecomposition that ensures eigenvectors are perpendicular. numpy.linalg.eig doesn't guarantee that eigenvectors from the same eigenspace will be perpendicular. This method uses Gram-Schmidt to recover a perpendicular set. It further checks that all eigenvectors are perpendicular and raises an A...
[ "An", "eigendecomposition", "that", "ensures", "eigenvectors", "are", "perpendicular", "." ]
python
train
39.133333
gwpy/gwpy
gwpy/spectrogram/spectrogram.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/spectrogram/spectrogram.py#L360-L400
def from_spectra(cls, *spectra, **kwargs): """Build a new `Spectrogram` from a list of spectra. Parameters ---------- *spectra any number of `~gwpy.frequencyseries.FrequencySeries` series dt : `float`, `~astropy.units.Quantity`, optional stride between gi...
[ "def", "from_spectra", "(", "cls", ",", "*", "spectra", ",", "*", "*", "kwargs", ")", ":", "data", "=", "numpy", ".", "vstack", "(", "[", "s", ".", "value", "for", "s", "in", "spectra", "]", ")", "spec1", "=", "list", "(", "spectra", ")", "[", ...
Build a new `Spectrogram` from a list of spectra. Parameters ---------- *spectra any number of `~gwpy.frequencyseries.FrequencySeries` series dt : `float`, `~astropy.units.Quantity`, optional stride between given spectra Returns ------- S...
[ "Build", "a", "new", "Spectrogram", "from", "a", "list", "of", "spectra", "." ]
python
train
41.658537
owncloud/pyocclient
owncloud/owncloud.py
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L392-L412
def list(self, path, depth=1): """Returns the listing/contents of the given remote directory :param path: path to the remote directory :param depth: depth of the listing, integer or "infinity" :returns: directory listing :rtype: array of :class:`FileInfo` objects :raises...
[ "def", "list", "(", "self", ",", "path", ",", "depth", "=", "1", ")", ":", "if", "not", "path", ".", "endswith", "(", "'/'", ")", ":", "path", "+=", "'/'", "headers", "=", "{", "}", "if", "isinstance", "(", "depth", ",", "int", ")", "or", "dept...
Returns the listing/contents of the given remote directory :param path: path to the remote directory :param depth: depth of the listing, integer or "infinity" :returns: directory listing :rtype: array of :class:`FileInfo` objects :raises: HTTPResponseError in case an HTTP error ...
[ "Returns", "the", "listing", "/", "contents", "of", "the", "given", "remote", "directory" ]
python
train
35.857143
yohell/python-tui
tui/formats.py
https://github.com/yohell/python-tui/blob/de2e678e2f00e5940de52c000214dbcb8812a222/tui/formats.py#L216-L224
def present(self, value): """Return a user-friendly representation of a value. Lookup value in self.specials, or call .to_literal() if absent. """ for k, v in self.special.items(): if v == value: return k return self.to_literal(value, *self.ar...
[ "def", "present", "(", "self", ",", "value", ")", ":", "for", "k", ",", "v", "in", "self", ".", "special", ".", "items", "(", ")", ":", "if", "v", "==", "value", ":", "return", "k", "return", "self", ".", "to_literal", "(", "value", ",", "*", "...
Return a user-friendly representation of a value. Lookup value in self.specials, or call .to_literal() if absent.
[ "Return", "a", "user", "-", "friendly", "representation", "of", "a", "value", ".", "Lookup", "value", "in", "self", ".", "specials", "or", "call", ".", "to_literal", "()", "if", "absent", "." ]
python
valid
36.222222
django-extensions/django-extensions
django_extensions/management/commands/shell_plus.py
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/shell_plus.py#L394-L425
def set_application_name(self, options): """ Set the application_name on PostgreSQL connection Use the fallback_application_name to let the user override it with PGAPPNAME env variable http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS # noqa ...
[ "def", "set_application_name", "(", "self", ",", "options", ")", ":", "supported_backends", "=", "[", "'django.db.backends.postgresql'", ",", "'django.db.backends.postgresql_psycopg2'", "]", "opt_name", "=", "'fallback_application_name'", "default_app_name", "=", "'django_she...
Set the application_name on PostgreSQL connection Use the fallback_application_name to let the user override it with PGAPPNAME env variable http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS # noqa
[ "Set", "the", "application_name", "on", "PostgreSQL", "connection" ]
python
train
38.09375
polyaxon/rhea
rhea/manager.py
https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L189-L229
def get_string(self, key, is_list=False, is_optional=False, is_secret=False, is_local=False, default=None, options=None): """ Get a the value corresponding to the key and ...
[ "def", "get_string", "(", "self", ",", "key", ",", "is_list", "=", "False", ",", "is_optional", "=", "False", ",", "is_secret", "=", "False", ",", "is_local", "=", "False", ",", "default", "=", "None", ",", "options", "=", "None", ")", ":", "if", "is...
Get a the value corresponding to the key and converts it to `str`/`list(str)`. Args: key: the dict key. is_list: If this is one element or a list of elements. is_optional: To raise an error if key was not found. is_secret: If the key is a secret. is_l...
[ "Get", "a", "the", "value", "corresponding", "to", "the", "key", "and", "converts", "it", "to", "str", "/", "list", "(", "str", ")", "." ]
python
train
43.756098
tanghaibao/jcvi
jcvi/apps/uniprot.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/uniprot.py#L44-L149
def fetch(args): """ %prog fetch "query" OR %prog fetch queries.txt Please provide a UniProt compatible `query` to retrieve data. If `query` contains spaces, please remember to "quote" it. You can also specify a `filename` which contains queries, one per line. Follow this syntax <...
[ "def", "fetch", "(", "args", ")", ":", "import", "re", "import", "csv", "p", "=", "OptionParser", "(", "fetch", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--format\"", ",", "default", "=", "\"tab\"", ",", "choices", "=", "valid_formats", ",", ...
%prog fetch "query" OR %prog fetch queries.txt Please provide a UniProt compatible `query` to retrieve data. If `query` contains spaces, please remember to "quote" it. You can also specify a `filename` which contains queries, one per line. Follow this syntax <http://www.uniprot.org/help/t...
[ "%prog", "fetch", "query", "OR", "%prog", "fetch", "queries", ".", "txt" ]
python
train
34.679245
Robpol86/colorclass
colorclass/color.py
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L127-L136
def blue(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('blue', string, ...
[ "def", "blue", "(", "cls", ",", "string", ",", "auto", "=", "False", ")", ":", "return", "cls", ".", "colorize", "(", "'blue'", ",", "string", ",", "auto", "=", "auto", ")" ]
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
[ "Color", "-", "code", "entire", "string", "." ]
python
train
32.1
klmitch/tendril
tendril/framers.py
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L507-L522
def _get_tab(cls): """Generate and return the COBS table.""" if not cls._tabs['dec_cobs']: # Compute the COBS table for decoding cls._tabs['dec_cobs']['\xff'] = (255, '') cls._tabs['dec_cobs'].update(dict((chr(l), (l, '\0')) ...
[ "def", "_get_tab", "(", "cls", ")", ":", "if", "not", "cls", ".", "_tabs", "[", "'dec_cobs'", "]", ":", "# Compute the COBS table for decoding", "cls", ".", "_tabs", "[", "'dec_cobs'", "]", "[", "'\\xff'", "]", "=", "(", "255", ",", "''", ")", "cls", "...
Generate and return the COBS table.
[ "Generate", "and", "return", "the", "COBS", "table", "." ]
python
train
41.0625
bsolomon1124/pyfinance
pyfinance/general.py
https://github.com/bsolomon1124/pyfinance/blob/c95925209a809b4e648e79cbeaf7711d8e5ff1a6/pyfinance/general.py#L1002-L1064
def variance_inflation_factor(regressors, hasconst=False): """Calculate variance inflation factor (VIF) for each all `regressors`. A wrapper/modification of statsmodels: statsmodels.stats.outliers_influence.variance_inflation_factor One recommendation is that if VIF is greater than 5, then the e...
[ "def", "variance_inflation_factor", "(", "regressors", ",", "hasconst", "=", "False", ")", ":", "if", "not", "hasconst", ":", "regressors", "=", "add_constant", "(", "regressors", ",", "prepend", "=", "False", ")", "k", "=", "regressors", ".", "shape", "[", ...
Calculate variance inflation factor (VIF) for each all `regressors`. A wrapper/modification of statsmodels: statsmodels.stats.outliers_influence.variance_inflation_factor One recommendation is that if VIF is greater than 5, then the explanatory variable `x` is highly collinear with the other exp...
[ "Calculate", "variance", "inflation", "factor", "(", "VIF", ")", "for", "each", "all", "regressors", ".", "A", "wrapper", "/", "modification", "of", "statsmodels", ":", "statsmodels", ".", "stats", ".", "outliers_influence", ".", "variance_inflation_factor", "One"...
python
train
34.285714
brocade/pynos
pynos/versions/base/yang/brocade_ras.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_ras.py#L417-L427
def support_support_param_username(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") support = ET.SubElement(config, "support", xmlns="urn:brocade.com:mgmt:brocade-ras") support_param = ET.SubElement(support, "support-param") username = ET.SubEleme...
[ "def", "support_support_param_username", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "support", "=", "ET", ".", "SubElement", "(", "config", ",", "\"support\"", ",", "xmlns", "=", "\"urn:broc...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
43.363636
ownport/scrapy-dblite
dblite/query.py
https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L100-L125
def _logical(self, operator, params): ''' $and: joins query clauses with a logical AND returns all items that match the conditions of both clauses $or: joins query clauses with a logical OR returns all items that match the conditions of either clause. ...
[ "def", "_logical", "(", "self", ",", "operator", ",", "params", ")", ":", "result", "=", "list", "(", ")", "if", "isinstance", "(", "params", ",", "dict", ")", ":", "for", "k", ",", "v", "in", "params", ".", "items", "(", ")", ":", "selectors", "...
$and: joins query clauses with a logical AND returns all items that match the conditions of both clauses $or: joins query clauses with a logical OR returns all items that match the conditions of either clause.
[ "$and", ":", "joins", "query", "clauses", "with", "a", "logical", "AND", "returns", "all", "items", "that", "match", "the", "conditions", "of", "both", "clauses", "$or", ":", "joins", "query", "clauses", "with", "a", "logical", "OR", "returns", "all", "ite...
python
train
39.538462
nerdvegas/rez
src/rez/utils/patching.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/patching.py#L4-L78
def get_patched_request(requires, patchlist): """Apply patch args to a request. For example, consider: >>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"]) ["foo-6", "bah-8.1"] >>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"]) ["foo-5"] The following ...
[ "def", "get_patched_request", "(", "requires", ",", "patchlist", ")", ":", "# rules from table in docstring above", "rules", "=", "{", "''", ":", "(", "True", ",", "True", ",", "True", ")", ",", "'!'", ":", "(", "False", ",", "False", ",", "False", ")", ...
Apply patch args to a request. For example, consider: >>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"]) ["foo-6", "bah-8.1"] >>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"]) ["foo-5"] The following rules apply wrt how normal/conflict/weak patches over...
[ "Apply", "patch", "args", "to", "a", "request", "." ]
python
train
28.6
googleapis/dialogflow-python-client-v2
samples/detect_intent_with_texttospeech_response.py
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_with_texttospeech_response.py#L30-L68
def detect_intent_with_texttospeech_response(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs and includes the response in an audio format. Using the same `session_id` between requests allows continuation...
[ "def", "detect_intent_with_texttospeech_response", "(", "project_id", ",", "session_id", ",", "texts", ",", "language_code", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "session_path...
Returns the result of detect intent with texts as inputs and includes the response in an audio format. Using the same `session_id` between requests allows continuation of the conversaion.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "texts", "as", "inputs", "and", "includes", "the", "response", "in", "an", "audio", "format", "." ]
python
train
43.666667
Azure/blobxfer
blobxfer/operations/download.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/download.py#L515-L590
def _process_download_descriptor(self, dd): # type: (Downloader, blobxfer.models.download.Descriptor) -> None """Process download descriptor :param Downloader self: this :param blobxfer.models.download.Descriptor dd: download descriptor """ # update progress bar s...
[ "def", "_process_download_descriptor", "(", "self", ",", "dd", ")", ":", "# type: (Downloader, blobxfer.models.download.Descriptor) -> None", "# update progress bar", "self", ".", "_update_progress_bar", "(", ")", "# get download offsets", "offsets", ",", "resume_bytes", "=", ...
Process download descriptor :param Downloader self: this :param blobxfer.models.download.Descriptor dd: download descriptor
[ "Process", "download", "descriptor", ":", "param", "Downloader", "self", ":", "this", ":", "param", "blobxfer", ".", "models", ".", "download", ".", "Descriptor", "dd", ":", "download", "descriptor" ]
python
train
43.644737
ff0000/scarlet
scarlet/cms/bundles.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L614-L638
def get_urls(self): """ Returns urls handling bundles and views. This processes the 'item view' first in order and then adds any non item views at the end. """ parts = [] seen = set() # Process item views in order for v in list(self._meta.item_vie...
[ "def", "get_urls", "(", "self", ")", ":", "parts", "=", "[", "]", "seen", "=", "set", "(", ")", "# Process item views in order", "for", "v", "in", "list", "(", "self", ".", "_meta", ".", "item_views", ")", "+", "list", "(", "self", ".", "_meta", ".",...
Returns urls handling bundles and views. This processes the 'item view' first in order and then adds any non item views at the end.
[ "Returns", "urls", "handling", "bundles", "and", "views", ".", "This", "processes", "the", "item", "view", "first", "in", "order", "and", "then", "adds", "any", "non", "item", "views", "at", "the", "end", "." ]
python
train
33.6
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/containers.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/containers.py#L1752-L1757
def _getOccurs(self, e): '''return a 3 item tuple ''' minOccurs = maxOccurs = '1' nillable = True return minOccurs,maxOccurs,nillable
[ "def", "_getOccurs", "(", "self", ",", "e", ")", ":", "minOccurs", "=", "maxOccurs", "=", "'1'", "nillable", "=", "True", "return", "minOccurs", ",", "maxOccurs", ",", "nillable" ]
return a 3 item tuple
[ "return", "a", "3", "item", "tuple" ]
python
train
28.166667
observermedia/django-wordpress-rest
wordpress/loading.py
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L881-L926
def process_new_post(self, bulk_mode, api_post, posts, author, post_categories, post_tags, post_media_attachments): """ Instantiate a new Post object using data from the WP API. Related fields -- author, categories, tags, and attachments should be processed in advance :param bulk_mode: ...
[ "def", "process_new_post", "(", "self", ",", "bulk_mode", ",", "api_post", ",", "posts", ",", "author", ",", "post_categories", ",", "post_tags", ",", "post_media_attachments", ")", ":", "post", "=", "Post", "(", "site_id", "=", "self", ".", "site_id", ",", ...
Instantiate a new Post object using data from the WP API. Related fields -- author, categories, tags, and attachments should be processed in advance :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the Post :param posts: t...
[ "Instantiate", "a", "new", "Post", "object", "using", "data", "from", "the", "WP", "API", ".", "Related", "fields", "--", "author", "categories", "tags", "and", "attachments", "should", "be", "processed", "in", "advance" ]
python
train
53.130435
odlgroup/odl
odl/solvers/nonsmooth/primal_dual_hybrid_gradient.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/solvers/nonsmooth/primal_dual_hybrid_gradient.py#L308-L371
def pdhg_stepsize(L, tau=None, sigma=None): r"""Default step sizes for `pdhg`. Parameters ---------- L : `Operator` or float Operator or norm of the operator that are used in the `pdhg` method. If it is an `Operator`, the norm is computed with ``Operator.norm(estimate=True)``. ...
[ "def", "pdhg_stepsize", "(", "L", ",", "tau", "=", "None", ",", "sigma", "=", "None", ")", ":", "if", "tau", "is", "not", "None", "and", "sigma", "is", "not", "None", ":", "return", "float", "(", "tau", ")", ",", "float", "(", "sigma", ")", "L_no...
r"""Default step sizes for `pdhg`. Parameters ---------- L : `Operator` or float Operator or norm of the operator that are used in the `pdhg` method. If it is an `Operator`, the norm is computed with ``Operator.norm(estimate=True)``. tau : positive float, optional Use th...
[ "r", "Default", "step", "sizes", "for", "pdhg", "." ]
python
train
29.75
xtuml/pyxtuml
xtuml/meta.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/xtuml/meta.py#L1053-L1061
def delete(instance, disconnect=True): ''' Delete an *instance* from its metaclass instance pool and optionally *disconnect* it from any links it might be connected to. ''' if not isinstance(instance, Class): raise DeleteException("the provided argument is not an xtuml instance") ...
[ "def", "delete", "(", "instance", ",", "disconnect", "=", "True", ")", ":", "if", "not", "isinstance", "(", "instance", ",", "Class", ")", ":", "raise", "DeleteException", "(", "\"the provided argument is not an xtuml instance\"", ")", "return", "get_metaclass", "...
Delete an *instance* from its metaclass instance pool and optionally *disconnect* it from any links it might be connected to.
[ "Delete", "an", "*", "instance", "*", "from", "its", "metaclass", "instance", "pool", "and", "optionally", "*", "disconnect", "*", "it", "from", "any", "links", "it", "might", "be", "connected", "to", "." ]
python
test
41.888889
jkitzes/macroeco
macroeco/main/_main.py
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L29-L96
def main(param_path='parameters.txt'): """ Entry point function for analysis based on parameter files. Parameters ---------- param_path : str Path to user-generated parameter file """ # Confirm parameters file is present if not os.path.isfile(param_path): raise IOError...
[ "def", "main", "(", "param_path", "=", "'parameters.txt'", ")", ":", "# Confirm parameters file is present", "if", "not", "os", ".", "path", ".", "isfile", "(", "param_path", ")", ":", "raise", "IOError", ",", "\"Parameter file not found at %s\"", "%", "param_path",...
Entry point function for analysis based on parameter files. Parameters ---------- param_path : str Path to user-generated parameter file
[ "Entry", "point", "function", "for", "analysis", "based", "on", "parameter", "files", "." ]
python
train
36.691176
fboender/ansible-cmdb
lib/mako/_ast_util.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/lib/mako/_ast_util.py#L274-L279
def visit(self, node): """Visit a node.""" f = self.get_visitor(node) if f is not None: return f(node) return self.generic_visit(node)
[ "def", "visit", "(", "self", ",", "node", ")", ":", "f", "=", "self", ".", "get_visitor", "(", "node", ")", "if", "f", "is", "not", "None", ":", "return", "f", "(", "node", ")", "return", "self", ".", "generic_visit", "(", "node", ")" ]
Visit a node.
[ "Visit", "a", "node", "." ]
python
train
28.833333
OSSOS/MOP
src/jjk/preproc/cfeps_object.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/cfeps_object.py#L30-L37
def get_orbits(official='%'): """Query the orbit table for the object whose official desingation matches parameter official. By default all entries are returned """ sql= "SELECT * FROM orbits WHERE official LIKE '%s' " % (official, ) cfeps.execute(sql) return mk_dict(cfeps.fetchall(),cfep...
[ "def", "get_orbits", "(", "official", "=", "'%'", ")", ":", "sql", "=", "\"SELECT * FROM orbits WHERE official LIKE '%s' \"", "%", "(", "official", ",", ")", "cfeps", ".", "execute", "(", "sql", ")", "return", "mk_dict", "(", "cfeps", ".", "fetchall", "(", "...
Query the orbit table for the object whose official desingation matches parameter official. By default all entries are returned
[ "Query", "the", "orbit", "table", "for", "the", "object", "whose", "official", "desingation", "matches", "parameter", "official", ".", "By", "default", "all", "entries", "are", "returned" ]
python
train
40.875
PRIArobotics/HedgehogProtocol
hedgehog/protocol/zmq/__init__.py
https://github.com/PRIArobotics/HedgehogProtocol/blob/140df1ade46fbfee7eea7a6c0b35cbc7ffbf89fe/hedgehog/protocol/zmq/__init__.py#L22-L27
def raw_to_delimited(header: Header, raw_payload: RawPayload) -> DelimitedMsg: """\ Returns a message consisting of header frames, delimiter frame, and payload frames. The payload frames may be given as sequences of bytes (raw) or as `Message`s. """ return tuple(header) + (b'',) + tuple(raw_payload)
[ "def", "raw_to_delimited", "(", "header", ":", "Header", ",", "raw_payload", ":", "RawPayload", ")", "->", "DelimitedMsg", ":", "return", "tuple", "(", "header", ")", "+", "(", "b''", ",", ")", "+", "tuple", "(", "raw_payload", ")" ]
\ Returns a message consisting of header frames, delimiter frame, and payload frames. The payload frames may be given as sequences of bytes (raw) or as `Message`s.
[ "\\", "Returns", "a", "message", "consisting", "of", "header", "frames", "delimiter", "frame", "and", "payload", "frames", ".", "The", "payload", "frames", "may", "be", "given", "as", "sequences", "of", "bytes", "(", "raw", ")", "or", "as", "Message", "s",...
python
valid
52.5
fooelisa/pyiosxr
pyIOSXR/iosxr.py
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L139-L152
def make_rpc_call(self, rpc_command): """ Allow a user to query a device directly using XML-requests. :param rpc_command: (str) rpc command such as: <Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get> """ # ~~~ hack: ~~~ ...
[ "def", "make_rpc_call", "(", "self", ",", "rpc_command", ")", ":", "# ~~~ hack: ~~~", "if", "not", "self", ".", "is_alive", "(", ")", ":", "self", ".", "close", "(", ")", "# force close for safety", "self", ".", "open", "(", ")", "# reopen", "# ~~~ end hack ...
Allow a user to query a device directly using XML-requests. :param rpc_command: (str) rpc command such as: <Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>
[ "Allow", "a", "user", "to", "query", "a", "device", "directly", "using", "XML", "-", "requests", "." ]
python
train
38
docker/docker-py
docker/api/container.py
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/container.py#L1189-L1251
def update_container( self, container, blkio_weight=None, cpu_period=None, cpu_quota=None, cpu_shares=None, cpuset_cpus=None, cpuset_mems=None, mem_limit=None, mem_reservation=None, memswap_limit=None, kernel_memory=None, restart_policy=None ): """ Update resource con...
[ "def", "update_container", "(", "self", ",", "container", ",", "blkio_weight", "=", "None", ",", "cpu_period", "=", "None", ",", "cpu_quota", "=", "None", ",", "cpu_shares", "=", "None", ",", "cpuset_cpus", "=", "None", ",", "cpuset_mems", "=", "None", ","...
Update resource configs of one or more containers. Args: container (str): The container to inspect blkio_weight (int): Block IO (relative weight), between 10 and 1000 cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period cpu_quota (int): Limit CPU CF...
[ "Update", "resource", "configs", "of", "one", "or", "more", "containers", "." ]
python
train
40.68254
saltstack/salt
salt/modules/postgres.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postgres.py#L680-L711
def tablespace_list(user=None, host=None, port=None, maintenance_db=None, password=None, runas=None): ''' Return dictionary with information about tablespaces of a Postgres server. CLI Example: .. code-block:: bash salt '*' postgres.tablespace_list .. versionadded:: 2...
[ "def", "tablespace_list", "(", "user", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ",", "maintenance_db", "=", "None", ",", "password", "=", "None", ",", "runas", "=", "None", ")", ":", "ret", "=", "{", "}", "query", "=", "(", ...
Return dictionary with information about tablespaces of a Postgres server. CLI Example: .. code-block:: bash salt '*' postgres.tablespace_list .. versionadded:: 2015.8.0
[ "Return", "dictionary", "with", "information", "about", "tablespaces", "of", "a", "Postgres", "server", "." ]
python
train
29.90625
troeger/opensubmit
web/opensubmit/social/env.py
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/social/env.py#L34-L45
def auth_complete(self, *args, **kwargs): """Completes loging process, must return user instance""" if self.ENV_USERNAME in os.environ: response = os.environ elif type(self.strategy).__name__ == "DjangoStrategy" and self.ENV_USERNAME in self.strategy.request.META: # Looks...
[ "def", "auth_complete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "ENV_USERNAME", "in", "os", ".", "environ", ":", "response", "=", "os", ".", "environ", "elif", "type", "(", "self", ".", "strategy", ")", ...
Completes loging process, must return user instance
[ "Completes", "loging", "process", "must", "return", "user", "instance" ]
python
train
61.75
globus/globus-cli
globus_cli/helpers/delegate_proxy.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/helpers/delegate_proxy.py#L12-L52
def fill_delegate_proxy_activation_requirements( requirements_data, cred_file, lifetime_hours=12 ): """ Given the activation requirements for an endpoint and a filename for X.509 credentials, extracts the public key from the activation requirements, uses the key and the credentials to make a proxy c...
[ "def", "fill_delegate_proxy_activation_requirements", "(", "requirements_data", ",", "cred_file", ",", "lifetime_hours", "=", "12", ")", ":", "# get the public key from the activation requirements", "for", "data", "in", "requirements_data", "[", "\"DATA\"", "]", ":", "if", ...
Given the activation requirements for an endpoint and a filename for X.509 credentials, extracts the public key from the activation requirements, uses the key and the credentials to make a proxy credential, and returns the requirements data with the proxy chain filled in.
[ "Given", "the", "activation", "requirements", "for", "an", "endpoint", "and", "a", "filename", "for", "X", ".", "509", "credentials", "extracts", "the", "public", "key", "from", "the", "activation", "requirements", "uses", "the", "key", "and", "the", "credenti...
python
train
37.609756
Clinical-Genomics/scout
scout/adapter/mongo/hgnc.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/hgnc.py#L587-L599
def load_exons(self, exons, genes=None, build='37'): """Create exon objects and insert them into the database Args: exons(iterable(dict)) """ genes = genes or self.ensembl_genes(build) for exon in exons: exon_obj = build_exon(exon, genes) ...
[ "def", "load_exons", "(", "self", ",", "exons", ",", "genes", "=", "None", ",", "build", "=", "'37'", ")", ":", "genes", "=", "genes", "or", "self", ".", "ensembl_genes", "(", "build", ")", "for", "exon", "in", "exons", ":", "exon_obj", "=", "build_e...
Create exon objects and insert them into the database Args: exons(iterable(dict))
[ "Create", "exon", "objects", "and", "insert", "them", "into", "the", "database", "Args", ":", "exons", "(", "iterable", "(", "dict", "))" ]
python
test
32.769231
rapidpro/expressions
python/temba_expressions/functions/excel.py
https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/functions/excel.py#L321-L333
def _max(ctx, *number): """ Returns the maximum value of all arguments """ if len(number) == 0: raise ValueError("Wrong number of arguments") result = conversions.to_decimal(number[0], ctx) for arg in number[1:]: arg = conversions.to_decimal(arg, ctx) if arg > result: ...
[ "def", "_max", "(", "ctx", ",", "*", "number", ")", ":", "if", "len", "(", "number", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Wrong number of arguments\"", ")", "result", "=", "conversions", ".", "to_decimal", "(", "number", "[", "0", "]", "...
Returns the maximum value of all arguments
[ "Returns", "the", "maximum", "value", "of", "all", "arguments" ]
python
train
26.769231
manns/pyspread
pyspread/src/gui/_toolbars.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_toolbars.py#L667-L677
def _create_penwidth_combo(self): """Create pen width combo box""" choices = map(unicode, xrange(12)) self.pen_width_combo = \ _widgets.PenWidthComboBox(self, choices=choices, style=wx.CB_READONLY, size=(50, -1)) self.pen_width_combo.Se...
[ "def", "_create_penwidth_combo", "(", "self", ")", ":", "choices", "=", "map", "(", "unicode", ",", "xrange", "(", "12", ")", ")", "self", ".", "pen_width_combo", "=", "_widgets", ".", "PenWidthComboBox", "(", "self", ",", "choices", "=", "choices", ",", ...
Create pen width combo box
[ "Create", "pen", "width", "combo", "box" ]
python
train
42.272727
spacetelescope/drizzlepac
drizzlepac/buildwcs.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/buildwcs.py#L231-L238
def convert_user_pars(wcspars): """ Convert the parameters provided by the configObj into the corresponding parameters from an HSTWCS object """ default_pars = default_user_wcs.copy() for kw in user_hstwcs_pars: default_pars[user_hstwcs_pars[kw]] = wcspars[kw] return default_pars
[ "def", "convert_user_pars", "(", "wcspars", ")", ":", "default_pars", "=", "default_user_wcs", ".", "copy", "(", ")", "for", "kw", "in", "user_hstwcs_pars", ":", "default_pars", "[", "user_hstwcs_pars", "[", "kw", "]", "]", "=", "wcspars", "[", "kw", "]", ...
Convert the parameters provided by the configObj into the corresponding parameters from an HSTWCS object
[ "Convert", "the", "parameters", "provided", "by", "the", "configObj", "into", "the", "corresponding", "parameters", "from", "an", "HSTWCS", "object" ]
python
train
38.625
saltstack/salt
salt/states/boto_route53.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_route53.py#L99-L256
def present(name, value, zone, record_type, ttl=None, identifier=None, region=None, key=None, keyid=None, profile=None, wait_for_sync=True, split_dns=False, private_zone=False): ''' Ensure the Route53 record is present. name Name of the record. value Value of the record. A...
[ "def", "present", "(", "name", ",", "value", ",", "zone", ",", "record_type", ",", "ttl", "=", "None", ",", "identifier", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ",",...
Ensure the Route53 record is present. name Name of the record. value Value of the record. As a special case, you can pass in: `private:<Name tag>` to have the function autodetermine the private IP `public:<Name tag>` to have the function autodetermine the public IP ...
[ "Ensure", "the", "Route53", "record", "is", "present", "." ]
python
train
43.082278
robinandeer/puzzle
puzzle/models/variant.py
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L146-L157
def add_gene(self, gene): """Add the information of a gene This adds a gene dict to variant['genes'] Args: gene (dict): A gene dictionary """ logger.debug("Adding gene {0} to variant {1}".format( gene, self['variant_id'])) self['gene...
[ "def", "add_gene", "(", "self", ",", "gene", ")", ":", "logger", ".", "debug", "(", "\"Adding gene {0} to variant {1}\"", ".", "format", "(", "gene", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", "[", "'genes'", "]", ".", "append", "(", "gene"...
Add the information of a gene This adds a gene dict to variant['genes'] Args: gene (dict): A gene dictionary
[ "Add", "the", "information", "of", "a", "gene" ]
python
train
27.083333
PyMySQL/Tornado-MySQL
tornado_mysql/pools.py
https://github.com/PyMySQL/Tornado-MySQL/blob/75d3466e4332e43b2bf853799f1122dec5da60bc/tornado_mysql/pools.py#L175-L183
def execute(self, query, args=None): """ :return: Future[Cursor] :rtype: Future """ self._ensure_conn() cur = self._conn.cursor() yield cur.execute(query, args) raise Return(cur)
[ "def", "execute", "(", "self", ",", "query", ",", "args", "=", "None", ")", ":", "self", ".", "_ensure_conn", "(", ")", "cur", "=", "self", ".", "_conn", ".", "cursor", "(", ")", "yield", "cur", ".", "execute", "(", "query", ",", "args", ")", "ra...
:return: Future[Cursor] :rtype: Future
[ ":", "return", ":", "Future", "[", "Cursor", "]", ":", "rtype", ":", "Future" ]
python
train
26
klmitch/appathy
appathy/response.py
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L135-L155
def _serialize(self): """ Serialize the ResponseObject. Returns a webob `Response` object. """ # Do something appropriate if the response object is unbound if self._defcode is None: raise exceptions.UnboundResponse() # Build the response res...
[ "def", "_serialize", "(", "self", ")", ":", "# Do something appropriate if the response object is unbound", "if", "self", ".", "_defcode", "is", "None", ":", "raise", "exceptions", ".", "UnboundResponse", "(", ")", "# Build the response", "resp", "=", "self", ".", "...
Serialize the ResponseObject. Returns a webob `Response` object.
[ "Serialize", "the", "ResponseObject", ".", "Returns", "a", "webob", "Response", "object", "." ]
python
train
30.285714
angr/angr
angr/exploration_techniques/unique.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/exploration_techniques/unique.py#L78-L88
def similarity(state_a, state_b): """ The (L2) distance between the counts of the state addresses in the history of the path. :param state_a: The first state to compare :param state_b: The second state to compare """ count_a = Counter(state_a.history.bbl_addrs) co...
[ "def", "similarity", "(", "state_a", ",", "state_b", ")", ":", "count_a", "=", "Counter", "(", "state_a", ".", "history", ".", "bbl_addrs", ")", "count_b", "=", "Counter", "(", "state_b", ".", "history", ".", "bbl_addrs", ")", "normal_distance", "=", "sum"...
The (L2) distance between the counts of the state addresses in the history of the path. :param state_a: The first state to compare :param state_b: The second state to compare
[ "The", "(", "L2", ")", "distance", "between", "the", "counts", "of", "the", "state", "addresses", "in", "the", "history", "of", "the", "path", ".", ":", "param", "state_a", ":", "The", "first", "state", "to", "compare", ":", "param", "state_b", ":", "T...
python
train
52.272727
Nekroze/librarian
librarian/library.py
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L11-L52
def Where_filter_gen(*data): """ Generate an sqlite "LIKE" filter generator based on the given data. This functions arguments should be a N length series of field and data tuples. """ where = [] def Fwhere(field, pattern): """Add where filter for the given field with the given patte...
[ "def", "Where_filter_gen", "(", "*", "data", ")", ":", "where", "=", "[", "]", "def", "Fwhere", "(", "field", ",", "pattern", ")", ":", "\"\"\"Add where filter for the given field with the given pattern.\"\"\"", "where", ".", "append", "(", "\"WHERE {0} LIKE '{1}'\"",...
Generate an sqlite "LIKE" filter generator based on the given data. This functions arguments should be a N length series of field and data tuples.
[ "Generate", "an", "sqlite", "LIKE", "filter", "generator", "based", "on", "the", "given", "data", ".", "This", "functions", "arguments", "should", "be", "a", "N", "length", "series", "of", "field", "and", "data", "tuples", "." ]
python
train
35.190476
learningequality/iceqube
src/iceqube/common/classes.py
https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/common/classes.py#L85-L122
def get_lambda_to_execute(self): """ return a function that executes the function assigned to this job. If job.track_progress is None (the default), the returned function accepts no argument and simply needs to be called. If job.track_progress is True, an update_progress function ...
[ "def", "get_lambda_to_execute", "(", "self", ")", ":", "def", "y", "(", "update_progress_func", ",", "cancel_job_func", ")", ":", "\"\"\"\n Call the function stored in self.func, and passing in update_progress_func\n or cancel_job_func depending if self.track_progre...
return a function that executes the function assigned to this job. If job.track_progress is None (the default), the returned function accepts no argument and simply needs to be called. If job.track_progress is True, an update_progress function is passed in that can be used by the function to pr...
[ "return", "a", "function", "that", "executes", "the", "function", "assigned", "to", "this", "job", "." ]
python
train
42.210526
greenbone/ospd
ospd/ospd.py
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L550-L616
def handle_start_scan_command(self, scan_et): """ Handles <start_scan> command. @return: Response string for <start_scan> command. """ target_str = scan_et.attrib.get('target') ports_str = scan_et.attrib.get('ports') # For backward compatibility, if target and ports att...
[ "def", "handle_start_scan_command", "(", "self", ",", "scan_et", ")", ":", "target_str", "=", "scan_et", ".", "attrib", ".", "get", "(", "'target'", ")", "ports_str", "=", "scan_et", ".", "attrib", ".", "get", "(", "'ports'", ")", "# For backward compatibility...
Handles <start_scan> command. @return: Response string for <start_scan> command.
[ "Handles", "<start_scan", ">", "command", "." ]
python
train
41.074627
lekhakpadmanabh/Summarizer
smrzr/core.py
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L32-L37
def _tokenize(sentence): '''Tokenizer and Stemmer''' _tokens = nltk.word_tokenize(sentence) tokens = [stemmer.stem(tk) for tk in _tokens] return tokens
[ "def", "_tokenize", "(", "sentence", ")", ":", "_tokens", "=", "nltk", ".", "word_tokenize", "(", "sentence", ")", "tokens", "=", "[", "stemmer", ".", "stem", "(", "tk", ")", "for", "tk", "in", "_tokens", "]", "return", "tokens" ]
Tokenizer and Stemmer
[ "Tokenizer", "and", "Stemmer" ]
python
train
27.166667
ibelie/typy
typy/google/protobuf/text_format.py
https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/text_format.py#L739-L759
def _SkipFieldValue(tokenizer): """Skips over a field value. Args: tokenizer: A tokenizer to parse the field name and values. Raises: ParseError: In case an invalid field value is found. """ # String/bytes tokens can come in multiple adjacent string literals. # If we can consume one, consume as ma...
[ "def", "_SkipFieldValue", "(", "tokenizer", ")", ":", "# String/bytes tokens can come in multiple adjacent string literals.", "# If we can consume one, consume as many as we can.", "if", "tokenizer", ".", "TryConsumeByteString", "(", ")", ":", "while", "tokenizer", ".", "TryConsu...
Skips over a field value. Args: tokenizer: A tokenizer to parse the field name and values. Raises: ParseError: In case an invalid field value is found.
[ "Skips", "over", "a", "field", "value", "." ]
python
valid
31.190476
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
43.4
frascoweb/frasco
frasco/actions/context.py
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/context.py#L25-L39
def ensure_context(**vars): """Ensures that a context is in the stack, creates one otherwise. """ ctx = _context_stack.top stacked = False if not ctx: ctx = Context() stacked = True _context_stack.push(ctx) ctx.update(vars) try: yield ctx finally: ...
[ "def", "ensure_context", "(", "*", "*", "vars", ")", ":", "ctx", "=", "_context_stack", ".", "top", "stacked", "=", "False", "if", "not", "ctx", ":", "ctx", "=", "Context", "(", ")", "stacked", "=", "True", "_context_stack", ".", "push", "(", "ctx", ...
Ensures that a context is in the stack, creates one otherwise.
[ "Ensures", "that", "a", "context", "is", "in", "the", "stack", "creates", "one", "otherwise", "." ]
python
train
23.333333
juju/charm-helpers
charmhelpers/contrib/hahelpers/cluster.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L198-L205
def oldest_peer(peers): """Determines who the oldest peer is by comparing unit numbers.""" local_unit_no = int(os.getenv('JUJU_UNIT_NAME').split('/')[1]) for peer in peers: remote_unit_no = int(peer.split('/')[1]) if remote_unit_no < local_unit_no: return False return True
[ "def", "oldest_peer", "(", "peers", ")", ":", "local_unit_no", "=", "int", "(", "os", ".", "getenv", "(", "'JUJU_UNIT_NAME'", ")", ".", "split", "(", "'/'", ")", "[", "1", "]", ")", "for", "peer", "in", "peers", ":", "remote_unit_no", "=", "int", "("...
Determines who the oldest peer is by comparing unit numbers.
[ "Determines", "who", "the", "oldest", "peer", "is", "by", "comparing", "unit", "numbers", "." ]
python
train
38.75
hearsaycorp/normalize
normalize/visitor.py
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L363-L384
def cast(cls, value_type, value, visitor=None, **kwargs): """Cast is for visitors where you are visiting some random data structure (perhaps returned by a previous ``VisitorPattern.visit()`` operation), and you want to convert back to the value type. This function also takes positional ...
[ "def", "cast", "(", "cls", ",", "value_type", ",", "value", ",", "visitor", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "visitor", "is", "None", ":", "visitor", "=", "cls", ".", "Visitor", "(", "cls", ".", "grok", ",", "cls", ".", "reve...
Cast is for visitors where you are visiting some random data structure (perhaps returned by a previous ``VisitorPattern.visit()`` operation), and you want to convert back to the value type. This function also takes positional arguments: ``value_type=``\ *RecordType* ...
[ "Cast", "is", "for", "visitors", "where", "you", "are", "visiting", "some", "random", "data", "structure", "(", "perhaps", "returned", "by", "a", "previous", "VisitorPattern", ".", "visit", "()", "operation", ")", "and", "you", "want", "to", "convert", "back...
python
train
36.045455
genomoncology/related
src/related/converters.py
https://github.com/genomoncology/related/blob/be47c0081e60fc60afcde3a25f00ebcad5d18510/src/related/converters.py#L215-L233
def to_datetime_field(formatter): """ Returns a callable instance that will convert a string to a DateTime. :param formatter: String that represents data format for parsing. :return: instance of the DateTimeConverter. """ class DateTimeConverter(object): def __init__(self, formatter): ...
[ "def", "to_datetime_field", "(", "formatter", ")", ":", "class", "DateTimeConverter", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "formatter", ")", ":", "self", ".", "formatter", "=", "formatter", "def", "__call__", "(", "self", ",", "val...
Returns a callable instance that will convert a string to a DateTime. :param formatter: String that represents data format for parsing. :return: instance of the DateTimeConverter.
[ "Returns", "a", "callable", "instance", "that", "will", "convert", "a", "string", "to", "a", "DateTime", "." ]
python
train
28.157895
bfrog/whizzer
whizzer/rpc/dispatch.py
https://github.com/bfrog/whizzer/blob/a1e43084b3ac8c1f3fb4ada081777cdbf791fd77/whizzer/rpc/dispatch.py#L30-L41
def call(self, function, args=(), kwargs={}): """Call a method given some args and kwargs. function -- string containing the method name to call args -- arguments, either a list or tuple returns the result of the method. May raise an exception if the method isn't in the dict. ...
[ "def", "call", "(", "self", ",", "function", ",", "args", "=", "(", ")", ",", "kwargs", "=", "{", "}", ")", ":", "return", "self", ".", "functions", "[", "function", "]", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Call a method given some args and kwargs. function -- string containing the method name to call args -- arguments, either a list or tuple returns the result of the method. May raise an exception if the method isn't in the dict.
[ "Call", "a", "method", "given", "some", "args", "and", "kwargs", "." ]
python
train
31.5
h2oai/h2o-3
h2o-py/h2o/model/model_base.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/model_base.py#L357-L366
def scoring_history(self): """ Retrieve Model Score History. :returns: The score history as an H2OTwoDimTable or a Pandas DataFrame. """ model = self._model_json["output"] if "scoring_history" in model and model["scoring_history"] is not None: return model["s...
[ "def", "scoring_history", "(", "self", ")", ":", "model", "=", "self", ".", "_model_json", "[", "\"output\"", "]", "if", "\"scoring_history\"", "in", "model", "and", "model", "[", "\"scoring_history\"", "]", "is", "not", "None", ":", "return", "model", "[", ...
Retrieve Model Score History. :returns: The score history as an H2OTwoDimTable or a Pandas DataFrame.
[ "Retrieve", "Model", "Score", "History", "." ]
python
test
39.2
gitpython-developers/smmap
smmap/mman.py
https://github.com/gitpython-developers/smmap/blob/48e9e30b0ef3c24ac7ed88e6e3bfa37dc945bf4c/smmap/mman.py#L346-L382
def _obtain_region(self, a, offset, size, flags, is_recursive): """Utilty to create a new region - for more information on the parameters, see MapCursor.use_region. :param a: A regions (a)rray :return: The newly created region""" if self._memory_size + size > self._max_memory_siz...
[ "def", "_obtain_region", "(", "self", ",", "a", ",", "offset", ",", "size", ",", "flags", ",", "is_recursive", ")", ":", "if", "self", ".", "_memory_size", "+", "size", ">", "self", ".", "_max_memory_size", ":", "self", ".", "_collect_lru_region", "(", "...
Utilty to create a new region - for more information on the parameters, see MapCursor.use_region. :param a: A regions (a)rray :return: The newly created region
[ "Utilty", "to", "create", "a", "new", "region", "-", "for", "more", "information", "on", "the", "parameters", "see", "MapCursor", ".", "use_region", ".", ":", "param", "a", ":", "A", "regions", "(", "a", ")", "rray", ":", "return", ":", "The", "newly",...
python
train
40.837838
orb-framework/orb
orb/core/query.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/query.py#L904-L923
def isNot(self, value): """ Sets the operator type to Query.Op.IsNot and sets the value to the inputted value. :param value <variant> :return <Query> :sa __ne__ :usage |>>> from orb import Query as Q ...
[ "def", "isNot", "(", "self", ",", "value", ")", ":", "newq", "=", "self", ".", "copy", "(", ")", "newq", ".", "setOp", "(", "Query", ".", "Op", ".", "IsNot", ")", "newq", ".", "setValue", "(", "value", ")", "return", "newq" ]
Sets the operator type to Query.Op.IsNot and sets the value to the inputted value. :param value <variant> :return <Query> :sa __ne__ :usage |>>> from orb import Query as Q |>>> query = Q('test').i...
[ "Sets", "the", "operator", "type", "to", "Query", ".", "Op", ".", "IsNot", "and", "sets", "the", "value", "to", "the", "inputted", "value", ".", ":", "param", "value", "<variant", ">", ":", "return", "<Query", ">", ":", "sa", "__ne__", ":", "usage", ...
python
train
27.35
DLR-RM/RAFCON
source/rafcon/core/states/container_state.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/container_state.py#L1390-L1400
def get_scoped_variable_from_name(self, name): """ Get the scoped variable for a unique name :param name: the unique name of the scoped variable :return: the scoped variable specified by the name :raises exceptions.AttributeError: if the name is not in the the scoped_variables dictionar...
[ "def", "get_scoped_variable_from_name", "(", "self", ",", "name", ")", ":", "for", "scoped_variable_id", ",", "scoped_variable", "in", "self", ".", "scoped_variables", ".", "items", "(", ")", ":", "if", "scoped_variable", ".", "name", "==", "name", ":", "retur...
Get the scoped variable for a unique name :param name: the unique name of the scoped variable :return: the scoped variable specified by the name :raises exceptions.AttributeError: if the name is not in the the scoped_variables dictionary
[ "Get", "the", "scoped", "variable", "for", "a", "unique", "name" ]
python
train
52.363636
mitsei/dlkit
dlkit/records/assessment/basic/assessment_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/basic/assessment_records.py#L330-L336
def clear_max_attempts(self): """stub""" if (self.get_max_attempts_metadata().is_read_only() or self.get_max_attempts_metadata().is_required()): raise NoAccess() self.my_osid_object_form._my_map['maxAttempts'] = \ list(self._max_attempts_metadata['default_...
[ "def", "clear_max_attempts", "(", "self", ")", ":", "if", "(", "self", ".", "get_max_attempts_metadata", "(", ")", ".", "is_read_only", "(", ")", "or", "self", ".", "get_max_attempts_metadata", "(", ")", ".", "is_required", "(", ")", ")", ":", "raise", "No...
stub
[ "stub" ]
python
train
47.714286
inodb/sufam
sufam/mutation.py
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/mutation.py#L116-L137
def to_oncotator(self): """Returns mutation in oncotator input format. Assumes mutations have vcf/mpileup style positions.""" if self.type == ".": ref = self.ref alt = self.change start = self.pos end = self.pos elif self.type == "-": ...
[ "def", "to_oncotator", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\".\"", ":", "ref", "=", "self", ".", "ref", "alt", "=", "self", ".", "change", "start", "=", "self", ".", "pos", "end", "=", "self", ".", "pos", "elif", "self", ".",...
Returns mutation in oncotator input format. Assumes mutations have vcf/mpileup style positions.
[ "Returns", "mutation", "in", "oncotator", "input", "format", ".", "Assumes", "mutations", "have", "vcf", "/", "mpileup", "style", "positions", "." ]
python
train
38.590909
akfullfo/taskforce
taskforce/watch_files.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L700-L721
def remove(self, paths, **params): """ Delete paths from the watched list. """ log = self._getparam('log', self._discard, **params) commit = self._getparam('commit', True, **params) if type(paths) is not list: paths = [paths] rebuild = False for ...
[ "def", "remove", "(", "self", ",", "paths", ",", "*", "*", "params", ")", ":", "log", "=", "self", ".", "_getparam", "(", "'log'", ",", "self", ".", "_discard", ",", "*", "*", "params", ")", "commit", "=", "self", ".", "_getparam", "(", "'commit'",...
Delete paths from the watched list.
[ "Delete", "paths", "from", "the", "watched", "list", "." ]
python
train
33.454545
pypa/pipenv
pipenv/vendor/pyparsing.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pyparsing.py#L822-L837
def asList( self ): """ Returns the parse results as a nested list of matching tokens, all converted to strings. Example:: patt = OneOrMore(Word(alphas)) result = patt.parseString("sldkj lsdkj sldkj") # even though the result prints in string-like form, it i...
[ "def", "asList", "(", "self", ")", ":", "return", "[", "res", ".", "asList", "(", ")", "if", "isinstance", "(", "res", ",", "ParseResults", ")", "else", "res", "for", "res", "in", "self", ".", "__toklist", "]" ]
Returns the parse results as a nested list of matching tokens, all converted to strings. Example:: patt = OneOrMore(Word(alphas)) result = patt.parseString("sldkj lsdkj sldkj") # even though the result prints in string-like form, it is actually a pyparsing ParseResults ...
[ "Returns", "the", "parse", "results", "as", "a", "nested", "list", "of", "matching", "tokens", "all", "converted", "to", "strings", "." ]
python
train
46.75
scarface-4711/denonavr
denonavr/denonavr.py
https://github.com/scarface-4711/denonavr/blob/59a136e27b43cb1d1e140cf67705087b3aa377cd/denonavr/denonavr.py#L690-L709
def _get_zone_name(self): """Get receivers zone name if not set yet.""" if self._name is None: # Collect tags for AppCommand.xml call tags = ["GetZoneName"] # Execute call root = self.exec_appcommand_post(tags) # Check result if roo...
[ "def", "_get_zone_name", "(", "self", ")", ":", "if", "self", ".", "_name", "is", "None", ":", "# Collect tags for AppCommand.xml call", "tags", "=", "[", "\"GetZoneName\"", "]", "# Execute call", "root", "=", "self", ".", "exec_appcommand_post", "(", "tags", ")...
Get receivers zone name if not set yet.
[ "Get", "receivers", "zone", "name", "if", "not", "set", "yet", "." ]
python
train
36.95
sernst/cauldron
cauldron/cli/commander.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commander.py#L35-L61
def fetch(reload: bool = False) -> dict: """ Returns a dictionary containing all of the available Cauldron commands currently registered. This data is cached for performance. Unless the reload argument is set to True, the command list will only be generated the first time this function is called. ...
[ "def", "fetch", "(", "reload", ":", "bool", "=", "False", ")", "->", "dict", ":", "if", "len", "(", "list", "(", "COMMANDS", ".", "keys", "(", ")", ")", ")", ">", "0", "and", "not", "reload", ":", "return", "COMMANDS", "COMMANDS", ".", "clear", "...
Returns a dictionary containing all of the available Cauldron commands currently registered. This data is cached for performance. Unless the reload argument is set to True, the command list will only be generated the first time this function is called. :param reload: Whether or not to disregard...
[ "Returns", "a", "dictionary", "containing", "all", "of", "the", "available", "Cauldron", "commands", "currently", "registered", ".", "This", "data", "is", "cached", "for", "performance", ".", "Unless", "the", "reload", "argument", "is", "set", "to", "True", "t...
python
train
32.518519
boriel/zxbasic
zxbparser.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L1049-L1066
def p_lexpr(p): """ lexpr : ID EQ | LET ID EQ | ARRAY_ID EQ | LET ARRAY_ID EQ """ global LET_ASSIGNMENT LET_ASSIGNMENT = True # Mark we're about to start a LET sentence if p[1] == 'LET': p[0] = p[2] i = 2 else: p[0] = p[1] ...
[ "def", "p_lexpr", "(", "p", ")", ":", "global", "LET_ASSIGNMENT", "LET_ASSIGNMENT", "=", "True", "# Mark we're about to start a LET sentence", "if", "p", "[", "1", "]", "==", "'LET'", ":", "p", "[", "0", "]", "=", "p", "[", "2", "]", "i", "=", "2", "el...
lexpr : ID EQ | LET ID EQ | ARRAY_ID EQ | LET ARRAY_ID EQ
[ "lexpr", ":", "ID", "EQ", "|", "LET", "ID", "EQ", "|", "ARRAY_ID", "EQ", "|", "LET", "ARRAY_ID", "EQ" ]
python
train
19.944444
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L60-L69
def show_in_external_file_explorer(fnames=None): """Show files in external file explorer Args: fnames (list): Names of files to show. """ if not isinstance(fnames, (tuple, list)): fnames = [fnames] for fname in fnames: open_file_in_external_explorer(fname)
[ "def", "show_in_external_file_explorer", "(", "fnames", "=", "None", ")", ":", "if", "not", "isinstance", "(", "fnames", ",", "(", "tuple", ",", "list", ")", ")", ":", "fnames", "=", "[", "fnames", "]", "for", "fname", "in", "fnames", ":", "open_file_in_...
Show files in external file explorer Args: fnames (list): Names of files to show.
[ "Show", "files", "in", "external", "file", "explorer", "Args", ":", "fnames", "(", "list", ")", ":", "Names", "of", "files", "to", "show", "." ]
python
train
30.1