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
BasementCat/bubbler
bubbler/__init__.py
https://github.com/BasementCat/bubbler/blob/ac3c6be8358cd4f448a95545c5b493581fd1854a/bubbler/__init__.py#L120-L138
def getContext(self, context_name = 'default'): """Get a context by name, create the default context if it does not exist Params: context_name (string): Context name Raises: KeyError: If the context name does not exist Returns: bubbler.Bubbler: Named context """ if con...
[ "def", "getContext", "(", "self", ",", "context_name", "=", "'default'", ")", ":", "if", "context_name", "==", "'default'", "and", "'default'", "not", "in", "self", ".", "contexts", ":", "self", "(", "'default'", ")", "return", "self", ".", "contexts", "["...
Get a context by name, create the default context if it does not exist Params: context_name (string): Context name Raises: KeyError: If the context name does not exist Returns: bubbler.Bubbler: Named context
[ "Get", "a", "context", "by", "name", "create", "the", "default", "context", "if", "it", "does", "not", "exist", "Params", ":", "context_name", "(", "string", ")", ":", "Context", "name", "Raises", ":", "KeyError", ":", "If", "the", "context", "name", "do...
python
train
22.105263
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1278-L1295
def resume_service(name): """ Resume the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{pause_ser...
[ "def", "resume_service", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_CONNECT", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManager", ",", "name", ",", "d...
Resume the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service}
[ "Resume", "the", "service", "given", "by", "name", "." ]
python
train
37.333333
jmcgeheeiv/pyfakefs
pyfakefs/fake_filesystem.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L2485-L2510
def add_real_paths(self, path_list, read_only=True, lazy_dir_read=True): """This convenience method adds multiple files and/or directories from the real file system to the fake file system. See `add_real_file()` and `add_real_directory()`. Args: path_list: List of file and d...
[ "def", "add_real_paths", "(", "self", ",", "path_list", ",", "read_only", "=", "True", ",", "lazy_dir_read", "=", "True", ")", ":", "for", "path", "in", "path_list", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "self", ".", "add...
This convenience method adds multiple files and/or directories from the real file system to the fake file system. See `add_real_file()` and `add_real_directory()`. Args: path_list: List of file and directory paths in the real file system. read_only: If se...
[ "This", "convenience", "method", "adds", "multiple", "files", "and", "/", "or", "directories", "from", "the", "real", "file", "system", "to", "the", "fake", "file", "system", ".", "See", "add_real_file", "()", "and", "add_real_directory", "()", "." ]
python
train
46.961538
tek/ribosome
ribosome/rpc/comm.py
https://github.com/tek/ribosome/blob/b2ce9e118faa46d93506cbbb5f27ecfbd4e8a1cc/ribosome/rpc/comm.py#L105-L114
def exclusive_ns(guard: StateGuard[A], desc: str, thunk: Callable[..., NS[A, B]], *a: Any) -> Do: '''this is the central unsafe function, using a lock and updating the state in `guard` in-place. ''' yield guard.acquire() log.debug2(lambda: f'exclusive: {desc}') state, response = yield N.ensure_failu...
[ "def", "exclusive_ns", "(", "guard", ":", "StateGuard", "[", "A", "]", ",", "desc", ":", "str", ",", "thunk", ":", "Callable", "[", "...", ",", "NS", "[", "A", ",", "B", "]", "]", ",", "*", "a", ":", "Any", ")", "->", "Do", ":", "yield", "gua...
this is the central unsafe function, using a lock and updating the state in `guard` in-place.
[ "this", "is", "the", "central", "unsafe", "function", "using", "a", "lock", "and", "updating", "the", "state", "in", "guard", "in", "-", "place", "." ]
python
test
51.5
seequent/properties
properties/base/containers.py
https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L307-L316
def serialize(self, value, **kwargs): """Return a serialized copy of the tuple""" kwargs.update({'include_class': kwargs.get('include_class', True)}) if self.serializer is not None: return self.serializer(value, **kwargs) if value is None: return None seri...
[ "def", "serialize", "(", "self", ",", "value", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'include_class'", ":", "kwargs", ".", "get", "(", "'include_class'", ",", "True", ")", "}", ")", "if", "self", ".", "serializer", "i...
Return a serialized copy of the tuple
[ "Return", "a", "serialized", "copy", "of", "the", "tuple" ]
python
train
42.4
grycap/RADL
radl/radl.py
https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl.py#L318-L335
def getValue(self, prop, default=None): """Return the value of feature with that name or ``default``.""" f = self.props.get(prop, None) if not f: return default if isinstance(f, Feature): return f.getValue() if isinstance(f, tuple): # if f[0]....
[ "def", "getValue", "(", "self", ",", "prop", ",", "default", "=", "None", ")", ":", "f", "=", "self", ".", "props", ".", "get", "(", "prop", ",", "None", ")", "if", "not", "f", ":", "return", "default", "if", "isinstance", "(", "f", ",", "Feature...
Return the value of feature with that name or ``default``.
[ "Return", "the", "value", "of", "feature", "with", "that", "name", "or", "default", "." ]
python
train
35
RudolfCardinal/pythonlib
cardinal_pythonlib/interval.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/interval.py#L925-L974
def subset(self, interval: Interval, flexibility: int = 2) -> "IntervalList": """ Returns an IntervalList that's a subset of this one, only containing intervals that meet the "interval" parameter criterion. What "meet" means is defined by the ``flexibility`` parameter. ...
[ "def", "subset", "(", "self", ",", "interval", ":", "Interval", ",", "flexibility", ":", "int", "=", "2", ")", "->", "\"IntervalList\"", ":", "if", "flexibility", "not", "in", "[", "0", ",", "1", ",", "2", "]", ":", "raise", "ValueError", "(", "\"sub...
Returns an IntervalList that's a subset of this one, only containing intervals that meet the "interval" parameter criterion. What "meet" means is defined by the ``flexibility`` parameter. ``flexibility == 0``: permits only wholly contained intervals: .. code-block:: none i...
[ "Returns", "an", "IntervalList", "that", "s", "a", "subset", "of", "this", "one", "only", "containing", "intervals", "that", "meet", "the", "interval", "parameter", "criterion", ".", "What", "meet", "means", "is", "defined", "by", "the", "flexibility", "parame...
python
train
33
pybel/pybel
src/pybel/struct/query/query.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/query/query.py#L111-L119
def run(self, manager): """Run this query and returns the resulting BEL graph. :param manager: A cache manager :rtype: Optional[pybel.BELGraph] """ universe = self._get_universe(manager) graph = self.seeding.run(universe) return self.pipeline.run(graph, universe=...
[ "def", "run", "(", "self", ",", "manager", ")", ":", "universe", "=", "self", ".", "_get_universe", "(", "manager", ")", "graph", "=", "self", ".", "seeding", ".", "run", "(", "universe", ")", "return", "self", ".", "pipeline", ".", "run", "(", "grap...
Run this query and returns the resulting BEL graph. :param manager: A cache manager :rtype: Optional[pybel.BELGraph]
[ "Run", "this", "query", "and", "returns", "the", "resulting", "BEL", "graph", "." ]
python
train
35.666667
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/builtin_trap.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/builtin_trap.py#L91-L96
def remove_builtin(self, key, orig): """Remove an added builtin and re-set the original.""" if orig is BuiltinUndefined: del __builtin__.__dict__[key] else: __builtin__.__dict__[key] = orig
[ "def", "remove_builtin", "(", "self", ",", "key", ",", "orig", ")", ":", "if", "orig", "is", "BuiltinUndefined", ":", "del", "__builtin__", ".", "__dict__", "[", "key", "]", "else", ":", "__builtin__", ".", "__dict__", "[", "key", "]", "=", "orig" ]
Remove an added builtin and re-set the original.
[ "Remove", "an", "added", "builtin", "and", "re", "-", "set", "the", "original", "." ]
python
test
38.666667
pantsbuild/pants
src/python/pants/util/memo.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/memo.py#L177-L240
def memoized_property(func=None, key_factory=per_instance, **kwargs): """A convenience wrapper for memoizing properties. Applied like so: >>> class Foo(object): ... @memoized_property ... def name(self): ... pass Is equivalent to: >>> class Foo(object): ... @property ... @memoized_me...
[ "def", "memoized_property", "(", "func", "=", "None", ",", "key_factory", "=", "per_instance", ",", "*", "*", "kwargs", ")", ":", "getter", "=", "memoized_method", "(", "func", "=", "func", ",", "key_factory", "=", "key_factory", ",", "*", "*", "kwargs", ...
A convenience wrapper for memoizing properties. Applied like so: >>> class Foo(object): ... @memoized_property ... def name(self): ... pass Is equivalent to: >>> class Foo(object): ... @property ... @memoized_method ... def name(self): ... pass Which is equivalent to: >...
[ "A", "convenience", "wrapper", "for", "memoizing", "properties", "." ]
python
train
28.34375
oscarbranson/latools
latools/latools.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/latools.py#L3449-L3475
def filter_reports(self, analytes, filt_str='all', nbin=5, samples=None, outdir=None, subset='All_Samples'): """ Plot filter reports for all filters that contain ``filt_str`` in the name. """ if outdir is None: outdir = self.report_dir + '/filte...
[ "def", "filter_reports", "(", "self", ",", "analytes", ",", "filt_str", "=", "'all'", ",", "nbin", "=", "5", ",", "samples", "=", "None", ",", "outdir", "=", "None", ",", "subset", "=", "'All_Samples'", ")", ":", "if", "outdir", "is", "None", ":", "o...
Plot filter reports for all filters that contain ``filt_str`` in the name.
[ "Plot", "filter", "reports", "for", "all", "filters", "that", "contain", "filt_str", "in", "the", "name", "." ]
python
test
38.62963
aksas/pypo4sel
core/pypo4sel/core/waiter.py
https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/waiter.py#L86-L96
def wait_not_displayed(element, timeout=None, fail_on_timeout=None): """ Wait until element becomes invisible or time out. Returns true is element became invisible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :pa...
[ "def", "wait_not_displayed", "(", "element", ",", "timeout", "=", "None", ",", "fail_on_timeout", "=", "None", ")", ":", "return", "wait", "(", "lambda", ":", "not", "element", ".", "is_displayed", "(", ")", ",", "timeout", "or", "element", ".", "wait_time...
Wait until element becomes invisible or time out. Returns true is element became invisible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :param fail_on_timeout: :return:
[ "Wait", "until", "element", "becomes", "invisible", "or", "time", "out", ".", "Returns", "true", "is", "element", "became", "invisible", "otherwise", "false", ".", "If", "timeout", "is", "not", "specified", "or", "0", "then", "uses", "specific", "element", "...
python
train
41.181818
numenta/nupic
src/nupic/frameworks/opf/model.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L239-L265
def writeToCheckpoint(self, checkpointDir): """Serializes model using capnproto and writes data to ``checkpointDir``""" proto = self.getSchema().new_message() self.write(proto) checkpointPath = self._getModelCheckpointFilePath(checkpointDir) # Clean up old saved state, if any if os.path.exist...
[ "def", "writeToCheckpoint", "(", "self", ",", "checkpointDir", ")", ":", "proto", "=", "self", ".", "getSchema", "(", ")", ".", "new_message", "(", ")", "self", ".", "write", "(", "proto", ")", "checkpointPath", "=", "self", ".", "_getModelCheckpointFilePath...
Serializes model using capnproto and writes data to ``checkpointDir``
[ "Serializes", "model", "using", "capnproto", "and", "writes", "data", "to", "checkpointDir" ]
python
valid
39.037037
Jajcus/pyxmpp2
pyxmpp2/stanzaprocessor.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/stanzaprocessor.py#L504-L517
def send(self, stanza): """Send a stanza somwhere. The default implementation sends it via the `uplink` if it is defined or raises the `NoRouteError`. :Parameters: - `stanza`: the stanza to send. :Types: - `stanza`: `pyxmpp.stanza.Stanza`""" if s...
[ "def", "send", "(", "self", ",", "stanza", ")", ":", "if", "self", ".", "uplink", ":", "self", ".", "uplink", ".", "send", "(", "stanza", ")", "else", ":", "raise", "NoRouteError", "(", "\"No route for stanza\"", ")" ]
Send a stanza somwhere. The default implementation sends it via the `uplink` if it is defined or raises the `NoRouteError`. :Parameters: - `stanza`: the stanza to send. :Types: - `stanza`: `pyxmpp.stanza.Stanza`
[ "Send", "a", "stanza", "somwhere", "." ]
python
valid
30.214286
3DLIRIOUS/MeshLabXML
meshlabxml/texture.py
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/texture.py#L6-L30
def flat_plane(script, plane=0, aspect_ratio=False): """Flat plane parameterization """ filter_xml = ''.join([ ' <filter name="Parametrization: Flat Plane ">\n', ' <Param name="projectionPlane"', 'value="%d"' % plane, 'description="Projection plane"', 'enum_val0=...
[ "def", "flat_plane", "(", "script", ",", "plane", "=", "0", ",", "aspect_ratio", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Parametrization: Flat Plane \">\\n'", ",", "' <Param name=\"projectionPlane\"'", ",", "'val...
Flat plane parameterization
[ "Flat", "plane", "parameterization" ]
python
test
36.04
glomex/gcdt
gcdt/kumo_core.py
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_core.py#L322-L344
def deploy_stack(awsclient, context, conf, cloudformation, override_stack_policy=False): """Deploy the stack to AWS cloud. Does either create or update the stack. :param conf: :param override_stack_policy: :return: exit_code """ stack_name = _get_stack_name(conf) parameters = _generate_para...
[ "def", "deploy_stack", "(", "awsclient", ",", "context", ",", "conf", ",", "cloudformation", ",", "override_stack_policy", "=", "False", ")", ":", "stack_name", "=", "_get_stack_name", "(", "conf", ")", "parameters", "=", "_generate_parameters", "(", "conf", ")"...
Deploy the stack to AWS cloud. Does either create or update the stack. :param conf: :param override_stack_policy: :return: exit_code
[ "Deploy", "the", "stack", "to", "AWS", "cloud", ".", "Does", "either", "create", "or", "update", "the", "stack", "." ]
python
train
45.304348
pypa/pipenv
pipenv/vendor/distlib/locators.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/locators.py#L1147-L1185
def try_to_replace(self, provider, other, problems): """ Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must ...
[ "def", "try_to_replace", "(", "self", ",", "provider", ",", "other", ",", "problems", ")", ":", "rlist", "=", "self", ".", "reqts", "[", "other", "]", "unmatched", "=", "set", "(", ")", "for", "s", "in", "rlist", ":", "matcher", "=", "self", ".", "...
Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must meet all the requirements which ``other`` fulfills. :par...
[ "Attempt", "to", "replace", "one", "provider", "with", "another", ".", "This", "is", "typically", "used", "when", "resolving", "dependencies", "from", "multiple", "sources", "e", ".", "g", ".", "A", "requires", "(", "B", ">", "=", "1", ".", "0", ")", "...
python
train
42.820513
pgxcentre/geneparse
geneparse/readers/dataframe.py
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/dataframe.py#L50-L68
def iter_genotypes(self): """Iterates on available markers. Returns: Genotypes instances. """ # Parsing each column of the dataframe for variant in self.df.columns: genotypes = self.df.loc[:, variant].values info = self.map_info.loc[variant, ...
[ "def", "iter_genotypes", "(", "self", ")", ":", "# Parsing each column of the dataframe", "for", "variant", "in", "self", ".", "df", ".", "columns", ":", "genotypes", "=", "self", ".", "df", ".", "loc", "[", ":", ",", "variant", "]", ".", "values", "info",...
Iterates on available markers. Returns: Genotypes instances.
[ "Iterates", "on", "available", "markers", "." ]
python
train
29.210526
bitesofcode/projexui
projexui/widgets/xcombobox.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L167-L176
def checkedItems( self ): """ Returns the checked items for this combobox. :return [<str>, ..] """ if not self.isCheckable(): return [] return [nativestring(self.itemText(i)) for i in self.checkedIndexes()]
[ "def", "checkedItems", "(", "self", ")", ":", "if", "not", "self", ".", "isCheckable", "(", ")", ":", "return", "[", "]", "return", "[", "nativestring", "(", "self", ".", "itemText", "(", "i", ")", ")", "for", "i", "in", "self", ".", "checkedIndexes"...
Returns the checked items for this combobox. :return [<str>, ..]
[ "Returns", "the", "checked", "items", "for", "this", "combobox", ".", ":", "return", "[", "<str", ">", "..", "]" ]
python
train
27.9
seung-lab/cloud-volume
cloudvolume/cloudvolume.py
https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/cloudvolume.py#L1191-L1259
def upload_from_shared_memory(self, location, bbox, order='F', cutout_bbox=None): """ Upload from a shared memory array. https://github.com/seung-lab/cloud-volume/wiki/Advanced-Topic:-Shared-Memory tip: If you want to use slice notation, np.s_[...] will help in a pinch. MEMORY LIFECYCLE WARNING:...
[ "def", "upload_from_shared_memory", "(", "self", ",", "location", ",", "bbox", ",", "order", "=", "'F'", ",", "cutout_bbox", "=", "None", ")", ":", "def", "tobbox", "(", "x", ")", ":", "if", "type", "(", "x", ")", "==", "Bbox", ":", "return", "x", ...
Upload from a shared memory array. https://github.com/seung-lab/cloud-volume/wiki/Advanced-Topic:-Shared-Memory tip: If you want to use slice notation, np.s_[...] will help in a pinch. MEMORY LIFECYCLE WARNING: You are responsible for managing the lifecycle of the shared memory. CloudVolume will ...
[ "Upload", "from", "a", "shared", "memory", "array", "." ]
python
train
45.652174
yyuu/botornado
botornado/sqs/connection.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/botornado/sqs/connection.py#L47-L75
def create_queue(self, queue_name, visibility_timeout=None, callback=None): """ Create an SQS Queue. :type queue_name: str or unicode :param queue_name: The name of the new queue. Names are scoped to an account and need to be unique within that ...
[ "def", "create_queue", "(", "self", ",", "queue_name", ",", "visibility_timeout", "=", "None", ",", "callback", "=", "None", ")", ":", "params", "=", "{", "'QueueName'", ":", "queue_name", "}", "if", "visibility_timeout", ":", "params", "[", "'DefaultVisibilit...
Create an SQS Queue. :type queue_name: str or unicode :param queue_name: The name of the new queue. Names are scoped to an account and need to be unique within that account. Calling this method on an existing queue name ...
[ "Create", "an", "SQS", "Queue", "." ]
python
train
51.034483
tanghaibao/goatools
goatools/grouper/aart_geneproducts_all.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_all.py#L49-L88
def prt_mrks(self, name_marks_list, prt=sys.stdout): """Print summary of all GOEAs. Example: Key for GO sections: A immune B viral/bacteria C neuro D cell death E lipid F adhesion G cell cycle ...
[ "def", "prt_mrks", "(", "self", ",", "name_marks_list", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "if", "not", "name_marks_list", ":", "return", "# prt.write(\"\\nKey for GO sections:\\n\")", "# self.prt_section_key(prt)", "prt", ".", "write", "(", "\"\\n{HDR...
Print summary of all GOEAs. Example: Key for GO sections: A immune B viral/bacteria C neuro D cell death E lipid F adhesion G cell cycle H chromosome I development J ...
[ "Print", "summary", "of", "all", "GOEAs", ".", "Example", ":", "Key", "for", "GO", "sections", ":", "A", "immune", "B", "viral", "/", "bacteria", "C", "neuro", "D", "cell", "death", "E", "lipid", "F", "adhesion", "G", "cell", "cycle", "H", "chromosome"...
python
train
31.625
facelessuser/wcmatch
wcmatch/_wcparse.py
https://github.com/facelessuser/wcmatch/blob/d153e7007cc73b994ae1ba553dc4584039f5c212/wcmatch/_wcparse.py#L322-L343
def _sequence(self, i): """Handle character group.""" c = next(i) if c == '!': c = next(i) if c in ('^', '-', '['): c = next(i) while c != ']': if c == '\\': # Handle escapes subindex = i.index ...
[ "def", "_sequence", "(", "self", ",", "i", ")", ":", "c", "=", "next", "(", "i", ")", "if", "c", "==", "'!'", ":", "c", "=", "next", "(", "i", ")", "if", "c", "in", "(", "'^'", ",", "'-'", ",", "'['", ")", ":", "c", "=", "next", "(", "i...
Handle character group.
[ "Handle", "character", "group", "." ]
python
train
27.5
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L361-L389
def start(self): '''start sending packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.connect(('', gen_setting...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_D...
start sending packets
[ "start", "sending", "packets" ]
python
train
35.034483
PmagPy/PmagPy
dialogs/demag_interpretation_editor.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/demag_interpretation_editor.py#L731-L740
def on_select_mean_type_box(self, event): """ set parent Zeq_GUI to reflect change in this box and change the @param: event -> the wx.ComboBoxEvent that triggered this function """ new_mean_type = self.mean_type_box.GetValue() if new_mean_type == "None": self....
[ "def", "on_select_mean_type_box", "(", "self", ",", "event", ")", ":", "new_mean_type", "=", "self", ".", "mean_type_box", ".", "GetValue", "(", ")", "if", "new_mean_type", "==", "\"None\"", ":", "self", ".", "parent", ".", "clear_high_level_pars", "(", ")", ...
set parent Zeq_GUI to reflect change in this box and change the @param: event -> the wx.ComboBoxEvent that triggered this function
[ "set", "parent", "Zeq_GUI", "to", "reflect", "change", "in", "this", "box", "and", "change", "the" ]
python
train
45.9
belbio/bel
bel/scripts.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/scripts.py#L252-L302
def convert_belscript(ctx, input_fn, output_fn): """Convert belscript to nanopubs_bel format This will convert the OpenBEL BELScript file format to nanopub_bel-1.0.0 format. \b input_fn: If input fn has *.gz, will read as a gzip file \b output_fn: If output fn has *.gz, wi...
[ "def", "convert_belscript", "(", "ctx", ",", "input_fn", ",", "output_fn", ")", ":", "try", ":", "(", "out_fh", ",", "yaml_flag", ",", "jsonl_flag", ",", "json_flag", ",", ")", "=", "bel", ".", "nanopub", ".", "files", ".", "create_nanopubs_fh", "(", "ou...
Convert belscript to nanopubs_bel format This will convert the OpenBEL BELScript file format to nanopub_bel-1.0.0 format. \b input_fn: If input fn has *.gz, will read as a gzip file \b output_fn: If output fn has *.gz, will written as a gzip file If output fn has *.jso...
[ "Convert", "belscript", "to", "nanopubs_bel", "format" ]
python
train
26.117647
gear11/pypelogs
pypein/flickr.py
https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypein/flickr.py#L108-L133
def _paged_api_call(self, func, kwargs, item_type='photo'): """ Takes a Flickr API function object and dict of keyword args and calls the API call repeatedly with an incrementing page value until all contents are exhausted. Flickr seems to limit to about 500 items. """ pa...
[ "def", "_paged_api_call", "(", "self", ",", "func", ",", "kwargs", ",", "item_type", "=", "'photo'", ")", ":", "page", "=", "1", "while", "True", ":", "LOG", ".", "info", "(", "\"Fetching page %s\"", "%", "page", ")", "kwargs", "[", "'page'", "]", "=",...
Takes a Flickr API function object and dict of keyword args and calls the API call repeatedly with an incrementing page value until all contents are exhausted. Flickr seems to limit to about 500 items.
[ "Takes", "a", "Flickr", "API", "function", "object", "and", "dict", "of", "keyword", "args", "and", "calls", "the", "API", "call", "repeatedly", "with", "an", "incrementing", "page", "value", "until", "all", "contents", "are", "exhausted", ".", "Flickr", "se...
python
train
40.038462
UDST/pandana
pandana/loaders/osm.py
https://github.com/UDST/pandana/blob/961a7ef8d3b0144b190cb60bbd61845fca6fb314/pandana/loaders/osm.py#L13-L58
def pdna_network_from_bbox( lat_min=None, lng_min=None, lat_max=None, lng_max=None, bbox=None, network_type='walk', two_way=True, timeout=180, memory=None, max_query_area_size=50 * 1000 * 50 * 1000): """ Make a Pandana network from a bounding lat/lon box request to the Overpass API. ...
[ "def", "pdna_network_from_bbox", "(", "lat_min", "=", "None", ",", "lng_min", "=", "None", ",", "lat_max", "=", "None", ",", "lng_max", "=", "None", ",", "bbox", "=", "None", ",", "network_type", "=", "'walk'", ",", "two_way", "=", "True", ",", "timeout"...
Make a Pandana network from a bounding lat/lon box request to the Overpass API. Distance will be in the default units meters. Parameters ---------- lat_min, lng_min, lat_max, lng_max : float bbox : tuple Bounding box formatted as a 4 element tuple: (lng_max, lat_min, lng_min, lat_ma...
[ "Make", "a", "Pandana", "network", "from", "a", "bounding", "lat", "/", "lon", "box", "request", "to", "the", "Overpass", "API", ".", "Distance", "will", "be", "in", "the", "default", "units", "meters", "." ]
python
test
40.869565
artefactual-labs/mets-reader-writer
metsrw/metadata.py
https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/metadata.py#L88-L103
def parse(cls, root): """ Create a new AMDSec by parsing root. :param root: Element or ElementTree to be parsed into an object. """ if root.tag != utils.lxmlns("mets") + "amdSec": raise exceptions.ParseError( "AMDSec can only parse amdSec elements wit...
[ "def", "parse", "(", "cls", ",", "root", ")", ":", "if", "root", ".", "tag", "!=", "utils", ".", "lxmlns", "(", "\"mets\"", ")", "+", "\"amdSec\"", ":", "raise", "exceptions", ".", "ParseError", "(", "\"AMDSec can only parse amdSec elements with METS namespace.\...
Create a new AMDSec by parsing root. :param root: Element or ElementTree to be parsed into an object.
[ "Create", "a", "new", "AMDSec", "by", "parsing", "root", "." ]
python
train
35.0625
wonambi-python/wonambi
wonambi/trans/select.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/trans/select.py#L270-L308
def resample(data, s_freq=None, axis='time', ftype='fir', n=None): """Downsample the data after applying a filter. Parameters ---------- data : instance of Data data to downsample s_freq : int or float desired sampling frequency axis : str axis you want to apply downsamp...
[ "def", "resample", "(", "data", ",", "s_freq", "=", "None", ",", "axis", "=", "'time'", ",", "ftype", "=", "'fir'", ",", "n", "=", "None", ")", ":", "output", "=", "data", ".", "_copy", "(", ")", "ratio", "=", "int", "(", "data", ".", "s_freq", ...
Downsample the data after applying a filter. Parameters ---------- data : instance of Data data to downsample s_freq : int or float desired sampling frequency axis : str axis you want to apply downsample on (most likely 'time') ftype : str filter type to apply. T...
[ "Downsample", "the", "data", "after", "applying", "a", "filter", "." ]
python
train
31.769231
chrippa/ds4drv
ds4drv/uinput.py
https://github.com/chrippa/ds4drv/blob/be7327fc3f5abb8717815f2a1a2ad3d335535d8a/ds4drv/uinput.py#L472-L477
def next_joystick_device(): """Finds the next available js device name.""" for i in range(100): dev = "/dev/input/js{0}".format(i) if not os.path.exists(dev): return dev
[ "def", "next_joystick_device", "(", ")", ":", "for", "i", "in", "range", "(", "100", ")", ":", "dev", "=", "\"/dev/input/js{0}\"", ".", "format", "(", "i", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "dev", ")", ":", "return", "dev" ]
Finds the next available js device name.
[ "Finds", "the", "next", "available", "js", "device", "name", "." ]
python
train
33.333333
erdewit/ib_insync
ib_insync/ib.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1493-L1524
def reqHistoricalNews( self, conId: int, providerCodes: str, startDateTime: Union[str, datetime.date], endDateTime: Union[str, datetime.date], totalResults: int, historicalNewsOptions: List[TagValue] = None) -> HistoricalNews: """ Get historica...
[ "def", "reqHistoricalNews", "(", "self", ",", "conId", ":", "int", ",", "providerCodes", ":", "str", ",", "startDateTime", ":", "Union", "[", "str", ",", "datetime", ".", "date", "]", ",", "endDateTime", ":", "Union", "[", "str", ",", "datetime", ".", ...
Get historical news headline. https://interactivebrokers.github.io/tws-api/news.html This method is blocking. Args: conId: Search news articles for contract with this conId. providerCodes: A '+'-separated list of provider codes, like 'BZ+FLY'. ...
[ "Get", "historical", "news", "headline", "." ]
python
train
46.40625
inspirehep/refextract
refextract/documents/text.py
https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/documents/text.py#L45-L95
def get_url_repair_patterns(): """Initialise and return a list of precompiled regexp patterns that are used to try to re-assemble URLs that have been broken during a document's conversion to plain-text. @return: (list) of compiled re regexp patterns used for finding various broken URLs....
[ "def", "get_url_repair_patterns", "(", ")", ":", "file_types_list", "=", "[", "ur'h\\s*t\\s*m'", ",", "# htm", "ur'h\\s*t\\s*m\\s*l'", ",", "# html", "ur't\\s*x\\s*t'", "# txt", "ur'p\\s*h\\s*p'", "# php", "ur'a\\s*s\\s*p\\s*'", "# asp", "ur'j\\s*s\\s*p'", ",", "# jsp", ...
Initialise and return a list of precompiled regexp patterns that are used to try to re-assemble URLs that have been broken during a document's conversion to plain-text. @return: (list) of compiled re regexp patterns used for finding various broken URLs.
[ "Initialise", "and", "return", "a", "list", "of", "precompiled", "regexp", "patterns", "that", "are", "used", "to", "try", "to", "re", "-", "assemble", "URLs", "that", "have", "been", "broken", "during", "a", "document", "s", "conversion", "to", "plain", "...
python
train
39.137255
samghelms/mathviz
mathviz_hopper/src/bottle.py
https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/bottle.py#L3602-L3614
def load_app(target): """ Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter. """ global NORUN NORUN, nr_old = True, NORUN tmp = defaul...
[ "def", "load_app", "(", "target", ")", ":", "global", "NORUN", "NORUN", ",", "nr_old", "=", "True", ",", "NORUN", "tmp", "=", "default_app", ".", "push", "(", ")", "# Create a new \"default application\"", "try", ":", "rv", "=", "load", "(", "target", ")",...
Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter.
[ "Load", "a", "bottle", "application", "from", "a", "module", "and", "make", "sure", "that", "the", "import", "does", "not", "affect", "the", "current", "default", "application", "but", "returns", "a", "separate", "application", "object", ".", "See", ":", "fu...
python
train
44.769231
mitsei/dlkit
dlkit/json_/relationship/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/relationship/managers.py#L334-L356
def get_relationship_admin_session_for_family(self, family_id): """Gets the ``OsidSession`` associated with the relationship administration service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the ``Family`` return: (osid.relationship.RelationshipAdminSession) - a ...
[ "def", "get_relationship_admin_session_for_family", "(", "self", ",", "family_id", ")", ":", "if", "not", "self", ".", "supports_relationship_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "##", "# Also include check to see if the catalog Id i...
Gets the ``OsidSession`` associated with the relationship administration service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the ``Family`` return: (osid.relationship.RelationshipAdminSession) - a ``RelationshipAdminSession`` raise: NotFound - no family ...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "relationship", "administration", "service", "for", "the", "given", "family", "." ]
python
train
50.391304
xiaocong/uiautomator
uiautomator/__init__.py
https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L799-L839
def screen(self): ''' Turn on/off screen. Usage: d.screen.on() d.screen.off() d.screen == 'on' # Check if the screen is on, same as 'd.screenOn' d.screen == 'off' # Check if the screen is off, same as 'not d.screenOn' ''' devive_self = self ...
[ "def", "screen", "(", "self", ")", ":", "devive_self", "=", "self", "class", "_Screen", "(", "object", ")", ":", "def", "on", "(", "self", ")", ":", "return", "devive_self", ".", "wakeup", "(", ")", "def", "off", "(", "self", ")", ":", "return", "d...
Turn on/off screen. Usage: d.screen.on() d.screen.off() d.screen == 'on' # Check if the screen is on, same as 'd.screenOn' d.screen == 'off' # Check if the screen is off, same as 'not d.screenOn'
[ "Turn", "on", "/", "off", "screen", ".", "Usage", ":", "d", ".", "screen", ".", "on", "()", "d", ".", "screen", ".", "off", "()" ]
python
train
32.609756
wonambi-python/wonambi
wonambi/detect/slowwave.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/detect/slowwave.py#L252-L309
def _add_halfwave(data, events, s_freq, opts): """Find the next zero crossing and the intervening peak and add them to events. If no zero found before max_dur, event is discarded. If peak-to-peak is smaller than min_ptp, the event is discarded. Parameters ---------- data : ndarray (dtype='float...
[ "def", "_add_halfwave", "(", "data", ",", "events", ",", "s_freq", ",", "opts", ")", ":", "max_dur", "=", "opts", ".", "duration", "[", "1", "]", "if", "max_dur", "is", "None", ":", "max_dur", "=", "MAXIMUM_DURATION", "window", "=", "int", "(", "s_freq...
Find the next zero crossing and the intervening peak and add them to events. If no zero found before max_dur, event is discarded. If peak-to-peak is smaller than min_ptp, the event is discarded. Parameters ---------- data : ndarray (dtype='float') vector with the data events : ndarray (...
[ "Find", "the", "next", "zero", "crossing", "and", "the", "intervening", "peak", "and", "add", "them", "to", "events", ".", "If", "no", "zero", "found", "before", "max_dur", "event", "is", "discarded", ".", "If", "peak", "-", "to", "-", "peak", "is", "s...
python
train
31.034483
frostming/atoml
atoml/decoder.py
https://github.com/frostming/atoml/blob/85414ef77777366887a819a05b496d5279296cd2/atoml/decoder.py#L428-L463
def split_string(self, string, splitter='.', allow_empty=True): """Split the string with respect of quotes""" i = 0 rv = [] need_split = False while i < len(string): m = re.compile(_KEY_NAME).match(string, i) if not need_split and m: i = m....
[ "def", "split_string", "(", "self", ",", "string", ",", "splitter", "=", "'.'", ",", "allow_empty", "=", "True", ")", ":", "i", "=", "0", "rv", "=", "[", "]", "need_split", "=", "False", "while", "i", "<", "len", "(", "string", ")", ":", "m", "="...
Split the string with respect of quotes
[ "Split", "the", "string", "with", "respect", "of", "quotes" ]
python
train
39
google/transitfeed
transitfeed/util.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L449-L455
def FindUniqueId(dic): """Return a string not used as a key in the dictionary dic""" name = str(len(dic)) while name in dic: # Use bigger numbers so it is obvious when an id is picked randomly. name = str(random.randint(1000000, 999999999)) return name
[ "def", "FindUniqueId", "(", "dic", ")", ":", "name", "=", "str", "(", "len", "(", "dic", ")", ")", "while", "name", "in", "dic", ":", "# Use bigger numbers so it is obvious when an id is picked randomly.", "name", "=", "str", "(", "random", ".", "randint", "("...
Return a string not used as a key in the dictionary dic
[ "Return", "a", "string", "not", "used", "as", "a", "key", "in", "the", "dictionary", "dic" ]
python
train
37.428571
robinandeer/puzzle
puzzle/utils/get_info.py
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_info.py#L121-L139
def get_cytoband_coord(chrom, pos): """Get the cytoband coordinate for a position Args: chrom(str): A chromosome pos(int): The position Returns: cytoband """ chrom = chrom.strip('chr') pos = int(pos) result = None logger.debug("Finding Cytoba...
[ "def", "get_cytoband_coord", "(", "chrom", ",", "pos", ")", ":", "chrom", "=", "chrom", ".", "strip", "(", "'chr'", ")", "pos", "=", "int", "(", "pos", ")", "result", "=", "None", "logger", ".", "debug", "(", "\"Finding Cytoband for chrom:{0} pos:{1}\"", "...
Get the cytoband coordinate for a position Args: chrom(str): A chromosome pos(int): The position Returns: cytoband
[ "Get", "the", "cytoband", "coordinate", "for", "a", "position" ]
python
train
26.263158
wandb/client
wandb/vendor/prompt_toolkit/styles/utils.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/styles/utils.py#L10-L25
def split_token_in_parts(token): """ Take a Token, and turn it in a list of tokens, by splitting it on ':' (taking that as a separator.) """ result = [] current = [] for part in token + (':', ): if part == ':': if current: result.append(tuple(current)) ...
[ "def", "split_token_in_parts", "(", "token", ")", ":", "result", "=", "[", "]", "current", "=", "[", "]", "for", "part", "in", "token", "+", "(", "':'", ",", ")", ":", "if", "part", "==", "':'", ":", "if", "current", ":", "result", ".", "append", ...
Take a Token, and turn it in a list of tokens, by splitting it on ':' (taking that as a separator.)
[ "Take", "a", "Token", "and", "turn", "it", "in", "a", "list", "of", "tokens", "by", "splitting", "it", "on", ":", "(", "taking", "that", "as", "a", "separator", ".", ")" ]
python
train
24.75
timothycrosley/isort
isort/isort.py
https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L423-L547
def _add_formatted_imports(self) -> None: """Adds the imports back to the file. (at the index of the first import) sorted alphabetically and split between groups """ sort_ignore_case = self.config['force_alphabetical_sort_within_sections'] sections = itertools.chain(self.sectio...
[ "def", "_add_formatted_imports", "(", "self", ")", "->", "None", ":", "sort_ignore_case", "=", "self", ".", "config", "[", "'force_alphabetical_sort_within_sections'", "]", "sections", "=", "itertools", ".", "chain", "(", "self", ".", "sections", ",", "self", "....
Adds the imports back to the file. (at the index of the first import) sorted alphabetically and split between groups
[ "Adds", "the", "imports", "back", "to", "the", "file", "." ]
python
train
48.76
hekyou/python-ltsv
ltsv/_reader.py
https://github.com/hekyou/python-ltsv/blob/fd5e9c82c28da666d1dbdb3318f6e90d86143ff8/ltsv/_reader.py#L28-L36
def DictReader(ltsvfile, labels=None, dict_type=dict): """Make LTSV Reader for reading selected labels. :param ltsvfile: iterable of lines. :param labels: sequence of labels. :return: generator of record in {label: value, ...} form. """ for rec in reader(ltsvfile, labels): yield dict_...
[ "def", "DictReader", "(", "ltsvfile", ",", "labels", "=", "None", ",", "dict_type", "=", "dict", ")", ":", "for", "rec", "in", "reader", "(", "ltsvfile", ",", "labels", ")", ":", "yield", "dict_type", "(", "rec", ")" ]
Make LTSV Reader for reading selected labels. :param ltsvfile: iterable of lines. :param labels: sequence of labels. :return: generator of record in {label: value, ...} form.
[ "Make", "LTSV", "Reader", "for", "reading", "selected", "labels", "." ]
python
valid
35.666667
python-cmd2/cmd2
cmd2/cmd2.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L655-L708
def ppaged(self, msg: str, end: str = '\n', chop: bool = False) -> None: """Print output using a pager if it would go off screen and stdout isn't currently being redirected. Never uses a pager inside of a script (Python or text) or when output is being redirected or piped or when stdout or stdi...
[ "def", "ppaged", "(", "self", ",", "msg", ":", "str", ",", "end", ":", "str", "=", "'\\n'", ",", "chop", ":", "bool", "=", "False", ")", "->", "None", ":", "import", "subprocess", "if", "msg", "is", "not", "None", "and", "msg", "!=", "''", ":", ...
Print output using a pager if it would go off screen and stdout isn't currently being redirected. Never uses a pager inside of a script (Python or text) or when output is being redirected or piped or when stdout or stdin are not a fully functional terminal. :param msg: message to print to curr...
[ "Print", "output", "using", "a", "pager", "if", "it", "would", "go", "off", "screen", "and", "stdout", "isn", "t", "currently", "being", "redirected", "." ]
python
train
63.592593
Clinical-Genomics/scout
scout/parse/variant/headers.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/parse/variant/headers.py#L24-L38
def parse_header_format(description): """Get the format from a vcf header line description If format begins with white space it will be stripped Args: description(str): Description from a vcf header line Return: format(str): The format information from description """ ...
[ "def", "parse_header_format", "(", "description", ")", ":", "description", "=", "description", ".", "strip", "(", "'\"'", ")", "keyword", "=", "'Format:'", "before_keyword", ",", "keyword", ",", "after_keyword", "=", "description", ".", "partition", "(", "keywor...
Get the format from a vcf header line description If format begins with white space it will be stripped Args: description(str): Description from a vcf header line Return: format(str): The format information from description
[ "Get", "the", "format", "from", "a", "vcf", "header", "line", "description", "If", "format", "begins", "with", "white", "space", "it", "will", "be", "stripped", "Args", ":", "description", "(", "str", ")", ":", "Description", "from", "a", "vcf", "header", ...
python
test
31.933333
Naught0/asyncurban
asyncurban/urbandictionary.py
https://github.com/Naught0/asyncurban/blob/ae571a13c52869399808ac88a46ea45888ac0181/asyncurban/urbandictionary.py#L86-L109
async def search(self, term: str, limit: int = 3) -> 'List[Word]': """Performs a search for a term and returns a list of possible matching :class:`Word` objects. Args: term: The term to be defined. limit (optional): Max amount of results returned. ...
[ "async", "def", "search", "(", "self", ",", "term", ":", "str", ",", "limit", ":", "int", "=", "3", ")", "->", "'List[Word]'", ":", "resp", "=", "await", "self", ".", "_get", "(", "term", "=", "term", ")", "words", "=", "resp", "[", "'list'", "]"...
Performs a search for a term and returns a list of possible matching :class:`Word` objects. Args: term: The term to be defined. limit (optional): Max amount of results returned. Defaults to 3. Note: The API will relay...
[ "Performs", "a", "search", "for", "a", "term", "and", "returns", "a", "list", "of", "possible", "matching", ":", "class", ":", "Word", "objects", ".", "Args", ":", "term", ":", "The", "term", "to", "be", "defined", ".", "limit", "(", "optional", ")", ...
python
train
37.708333
GNS3/gns3-server
gns3server/controller/compute.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L376-L388
def http_query(self, method, path, data=None, dont_connect=False, **kwargs): """ :param dont_connect: If true do not reconnect if not connected """ if not self._connected and not dont_connect: if self._id == "vm" and not self._controller.gns3vm.running: yield...
[ "def", "http_query", "(", "self", ",", "method", ",", "path", ",", "data", "=", "None", ",", "dont_connect", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_connected", "and", "not", "dont_connect", ":", "if", "self", "."...
:param dont_connect: If true do not reconnect if not connected
[ ":", "param", "dont_connect", ":", "If", "true", "do", "not", "reconnect", "if", "not", "connected" ]
python
train
51
apache/incubator-mxnet
python/mxnet/symbol/symbol.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2718-L2739
def load_json(json_str): """Loads symbol from json string. Parameters ---------- json_str : str A JSON string. Returns ------- sym : Symbol The loaded symbol. See Also -------- Symbol.tojson : Used to save symbol into json string. """ if not isinstance(...
[ "def", "load_json", "(", "json_str", ")", ":", "if", "not", "isinstance", "(", "json_str", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'fname required to be string'", ")", "handle", "=", "SymbolHandle", "(", ")", "check_call", "(", "_LIB", ".", ...
Loads symbol from json string. Parameters ---------- json_str : str A JSON string. Returns ------- sym : Symbol The loaded symbol. See Also -------- Symbol.tojson : Used to save symbol into json string.
[ "Loads", "symbol", "from", "json", "string", "." ]
python
train
23.409091
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L231-L262
def morphAveragePitch(fromDataList, toDataList): ''' Adjusts the values in fromPitchList to have the same average as toPitchList Because other manipulations can alter the average pitch, morphing the pitch is the last pitch manipulation that should be done After the morphing, the code remov...
[ "def", "morphAveragePitch", "(", "fromDataList", ",", "toDataList", ")", ":", "timeList", ",", "fromPitchList", "=", "zip", "(", "*", "fromDataList", ")", "toPitchList", "=", "[", "pitchVal", "for", "_", ",", "pitchVal", "in", "toDataList", "]", "# Zero pitch ...
Adjusts the values in fromPitchList to have the same average as toPitchList Because other manipulations can alter the average pitch, morphing the pitch is the last pitch manipulation that should be done After the morphing, the code removes any values below zero, thus the final average might no...
[ "Adjusts", "the", "values", "in", "fromPitchList", "to", "have", "the", "same", "average", "as", "toPitchList", "Because", "other", "manipulations", "can", "alter", "the", "average", "pitch", "morphing", "the", "pitch", "is", "the", "last", "pitch", "manipulatio...
python
train
38.71875
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_cee_map.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_cee_map.py#L152-L164
def cee_map_priority_table_map_cos5_pgid(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") cee_map = ET.SubElement(config, "cee-map", xmlns="urn:brocade.com:mgmt:brocade-cee-map") name_key = ET.SubElement(cee_map, "name") name_key.text = kwargs.pop...
[ "def", "cee_map_priority_table_map_cos5_pgid", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "cee_map", "=", "ET", ".", "SubElement", "(", "config", ",", "\"cee-map\"", ",", "xmlns", "=", "\"ur...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
46.230769
BD2KGenomics/protect
src/protect/common.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/common.py#L557-L582
def chrom_sorted(in_chroms): """ Sort a list of chromosomes in the order 1..22, X, Y, M, <others in alphabetical order>. :param list in_chroms: Input chromosomes :return: Sorted chromosomes :rtype: list[str] """ in_chroms.sort() canonicals = [str(c) for c in range(1, 23)] + ['X', 'Y', '...
[ "def", "chrom_sorted", "(", "in_chroms", ")", ":", "in_chroms", ".", "sort", "(", ")", "canonicals", "=", "[", "str", "(", "c", ")", "for", "c", "in", "range", "(", "1", ",", "23", ")", "]", "+", "[", "'X'", ",", "'Y'", ",", "'M'", ",", "'MT'",...
Sort a list of chromosomes in the order 1..22, X, Y, M, <others in alphabetical order>. :param list in_chroms: Input chromosomes :return: Sorted chromosomes :rtype: list[str]
[ "Sort", "a", "list", "of", "chromosomes", "in", "the", "order", "1", "..", "22", "X", "Y", "M", "<others", "in", "alphabetical", "order", ">", "." ]
python
train
43.692308
portfoliome/postpy
postpy/ddl.py
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/ddl.py#L39-L46
def compile_column(name: str, data_type: str, nullable: bool) -> str: """Create column definition statement.""" null_str = 'NULL' if nullable else 'NOT NULL' return '{name} {data_type} {null},'.format(name=name, data_type=data_type, ...
[ "def", "compile_column", "(", "name", ":", "str", ",", "data_type", ":", "str", ",", "nullable", ":", "bool", ")", "->", "str", ":", "null_str", "=", "'NULL'", "if", "nullable", "else", "'NOT NULL'", "return", "'{name} {data_type} {null},'", ".", "format", "...
Create column definition statement.
[ "Create", "column", "definition", "statement", "." ]
python
train
43.5
openatx/facebook-wda
wda/__init__.py
https://github.com/openatx/facebook-wda/blob/aa644204620c6d5c7705a9c7452d8c0cc39330d5/wda/__init__.py#L450-L461
def tap_hold(self, x, y, duration=1.0): """ Tap and hold for a moment Args: - x, y(int): position - duration(float): seconds of hold time [[FBRoute POST:@"/wda/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHoldCoordinate:)], """ ...
[ "def", "tap_hold", "(", "self", ",", "x", ",", "y", ",", "duration", "=", "1.0", ")", ":", "data", "=", "{", "'x'", ":", "x", ",", "'y'", ":", "y", ",", "'duration'", ":", "duration", "}", "return", "self", ".", "http", ".", "post", "(", "'/wda...
Tap and hold for a moment Args: - x, y(int): position - duration(float): seconds of hold time [[FBRoute POST:@"/wda/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHoldCoordinate:)],
[ "Tap", "and", "hold", "for", "a", "moment" ]
python
train
35.166667
pip-services3-python/pip-services3-commons-python
pip_services3_commons/data/AnyValueMap.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/AnyValueMap.py#L210-L219
def get_as_boolean(self, key): """ Converts map element into a boolean or returns false if conversion is not possible. :param key: an index of element to get. :return: boolean value ot the element or false if conversion is not supported. """ value = self.get(key) ...
[ "def", "get_as_boolean", "(", "self", ",", "key", ")", ":", "value", "=", "self", ".", "get", "(", "key", ")", "return", "BooleanConverter", ".", "to_boolean", "(", "value", ")" ]
Converts map element into a boolean or returns false if conversion is not possible. :param key: an index of element to get. :return: boolean value ot the element or false if conversion is not supported.
[ "Converts", "map", "element", "into", "a", "boolean", "or", "returns", "false", "if", "conversion", "is", "not", "possible", "." ]
python
train
35.4
python-diamond/Diamond
src/diamond/handler/graphitepickle.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphitepickle.py#L88-L101
def _pickle_batch(self): """ Pickle the metrics into a form that can be understood by the graphite pickle connector. """ # Pickle payload = pickle.dumps(self.batch) # Pack Message header = struct.pack("!L", len(payload)) message = header + payload...
[ "def", "_pickle_batch", "(", "self", ")", ":", "# Pickle", "payload", "=", "pickle", ".", "dumps", "(", "self", ".", "batch", ")", "# Pack Message", "header", "=", "struct", ".", "pack", "(", "\"!L\"", ",", "len", "(", "payload", ")", ")", "message", "...
Pickle the metrics into a form that can be understood by the graphite pickle connector.
[ "Pickle", "the", "metrics", "into", "a", "form", "that", "can", "be", "understood", "by", "the", "graphite", "pickle", "connector", "." ]
python
train
25.428571
TiagoBras/audio-clip-extractor
audioclipextractor/parser.py
https://github.com/TiagoBras/audio-clip-extractor/blob/b0dd90266656dcbf7e663b3e174dce4d09e74c32/audioclipextractor/parser.py#L82-L115
def parse(cls, specsFileOrString): """Parsers a file or string and returns a list of AudioClipSpec Arguments: specsFileOrString (str): specifications' file or string Examples: >>> SpecsParser.parse('23.4 34.1\n40.2 79.65 Hello World!') [<Audi...
[ "def", "parse", "(", "cls", ",", "specsFileOrString", ")", ":", "stringToParse", "=", "None", "# Read the contents of the file if specsFileOrString is not a string", "if", "os", ".", "path", ".", "isfile", "(", "specsFileOrString", ")", ":", "with", "open", "(", "sp...
Parsers a file or string and returns a list of AudioClipSpec Arguments: specsFileOrString (str): specifications' file or string Examples: >>> SpecsParser.parse('23.4 34.1\n40.2 79.65 Hello World!') [<AudioClipSpec start:23.40, end:34.10, text:''>, ...
[ "Parsers", "a", "file", "or", "string", "and", "returns", "a", "list", "of", "AudioClipSpec", "Arguments", ":", "specsFileOrString", "(", "str", ")", ":", "specifications", "file", "or", "string", "Examples", ":", ">>>", "SpecsParser", ".", "parse", "(", "23...
python
train
32.294118
mfitzp/padua
padua/utils.py
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L282-L317
def calculate_s0_curve(s0, minpval, maxpval, minratio, maxratio, curve_interval=0.1): """ Calculate s0 curve for volcano plot. Taking an min and max p value, and a min and max ratio, calculate an smooth curve starting from parameter `s0` in each direction. The `curve_interval` parameter defines th...
[ "def", "calculate_s0_curve", "(", "s0", ",", "minpval", ",", "maxpval", ",", "minratio", ",", "maxratio", ",", "curve_interval", "=", "0.1", ")", ":", "mminpval", "=", "-", "np", ".", "log10", "(", "minpval", ")", "mmaxpval", "=", "-", "np", ".", "log1...
Calculate s0 curve for volcano plot. Taking an min and max p value, and a min and max ratio, calculate an smooth curve starting from parameter `s0` in each direction. The `curve_interval` parameter defines the smoothness of the resulting curve. :param s0: `float` offset of curve from interset :pa...
[ "Calculate", "s0", "curve", "for", "volcano", "plot", "." ]
python
train
32.583333
bstriner/keras-tqdm
keras_tqdm/tqdm_callback.py
https://github.com/bstriner/keras-tqdm/blob/9696a8d6602d098364314f33b746fb868e225c95/keras_tqdm/tqdm_callback.py#L73-L80
def build_tqdm_inner(self, desc, total): """ Extension point. Override to provide custom options to inner progress bars (Batch loop) :param desc: Description :param total: Number of batches :return: new progress bar """ return self.tqdm(desc=desc, total=total, lea...
[ "def", "build_tqdm_inner", "(", "self", ",", "desc", ",", "total", ")", ":", "return", "self", ".", "tqdm", "(", "desc", "=", "desc", ",", "total", "=", "total", ",", "leave", "=", "self", ".", "leave_inner", ")" ]
Extension point. Override to provide custom options to inner progress bars (Batch loop) :param desc: Description :param total: Number of batches :return: new progress bar
[ "Extension", "point", ".", "Override", "to", "provide", "custom", "options", "to", "inner", "progress", "bars", "(", "Batch", "loop", ")", ":", "param", "desc", ":", "Description", ":", "param", "total", ":", "Number", "of", "batches", ":", "return", ":", ...
python
train
41.625
pyBookshelf/bookshelf
bookshelf/api_v2/os_helpers.py
https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L319-L341
def install_os_updates(distribution, force=False): """ installs OS updates """ if ('centos' in distribution or 'rhel' in distribution or 'redhat' in distribution): bookshelf2.logging_helpers.log_green('installing OS updates') sudo("yum -y --quiet clean all") sudo(...
[ "def", "install_os_updates", "(", "distribution", ",", "force", "=", "False", ")", ":", "if", "(", "'centos'", "in", "distribution", "or", "'rhel'", "in", "distribution", "or", "'redhat'", "in", "distribution", ")", ":", "bookshelf2", ".", "logging_helpers", "...
installs OS updates
[ "installs", "OS", "updates" ]
python
train
47.043478
maxpumperla/elephas
elephas/utils/sockets.py
https://github.com/maxpumperla/elephas/blob/84605acdc9564673c487637dcb27f5def128bcc7/elephas/utils/sockets.py#L58-L71
def send(socket, data, num_bytes=20): """Send data to specified socket. :param socket: open socket instance :param data: data to send :param num_bytes: number of bytes to read :return: received data """ pickled_data = pickle.dumps(data, -1) length = str(len(pickled_data)).zfill(num_by...
[ "def", "send", "(", "socket", ",", "data", ",", "num_bytes", "=", "20", ")", ":", "pickled_data", "=", "pickle", ".", "dumps", "(", "data", ",", "-", "1", ")", "length", "=", "str", "(", "len", "(", "pickled_data", ")", ")", ".", "zfill", "(", "n...
Send data to specified socket. :param socket: open socket instance :param data: data to send :param num_bytes: number of bytes to read :return: received data
[ "Send", "data", "to", "specified", "socket", "." ]
python
train
27.142857
StackStorm/pybind
pybind/nos/v6_0_2f/brocade_system_monitor_ext_rpc/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/brocade_system_monitor_ext_rpc/__init__.py#L96-L117
def _set_show_system_monitor(self, v, load=False): """ Setter method for show_system_monitor, mapped from YANG variable /brocade_system_monitor_ext_rpc/show_system_monitor (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_system_monitor is considered as a privat...
[ "def", "_set_show_system_monitor", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",...
Setter method for show_system_monitor, mapped from YANG variable /brocade_system_monitor_ext_rpc/show_system_monitor (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_system_monitor is considered as a private method. Backends looking to populate this variable should...
[ "Setter", "method", "for", "show_system_monitor", "mapped", "from", "YANG", "variable", "/", "brocade_system_monitor_ext_rpc", "/", "show_system_monitor", "(", "rpc", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in...
python
train
80
usc-isi-i2/etk
etk/data_extractors/htiExtractors/parser.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/data_extractors/htiExtractors/parser.py#L605-L615
def parse_posting_id(text, city): """ Parse the posting ID from the Backpage ad. text -> The ad's HTML (or the a substring containing the "Post ID:" section) city -> The Backpage city of the ad """ parts = text.split('Post ID: ') if len(parts) == 2: post_id = parts[1].split(' ')[0] if p...
[ "def", "parse_posting_id", "(", "text", ",", "city", ")", ":", "parts", "=", "text", ".", "split", "(", "'Post ID: '", ")", "if", "len", "(", "parts", ")", "==", "2", ":", "post_id", "=", "parts", "[", "1", "]", ".", "split", "(", "' '", ")", "["...
Parse the posting ID from the Backpage ad. text -> The ad's HTML (or the a substring containing the "Post ID:" section) city -> The Backpage city of the ad
[ "Parse", "the", "posting", "ID", "from", "the", "Backpage", "ad", ".", "text", "-", ">", "The", "ad", "s", "HTML", "(", "or", "the", "a", "substring", "containing", "the", "Post", "ID", ":", "section", ")", "city", "-", ">", "The", "Backpage", "city"...
python
train
33.090909
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L14-L20
def get_text(nodelist): """Get the value from a text node.""" value = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: value.append(node.data) return ''.join(value)
[ "def", "get_text", "(", "nodelist", ")", ":", "value", "=", "[", "]", "for", "node", "in", "nodelist", ":", "if", "node", ".", "nodeType", "==", "node", ".", "TEXT_NODE", ":", "value", ".", "append", "(", "node", ".", "data", ")", "return", "''", "...
Get the value from a text node.
[ "Get", "the", "value", "from", "a", "text", "node", "." ]
python
train
29.428571
lucianoratamero/django_apistar
django_apistar/authentication/components.py
https://github.com/lucianoratamero/django_apistar/blob/615024680b8033aa346acd188cd542db3341064f/django_apistar/authentication/components.py#L9-L23
def resolve(self, authorization: http.Header): """ Determine the user associated with a request, using HTTP Basic Authentication. """ if authorization is None: return None scheme, token = authorization.split() if scheme.lower() != 'basic': return ...
[ "def", "resolve", "(", "self", ",", "authorization", ":", "http", ".", "Header", ")", ":", "if", "authorization", "is", "None", ":", "return", "None", "scheme", ",", "token", "=", "authorization", ".", "split", "(", ")", "if", "scheme", ".", "lower", "...
Determine the user associated with a request, using HTTP Basic Authentication.
[ "Determine", "the", "user", "associated", "with", "a", "request", "using", "HTTP", "Basic", "Authentication", "." ]
python
train
31.866667
ga4gh/ga4gh-server
ga4gh/server/exceptions.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/exceptions.py#L94-L102
def toProtocolElement(self): """ Converts this exception into the GA4GH protocol type so that it can be communicated back to the client. """ error = protocol.GAException() error.error_code = self.getErrorCode() error.message = self.getMessage() return erro...
[ "def", "toProtocolElement", "(", "self", ")", ":", "error", "=", "protocol", ".", "GAException", "(", ")", "error", ".", "error_code", "=", "self", ".", "getErrorCode", "(", ")", "error", ".", "message", "=", "self", ".", "getMessage", "(", ")", "return"...
Converts this exception into the GA4GH protocol type so that it can be communicated back to the client.
[ "Converts", "this", "exception", "into", "the", "GA4GH", "protocol", "type", "so", "that", "it", "can", "be", "communicated", "back", "to", "the", "client", "." ]
python
train
34.777778
StackStorm/pybind
pybind/slxos/v17s_1_02/interface/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/interface/__init__.py#L267-L288
def _set_tunnel(self, v, load=False): """ Setter method for tunnel, mapped from YANG variable /interface/tunnel (list) If this variable is read-only (config: false) in the source YANG file, then _set_tunnel is considered as a private method. Backends looking to populate this variable should do s...
[ "def", "_set_tunnel", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for tunnel, mapped from YANG variable /interface/tunnel (list) If this variable is read-only (config: false) in the source YANG file, then _set_tunnel is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_tunnel() directly.
[ "Setter", "method", "for", "tunnel", "mapped", "from", "YANG", "variable", "/", "interface", "/", "tunnel", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file", ...
python
train
116.772727
gmr/tinman
tinman/application.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/application.py#L116-L122
def _insert_base_path(self): """If the "base" path is set in the paths section of the config, insert it into the python path. """ if config.BASE in self.paths: sys.path.insert(0, self.paths[config.BASE])
[ "def", "_insert_base_path", "(", "self", ")", ":", "if", "config", ".", "BASE", "in", "self", ".", "paths", ":", "sys", ".", "path", ".", "insert", "(", "0", ",", "self", ".", "paths", "[", "config", ".", "BASE", "]", ")" ]
If the "base" path is set in the paths section of the config, insert it into the python path.
[ "If", "the", "base", "path", "is", "set", "in", "the", "paths", "section", "of", "the", "config", "insert", "it", "into", "the", "python", "path", "." ]
python
train
34.571429
yvesalexandre/bandicoot
bandicoot/network.py
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L158-L171
def matrix_undirected_unweighted(user): """ Returns an undirected, unweighted matrix where an edge exists if the relationship is reciprocated. """ matrix = matrix_undirected_weighted(user, interaction=None) for a, b in combinations(range(len(matrix)), 2): if matrix[a][b] is None or matri...
[ "def", "matrix_undirected_unweighted", "(", "user", ")", ":", "matrix", "=", "matrix_undirected_weighted", "(", "user", ",", "interaction", "=", "None", ")", "for", "a", ",", "b", "in", "combinations", "(", "range", "(", "len", "(", "matrix", ")", ")", ","...
Returns an undirected, unweighted matrix where an edge exists if the relationship is reciprocated.
[ "Returns", "an", "undirected", "unweighted", "matrix", "where", "an", "edge", "exists", "if", "the", "relationship", "is", "reciprocated", "." ]
python
train
32.857143
saltstack/salt
salt/cloud/clouds/vmware.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vmware.py#L238-L263
def _get_si(): ''' Authenticate with vCenter server and return service instance object. ''' url = config.get_cloud_config_value( 'url', get_configured_provider(), __opts__, search_global=False ) username = config.get_cloud_config_value( 'user', get_configured_provider(), __opts_...
[ "def", "_get_si", "(", ")", ":", "url", "=", "config", ".", "get_cloud_config_value", "(", "'url'", ",", "get_configured_provider", "(", ")", ",", "__opts__", ",", "search_global", "=", "False", ")", "username", "=", "config", ".", "get_cloud_config_value", "(...
Authenticate with vCenter server and return service instance object.
[ "Authenticate", "with", "vCenter", "server", "and", "return", "service", "instance", "object", "." ]
python
train
39.923077
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L256-L264
def acknowledge_message(self, delivery_tag, **kwargs): """Acknowledge the message delivery from RabbitMQ by sending a Basic.Ack RPC method for the delivery tag. :param int delivery_tag: The delivery tag from the Basic.Deliver frame """ logger.info('Acknowledging message', deliv...
[ "def", "acknowledge_message", "(", "self", ",", "delivery_tag", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'Acknowledging message'", ",", "delivery_tag", "=", "delivery_tag", ",", "*", "*", "kwargs", ")", "self", ".", "_channel", ".", ...
Acknowledge the message delivery from RabbitMQ by sending a Basic.Ack RPC method for the delivery tag. :param int delivery_tag: The delivery tag from the Basic.Deliver frame
[ "Acknowledge", "the", "message", "delivery", "from", "RabbitMQ", "by", "sending", "a", "Basic", ".", "Ack", "RPC", "method", "for", "the", "delivery", "tag", "." ]
python
train
43.222222
DataDog/integrations-core
datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L615-L624
def _get_hostname(self, hostname, metric): """ If hostname is None, look at label_to_hostname setting """ if hostname is None and self.label_to_hostname is not None: for label in metric.label: if label.name == self.label_to_hostname: return...
[ "def", "_get_hostname", "(", "self", ",", "hostname", ",", "metric", ")", ":", "if", "hostname", "is", "None", "and", "self", ".", "label_to_hostname", "is", "not", "None", ":", "for", "label", "in", "metric", ".", "label", ":", "if", "label", ".", "na...
If hostname is None, look at label_to_hostname setting
[ "If", "hostname", "is", "None", "look", "at", "label_to_hostname", "setting" ]
python
train
38
log2timeline/plaso
plaso/parsers/sqlite_plugins/kodi.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/sqlite_plugins/kodi.py#L162-L183
def ParseVideoRow(self, parser_mediator, query, row, **unused_kwargs): """Parses a Video row. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. query (str): query that created the row. row (sqlite3.Row): ro...
[ "def", "ParseVideoRow", "(", "self", ",", "parser_mediator", ",", "query", ",", "row", ",", "*", "*", "unused_kwargs", ")", ":", "query_hash", "=", "hash", "(", "query", ")", "event_data", "=", "KodiVideoEventData", "(", ")", "event_data", ".", "filename", ...
Parses a Video row. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. query (str): query that created the row. row (sqlite3.Row): row.
[ "Parses", "a", "Video", "row", "." ]
python
train
40.909091
Jajcus/pyxmpp2
pyxmpp2/ext/disco.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/disco.py#L628-L638
def get_features(self): """Get the features contained in `self`. :return: the list of features. :returntype: `list` of `unicode`""" l = self.xpath_ctxt.xpathEval("d:feature") ret = [] for f in l: if f.hasProp("var"): ret.append( f.prop("var")....
[ "def", "get_features", "(", "self", ")", ":", "l", "=", "self", ".", "xpath_ctxt", ".", "xpathEval", "(", "\"d:feature\"", ")", "ret", "=", "[", "]", "for", "f", "in", "l", ":", "if", "f", ".", "hasProp", "(", "\"var\"", ")", ":", "ret", ".", "ap...
Get the features contained in `self`. :return: the list of features. :returntype: `list` of `unicode`
[ "Get", "the", "features", "contained", "in", "self", "." ]
python
valid
31.454545
javipalanca/spade
spade/behaviour.py
https://github.com/javipalanca/spade/blob/59942bd1a1edae4c807d06cabb178d5630cbf61b/spade/behaviour.py#L113-L116
def start(self): """starts behaviour in the event loop""" self.agent.submit(self._start()) self.is_running = True
[ "def", "start", "(", "self", ")", ":", "self", ".", "agent", ".", "submit", "(", "self", ".", "_start", "(", ")", ")", "self", ".", "is_running", "=", "True" ]
starts behaviour in the event loop
[ "starts", "behaviour", "in", "the", "event", "loop" ]
python
train
33.5
thomwiggers/httpserver
httpserver/httpserver.py
https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L85-L94
def connection_made(self, transport): """Called when the connection is made""" self.logger.info('Connection made at object %s', id(self)) self.transport = transport self.keepalive = True if self._timeout: self.logger.debug('Registering timeout event') sel...
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "self", ".", "logger", ".", "info", "(", "'Connection made at object %s'", ",", "id", "(", "self", ")", ")", "self", ".", "transport", "=", "transport", "self", ".", "keepalive", "=", "True...
Called when the connection is made
[ "Called", "when", "the", "connection", "is", "made" ]
python
train
40.5
chrisrink10/basilisp
src/basilisp/lang/compiler/generator.py
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L582-L602
def __should_warn_on_redef( ctx: GeneratorContext, defsym: sym.Symbol, safe_name: str, def_meta: lmap.Map ) -> bool: """Return True if the compiler should emit a warning about this name being redefined.""" no_warn_on_redef = def_meta.entry(SYM_NO_WARN_ON_REDEF_META_KEY, False) if no_warn_on_redef: ...
[ "def", "__should_warn_on_redef", "(", "ctx", ":", "GeneratorContext", ",", "defsym", ":", "sym", ".", "Symbol", ",", "safe_name", ":", "str", ",", "def_meta", ":", "lmap", ".", "Map", ")", "->", "bool", ":", "no_warn_on_redef", "=", "def_meta", ".", "entry...
Return True if the compiler should emit a warning about this name being redefined.
[ "Return", "True", "if", "the", "compiler", "should", "emit", "a", "warning", "about", "this", "name", "being", "redefined", "." ]
python
test
36.238095
h2oai/h2o-3
h2o-py/h2o/model/metrics_base.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/metrics_base.py#L669-L691
def find_idx_by_threshold(self, threshold): """ Retrieve the index in this metric's threshold list at which the given threshold is located. :param threshold: Find the index of this input threshold. :returns: the index :raises ValueError: if no such index can be found. ""...
[ "def", "find_idx_by_threshold", "(", "self", ",", "threshold", ")", ":", "assert_is_type", "(", "threshold", ",", "numeric", ")", "thresh2d", "=", "self", ".", "_metric_json", "[", "'thresholds_and_metric_scores'", "]", "for", "i", ",", "e", "in", "enumerate", ...
Retrieve the index in this metric's threshold list at which the given threshold is located. :param threshold: Find the index of this input threshold. :returns: the index :raises ValueError: if no such index can be found.
[ "Retrieve", "the", "index", "in", "this", "metric", "s", "threshold", "list", "at", "which", "the", "given", "threshold", "is", "located", "." ]
python
test
50.608696
mila-iqia/fuel
fuel/converters/svhn.py
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/svhn.py#L25-L264
def convert_svhn_format_1(directory, output_directory, output_filename='svhn_format_1.hdf5'): """Converts the SVHN dataset (format 1) to HDF5. This method assumes the existence of the files `{train,test,extra}.tar.gz`, which are accessible through the official website [SVHNSIT...
[ "def", "convert_svhn_format_1", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'svhn_format_1.hdf5'", ")", ":", "try", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file"...
Converts the SVHN dataset (format 1) to HDF5. This method assumes the existence of the files `{train,test,extra}.tar.gz`, which are accessible through the official website [SVHNSITE]. .. [SVHNSITE] http://ufldl.stanford.edu/housenumbers/ Parameters ---------- directory : str Direc...
[ "Converts", "the", "SVHN", "dataset", "(", "format", "1", ")", "to", "HDF5", "." ]
python
train
50.05
tanghaibao/jcvi
jcvi/formats/gff.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/gff.py#L2234-L2292
def merge(args): """ %prog merge gffiles Merge several gff files into one. When only one file is given, it is assumed to be a file with a list of gff files. """ p = OptionParser(merge.__doc__) p.add_option("--seq", default=False, action="store_true", help="Print FASTA seque...
[ "def", "merge", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "merge", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--seq\"", ",", "default", "=", "False", ",", "action", "=", "\"store_true\"", ",", "help", "=", "\"Print FASTA sequences at ...
%prog merge gffiles Merge several gff files into one. When only one file is given, it is assumed to be a file with a list of gff files.
[ "%prog", "merge", "gffiles" ]
python
train
24.508475
minhhoit/yacms
yacms/project_template/fabfile.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L262-L270
def rsync_upload(): """ Uploads the project with rsync excluding some files and folders. """ excludes = ["*.pyc", "*.pyo", "*.db", ".DS_Store", ".coverage", "local_settings.py", "/static", "/.git", "/.hg"] local_dir = os.getcwd() + os.sep return rsync_project(remote_dir=env.proj_...
[ "def", "rsync_upload", "(", ")", ":", "excludes", "=", "[", "\"*.pyc\"", ",", "\"*.pyo\"", ",", "\"*.db\"", ",", "\".DS_Store\"", ",", "\".coverage\"", ",", "\"local_settings.py\"", ",", "\"/static\"", ",", "\"/.git\"", ",", "\"/.hg\"", "]", "local_dir", "=", ...
Uploads the project with rsync excluding some files and folders.
[ "Uploads", "the", "project", "with", "rsync", "excluding", "some", "files", "and", "folders", "." ]
python
train
42.333333
bitlabstudio/django-libs
django_libs/templatetags/libs_tags.py
https://github.com/bitlabstudio/django-libs/blob/2c5376cda084bf16edea540e0f6999f1d844afd0/django_libs/templatetags/libs_tags.py#L95-L99
def calculate_dimensions(image, long_side, short_side): """Returns the thumbnail dimensions depending on the images format.""" if image.width >= image.height: return '{0}x{1}'.format(long_side, short_side) return '{0}x{1}'.format(short_side, long_side)
[ "def", "calculate_dimensions", "(", "image", ",", "long_side", ",", "short_side", ")", ":", "if", "image", ".", "width", ">=", "image", ".", "height", ":", "return", "'{0}x{1}'", ".", "format", "(", "long_side", ",", "short_side", ")", "return", "'{0}x{1}'",...
Returns the thumbnail dimensions depending on the images format.
[ "Returns", "the", "thumbnail", "dimensions", "depending", "on", "the", "images", "format", "." ]
python
train
53.6
crytic/slither
slither/core/variables/local_variable.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/variables/local_variable.py#L30-L51
def is_storage(self): """ Return true if the variable is located in storage See https://solidity.readthedocs.io/en/v0.4.24/types.html?highlight=storage%20location#data-location Returns: (bool) """ if self.location == 'memory': return False ...
[ "def", "is_storage", "(", "self", ")", ":", "if", "self", ".", "location", "==", "'memory'", ":", "return", "False", "# Use by slithIR SSA", "if", "self", ".", "location", "==", "'reference_to_storage'", ":", "return", "False", "if", "self", ".", "location", ...
Return true if the variable is located in storage See https://solidity.readthedocs.io/en/v0.4.24/types.html?highlight=storage%20location#data-location Returns: (bool)
[ "Return", "true", "if", "the", "variable", "is", "located", "in", "storage", "See", "https", ":", "//", "solidity", ".", "readthedocs", ".", "io", "/", "en", "/", "v0", ".", "4", ".", "24", "/", "types", ".", "html?highlight", "=", "storage%20location#da...
python
train
31.045455
rosenbrockc/fortpy
fortpy/templates/genf90.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/templates/genf90.py#L347-L364
def fpy_interface_sub(fpy, dtype, kind, suffix=None): """Generates the interface for reading/writing values for variables of the specified suffix for dimensions 0 through 7. :arg fpy: the generating function that accepts the dimension and type information and returns the (xnames, subtext). :arg s...
[ "def", "fpy_interface_sub", "(", "fpy", ",", "dtype", ",", "kind", ",", "suffix", "=", "None", ")", ":", "allsubs", "=", "[", "]", "xnames", "=", "[", "]", "drange", "=", "list", "(", "range", "(", "8", ")", ")", "if", "suffix", "is", "None", "el...
Generates the interface for reading/writing values for variables of the specified suffix for dimensions 0 through 7. :arg fpy: the generating function that accepts the dimension and type information and returns the (xnames, subtext). :arg suffix: one of [None, "_f", "_p"] corresponding to "allocatabl...
[ "Generates", "the", "interface", "for", "reading", "/", "writing", "values", "for", "variables", "of", "the", "specified", "suffix", "for", "dimensions", "0", "through", "7", "." ]
python
train
38.722222
CGATOxford/UMI-tools
umi_tools/network.py
https://github.com/CGATOxford/UMI-tools/blob/c4b5d84aac391d59916d294f8f4f8f5378abcfbe/umi_tools/network.py#L240-L247
def _group_unique(self, clusters, adj_list, counts): ''' return groups for unique method''' if len(clusters) == 1: groups = [clusters] else: groups = [[x] for x in clusters] return groups
[ "def", "_group_unique", "(", "self", ",", "clusters", ",", "adj_list", ",", "counts", ")", ":", "if", "len", "(", "clusters", ")", "==", "1", ":", "groups", "=", "[", "clusters", "]", "else", ":", "groups", "=", "[", "[", "x", "]", "for", "x", "i...
return groups for unique method
[ "return", "groups", "for", "unique", "method" ]
python
train
29.625
rocky/python3-trepan
trepan/lib/breakpoint.py
https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/lib/breakpoint.py#L148-L196
def find_bp(self, filename, lineno, frame): """Determine which breakpoint for this file:line is to be acted upon. Called only if we know there is a bpt at this location. Returns breakpoint that was triggered and a flag that indicates if it is ok to delete a temporary breakpoint. ...
[ "def", "find_bp", "(", "self", ",", "filename", ",", "lineno", ",", "frame", ")", ":", "possibles", "=", "self", ".", "bplist", "[", "filename", ",", "lineno", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "possibles", ")", ")", ":", ...
Determine which breakpoint for this file:line is to be acted upon. Called only if we know there is a bpt at this location. Returns breakpoint that was triggered and a flag that indicates if it is ok to delete a temporary breakpoint.
[ "Determine", "which", "breakpoint", "for", "this", "file", ":", "line", "is", "to", "be", "acted", "upon", "." ]
python
test
38.469388
odlgroup/odl
odl/set/sets.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/set/sets.py#L362-L373
def element(self, inp=None): """Return a complex number from ``inp`` or from scratch.""" if inp is not None: # Workaround for missing __complex__ of numpy.ndarray # for Numpy version < 1.12 # TODO: remove when Numpy >= 1.12 is required if isinstance(inp, n...
[ "def", "element", "(", "self", ",", "inp", "=", "None", ")", ":", "if", "inp", "is", "not", "None", ":", "# Workaround for missing __complex__ of numpy.ndarray", "# for Numpy version < 1.12", "# TODO: remove when Numpy >= 1.12 is required", "if", "isinstance", "(", "inp",...
Return a complex number from ``inp`` or from scratch.
[ "Return", "a", "complex", "number", "from", "inp", "or", "from", "scratch", "." ]
python
train
39.75
makinacorpus/django-tracking-fields
tracking_fields/tracking.py
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L29-L54
def _set_original_fields(instance): """ Save fields value, only for non-m2m fields. """ original_fields = {} def _set_original_field(instance, field): if instance.pk is None: original_fields[field] = None else: if isinstance(instance._meta.get_field(field), F...
[ "def", "_set_original_fields", "(", "instance", ")", ":", "original_fields", "=", "{", "}", "def", "_set_original_field", "(", "instance", ",", "field", ")", ":", "if", "instance", ".", "pk", "is", "None", ":", "original_fields", "[", "field", "]", "=", "N...
Save fields value, only for non-m2m fields.
[ "Save", "fields", "value", "only", "for", "non", "-", "m2m", "fields", "." ]
python
train
39.384615
datastax/python-driver
cassandra/cluster.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cluster.py#L2575-L2631
def add_or_renew_pool(self, host, is_host_addition): """ For internal use only. """ distance = self._profile_manager.distance(host) if distance == HostDistance.IGNORED: return None def run_add_or_renew_pool(): try: if self._protoco...
[ "def", "add_or_renew_pool", "(", "self", ",", "host", ",", "is_host_addition", ")", ":", "distance", "=", "self", ".", "_profile_manager", ".", "distance", "(", "host", ")", "if", "distance", "==", "HostDistance", ".", "IGNORED", ":", "return", "None", "def"...
For internal use only.
[ "For", "internal", "use", "only", "." ]
python
train
43.877193
fastai/fastai
fastai/tabular/data.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/tabular/data.py#L129-L131
def get_emb_szs(self, sz_dict=None): "Return the default embedding sizes suitable for this data or takes the ones in `sz_dict`." return [def_emb_sz(self.classes, n, sz_dict) for n in self.cat_names]
[ "def", "get_emb_szs", "(", "self", ",", "sz_dict", "=", "None", ")", ":", "return", "[", "def_emb_sz", "(", "self", ".", "classes", ",", "n", ",", "sz_dict", ")", "for", "n", "in", "self", ".", "cat_names", "]" ]
Return the default embedding sizes suitable for this data or takes the ones in `sz_dict`.
[ "Return", "the", "default", "embedding", "sizes", "suitable", "for", "this", "data", "or", "takes", "the", "ones", "in", "sz_dict", "." ]
python
train
70.666667
MisterWil/abodepy
abodepy/devices/alarm.py
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/alarm.py#L111-L115
def mode(self): """Get alarm mode.""" mode = self.get_value('mode').get(self.device_id, None) return mode.lower()
[ "def", "mode", "(", "self", ")", ":", "mode", "=", "self", ".", "get_value", "(", "'mode'", ")", ".", "get", "(", "self", ".", "device_id", ",", "None", ")", "return", "mode", ".", "lower", "(", ")" ]
Get alarm mode.
[ "Get", "alarm", "mode", "." ]
python
train
26.8
squaresLab/BugZoo
bugzoo/core/coverage.py
https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/core/coverage.py#L93-L103
def from_dict(d: Dict[str, Any]) -> 'CoverageInstructions': """ Loads a set of coverage instructions from a given dictionary. Raises: BadCoverageInstructions: if the given coverage instructions are illegal. """ name_type = d['type'] cls = _NAM...
[ "def", "from_dict", "(", "d", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "'CoverageInstructions'", ":", "name_type", "=", "d", "[", "'type'", "]", "cls", "=", "_NAME_TO_INSTRUCTIONS", "[", "name_type", "]", "return", "cls", ".", "from_dict", "(...
Loads a set of coverage instructions from a given dictionary. Raises: BadCoverageInstructions: if the given coverage instructions are illegal.
[ "Loads", "a", "set", "of", "coverage", "instructions", "from", "a", "given", "dictionary", "." ]
python
train
33.636364
openpaperwork/paperwork-backend
paperwork_backend/labels.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/labels.py#L111-L118
def get_html_color(self): """ get a string representing the color, using HTML notation """ color = self.color return ("#%02x%02x%02x" % ( int(color.red), int(color.green), int(color.blue) ))
[ "def", "get_html_color", "(", "self", ")", ":", "color", "=", "self", ".", "color", "return", "(", "\"#%02x%02x%02x\"", "%", "(", "int", "(", "color", ".", "red", ")", ",", "int", "(", "color", ".", "green", ")", ",", "int", "(", "color", ".", "blu...
get a string representing the color, using HTML notation
[ "get", "a", "string", "representing", "the", "color", "using", "HTML", "notation" ]
python
train
30.375
KenjiTakahashi/td
td/model.py
https://github.com/KenjiTakahashi/td/blob/7311eabc63efe6fe6600687c3026f0837454c2e4/td/model.py#L249-L263
def exists(self, index): """Checks whether :index: exists in the Model. :index: Index to look for. :returns: True if :index: exists in the Model, False otherwise. """ data = self.data try: for c in self._split(index): i = int(c) - 1 ...
[ "def", "exists", "(", "self", ",", "index", ")", ":", "data", "=", "self", ".", "data", "try", ":", "for", "c", "in", "self", ".", "_split", "(", "index", ")", ":", "i", "=", "int", "(", "c", ")", "-", "1", "data", "=", "data", "[", "i", "]...
Checks whether :index: exists in the Model. :index: Index to look for. :returns: True if :index: exists in the Model, False otherwise.
[ "Checks", "whether", ":", "index", ":", "exists", "in", "the", "Model", "." ]
python
train
26.733333
mvn23/pyotgw
pyotgw/pyotgw.py
https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L449-L456
def get_gpio_mode(self, gpio_id): """ Return the gpio mode for gpio :gpio_id:. @gpio_id Character A or B. """ if not self._connected: return return self._protocol.status.get("OTGW_GPIO_{}".format(gpio_id))
[ "def", "get_gpio_mode", "(", "self", ",", "gpio_id", ")", ":", "if", "not", "self", ".", "_connected", ":", "return", "return", "self", ".", "_protocol", ".", "status", ".", "get", "(", "\"OTGW_GPIO_{}\"", ".", "format", "(", "gpio_id", ")", ")" ]
Return the gpio mode for gpio :gpio_id:. @gpio_id Character A or B.
[ "Return", "the", "gpio", "mode", "for", "gpio", ":", "gpio_id", ":", "." ]
python
train
32.25
ghukill/pyfc4
pyfc4/models.py
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L141-L159
def create_resource(self, resource_type=None, uri=None): ''' Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), B...
[ "def", "create_resource", "(", "self", ",", "resource_type", "=", "None", ",", "uri", "=", "None", ")", ":", "if", "resource_type", "in", "[", "NonRDFSource", ",", "Binary", ",", "BasicContainer", ",", "DirectContainer", ",", "IndirectContainer", "]", ":", "...
Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), BasicContainer, DirectContainer, IndirectContainer): resource type...
[ "Convenience", "method", "for", "creating", "a", "new", "resource" ]
python
train
38.578947
google/grumpy
third_party/pythonparser/parser.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L971-L984
def raise_stmt__26(self, raise_loc, type_opt): """(2.6, 2.7) raise_stmt: 'raise' [test [',' test [',' test]]]""" type_ = inst = tback = None loc = raise_loc if type_opt: type_, inst_opt = type_opt loc = loc.join(type_.loc) if inst_opt: ...
[ "def", "raise_stmt__26", "(", "self", ",", "raise_loc", ",", "type_opt", ")", ":", "type_", "=", "inst", "=", "tback", "=", "None", "loc", "=", "raise_loc", "if", "type_opt", ":", "type_", ",", "inst_opt", "=", "type_opt", "loc", "=", "loc", ".", "join...
(2.6, 2.7) raise_stmt: 'raise' [test [',' test [',' test]]]
[ "(", "2", ".", "6", "2", ".", "7", ")", "raise_stmt", ":", "raise", "[", "test", "[", "test", "[", "test", "]]]" ]
python
valid
42.071429
MIT-LCP/wfdb-python
wfdb/processing/peaks.py
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/peaks.py#L191-L223
def shift_peaks(sig, peak_inds, search_radius, peak_up): """ Helper function for correct_peaks. Return the shifted peaks to local maxima or minima within a radius. peak_up : bool Whether the expected peak direction is up """ sig_len = sig.shape[0] n_peaks = len(peak_inds) # The ...
[ "def", "shift_peaks", "(", "sig", ",", "peak_inds", ",", "search_radius", ",", "peak_up", ")", ":", "sig_len", "=", "sig", ".", "shape", "[", "0", "]", "n_peaks", "=", "len", "(", "peak_inds", ")", "# The indices to shift each peak ind by", "shift_inds", "=", ...
Helper function for correct_peaks. Return the shifted peaks to local maxima or minima within a radius. peak_up : bool Whether the expected peak direction is up
[ "Helper", "function", "for", "correct_peaks", ".", "Return", "the", "shifted", "peaks", "to", "local", "maxima", "or", "minima", "within", "a", "radius", "." ]
python
train
29.121212
pyviz/holoviews
holoviews/core/io.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/io.py#L762-L783
def _unique_name(self, basename, ext, existing, force=False): """ Find a unique basename for a new file/key where existing is either a list of (basename, ext) pairs or an absolute path to a directory. By default, uniqueness is enforced depending on the state of the uniqu...
[ "def", "_unique_name", "(", "self", ",", "basename", ",", "ext", ",", "existing", ",", "force", "=", "False", ")", ":", "skip", "=", "False", "if", "force", "else", "(", "not", "self", ".", "unique_name", ")", "if", "skip", ":", "return", "(", "basen...
Find a unique basename for a new file/key where existing is either a list of (basename, ext) pairs or an absolute path to a directory. By default, uniqueness is enforced depending on the state of the unique_name parameter (for export names). If force is True, this parameter is i...
[ "Find", "a", "unique", "basename", "for", "a", "new", "file", "/", "key", "where", "existing", "is", "either", "a", "list", "of", "(", "basename", "ext", ")", "pairs", "or", "an", "absolute", "path", "to", "a", "directory", "." ]
python
train
45.136364
lord63/tldr.py
tldr/cli.py
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L101-L104
def find(command, on): """Find the command usage.""" output_lines = parse_man_page(command, on) click.echo(''.join(output_lines))
[ "def", "find", "(", "command", ",", "on", ")", ":", "output_lines", "=", "parse_man_page", "(", "command", ",", "on", ")", "click", ".", "echo", "(", "''", ".", "join", "(", "output_lines", ")", ")" ]
Find the command usage.
[ "Find", "the", "command", "usage", "." ]
python
train
34.5
ktbyers/netmiko
netmiko/utilities.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L110-L117
def obtain_all_devices(my_devices): """Dynamically create 'all' group.""" new_devices = {} for device_name, device_or_group in my_devices.items(): # Skip any groups if not isinstance(device_or_group, list): new_devices[device_name] = device_or_group return new_devices
[ "def", "obtain_all_devices", "(", "my_devices", ")", ":", "new_devices", "=", "{", "}", "for", "device_name", ",", "device_or_group", "in", "my_devices", ".", "items", "(", ")", ":", "# Skip any groups", "if", "not", "isinstance", "(", "device_or_group", ",", ...
Dynamically create 'all' group.
[ "Dynamically", "create", "all", "group", "." ]
python
train
38.125