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
markovmodel/PyEMMA
pyemma/coordinates/api.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/api.py#L1028-L1267
def tica(data=None, lag=10, dim=-1, var_cutoff=0.95, kinetic_map=True, commute_map=False, weights='empirical', stride=1, remove_mean=True, skip=0, reversible=True, ncov_max=float('inf'), chunksize=None, **kwargs): r""" Time-lagged independent component analysis (TICA). TICA is a linear transformation ...
[ "def", "tica", "(", "data", "=", "None", ",", "lag", "=", "10", ",", "dim", "=", "-", "1", ",", "var_cutoff", "=", "0.95", ",", "kinetic_map", "=", "True", ",", "commute_map", "=", "False", ",", "weights", "=", "'empirical'", ",", "stride", "=", "1...
r""" Time-lagged independent component analysis (TICA). TICA is a linear transformation method. In contrast to PCA, which finds coordinates of maximal variance, TICA finds coordinates of maximal autocorrelation at the given lag time. Therefore, TICA is useful in order to find the *slow* components in a...
[ "r", "Time", "-", "lagged", "independent", "component", "analysis", "(", "TICA", ")", "." ]
python
train
47.958333
kibitzr/kibitzr
kibitzr/fetcher/browser/fetcher.py
https://github.com/kibitzr/kibitzr/blob/749da312488f1dda1ed1093cf4c95aaac0a604f7/kibitzr/fetcher/browser/fetcher.py#L102-L110
def _run_automation(self, conf): """ 1. Fill form. 2. Run scenario. 3. Delay. """ self._fill_form(self._find_form(conf)) self._run_scenario(conf) self._delay(conf)
[ "def", "_run_automation", "(", "self", ",", "conf", ")", ":", "self", ".", "_fill_form", "(", "self", ".", "_find_form", "(", "conf", ")", ")", "self", ".", "_run_scenario", "(", "conf", ")", "self", ".", "_delay", "(", "conf", ")" ]
1. Fill form. 2. Run scenario. 3. Delay.
[ "1", ".", "Fill", "form", ".", "2", ".", "Run", "scenario", ".", "3", ".", "Delay", "." ]
python
train
24.333333
michael-lazar/rtv
rtv/packages/praw/__init__.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1192-L1201
def get_traffic(self, subreddit): """Return the json dictionary containing traffic stats for a subreddit. :param subreddit: The subreddit whose /about/traffic page we will collect. """ url = self.config['subreddit_traffic'].format( subreddit=six.text_type(subred...
[ "def", "get_traffic", "(", "self", ",", "subreddit", ")", ":", "url", "=", "self", ".", "config", "[", "'subreddit_traffic'", "]", ".", "format", "(", "subreddit", "=", "six", ".", "text_type", "(", "subreddit", ")", ")", "return", "self", ".", "request_...
Return the json dictionary containing traffic stats for a subreddit. :param subreddit: The subreddit whose /about/traffic page we will collect.
[ "Return", "the", "json", "dictionary", "containing", "traffic", "stats", "for", "a", "subreddit", "." ]
python
train
35.4
Loudr/asana-hub
asana_hub/action.py
https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/action.py#L5-L10
def get_subclasses(c): """Gets the subclasses of a class.""" subclasses = c.__subclasses__() for d in list(subclasses): subclasses.extend(get_subclasses(d)) return subclasses
[ "def", "get_subclasses", "(", "c", ")", ":", "subclasses", "=", "c", ".", "__subclasses__", "(", ")", "for", "d", "in", "list", "(", "subclasses", ")", ":", "subclasses", ".", "extend", "(", "get_subclasses", "(", "d", ")", ")", "return", "subclasses" ]
Gets the subclasses of a class.
[ "Gets", "the", "subclasses", "of", "a", "class", "." ]
python
test
32.166667
mardix/Juice
juice/core.py
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/core.py#L600-L624
def meta_tags(cls, **kwargs): """ Meta allows you to add meta data to site :params **kwargs: meta keys we're expecting: title (str) description (str) url (str) (Will pick it up by itself if not set) image (str) site_name (str) ...
[ "def", "meta_tags", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "page_meta", "=", "cls", ".", "_global", ".", "get", "(", "\"__META__\"", ",", "{", "}", ")", "page_meta", ".", "update", "(", "*", "*", "kwargs", ")", "cls", ".", "g", "(", "__ME...
Meta allows you to add meta data to site :params **kwargs: meta keys we're expecting: title (str) description (str) url (str) (Will pick it up by itself if not set) image (str) site_name (str) (but can pick it up from config file) ...
[ "Meta", "allows", "you", "to", "add", "meta", "data", "to", "site", ":", "params", "**", "kwargs", ":" ]
python
train
28.16
saltstack/salt
salt/modules/publish.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/publish.py#L27-L38
def _parse_args(arg): ''' yamlify `arg` and ensure it's outermost datatype is a list ''' yaml_args = salt.utils.args.yamlify_arg(arg) if yaml_args is None: return [] elif not isinstance(yaml_args, list): return [yaml_args] else: return yaml_args
[ "def", "_parse_args", "(", "arg", ")", ":", "yaml_args", "=", "salt", ".", "utils", ".", "args", ".", "yamlify_arg", "(", "arg", ")", "if", "yaml_args", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "yaml_args", ",", "list", ...
yamlify `arg` and ensure it's outermost datatype is a list
[ "yamlify", "arg", "and", "ensure", "it", "s", "outermost", "datatype", "is", "a", "list" ]
python
train
23.916667
csparpa/pyowm
pyowm/uvindexapi30/parsers.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/uvindexapi30/parsers.py#L77-L96
def parse_JSON(self, JSON_string): """ Parses a list of *UVIndex* instances out of raw JSON data. Only certain properties of the data are used: if these properties are not found or cannot be parsed, an error is issued. :param JSON_string: a raw JSON string :type JSON_str...
[ "def", "parse_JSON", "(", "self", ",", "JSON_string", ")", ":", "if", "JSON_string", "is", "None", ":", "raise", "parse_response_error", ".", "ParseResponseError", "(", "'JSON data is None'", ")", "d", "=", "json", ".", "loads", "(", "JSON_string", ")", "uvind...
Parses a list of *UVIndex* instances out of raw JSON data. Only certain properties of the data are used: if these properties are not found or cannot be parsed, an error is issued. :param JSON_string: a raw JSON string :type JSON_string: str :returns: a list of *UVIndex* instance...
[ "Parses", "a", "list", "of", "*", "UVIndex", "*", "instances", "out", "of", "raw", "JSON", "data", ".", "Only", "certain", "properties", "of", "the", "data", "are", "used", ":", "if", "these", "properties", "are", "not", "found", "or", "cannot", "be", ...
python
train
44.4
cimm-kzn/CGRtools
CGRtools/algorithms/compose.py
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/compose.py#L182-L201
def decompose(self): """ decompose CGR to pair of Molecules, which represents reactants and products state of reaction :return: tuple of two molecules """ mc = self._get_subclass('MoleculeContainer') reactants = mc() products = mc() for n, atom in self.a...
[ "def", "decompose", "(", "self", ")", ":", "mc", "=", "self", ".", "_get_subclass", "(", "'MoleculeContainer'", ")", "reactants", "=", "mc", "(", ")", "products", "=", "mc", "(", ")", "for", "n", ",", "atom", "in", "self", ".", "atoms", "(", ")", "...
decompose CGR to pair of Molecules, which represents reactants and products state of reaction :return: tuple of two molecules
[ "decompose", "CGR", "to", "pair", "of", "Molecules", "which", "represents", "reactants", "and", "products", "state", "of", "reaction" ]
python
train
33.95
rodluger/everest
everest/basecamp.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L587-L600
def apply_mask(self, x=None): ''' Returns the outlier mask, an array of indices corresponding to the non-outliers. :param numpy.ndarray x: If specified, returns the masked version of \ :py:obj:`x` instead. Default :py:obj:`None` ''' if x is None: ...
[ "def", "apply_mask", "(", "self", ",", "x", "=", "None", ")", ":", "if", "x", "is", "None", ":", "return", "np", ".", "delete", "(", "np", ".", "arange", "(", "len", "(", "self", ".", "time", ")", ")", ",", "self", ".", "mask", ")", "else", "...
Returns the outlier mask, an array of indices corresponding to the non-outliers. :param numpy.ndarray x: If specified, returns the masked version of \ :py:obj:`x` instead. Default :py:obj:`None`
[ "Returns", "the", "outlier", "mask", "an", "array", "of", "indices", "corresponding", "to", "the", "non", "-", "outliers", "." ]
python
train
30.785714
quantopian/pyfolio
pyfolio/perf_attrib.py
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L471-L501
def plot_risk_exposures(exposures, ax=None, title='Daily risk factor exposures'): """ Parameters ---------- exposures : pd.DataFrame df indexed by datetime, with factors as columns - Example: momentum reversal dt 20...
[ "def", "plot_risk_exposures", "(", "exposures", ",", "ax", "=", "None", ",", "title", "=", "'Daily risk factor exposures'", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "for", "col", "in", "exposures", ":", "ax", "."...
Parameters ---------- exposures : pd.DataFrame df indexed by datetime, with factors as columns - Example: momentum reversal dt 2017-01-01 -0.238655 0.077123 2017-01-02 0.821872 1.520515 ax : matplotlib.axes.Axes axes o...
[ "Parameters", "----------", "exposures", ":", "pd", ".", "DataFrame", "df", "indexed", "by", "datetime", "with", "factors", "as", "columns", "-", "Example", ":", "momentum", "reversal", "dt", "2017", "-", "01", "-", "01", "-", "0", ".", "238655", "0", "....
python
valid
24.322581
wbond/oscrypto
oscrypto/_openssl/asymmetric.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_openssl/asymmetric.py#L552-L588
def load_certificate(source): """ Loads an x509 certificate into a Certificate object :param source: A byte string of file contents, a unicode string filename or an asn1crypto.x509.Certificate object :raises: ValueError - when any of the parameters contain an invalid value ...
[ "def", "load_certificate", "(", "source", ")", ":", "if", "isinstance", "(", "source", ",", "asn1x509", ".", "Certificate", ")", ":", "certificate", "=", "source", "elif", "isinstance", "(", "source", ",", "byte_cls", ")", ":", "certificate", "=", "parse_cer...
Loads an x509 certificate into a Certificate object :param source: A byte string of file contents, a unicode string filename or an asn1crypto.x509.Certificate object :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of the parameters...
[ "Loads", "an", "x509", "certificate", "into", "a", "Certificate", "object" ]
python
valid
28.162162
rfverbruggen/rachiopy
rachiopy/zone.py
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/zone.py#L17-L21
def startMultiple(self, zones): """Start multiple zones.""" path = 'zone/start_multiple' payload = {'zones': zones} return self.rachio.put(path, payload)
[ "def", "startMultiple", "(", "self", ",", "zones", ")", ":", "path", "=", "'zone/start_multiple'", "payload", "=", "{", "'zones'", ":", "zones", "}", "return", "self", ".", "rachio", ".", "put", "(", "path", ",", "payload", ")" ]
Start multiple zones.
[ "Start", "multiple", "zones", "." ]
python
train
36.2
ModisWorks/modis
modis/discord_modis/modules/manager/api_manager.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/api_manager.py#L14-L71
async def activate_module(channel, module_name, activate): """ Changes a modules activated/deactivated state for a server Args: channel: The channel to send the message to module_name: The name of the module to change state for activate: The activated/deactivated state of the module...
[ "async", "def", "activate_module", "(", "channel", ",", "module_name", ",", "activate", ")", ":", "data", "=", "datatools", ".", "get_data", "(", ")", "server_id", "=", "channel", ".", "server", ".", "id", "_dir", "=", "os", ".", "path", ".", "realpath",...
Changes a modules activated/deactivated state for a server Args: channel: The channel to send the message to module_name: The name of the module to change state for activate: The activated/deactivated state of the module
[ "Changes", "a", "modules", "activated", "/", "deactivated", "state", "for", "a", "server" ]
python
train
41.810345
Azure/azure-uamqp-python
uamqp/authentication/cbs_auth_async.py
https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/authentication/cbs_auth_async.py#L56-L64
async def close_authenticator_async(self): """Close the CBS auth channel and session asynchronously.""" _logger.info("Shutting down CBS session on connection: %r.", self._connection.container_id) try: self._cbs_auth.destroy() _logger.info("Auth closed, destroying session ...
[ "async", "def", "close_authenticator_async", "(", "self", ")", ":", "_logger", ".", "info", "(", "\"Shutting down CBS session on connection: %r.\"", ",", "self", ".", "_connection", ".", "container_id", ")", "try", ":", "self", ".", "_cbs_auth", ".", "destroy", "(...
Close the CBS auth channel and session asynchronously.
[ "Close", "the", "CBS", "auth", "channel", "and", "session", "asynchronously", "." ]
python
train
60.111111
saltstack/salt
salt/modules/redismod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L194-L205
def expireat(key, timestamp, host=None, port=None, db=None, password=None): ''' Set a keys expire at given UNIX time CLI Example: .. code-block:: bash salt '*' redis.expireat foo 1400000000 ''' server = _connect(host, port, db, password) return server.expireat(key, timestamp)
[ "def", "expireat", "(", "key", ",", "timestamp", ",", "host", "=", "None", ",", "port", "=", "None", ",", "db", "=", "None", ",", "password", "=", "None", ")", ":", "server", "=", "_connect", "(", "host", ",", "port", ",", "db", ",", "password", ...
Set a keys expire at given UNIX time CLI Example: .. code-block:: bash salt '*' redis.expireat foo 1400000000
[ "Set", "a", "keys", "expire", "at", "given", "UNIX", "time" ]
python
train
25.333333
peterdemin/pip-compile-multi
pipcompilemulti/dependency.py
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/dependency.py#L63-L88
def serialize(self): """ Render dependency back in string using: ~= if package is internal == otherwise """ if self.is_vcs: return self.without_editable(self.line).strip() equal = '~=' if self.is_compatible else '==' package_version = '...
[ "def", "serialize", "(", "self", ")", ":", "if", "self", ".", "is_vcs", ":", "return", "self", ".", "without_editable", "(", "self", ".", "line", ")", ".", "strip", "(", ")", "equal", "=", "'~='", "if", "self", ".", "is_compatible", "else", "'=='", "...
Render dependency back in string using: ~= if package is internal == otherwise
[ "Render", "dependency", "back", "in", "string", "using", ":", "~", "=", "if", "package", "is", "internal", "==", "otherwise" ]
python
train
34.076923
mitsei/dlkit
dlkit/json_/relationship/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/relationship/sessions.py#L2493-L2511
def add_child_family(self, family_id, child_id): """Adds a child to a family. arg: family_id (osid.id.Id): the ``Id`` of a family arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``family_id`` is already a parent of ``child_id`` ...
[ "def", "add_child_family", "(", "self", ",", "family_id", ",", "child_id", ")", ":", "# Implemented from template for", "# osid.resource.BinHierarchyDesignSession.add_child_bin_template", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", "...
Adds a child to a family. arg: family_id (osid.id.Id): the ``Id`` of a family arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``family_id`` is already a parent of ``child_id`` raise: NotFound - ``family_id`` or ``child_id`` not foun...
[ "Adds", "a", "child", "to", "a", "family", "." ]
python
train
51.421053
tensorpack/tensorpack
examples/FasterRCNN/config.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/config.py#L214-L282
def finalize_configs(is_training): """ Run some sanity checks, and populate some configs from others """ _C.freeze(False) # populate new keys now _C.DATA.NUM_CLASS = _C.DATA.NUM_CATEGORY + 1 # +1 background _C.DATA.BASEDIR = os.path.expanduser(_C.DATA.BASEDIR) if isinstance(_C.DATA.VAL, si...
[ "def", "finalize_configs", "(", "is_training", ")", ":", "_C", ".", "freeze", "(", "False", ")", "# populate new keys now", "_C", ".", "DATA", ".", "NUM_CLASS", "=", "_C", ".", "DATA", ".", "NUM_CATEGORY", "+", "1", "# +1 background", "_C", ".", "DATA", "....
Run some sanity checks, and populate some configs from others
[ "Run", "some", "sanity", "checks", "and", "populate", "some", "configs", "from", "others" ]
python
train
43.492754
saltstack/salt
salt/returners/rawfile_json.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/rawfile_json.py#L68-L84
def event_return(events): ''' Write event data (return data and non-return data) to file on the master. ''' if not events: # events is an empty list. # Don't open the logfile in vain. return opts = _get_options({}) # Pass in empty ret, since this is a list of events try:...
[ "def", "event_return", "(", "events", ")", ":", "if", "not", "events", ":", "# events is an empty list.", "# Don't open the logfile in vain.", "return", "opts", "=", "_get_options", "(", "{", "}", ")", "# Pass in empty ret, since this is a list of events", "try", ":", "...
Write event data (return data and non-return data) to file on the master.
[ "Write", "event", "data", "(", "return", "data", "and", "non", "-", "return", "data", ")", "to", "file", "on", "the", "master", "." ]
python
train
39
ethereum/py-evm
scripts/benchmark/_utils/tx.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/scripts/benchmark/_utils/tx.py#L17-L41
def new_transaction( vm: VM, from_: Address, to: Address, amount: int=0, private_key: PrivateKey=None, gas_price: int=10, gas: int=100000, data: bytes=b'') -> BaseTransaction: """ Create and return a transaction sending amount from <from_> to <to>....
[ "def", "new_transaction", "(", "vm", ":", "VM", ",", "from_", ":", "Address", ",", "to", ":", "Address", ",", "amount", ":", "int", "=", "0", ",", "private_key", ":", "PrivateKey", "=", "None", ",", "gas_price", ":", "int", "=", "10", ",", "gas", "...
Create and return a transaction sending amount from <from_> to <to>. The transaction will be signed with the given private key.
[ "Create", "and", "return", "a", "transaction", "sending", "amount", "from", "<from_", ">", "to", "<to", ">", "." ]
python
train
25.04
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L287-L331
def action(arguments): """ Trim the alignment as specified """ # Determine file format for input and output source_format = (arguments.source_format or fileformat.from_handle(arguments.source_file)) output_format = (arguments.output_format or fileformat....
[ "def", "action", "(", "arguments", ")", ":", "# Determine file format for input and output", "source_format", "=", "(", "arguments", ".", "source_format", "or", "fileformat", ".", "from_handle", "(", "arguments", ".", "source_file", ")", ")", "output_format", "=", "...
Trim the alignment as specified
[ "Trim", "the", "alignment", "as", "specified" ]
python
train
34.933333
DataONEorg/d1_python
lib_client/src/d1_client/cnclient.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/cnclient.py#L868-L890
def setReplicationStatusResponse( self, pid, nodeRef, status, dataoneError=None, vendorSpecific=None ): """CNReplication.setReplicationStatus(session, pid, nodeRef, status, failure) → boolean https://releases.dataone.org/online/api-documentatio n-v2.0.1/apis/CN_APIs.html#CNReplicatio...
[ "def", "setReplicationStatusResponse", "(", "self", ",", "pid", ",", "nodeRef", ",", "status", ",", "dataoneError", "=", "None", ",", "vendorSpecific", "=", "None", ")", ":", "mmp_dict", "=", "{", "'nodeRef'", ":", "nodeRef", ",", "'status'", ":", "status", ...
CNReplication.setReplicationStatus(session, pid, nodeRef, status, failure) → boolean https://releases.dataone.org/online/api-documentatio n-v2.0.1/apis/CN_APIs.html#CNReplication.setReplicationStatus. Args: pid: nodeRef: status: dataoneError: ve...
[ "CNReplication", ".", "setReplicationStatus", "(", "session", "pid", "nodeRef", "status", "failure", ")", "→", "boolean", "https", ":", "//", "releases", ".", "dataone", ".", "org", "/", "online", "/", "api", "-", "documentatio", "n", "-", "v2", ".", "0", ...
python
train
34.391304
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_uninstall.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_uninstall.py#L134-L148
def rollback(self): """Rollback the changes previously made by remove().""" if self.save_dir is None: logger.error( "Can't roll back %s; was not uninstalled", self.dist.project_name, ) return False logger.info('Rolling back unin...
[ "def", "rollback", "(", "self", ")", ":", "if", "self", ".", "save_dir", "is", "None", ":", "logger", ".", "error", "(", "\"Can't roll back %s; was not uninstalled\"", ",", "self", ".", "dist", ".", "project_name", ",", ")", "return", "False", "logger", ".",...
Rollback the changes previously made by remove().
[ "Rollback", "the", "changes", "previously", "made", "by", "remove", "()", "." ]
python
test
38.066667
ewels/MultiQC
multiqc/modules/hicpro/hicpro.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/hicpro/hicpro.py#L399-L423
def hicpro_capture_chart (self): """ Generate Capture Hi-C plot""" keys = OrderedDict() keys['valid_pairs_on_target_cap_cap'] = { 'color': '#0039e6', 'name': 'Capture-Capture interactions' } keys['valid_pairs_on_target_cap_rep'] = { 'color': '#809fff', 'name': 'Capture-Reporter interac...
[ "def", "hicpro_capture_chart", "(", "self", ")", ":", "keys", "=", "OrderedDict", "(", ")", "keys", "[", "'valid_pairs_on_target_cap_cap'", "]", "=", "{", "'color'", ":", "'#0039e6'", ",", "'name'", ":", "'Capture-Capture interactions'", "}", "keys", "[", "'vali...
Generate Capture Hi-C plot
[ "Generate", "Capture", "Hi", "-", "C", "plot" ]
python
train
38.8
kushaldas/retask
retask/queue.py
https://github.com/kushaldas/retask/blob/5c955b8386653d3f0591ca2f4b1a213ff4b5a018/retask/queue.py#L299-L322
def wait(self, wait_time=0): """ Blocking call to check if the worker returns the result. One can use job.result after this call returns ``True``. :arg wait_time: Time in seconds to wait, default is infinite. :return: `True` or `False`. .. note:: This is a...
[ "def", "wait", "(", "self", ",", "wait_time", "=", "0", ")", ":", "if", "self", ".", "__result", ":", "return", "True", "data", "=", "self", ".", "rdb", ".", "brpop", "(", "self", ".", "urn", ",", "wait_time", ")", "if", "data", ":", "self", ".",...
Blocking call to check if the worker returns the result. One can use job.result after this call returns ``True``. :arg wait_time: Time in seconds to wait, default is infinite. :return: `True` or `False`. .. note:: This is a blocking call, you can specity wait_time argumen...
[ "Blocking", "call", "to", "check", "if", "the", "worker", "returns", "the", "result", ".", "One", "can", "use", "job", ".", "result", "after", "this", "call", "returns", "True", "." ]
python
train
27.666667
spyder-ide/spyder
spyder/widgets/comboboxes.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/comboboxes.py#L336-L340
def is_module_or_package(path): """Return True if path is a Python module/package""" is_module = osp.isfile(path) and osp.splitext(path)[1] in ('.py', '.pyw') is_package = osp.isdir(path) and osp.isfile(osp.join(path, '__init__.py')) return is_module or is_package
[ "def", "is_module_or_package", "(", "path", ")", ":", "is_module", "=", "osp", ".", "isfile", "(", "path", ")", "and", "osp", ".", "splitext", "(", "path", ")", "[", "1", "]", "in", "(", "'.py'", ",", "'.pyw'", ")", "is_package", "=", "osp", ".", "...
Return True if path is a Python module/package
[ "Return", "True", "if", "path", "is", "a", "Python", "module", "/", "package" ]
python
train
56
Sean1708/HipPy
hippy/parser.py
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/parser.py#L88-L91
def _skip_newlines(self): """Increment over newlines.""" while self._cur_token['type'] is TT.lbreak and not self._finished: self._increment()
[ "def", "_skip_newlines", "(", "self", ")", ":", "while", "self", ".", "_cur_token", "[", "'type'", "]", "is", "TT", ".", "lbreak", "and", "not", "self", ".", "_finished", ":", "self", ".", "_increment", "(", ")" ]
Increment over newlines.
[ "Increment", "over", "newlines", "." ]
python
train
41.5
agile-geoscience/striplog
striplog/lexicon.py
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L136-L168
def find_synonym(self, word): """ Given a string and a dict of synonyms, returns the 'preferred' word. Case insensitive. Args: word (str): A word. Returns: str: The preferred word, or the input word if not found. Example: >>> syn = {...
[ "def", "find_synonym", "(", "self", ",", "word", ")", ":", "if", "word", "and", "self", ".", "synonyms", ":", "# Make the reverse look-up table.", "reverse_lookup", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "synonyms", ".", "items", "(", ")...
Given a string and a dict of synonyms, returns the 'preferred' word. Case insensitive. Args: word (str): A word. Returns: str: The preferred word, or the input word if not found. Example: >>> syn = {'snake': ['python', 'adder']} >>> find...
[ "Given", "a", "string", "and", "a", "dict", "of", "synonyms", "returns", "the", "preferred", "word", ".", "Case", "insensitive", "." ]
python
test
29.121212
saltstack/salt
salt/states/service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/service.py#L323-L335
def _available(name, ret): ''' Check if the service is available ''' avail = False if 'service.available' in __salt__: avail = __salt__['service.available'](name) elif 'service.get_all' in __salt__: avail = name in __salt__['service.get_all']() if not avail: ret['resu...
[ "def", "_available", "(", "name", ",", "ret", ")", ":", "avail", "=", "False", "if", "'service.available'", "in", "__salt__", ":", "avail", "=", "__salt__", "[", "'service.available'", "]", "(", "name", ")", "elif", "'service.get_all'", "in", "__salt__", ":"...
Check if the service is available
[ "Check", "if", "the", "service", "is", "available" ]
python
train
32
nephila/djangocms-page-sitemap
djangocms_page_sitemap/utils.py
https://github.com/nephila/djangocms-page-sitemap/blob/0d89365e5513471b603c99c60dba6d1101f19d53/djangocms_page_sitemap/utils.py#L7-L15
def get_cache_key(page): """ Create the cache key for the current page and language """ try: site_id = page.node.site_id except AttributeError: site_id = page.site_id return _get_cache_key('page_sitemap', page, 'default', site_id)
[ "def", "get_cache_key", "(", "page", ")", ":", "try", ":", "site_id", "=", "page", ".", "node", ".", "site_id", "except", "AttributeError", ":", "site_id", "=", "page", ".", "site_id", "return", "_get_cache_key", "(", "'page_sitemap'", ",", "page", ",", "'...
Create the cache key for the current page and language
[ "Create", "the", "cache", "key", "for", "the", "current", "page", "and", "language" ]
python
train
29.111111
dev-pipeline/dev-pipeline-core
lib/devpipeline_core/paths.py
https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/paths.py#L8-L22
def make_path(config, *endings): """ Create a path based on component configuration. All paths are relative to the component's configuration directory; usually this will be the same for an entire session, but this function supuports component-specific configuration directories. Arguments: ...
[ "def", "make_path", "(", "config", ",", "*", "endings", ")", ":", "config_dir", "=", "config", ".", "get", "(", "\"dp.config_dir\"", ")", "return", "os", ".", "path", ".", "join", "(", "config_dir", ",", "*", "endings", ")" ]
Create a path based on component configuration. All paths are relative to the component's configuration directory; usually this will be the same for an entire session, but this function supuports component-specific configuration directories. Arguments: config - the configuration object for a compo...
[ "Create", "a", "path", "based", "on", "component", "configuration", "." ]
python
train
37.066667
Kane610/deconz
pydeconz/utils.py
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L40-L49
async def async_delete_all_keys(session, host, port, api_key, api_keys=[]): """Delete all API keys except for the ones provided to the method.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) api_keys.append(api_key) for key in...
[ "async", "def", "async_delete_all_keys", "(", "session", ",", "host", ",", "port", ",", "api_key", ",", "api_keys", "=", "[", "]", ")", ":", "url", "=", "'http://{}:{}/api/{}/config'", ".", "format", "(", "host", ",", "str", "(", "port", ")", ",", "api_k...
Delete all API keys except for the ones provided to the method.
[ "Delete", "all", "API", "keys", "except", "for", "the", "ones", "provided", "to", "the", "method", "." ]
python
train
43.8
crossbario/txaio-etcd
txaioetcd/_client_tx.py
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L408-L446
def watch(self, keys, on_watch, filters=None, start_revision=None, return_previous=None): """ Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction rev...
[ "def", "watch", "(", "self", ",", "keys", ",", "on_watch", ",", "filters", "=", "None", ",", "start_revision", "=", "None", ",", "return_previous", "=", "None", ")", ":", "d", "=", "self", ".", "_start_watching", "(", "keys", ",", "on_watch", ",", "fil...
Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction revision. :param keys: Watch these keys / key sets. :type keys: list of bytes or list of instanc...
[ "Watch", "one", "or", "more", "keys", "or", "key", "sets", "and", "invoke", "a", "callback", "." ]
python
train
40.179487
nuagenetworks/monolithe
monolithe/lib/sdkutils.py
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/lib/sdkutils.py#L44-L75
def massage_type_name(cls, type_name): """ Returns a readable type according to a java type """ if type_name.lower() in ("enum", "enumeration"): return "enum" if type_name.lower() in ("str", "string"): return "string" if type_name.lower() in ("boolean",...
[ "def", "massage_type_name", "(", "cls", ",", "type_name", ")", ":", "if", "type_name", ".", "lower", "(", ")", "in", "(", "\"enum\"", ",", "\"enumeration\"", ")", ":", "return", "\"enum\"", "if", "type_name", ".", "lower", "(", ")", "in", "(", "\"str\"",...
Returns a readable type according to a java type
[ "Returns", "a", "readable", "type", "according", "to", "a", "java", "type" ]
python
train
26.21875
limodou/uliweb
uliweb/lib/werkzeug/wrappers.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wrappers.py#L855-L870
def set_data(self, value): """Sets a new string as response. The value set must either by a unicode or bytestring. If a unicode string is set it's encoded automatically to the charset of the response (utf-8 by default). .. versionadded:: 0.9 """ # if an unicode string ...
[ "def", "set_data", "(", "self", ",", "value", ")", ":", "# if an unicode string is set, it's encoded directly so that we", "# can set the content length", "if", "isinstance", "(", "value", ",", "text_type", ")", ":", "value", "=", "value", ".", "encode", "(", "self", ...
Sets a new string as response. The value set must either by a unicode or bytestring. If a unicode string is set it's encoded automatically to the charset of the response (utf-8 by default). .. versionadded:: 0.9
[ "Sets", "a", "new", "string", "as", "response", ".", "The", "value", "set", "must", "either", "by", "a", "unicode", "or", "bytestring", ".", "If", "a", "unicode", "string", "is", "set", "it", "s", "encoded", "automatically", "to", "the", "charset", "of",...
python
train
41.25
mohamedattahri/PyXMLi
pyxmli/__init__.py
https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/__init__.py#L1042-L1048
def duplicate(self): ''' Returns a copy of the current group, including its lines. @returns: Group ''' return self.__class__(amount=self.amount, date=self.date, method=self.method, ref=self.ref)
[ "def", "duplicate", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "amount", "=", "self", ".", "amount", ",", "date", "=", "self", ".", "date", ",", "method", "=", "self", ".", "method", ",", "ref", "=", "self", ".", "ref", ")" ]
Returns a copy of the current group, including its lines. @returns: Group
[ "Returns", "a", "copy", "of", "the", "current", "group", "including", "its", "lines", "." ]
python
train
36.857143
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/exmaralda.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/exmaralda.py#L322-L335
def __add_tier(self, tier, token_tier_name): """ adds a tier to the document graph (either as additional attributes to the token nodes or as a span node with outgoing edges to the token nodes it represents) """ if tier.attrib['category'] == token_tier_name: se...
[ "def", "__add_tier", "(", "self", ",", "tier", ",", "token_tier_name", ")", ":", "if", "tier", ".", "attrib", "[", "'category'", "]", "==", "token_tier_name", ":", "self", ".", "__add_tokens", "(", "tier", ")", "else", ":", "if", "self", ".", "is_token_a...
adds a tier to the document graph (either as additional attributes to the token nodes or as a span node with outgoing edges to the token nodes it represents)
[ "adds", "a", "tier", "to", "the", "document", "graph", "(", "either", "as", "additional", "attributes", "to", "the", "token", "nodes", "or", "as", "a", "span", "node", "with", "outgoing", "edges", "to", "the", "token", "nodes", "it", "represents", ")" ]
python
train
36.5
AguaClara/aguaclara
aguaclara/core/physchem.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L134-L139
def re_general(Vel, Area, PerimWetted, Nu): """Return the Reynolds Number for a general cross section.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"]) return 4 * radius_hydraulic_general(A...
[ "def", "re_general", "(", "Vel", ",", "Area", ",", "PerimWetted", ",", "Nu", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "Vel", ",", "\">=0\"", ",", "\"Velocity\"",...
Return the Reynolds Number for a general cross section.
[ "Return", "the", "Reynolds", "Number", "for", "a", "general", "cross", "section", "." ]
python
train
58.833333
iotile/coretools
iotilegateway/iotilegateway/supervisor/client.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L646-L660
def service_info(self, name): """Pull descriptive info of a service by name. Information returned includes the service's user friendly name and whether it was preregistered or added dynamically. Returns: dict: A dictionary of service information with the following keys ...
[ "def", "service_info", "(", "self", ",", "name", ")", ":", "return", "self", ".", "_loop", ".", "run_coroutine", "(", "self", ".", "_client", ".", "service_info", "(", "name", ")", ")" ]
Pull descriptive info of a service by name. Information returned includes the service's user friendly name and whether it was preregistered or added dynamically. Returns: dict: A dictionary of service information with the following keys set: long_nam...
[ "Pull", "descriptive", "info", "of", "a", "service", "by", "name", "." ]
python
train
40.933333
novopl/peltak
src/peltak/extra/gitflow/logic/common.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L61-L77
def assert_on_branch(branch_name): # type: (str) -> None """ Print error and exit if *branch_name* is not the current branch. Args: branch_name (str): The supposed name of the current branch. """ branch = git.current_branch(refresh=True) if branch.name != branch_name: ...
[ "def", "assert_on_branch", "(", "branch_name", ")", ":", "# type: (str) -> None", "branch", "=", "git", ".", "current_branch", "(", "refresh", "=", "True", ")", "if", "branch", ".", "name", "!=", "branch_name", ":", "if", "context", ".", "get", "(", "'preten...
Print error and exit if *branch_name* is not the current branch. Args: branch_name (str): The supposed name of the current branch.
[ "Print", "error", "and", "exit", "if", "*", "branch_name", "*", "is", "not", "the", "current", "branch", "." ]
python
train
32.647059
ska-sa/spead2
spead2/__init__.py
https://github.com/ska-sa/spead2/blob/cac95fd01d8debaa302d2691bd26da64b7828bc6/spead2/__init__.py#L284-L292
def compatible_shape(self, shape): """Determine whether `shape` is compatible with the (possibly variable-sized) shape for this descriptor""" if len(shape) != len(self.shape): return False for x, y in zip(self.shape, shape): if x is not None and x != y: ...
[ "def", "compatible_shape", "(", "self", ",", "shape", ")", ":", "if", "len", "(", "shape", ")", "!=", "len", "(", "self", ".", "shape", ")", ":", "return", "False", "for", "x", ",", "y", "in", "zip", "(", "self", ".", "shape", ",", "shape", ")", ...
Determine whether `shape` is compatible with the (possibly variable-sized) shape for this descriptor
[ "Determine", "whether", "shape", "is", "compatible", "with", "the", "(", "possibly", "variable", "-", "sized", ")", "shape", "for", "this", "descriptor" ]
python
train
38.888889
urinieto/msaf
msaf/pymf/chnmf.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/pymf/chnmf.py#L193-L218
def factorize(self, show_progress=False, compute_w=True, compute_h=True, compute_err=True, niter=1): """ Factorize s.t. WH = data Parameters ---------- show_progress : bool print some extra information to stdout. compute_h : ...
[ "def", "factorize", "(", "self", ",", "show_progress", "=", "False", ",", "compute_w", "=", "True", ",", "compute_h", "=", "True", ",", "compute_err", "=", "True", ",", "niter", "=", "1", ")", ":", "AA", ".", "factorize", "(", "self", ",", "niter", "...
Factorize s.t. WH = data Parameters ---------- show_progress : bool print some extra information to stdout. compute_h : bool iteratively update values for H. compute_w : bool iteratively update value...
[ "Factorize", "s", ".", "t", ".", "WH", "=", "data" ]
python
test
36.230769
ellmetha/django-machina
machina/apps/forum/abstract_models.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/abstract_models.py#L134-L145
def clean(self): """ Validates the forum instance. """ super().clean() if self.parent and self.parent.is_link: raise ValidationError(_('A forum can not have a link forum as parent')) if self.is_category and self.parent and self.parent.is_category: raise Validati...
[ "def", "clean", "(", "self", ")", ":", "super", "(", ")", ".", "clean", "(", ")", "if", "self", ".", "parent", "and", "self", ".", "parent", ".", "is_link", ":", "raise", "ValidationError", "(", "_", "(", "'A forum can not have a link forum as parent'", ")...
Validates the forum instance.
[ "Validates", "the", "forum", "instance", "." ]
python
train
42.166667
cdgriffith/Reusables
reusables/tasker.py
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/tasker.py#L271-L277
def run(self): """Start the main loop as a background process. *nix only""" if win_based: raise NotImplementedError("Please run main_loop, " "backgrounding not supported on Windows") self.background_process = mp.Process(target=self.main_loop) ...
[ "def", "run", "(", "self", ")", ":", "if", "win_based", ":", "raise", "NotImplementedError", "(", "\"Please run main_loop, \"", "\"backgrounding not supported on Windows\"", ")", "self", ".", "background_process", "=", "mp", ".", "Process", "(", "target", "=", "self...
Start the main loop as a background process. *nix only
[ "Start", "the", "main", "loop", "as", "a", "background", "process", ".", "*", "nix", "only" ]
python
train
50
rosenbrockc/fortpy
fortpy/parsers/variable.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L80-L123
def _separate_multiple_def(self, defstring, parent, refstring, refline): """Separates the text after '::' in a variable definition to extract all the variables, their dimensions and default values. """ import pyparsing nester = pyparsing.nestedExpr('(', ')') try: ...
[ "def", "_separate_multiple_def", "(", "self", ",", "defstring", ",", "parent", ",", "refstring", ",", "refline", ")", ":", "import", "pyparsing", "nester", "=", "pyparsing", ".", "nestedExpr", "(", "'('", ",", "')'", ")", "try", ":", "parsed", "=", "nester...
Separates the text after '::' in a variable definition to extract all the variables, their dimensions and default values.
[ "Separates", "the", "text", "after", "::", "in", "a", "variable", "definition", "to", "extract", "all", "the", "variables", "their", "dimensions", "and", "default", "values", "." ]
python
train
39
brainiak/brainiak
brainiak/factoranalysis/tfa.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/factoranalysis/tfa.py#L415-L428
def set_centers_mean_cov(self, estimation, centers_mean_cov): """Set estimation on centers Parameters ---------- estimation : 1D arrary Either prior of posterior estimation centers : 2D array, in shape [K, n_dim] Estimation on centers """ ...
[ "def", "set_centers_mean_cov", "(", "self", ",", "estimation", ",", "centers_mean_cov", ")", ":", "estimation", "[", "self", ".", "map_offset", "[", "2", "]", ":", "self", ".", "map_offset", "[", "3", "]", "]", "=", "centers_mean_cov", ".", "ravel", "(", ...
Set estimation on centers Parameters ---------- estimation : 1D arrary Either prior of posterior estimation centers : 2D array, in shape [K, n_dim] Estimation on centers
[ "Set", "estimation", "on", "centers" ]
python
train
28.428571
mishan/twemredis-py
twemredis.py
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L132-L143
def get_key(self, key_type, key_id): """ get_key constructs a key given a key type and a key id. Keyword arguments: key_type -- the type of key (e.g.: 'friend_request') key_id -- the key id (e.g.: '12345') returns a string representing the key (e.g.: 'friend_requ...
[ "def", "get_key", "(", "self", ",", "key_type", ",", "key_id", ")", ":", "return", "\"{0}:{1}{2}{3}\"", ".", "format", "(", "key_type", ",", "self", ".", "_hash_start", ",", "key_id", ",", "self", ".", "_hash_stop", ")" ]
get_key constructs a key given a key type and a key id. Keyword arguments: key_type -- the type of key (e.g.: 'friend_request') key_id -- the key id (e.g.: '12345') returns a string representing the key (e.g.: 'friend_request:{12345}')
[ "get_key", "constructs", "a", "key", "given", "a", "key", "type", "and", "a", "key", "id", ".", "Keyword", "arguments", ":", "key_type", "--", "the", "type", "of", "key", "(", "e", ".", "g", ".", ":", "friend_request", ")", "key_id", "--", "the", "ke...
python
train
38.583333
mitsei/dlkit
dlkit/json_/authentication/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authentication/sessions.py#L255-L280
def get_agents_by_genus_type(self, agent_genus_type): """Gets an ``AgentList`` corresponding to the given agent genus ``Type`` which does not include agents of genus types derived from the specified ``Type``. In plenary mode, the returned list contains all known agents or an error results. Othe...
[ "def", "get_agents_by_genus_type", "(", "self", ",", "agent_genus_type", ")", ":", "# Implemented from template for", "# osid.resource.ResourceLookupSession.get_resources_by_genus_type", "# NOTE: This implementation currently ignores plenary view", "collection", "=", "JSONClientValidated",...
Gets an ``AgentList`` corresponding to the given agent genus ``Type`` which does not include agents of genus types derived from the specified ``Type``. In plenary mode, the returned list contains all known agents or an error results. Otherwise, the returned list may contain only those agents th...
[ "Gets", "an", "AgentList", "corresponding", "to", "the", "given", "agent", "genus", "Type", "which", "does", "not", "include", "agents", "of", "genus", "types", "derived", "from", "the", "specified", "Type", "." ]
python
train
55.076923
cameronbwhite/Flask-CAS
flask_cas/routing.py
https://github.com/cameronbwhite/Flask-CAS/blob/f85173938654cb9b9316a5c869000b74b008422e/flask_cas/routing.py#L90-L141
def validate(ticket): """ Will attempt to validate the ticket. If validation fails, then False is returned. If validation is successful, then True is returned and the validated username is saved in the session under the key `CAS_USERNAME_SESSION_KEY` while tha validated attributes dictionary is ...
[ "def", "validate", "(", "ticket", ")", ":", "cas_username_session_key", "=", "current_app", ".", "config", "[", "'CAS_USERNAME_SESSION_KEY'", "]", "cas_attributes_session_key", "=", "current_app", ".", "config", "[", "'CAS_ATTRIBUTES_SESSION_KEY'", "]", "current_app", "...
Will attempt to validate the ticket. If validation fails, then False is returned. If validation is successful, then True is returned and the validated username is saved in the session under the key `CAS_USERNAME_SESSION_KEY` while tha validated attributes dictionary is saved under the key 'CAS_ATTRIBUTE...
[ "Will", "attempt", "to", "validate", "the", "ticket", ".", "If", "validation", "fails", "then", "False", "is", "returned", ".", "If", "validation", "is", "successful", "then", "True", "is", "returned", "and", "the", "validated", "username", "is", "saved", "i...
python
train
41.211538
textbook/aslack
aslack/core.py
https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/core.py#L37-L62
def url_builder(self, endpoint, *, root=None, params=None, url_params=None): """Create a URL for the specified endpoint. Arguments: endpoint (:py:class:`str`): The API endpoint to access. root: (:py:class:`str`, optional): The root URL for the service API. para...
[ "def", "url_builder", "(", "self", ",", "endpoint", ",", "*", ",", "root", "=", "None", ",", "params", "=", "None", ",", "url_params", "=", "None", ")", ":", "if", "root", "is", "None", ":", "root", "=", "self", ".", "ROOT", "scheme", ",", "netloc"...
Create a URL for the specified endpoint. Arguments: endpoint (:py:class:`str`): The API endpoint to access. root: (:py:class:`str`, optional): The root URL for the service API. params: (:py:class:`dict`, optional): The values for format into the created URL...
[ "Create", "a", "URL", "for", "the", "specified", "endpoint", "." ]
python
valid
35.153846
grundic/yagocd
yagocd/client.py
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/client.py#L255-L263
def packages(self): """ Property for accessing :class:`PackageManager` instance, which is used to manage packages. :rtype: yagocd.resources.package.PackageManager """ if self._package_manager is None: self._package_manager = PackageManager(session=self._session) ...
[ "def", "packages", "(", "self", ")", ":", "if", "self", ".", "_package_manager", "is", "None", ":", "self", ".", "_package_manager", "=", "PackageManager", "(", "session", "=", "self", ".", "_session", ")", "return", "self", ".", "_package_manager" ]
Property for accessing :class:`PackageManager` instance, which is used to manage packages. :rtype: yagocd.resources.package.PackageManager
[ "Property", "for", "accessing", ":", "class", ":", "PackageManager", "instance", "which", "is", "used", "to", "manage", "packages", "." ]
python
train
38.222222
tcalmant/ipopo
pelix/shell/completion/ipopo.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/completion/ipopo.py#L112-L136
def complete( self, config, prompt, session, context, current_arguments, current ): # type: (CompletionInfo, str, ShellSession, BundleContext, List[str], str) -> List[str] """ Returns the list of services IDs matching the current state :param config: Configuration of the cur...
[ "def", "complete", "(", "self", ",", "config", ",", "prompt", ",", "session", ",", "context", ",", "current_arguments", ",", "current", ")", ":", "# type: (CompletionInfo, str, ShellSession, BundleContext, List[str], str) -> List[str]", "# Register a method to display helpful c...
Returns the list of services IDs matching the current state :param config: Configuration of the current completion :param prompt: Shell prompt (for re-display) :param session: Shell session (to display in shell) :param context: Bundle context of the Shell bundle :param current_a...
[ "Returns", "the", "list", "of", "services", "IDs", "matching", "the", "current", "state" ]
python
train
41.76
novopl/peltak
src/peltak/core/versioning.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L253-L266
def read(self): # type: () -> Optional[str] """ Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string. """ with open(self.version_file) as fp: version = fp.read().strip() ...
[ "def", "read", "(", "self", ")", ":", "# type: () -> Optional[str]", "with", "open", "(", "self", ".", "version_file", ")", "as", "fp", ":", "version", "=", "fp", ".", "read", "(", ")", ".", "strip", "(", ")", "if", "is_valid", "(", "version", ")", "...
Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string.
[ "Read", "the", "project", "version", "from", ".", "py", "file", "." ]
python
train
28.357143
grycap/cpyutils
config.py
https://github.com/grycap/cpyutils/blob/fa966fc6d2ae1e1e799e19941561aa79b617f1b1/config.py#L234-L257
def existing_config_files(): """ Method that calculates all the configuration files that are valid, according to the 'set_paths' and other methods for this module. """ global _ETC_PATHS global _MAIN_CONFIG_FILE global _CONFIG_VAR_INCLUDE global _CONFIG_FILTER config_files = ...
[ "def", "existing_config_files", "(", ")", ":", "global", "_ETC_PATHS", "global", "_MAIN_CONFIG_FILE", "global", "_CONFIG_VAR_INCLUDE", "global", "_CONFIG_FILTER", "config_files", "=", "[", "]", "for", "possible", "in", "_ETC_PATHS", ":", "config_files", "=", "config_f...
Method that calculates all the configuration files that are valid, according to the 'set_paths' and other methods for this module.
[ "Method", "that", "calculates", "all", "the", "configuration", "files", "that", "are", "valid", "according", "to", "the", "set_paths", "and", "other", "methods", "for", "this", "module", "." ]
python
train
33.791667
ktdreyer/txkoji
txkoji/cache.py
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/cache.py#L29-L43
def get_name(self, type_, id_): """ Read a cached name if available. :param type_: str, "owner" or "tag" :param id_: int, eg. 123456 :returns: str, or None """ cachefile = self.filename(type_, id_) try: with open(cachefile, 'r') as f: ...
[ "def", "get_name", "(", "self", ",", "type_", ",", "id_", ")", ":", "cachefile", "=", "self", ".", "filename", "(", "type_", ",", "id_", ")", "try", ":", "with", "open", "(", "cachefile", ",", "'r'", ")", "as", "f", ":", "return", "f", ".", "read...
Read a cached name if available. :param type_: str, "owner" or "tag" :param id_: int, eg. 123456 :returns: str, or None
[ "Read", "a", "cached", "name", "if", "available", "." ]
python
train
28.733333
bkabrda/flask-whooshee
flask_whooshee.py
https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L402-L407
def camel_to_snake(self, s): """Constructs nice dir name from class name, e.g. FooBar => foo_bar. :param s: The string which should be converted to snake_case. """ return self._underscore_re2.sub(r'\1_\2', self._underscore_re1.sub(r'\1_\2', s)).lower()
[ "def", "camel_to_snake", "(", "self", ",", "s", ")", ":", "return", "self", ".", "_underscore_re2", ".", "sub", "(", "r'\\1_\\2'", ",", "self", ".", "_underscore_re1", ".", "sub", "(", "r'\\1_\\2'", ",", "s", ")", ")", ".", "lower", "(", ")" ]
Constructs nice dir name from class name, e.g. FooBar => foo_bar. :param s: The string which should be converted to snake_case.
[ "Constructs", "nice", "dir", "name", "from", "class", "name", "e", ".", "g", ".", "FooBar", "=", ">", "foo_bar", "." ]
python
train
46.666667
Esri/ArcREST
src/arcrest/common/general.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L66-L93
def online_time_to_string(value, timeFormat, utcOffset=0): """Converts AGOL timestamp to formatted string. Args: value (float): A UTC timestamp as reported by AGOL (time in ms since Unix epoch * 1000) timeFormat (str): Date/Time format string as parsed by :py:func:`datetime.strftime`. u...
[ "def", "online_time_to_string", "(", "value", ",", "timeFormat", ",", "utcOffset", "=", "0", ")", ":", "try", ":", "return", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "value", "/", "1000", "+", "utcOffset", "*", "3600", ")", ".", "strftime", ...
Converts AGOL timestamp to formatted string. Args: value (float): A UTC timestamp as reported by AGOL (time in ms since Unix epoch * 1000) timeFormat (str): Date/Time format string as parsed by :py:func:`datetime.strftime`. utcOffset (int): Hours difference from UTC and desired output. Defa...
[ "Converts", "AGOL", "timestamp", "to", "formatted", "string", "." ]
python
train
36.464286
erdewit/ib_insync
ib_insync/util.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L23-L49
def df(objs, labels=None): """ Create pandas DataFrame from the sequence of same-type objects. When a list of labels is given then only retain those labels and drop the rest. """ import pandas as pd from .objects import Object, DynamicObject if objs: objs = list(objs) obj...
[ "def", "df", "(", "objs", ",", "labels", "=", "None", ")", ":", "import", "pandas", "as", "pd", "from", ".", "objects", "import", "Object", ",", "DynamicObject", "if", "objs", ":", "objs", "=", "list", "(", "objs", ")", "obj", "=", "objs", "[", "0"...
Create pandas DataFrame from the sequence of same-type objects. When a list of labels is given then only retain those labels and drop the rest.
[ "Create", "pandas", "DataFrame", "from", "the", "sequence", "of", "same", "-", "type", "objects", ".", "When", "a", "list", "of", "labels", "is", "given", "then", "only", "retain", "those", "labels", "and", "drop", "the", "rest", "." ]
python
train
34.888889
DomainTools/python_api
domaintools/api.py
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L129-L133
def registrant_monitor(self, query, exclude=[], days_back=0, limit=None, **kwargs): """One or more terms as a Python list or separated by the pipe character ( | ).""" return self._results('registrant-alert', '/v1/registrant-alert', query=delimited(query), exclude=delimited(ex...
[ "def", "registrant_monitor", "(", "self", ",", "query", ",", "exclude", "=", "[", "]", ",", "days_back", "=", "0", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'registrant-alert'", ",", "'/v1/re...
One or more terms as a Python list or separated by the pipe character ( | ).
[ "One", "or", "more", "terms", "as", "a", "Python", "list", "or", "separated", "by", "the", "pipe", "character", "(", "|", ")", "." ]
python
train
84
keflavich/plfit
plfit/plfit.py
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L1048-L1069
def discrete_ksD(data, xmin, alpha): """ given a sorted data set, a minimum, and an alpha, returns the power law ks-test D value w/data The returned value is the "D" parameter in the ks test (this is implemented differently from the continuous version because there are potentially multiple ide...
[ "def", "discrete_ksD", "(", "data", ",", "xmin", ",", "alpha", ")", ":", "zz", "=", "np", ".", "sort", "(", "data", "[", "data", ">=", "xmin", "]", ")", "nn", "=", "float", "(", "len", "(", "zz", ")", ")", "if", "nn", "<", "2", ":", "return",...
given a sorted data set, a minimum, and an alpha, returns the power law ks-test D value w/data The returned value is the "D" parameter in the ks test (this is implemented differently from the continuous version because there are potentially multiple identical points that need comparison to the power ...
[ "given", "a", "sorted", "data", "set", "a", "minimum", "and", "an", "alpha", "returns", "the", "power", "law", "ks", "-", "test", "D", "value", "w", "/", "data" ]
python
test
32.954545
crackinglandia/pype32
pype32/utils.py
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/utils.py#L231-L240
def readByte(self): """ Reads a byte value from the L{ReadData} stream object. @rtype: int @return: The byte value read from the L{ReadData} stream. """ byte = unpack('B' if not self.signed else 'b', self.readAt(self.offset, 1))[0] self.offset += 1 ...
[ "def", "readByte", "(", "self", ")", ":", "byte", "=", "unpack", "(", "'B'", "if", "not", "self", ".", "signed", "else", "'b'", ",", "self", ".", "readAt", "(", "self", ".", "offset", ",", "1", ")", ")", "[", "0", "]", "self", ".", "offset", "+...
Reads a byte value from the L{ReadData} stream object. @rtype: int @return: The byte value read from the L{ReadData} stream.
[ "Reads", "a", "byte", "value", "from", "the", "L", "{", "ReadData", "}", "stream", "object", "." ]
python
train
32.4
imjoey/pyhaproxy
pyhaproxy/parse.py
https://github.com/imjoey/pyhaproxy/blob/4f0904acfc6bdb29ba6104ce2f6724c0330441d3/pyhaproxy/parse.py#L170-L206
def build_frontend(self, frontend_node): """parse `frontend` sections, and return a config.Frontend Args: frontend_node (TreeNode): Description Raises: Exception: Description Returns: config.Frontend: an object """ proxy_name = front...
[ "def", "build_frontend", "(", "self", ",", "frontend_node", ")", ":", "proxy_name", "=", "frontend_node", ".", "frontend_header", ".", "proxy_name", ".", "text", "service_address_node", "=", "frontend_node", ".", "frontend_header", ".", "service_address", "# parse the...
parse `frontend` sections, and return a config.Frontend Args: frontend_node (TreeNode): Description Raises: Exception: Description Returns: config.Frontend: an object
[ "parse", "frontend", "sections", "and", "return", "a", "config", ".", "Frontend" ]
python
train
35.108108
Esri/ArcREST
src/arcrest/enrichment/_geoenrichment.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L293-L380
def createReport(self, out_file_path, studyAreas, report=None, format="PDF", reportFields=None, studyAreasOptions=None, useData=None, inSR=4326, ...
[ "def", "createReport", "(", "self", ",", "out_file_path", ",", "studyAreas", ",", "report", "=", "None", ",", "format", "=", "\"PDF\"", ",", "reportFields", "=", "None", ",", "studyAreasOptions", "=", "None", ",", "useData", "=", "None", ",", "inSR", "=", ...
The GeoEnrichment Create Report method uses the concept of a study area to define the location of the point or area that you want to enrich with generated reports. This method allows you to create many types of high-quality reports for a variety of use cases describing the input area. If...
[ "The", "GeoEnrichment", "Create", "Report", "method", "uses", "the", "concept", "of", "a", "study", "area", "to", "define", "the", "location", "of", "the", "point", "or", "area", "that", "you", "want", "to", "enrich", "with", "generated", "reports", ".", "...
python
train
50.034091
rfk/tnetstring
tnetstring/__init__.py
https://github.com/rfk/tnetstring/blob/146381498a07d6053e044375562be08ef16017c2/tnetstring/__init__.py#L61-L74
def dumps(value,encoding=None): """dumps(object,encoding=None) -> string This function dumps a python object as a tnetstring. """ # This uses a deque to collect output fragments in reverse order, # then joins them together at the end. It's measurably faster # than creating all the intermedi...
[ "def", "dumps", "(", "value", ",", "encoding", "=", "None", ")", ":", "# This uses a deque to collect output fragments in reverse order,", "# then joins them together at the end. It's measurably faster", "# than creating all the intermediate strings.", "# If you're reading this to get...
dumps(object,encoding=None) -> string This function dumps a python object as a tnetstring.
[ "dumps", "(", "object", "encoding", "=", "None", ")", "-", ">", "string" ]
python
train
43.214286
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L290-L293
def apps_notify_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/apps#send-notification-to-app" api_path = "/api/v2/apps/notify.json" return self.call(api_path, method="POST", data=data, **kwargs)
[ "def", "apps_notify_create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/apps/notify.json\"", "return", "self", ".", "call", "(", "api_path", ",", "method", "=", "\"POST\"", ",", "data", "=", "data", ",", "*", ...
https://developer.zendesk.com/rest_api/docs/core/apps#send-notification-to-app
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "apps#send", "-", "notification", "-", "to", "-", "app" ]
python
train
62
diux-dev/ncluster
ncluster/local_backend.py
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/local_backend.py#L428-L431
def run_with_output(self, *args, **kwargs): """Runs command on every first job in the run, returns stdout.""" for job in self.jobs: job.run_with_output(*args, **kwargs)
[ "def", "run_with_output", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "job", "in", "self", ".", "jobs", ":", "job", ".", "run_with_output", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Runs command on every first job in the run, returns stdout.
[ "Runs", "command", "on", "every", "first", "job", "in", "the", "run", "returns", "stdout", "." ]
python
train
44.75
briancappello/flask-unchained
flask_unchained/bundles/security/services/security_service.py
https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/services/security_service.py#L122-L163
def register_user(self, user, allow_login=None, send_email=None, _force_login_without_confirmation=False): """ Service method to register a user. Sends signal `user_registered`. Returns True if the user has been logged in, False otherwise. """ shou...
[ "def", "register_user", "(", "self", ",", "user", ",", "allow_login", "=", "None", ",", "send_email", "=", "None", ",", "_force_login_without_confirmation", "=", "False", ")", ":", "should_login_user", "=", "(", "not", "self", ".", "security", ".", "confirmabl...
Service method to register a user. Sends signal `user_registered`. Returns True if the user has been logged in, False otherwise.
[ "Service", "method", "to", "register", "a", "user", "." ]
python
train
44.595238
happyleavesaoc/python-firetv
firetv/__init__.py
https://github.com/happyleavesaoc/python-firetv/blob/3dd953376c0d5af502e775ae14ed0afe03224781/firetv/__init__.py#L472-L507
def available(self): """Check whether the ADB connection is intact.""" if not self.adb_server_ip: # python-adb return bool(self._adb) # pure-python-adb try: # make sure the server is available adb_devices = self._adb_client.devices() ...
[ "def", "available", "(", "self", ")", ":", "if", "not", "self", ".", "adb_server_ip", ":", "# python-adb", "return", "bool", "(", "self", ".", "_adb", ")", "# pure-python-adb", "try", ":", "# make sure the server is available", "adb_devices", "=", "self", ".", ...
Check whether the ADB connection is intact.
[ "Check", "whether", "the", "ADB", "connection", "is", "intact", "." ]
python
train
36.305556
HewlettPackard/python-hpOneView
hpOneView/resources/activity/alerts.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/activity/alerts.py#L135-L152
def update(self, resource, id_or_uri=None, timeout=-1): """ Updates the specified alert resource. Args: resource (dict): Object to update. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneVie...
[ "def", "update", "(", "self", ",", "resource", ",", "id_or_uri", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "uri", "=", "resource", ".", "pop", "(", "'uri'", ",", "None", ")", "if", "not", "uri", ":", "if", "not", "id_or_uri", ":", "ra...
Updates the specified alert resource. Args: resource (dict): Object to update. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. Returns: d...
[ "Updates", "the", "specified", "alert", "resource", "." ]
python
train
38.277778
bwhite/hadoopy
hadoopy/_hdfs.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_hdfs.py#L113-L135
def abspath(path): """Return the absolute path to a file and canonicalize it Path is returned without a trailing slash and without redundant slashes. Caches the user's home directory. :param path: A string for the path. This should not have any wildcards. :returns: Absolute path to the file :...
[ "def", "abspath", "(", "path", ")", ":", "global", "_USER_HOME_DIR", "# FIXME(brandyn): User's home directory must exist", "# FIXME(brandyn): Requires something to be in home dir", "if", "path", "[", "0", "]", "==", "'/'", ":", "return", "os", ".", "path", ".", "abspath...
Return the absolute path to a file and canonicalize it Path is returned without a trailing slash and without redundant slashes. Caches the user's home directory. :param path: A string for the path. This should not have any wildcards. :returns: Absolute path to the file :raises IOError: If unsucce...
[ "Return", "the", "absolute", "path", "to", "a", "file", "and", "canonicalize", "it" ]
python
train
36.086957
gem/oq-engine
openquake/hazardlib/gsim/boore_2014.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/boore_2014.py#L152-L160
def _get_site_scaling(self, C, pga_rock, sites, period, rjb): """ Returns the site-scaling term (equation 5), broken down into a linear scaling, a nonlinear scaling and a basin scaling term """ flin = self._get_linear_site_term(C, sites.vs30) fnl = self._get_nonlinear_sit...
[ "def", "_get_site_scaling", "(", "self", ",", "C", ",", "pga_rock", ",", "sites", ",", "period", ",", "rjb", ")", ":", "flin", "=", "self", ".", "_get_linear_site_term", "(", "C", ",", "sites", ".", "vs30", ")", "fnl", "=", "self", ".", "_get_nonlinear...
Returns the site-scaling term (equation 5), broken down into a linear scaling, a nonlinear scaling and a basin scaling term
[ "Returns", "the", "site", "-", "scaling", "term", "(", "equation", "5", ")", "broken", "down", "into", "a", "linear", "scaling", "a", "nonlinear", "scaling", "and", "a", "basin", "scaling", "term" ]
python
train
48.222222
LonamiWebs/Telethon
telethon_examples/interactive_telegram_client.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_examples/interactive_telegram_client.py#L46-L53
async def async_input(prompt): """ Python's ``input()`` is blocking, which means the event loop we set above can't be running while we're blocking there. This method will let the loop run while we wait for input. """ print(prompt, end='', flush=True) return (await loop.run_in_executor(None, ...
[ "async", "def", "async_input", "(", "prompt", ")", ":", "print", "(", "prompt", ",", "end", "=", "''", ",", "flush", "=", "True", ")", "return", "(", "await", "loop", ".", "run_in_executor", "(", "None", ",", "sys", ".", "stdin", ".", "readline", ")"...
Python's ``input()`` is blocking, which means the event loop we set above can't be running while we're blocking there. This method will let the loop run while we wait for input.
[ "Python", "s", "input", "()", "is", "blocking", "which", "means", "the", "event", "loop", "we", "set", "above", "can", "t", "be", "running", "while", "we", "re", "blocking", "there", ".", "This", "method", "will", "let", "the", "loop", "run", "while", ...
python
train
42.75
mila/pyoo
pyoo.py
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L916-L952
def get_target(self, row, col, row_count, col_count): """ Moves cursor to the specified position and returns in. """ # This method is called for almost any operation so it should # be maximally optimized. # # Any comparison here is negligible compared to UNO call....
[ "def", "get_target", "(", "self", ",", "row", ",", "col", ",", "row_count", ",", "col_count", ")", ":", "# This method is called for almost any operation so it should", "# be maximally optimized.", "#", "# Any comparison here is negligible compared to UNO call. So we do all", "# ...
Moves cursor to the specified position and returns in.
[ "Moves", "cursor", "to", "the", "specified", "position", "and", "returns", "in", "." ]
python
train
49.648649
etcher-be/elib_miz
elib_miz/mission.py
https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1298-L1309
def groups(self) -> typing.Iterator['Group']: """ Returns: generator of all groups in this country """ for group_category in Mission.valid_group_categories: if group_category in self._section_this_country.keys(): for group_index in self._section_this_country[g...
[ "def", "groups", "(", "self", ")", "->", "typing", ".", "Iterator", "[", "'Group'", "]", ":", "for", "group_category", "in", "Mission", ".", "valid_group_categories", ":", "if", "group_category", "in", "self", ".", "_section_this_country", ".", "keys", "(", ...
Returns: generator of all groups in this country
[ "Returns", ":", "generator", "of", "all", "groups", "in", "this", "country" ]
python
train
65.333333
ff0000/scarlet
scarlet/accounts/forms.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/forms.py#L99-L113
def save(self): """ Creates a new user and account. Returns the newly created user. """ username, email, password, first_name, last_name = (self.cleaned_data['username'], self.cleaned_data['email'], self.cleaned_data['password1'],...
[ "def", "save", "(", "self", ")", ":", "username", ",", "email", ",", "password", ",", "first_name", ",", "last_name", "=", "(", "self", ".", "cleaned_data", "[", "'username'", "]", ",", "self", ".", "cleaned_data", "[", "'email'", "]", ",", "self", "."...
Creates a new user and account. Returns the newly created user.
[ "Creates", "a", "new", "user", "and", "account", ".", "Returns", "the", "newly", "created", "user", "." ]
python
train
49.733333
yougov/mongo-connector
mongo_connector/oplog_manager.py
https://github.com/yougov/mongo-connector/blob/557cafd4b54c848cd54ef28a258391a154650cb4/mongo_connector/oplog_manager.py#L858-L883
def read_last_checkpoint(self): """Read the last checkpoint from the oplog progress dictionary. """ # In versions of mongo-connector 2.3 and before, # we used the repr of the # oplog collection as keys in the oplog_progress dictionary. # In versions thereafter, we use the...
[ "def", "read_last_checkpoint", "(", "self", ")", ":", "# In versions of mongo-connector 2.3 and before,", "# we used the repr of the", "# oplog collection as keys in the oplog_progress dictionary.", "# In versions thereafter, we use the replica set name. For backwards", "# compatibility, we chec...
Read the last checkpoint from the oplog progress dictionary.
[ "Read", "the", "last", "checkpoint", "from", "the", "oplog", "progress", "dictionary", "." ]
python
train
36.961538
tensorflow/tensor2tensor
tensor2tensor/data_generators/cleaner_en_xx.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/cleaner_en_xx.py#L66-L86
def paracrawl_v3_pairs(paracrawl_file): """Generates raw (English, other) pairs from a ParaCrawl V3.0 data file. Args: paracrawl_file: A ParaCrawl V3.0 en-.. data file. Yields: Pairs of (sentence_en, sentence_xx), as Unicode strings. Raises: StopIteration: If the file ends while this method is in t...
[ "def", "paracrawl_v3_pairs", "(", "paracrawl_file", ")", ":", "raw_sentences", "=", "_raw_sentences", "(", "paracrawl_file", ")", "for", "s_en", "in", "raw_sentences", ":", "try", ":", "s_xx", "=", "next", "(", "raw_sentences", ")", "if", "s_en", "and", "s_xx"...
Generates raw (English, other) pairs from a ParaCrawl V3.0 data file. Args: paracrawl_file: A ParaCrawl V3.0 en-.. data file. Yields: Pairs of (sentence_en, sentence_xx), as Unicode strings. Raises: StopIteration: If the file ends while this method is in the middle of creating a translation p...
[ "Generates", "raw", "(", "English", "other", ")", "pairs", "from", "a", "ParaCrawl", "V3", ".", "0", "data", "file", "." ]
python
train
33.333333
SKA-ScienceDataProcessor/integration-prototype
sip/tango_control/tango_master/app/sdp_master_device.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_master/app/sdp_master_device.py#L47-L57
def always_executed_hook(self): """Run for each command.""" _logT = self._devProxy.get_logging_target() if 'device::sip_sdp_logger' not in _logT: try: self._devProxy.add_logging_target('device::sip_sdp/elt/logger') self.info_stream("Test of Tango loggi...
[ "def", "always_executed_hook", "(", "self", ")", ":", "_logT", "=", "self", ".", "_devProxy", ".", "get_logging_target", "(", ")", "if", "'device::sip_sdp_logger'", "not", "in", "_logT", ":", "try", ":", "self", ".", "_devProxy", ".", "add_logging_target", "("...
Run for each command.
[ "Run", "for", "each", "command", "." ]
python
train
43.181818
ambitioninc/python-logentries-api
logentries_api/resources.py
https://github.com/ambitioninc/python-logentries-api/blob/77ff1a7a2995d7ea2725b74e34c0f880f4ee23bc/logentries_api/resources.py#L275-L296
def get(self, label_sn): """ Get tags by a label's sn key :param label_sn: A corresponding label's ``sn`` key. :type label_sn: str or int :return: A list of matching tags. An empty list is returned if there are not any matches :rtype: list of dict :...
[ "def", "get", "(", "self", ",", "label_sn", ")", ":", "tags", "=", "self", ".", "list", "(", ")", "return", "[", "tag", "for", "tag", "in", "tags", "if", "str", "(", "label_sn", ")", "in", "tag", ".", "get", "(", "'args'", ",", "{", "}", ")", ...
Get tags by a label's sn key :param label_sn: A corresponding label's ``sn`` key. :type label_sn: str or int :return: A list of matching tags. An empty list is returned if there are not any matches :rtype: list of dict :raises: This will raise a :class:...
[ "Get", "tags", "by", "a", "label", "s", "sn", "key" ]
python
test
28.909091
hvac/hvac
hvac/api/secrets_engines/azure.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/azure.py#L19-L62
def configure(self, subscription_id, tenant_id, client_id="", client_secret="", environment='AzurePublicCloud', mount_point=DEFAULT_MOUNT_POINT): """Configure the credentials required for the plugin to perform API calls to Azure. These credentials will be used to query roles and creat...
[ "def", "configure", "(", "self", ",", "subscription_id", ",", "tenant_id", ",", "client_id", "=", "\"\"", ",", "client_secret", "=", "\"\"", ",", "environment", "=", "'AzurePublicCloud'", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "if", "environme...
Configure the credentials required for the plugin to perform API calls to Azure. These credentials will be used to query roles and create/delete service principals. Environment variables will override any parameters set in the config. Supported methods: POST: /{mount_point}/config....
[ "Configure", "the", "credentials", "required", "for", "the", "plugin", "to", "perform", "API", "calls", "to", "Azure", "." ]
python
train
46.454545
vinci1it2000/schedula
schedula/utils/base.py
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/base.py#L111-L265
def plot(self, workflow=None, view=True, depth=-1, name=NONE, comment=NONE, format=NONE, engine=NONE, encoding=NONE, graph_attr=NONE, node_attr=NONE, edge_attr=NONE, body=NONE, node_styles=NONE, node_data=NONE, node_function=NONE, edge_data=NONE, max_lines=NONE, max_w...
[ "def", "plot", "(", "self", ",", "workflow", "=", "None", ",", "view", "=", "True", ",", "depth", "=", "-", "1", ",", "name", "=", "NONE", ",", "comment", "=", "NONE", ",", "format", "=", "NONE", ",", "engine", "=", "NONE", ",", "encoding", "=", ...
Plots the Dispatcher with a graph in the DOT language with Graphviz. :param workflow: If True the latest solution will be plotted, otherwise the dmap. :type workflow: bool, optional :param view: Open the rendered directed graph in the DOT language with the sys ...
[ "Plots", "the", "Dispatcher", "with", "a", "graph", "in", "the", "DOT", "language", "with", "Graphviz", "." ]
python
train
32.948387
openid/python-openid
openid/consumer/consumer.py
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/consumer/consumer.py#L701-L744
def _doIdRes(self, message, endpoint, return_to): """Handle id_res responses that are not cancellations of immediate mode requests. @param message: the response paramaters. @param endpoint: the discovered endpoint object. May be None. @raises ProtocolError: If the message conte...
[ "def", "_doIdRes", "(", "self", ",", "message", ",", "endpoint", ",", "return_to", ")", ":", "# Checks for presence of appropriate fields (and checks", "# signed list fields)", "self", ".", "_idResCheckForFields", "(", "message", ")", "if", "not", "self", ".", "_check...
Handle id_res responses that are not cancellations of immediate mode requests. @param message: the response paramaters. @param endpoint: the discovered endpoint object. May be None. @raises ProtocolError: If the message contents are not well-formed according to the OpenID s...
[ "Handle", "id_res", "responses", "that", "are", "not", "cancellations", "of", "immediate", "mode", "requests", "." ]
python
train
41.590909
ttroy50/pyephember
pyephember/pyephember.py
https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L243-L272
def set_target_temperature_by_id(self, zone_id, target_temperature): """ Set the target temperature for a zone by id """ if not self._do_auth(): raise RuntimeError("Unable to login") data = { "ZoneId": zone_id, "TargetTemperature": target_temp...
[ "def", "set_target_temperature_by_id", "(", "self", ",", "zone_id", ",", "target_temperature", ")", ":", "if", "not", "self", ".", "_do_auth", "(", ")", ":", "raise", "RuntimeError", "(", "\"Unable to login\"", ")", "data", "=", "{", "\"ZoneId\"", ":", "zone_i...
Set the target temperature for a zone by id
[ "Set", "the", "target", "temperature", "for", "a", "zone", "by", "id" ]
python
train
28.7
AguaClara/aguaclara
aguaclara/design/lfom.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/lfom.py#L67-L70
def area_pipe_min(self): """The minimum cross-sectional area of the LFOM pipe that assures a safety factor.""" return (self.safety_factor * self.q / self.vel_critical).to(u.cm**2)
[ "def", "area_pipe_min", "(", "self", ")", ":", "return", "(", "self", ".", "safety_factor", "*", "self", ".", "q", "/", "self", ".", "vel_critical", ")", ".", "to", "(", "u", ".", "cm", "**", "2", ")" ]
The minimum cross-sectional area of the LFOM pipe that assures a safety factor.
[ "The", "minimum", "cross", "-", "sectional", "area", "of", "the", "LFOM", "pipe", "that", "assures", "a", "safety", "factor", "." ]
python
train
50
hendrix/hendrix
hendrix/contrib/cache/__init__.py
https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/contrib/cache/__init__.py#L75-L80
def getDate(self): "returns the GMT response datetime or None" date = self.headers.get('date') if date: date = self.convertTimeString(date) return date
[ "def", "getDate", "(", "self", ")", ":", "date", "=", "self", ".", "headers", ".", "get", "(", "'date'", ")", "if", "date", ":", "date", "=", "self", ".", "convertTimeString", "(", "date", ")", "return", "date" ]
returns the GMT response datetime or None
[ "returns", "the", "GMT", "response", "datetime", "or", "None" ]
python
train
31.666667
crocs-muni/roca
roca/detect.py
https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1753-L1779
def process_js_mod(self, data, name, idx, sub_idx): """ Processes one moduli from JSON :param data: :param name: :param idx: :param sub_idx: :return: """ if isinstance(data, (int, long)): js = collections.OrderedDict() js['t...
[ "def", "process_js_mod", "(", "self", ",", "data", ",", "name", ",", "idx", ",", "sub_idx", ")", ":", "if", "isinstance", "(", "data", ",", "(", "int", ",", "long", ")", ")", ":", "js", "=", "collections", ".", "OrderedDict", "(", ")", "js", "[", ...
Processes one moduli from JSON :param data: :param name: :param idx: :param sub_idx: :return:
[ "Processes", "one", "moduli", "from", "JSON", ":", "param", "data", ":", ":", "param", "name", ":", ":", "param", "idx", ":", ":", "param", "sub_idx", ":", ":", "return", ":" ]
python
train
31.518519
knipknap/exscript
Exscript/emulators/command.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/emulators/command.py#L73-L96
def add_from_file(self, filename, handler_decorator=None): """ Wrapper around add() that reads the handlers from the file with the given name. The file is a Python script containing a list named 'commands' of tuples that map command names to handlers. :type filename: st...
[ "def", "add_from_file", "(", "self", ",", "filename", ",", "handler_decorator", "=", "None", ")", ":", "args", "=", "{", "}", "execfile", "(", "filename", ",", "args", ")", "commands", "=", "args", ".", "get", "(", "'commands'", ")", "if", "commands", ...
Wrapper around add() that reads the handlers from the file with the given name. The file is a Python script containing a list named 'commands' of tuples that map command names to handlers. :type filename: str :param filename: The name of the file containing the tuples. ...
[ "Wrapper", "around", "add", "()", "that", "reads", "the", "handlers", "from", "the", "file", "with", "the", "given", "name", ".", "The", "file", "is", "a", "Python", "script", "containing", "a", "list", "named", "commands", "of", "tuples", "that", "map", ...
python
train
42.333333
titilambert/pyfido
pyfido/client.py
https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L239-L287
def _get_usage(self, account_number, number): """Get Fido usage. Get the following data - talk - text - data Roaming data is not supported yet """ # Prepare data data = {"ctn": number, "language": "en-US", "account...
[ "def", "_get_usage", "(", "self", ",", "account_number", ",", "number", ")", ":", "# Prepare data", "data", "=", "{", "\"ctn\"", ":", "number", ",", "\"language\"", ":", "\"en-US\"", ",", "\"accountNumber\"", ":", "account_number", "}", "# Http request", "try", ...
Get Fido usage. Get the following data - talk - text - data Roaming data is not supported yet
[ "Get", "Fido", "usage", "." ]
python
train
38.183673
DLR-RM/RAFCON
source/rafcon/gui/controllers/state_machines_editor.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_machines_editor.py#L154-L162
def close_state_machine(self, widget, page_number, event=None): """Triggered when the close button in the tab is clicked """ page = widget.get_nth_page(page_number) for tab_info in self.tabs.values(): if tab_info['page'] is page: state_machine_m = tab_info['st...
[ "def", "close_state_machine", "(", "self", ",", "widget", ",", "page_number", ",", "event", "=", "None", ")", ":", "page", "=", "widget", ".", "get_nth_page", "(", "page_number", ")", "for", "tab_info", "in", "self", ".", "tabs", ".", "values", "(", ")",...
Triggered when the close button in the tab is clicked
[ "Triggered", "when", "the", "close", "button", "in", "the", "tab", "is", "clicked" ]
python
train
47.888889
nvbn/thefuck
thefuck/entrypoints/not_configured.py
https://github.com/nvbn/thefuck/blob/40ab4eb62db57627bff10cf029d29c94704086a2/thefuck/entrypoints/not_configured.py#L75-L79
def _is_already_configured(configuration_details): """Returns `True` when alias already in shell config.""" path = Path(configuration_details.path).expanduser() with path.open('r') as shell_config: return configuration_details.content in shell_config.read()
[ "def", "_is_already_configured", "(", "configuration_details", ")", ":", "path", "=", "Path", "(", "configuration_details", ".", "path", ")", ".", "expanduser", "(", ")", "with", "path", ".", "open", "(", "'r'", ")", "as", "shell_config", ":", "return", "con...
Returns `True` when alias already in shell config.
[ "Returns", "True", "when", "alias", "already", "in", "shell", "config", "." ]
python
train
54.6
diffeo/py-nilsimsa
nilsimsa/deprecated/_deprecated_nilsimsa.py
https://github.com/diffeo/py-nilsimsa/blob/c652f4bbfd836f7aebf292dcea676cc925ec315a/nilsimsa/deprecated/_deprecated_nilsimsa.py#L117-L119
def tran3(self, a, b, c, n): """Get accumulator for a transition n between chars a, b, c.""" return (((TRAN[(a+n)&255]^TRAN[b]*(n+n+1))+TRAN[(c)^TRAN[n]])&255)
[ "def", "tran3", "(", "self", ",", "a", ",", "b", ",", "c", ",", "n", ")", ":", "return", "(", "(", "(", "TRAN", "[", "(", "a", "+", "n", ")", "&", "255", "]", "^", "TRAN", "[", "b", "]", "*", "(", "n", "+", "n", "+", "1", ")", ")", ...
Get accumulator for a transition n between chars a, b, c.
[ "Get", "accumulator", "for", "a", "transition", "n", "between", "chars", "a", "b", "c", "." ]
python
train
57.666667
mongolab/mongoctl
mongoctl/commands/server/start.py
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/commands/server/start.py#L525-L545
def generate_start_command(server, options_override=None, standalone=False): """ Check if we need to use numactl if we are running on a NUMA box. 10gen recommends using numactl on NUMA. For more info, see http://www.mongodb.org/display/DOCS/NUMA """ command = [] if mongod_ne...
[ "def", "generate_start_command", "(", "server", ",", "options_override", "=", "None", ",", "standalone", "=", "False", ")", ":", "command", "=", "[", "]", "if", "mongod_needs_numactl", "(", ")", ":", "log_info", "(", "\"Running on a NUMA machine...\"", ")", "com...
Check if we need to use numactl if we are running on a NUMA box. 10gen recommends using numactl on NUMA. For more info, see http://www.mongodb.org/display/DOCS/NUMA
[ "Check", "if", "we", "need", "to", "use", "numactl", "if", "we", "are", "running", "on", "a", "NUMA", "box", ".", "10gen", "recommends", "using", "numactl", "on", "NUMA", ".", "For", "more", "info", "see", "http", ":", "//", "www", ".", "mongodb", "....
python
train
35.428571
pydata/xarray
xarray/core/missing.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/missing.py#L259-L272
def ffill(arr, dim=None, limit=None): '''forward fill missing values''' import bottleneck as bn axis = arr.get_axis_num(dim) # work around for bottleneck 178 _limit = limit if limit is not None else arr.shape[axis] return apply_ufunc(bn.push, arr, dask='parallelized', ...
[ "def", "ffill", "(", "arr", ",", "dim", "=", "None", ",", "limit", "=", "None", ")", ":", "import", "bottleneck", "as", "bn", "axis", "=", "arr", ".", "get_axis_num", "(", "dim", ")", "# work around for bottleneck 178", "_limit", "=", "limit", "if", "lim...
forward fill missing values
[ "forward", "fill", "missing", "values" ]
python
train
33.785714
saltstack/salt
salt/modules/yumpkg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L211-L234
def _check_versionlock(): ''' Ensure that the appropriate versionlock plugin is present ''' if _yum() == 'dnf': if int(__grains__.get('osmajorrelease')) >= 26: if six.PY3: vl_plugin = 'python3-dnf-plugin-versionlock' else: vl_plugin = 'pyth...
[ "def", "_check_versionlock", "(", ")", ":", "if", "_yum", "(", ")", "==", "'dnf'", ":", "if", "int", "(", "__grains__", ".", "get", "(", "'osmajorrelease'", ")", ")", ">=", "26", ":", "if", "six", ".", "PY3", ":", "vl_plugin", "=", "'python3-dnf-plugin...
Ensure that the appropriate versionlock plugin is present
[ "Ensure", "that", "the", "appropriate", "versionlock", "plugin", "is", "present" ]
python
train
34.125
jsommers/switchyard
switchyard/lib/packet/util.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/util.py#L3-L12
def create_ip_arp_reply(srchw, dsthw, srcip, targetip): ''' Create an ARP reply (just change what needs to be changed from a request) ''' pkt = create_ip_arp_request(srchw, srcip, targetip) pkt[0].dst = dsthw pkt[1].operation = ArpOperation.Reply pkt[1].targethwaddr = dsthw return pk...
[ "def", "create_ip_arp_reply", "(", "srchw", ",", "dsthw", ",", "srcip", ",", "targetip", ")", ":", "pkt", "=", "create_ip_arp_request", "(", "srchw", ",", "srcip", ",", "targetip", ")", "pkt", "[", "0", "]", ".", "dst", "=", "dsthw", "pkt", "[", "1", ...
Create an ARP reply (just change what needs to be changed from a request)
[ "Create", "an", "ARP", "reply", "(", "just", "change", "what", "needs", "to", "be", "changed", "from", "a", "request", ")" ]
python
train
31.2
dfunckt/django-connections
connections/models.py
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L131-L140
def get_connection(self, from_obj, to_obj): """ Returns a ``Connection`` instance for the given objects or ``None`` if there's no connection. """ self._validate_ctypes(from_obj, to_obj) try: return self.connections.get(from_pk=from_obj.pk, to_pk=to_obj.pk) ...
[ "def", "get_connection", "(", "self", ",", "from_obj", ",", "to_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "to_obj", ")", "try", ":", "return", "self", ".", "connections", ".", "get", "(", "from_pk", "=", "from_obj", ".", "pk"...
Returns a ``Connection`` instance for the given objects or ``None`` if there's no connection.
[ "Returns", "a", "Connection", "instance", "for", "the", "given", "objects", "or", "None", "if", "there", "s", "no", "connection", "." ]
python
train
37.1
Stufinite/djangoApiDec
djangoApiDec/djangoApiDec.py
https://github.com/Stufinite/djangoApiDec/blob/8b2d5776b3413b1b850df12a92f30526c05c0a46/djangoApiDec/djangoApiDec.py#L8-L36
def date_proc(func): """ An decorator checking whether date parameter is passing in or not. If not, default date value is all PTT data. Else, return PTT data with right date. Args: func: function you want to decorate. request: WSGI request parameter getten from django. Returns: date: a datetime variable,...
[ "def", "date_proc", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'date'", "in", "request", ".", "GET", "and", "request", ".", "GET", "[", "'da...
An decorator checking whether date parameter is passing in or not. If not, default date value is all PTT data. Else, return PTT data with right date. Args: func: function you want to decorate. request: WSGI request parameter getten from django. Returns: date: a datetime variable, you can only give year, y...
[ "An", "decorator", "checking", "whether", "date", "parameter", "is", "passing", "in", "or", "not", ".", "If", "not", "default", "date", "value", "is", "all", "PTT", "data", ".", "Else", "return", "PTT", "data", "with", "right", "date", ".", "Args", ":", ...
python
valid
34.344828
gccxml/pygccxml
pygccxml/utils/utils.py
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L35-L58
def find_xml_generator(name="castxml"): """ Try to find a c++ parser (xml generator) Args: name (str): name of the c++ parser (e.g. castxml) Returns: path (str), name (str): path to the xml generator and it's name If no c++ parser is found the function raises an exception. py...
[ "def", "find_xml_generator", "(", "name", "=", "\"castxml\"", ")", ":", "if", "sys", ".", "version_info", "[", ":", "2", "]", ">=", "(", "3", ",", "3", ")", ":", "path", "=", "_find_xml_generator_for_python_greater_equals_33", "(", "name", ")", "else", ":"...
Try to find a c++ parser (xml generator) Args: name (str): name of the c++ parser (e.g. castxml) Returns: path (str), name (str): path to the xml generator and it's name If no c++ parser is found the function raises an exception. pygccxml does currently only support castxml as c++ pa...
[ "Try", "to", "find", "a", "c", "++", "parser", "(", "xml", "generator", ")" ]
python
train
28.375
ming060/robotframework-uiautomatorlibrary
uiautomatorlibrary/Mobile.py
https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L354-L360
def wait_for_exists(self, timeout=0, *args, **selectors): """ Wait for the object which has *selectors* within the given timeout. Return true if the object *appear* in the given timeout. Else return false. """ return self.device(**selectors).wait.exists(timeout=timeout)
[ "def", "wait_for_exists", "(", "self", ",", "timeout", "=", "0", ",", "*", "args", ",", "*", "*", "selectors", ")", ":", "return", "self", ".", "device", "(", "*", "*", "selectors", ")", ".", "wait", ".", "exists", "(", "timeout", "=", "timeout", "...
Wait for the object which has *selectors* within the given timeout. Return true if the object *appear* in the given timeout. Else return false.
[ "Wait", "for", "the", "object", "which", "has", "*", "selectors", "*", "within", "the", "given", "timeout", "." ]
python
train
43.571429
lukasgeiter/mkdocs-awesome-pages-plugin
mkdocs_awesome_pages_plugin/utils.py
https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin/blob/f5693418b71a0849c5fee3b3307e117983c4e2d8/mkdocs_awesome_pages_plugin/utils.py#L37-L40
def join_paths(path1: Optional[str], path2: Optional[str]) -> Optional[str]: """ Joins two paths if neither of them is None """ if path1 is not None and path2 is not None: return os.path.join(path1, path2)
[ "def", "join_paths", "(", "path1", ":", "Optional", "[", "str", "]", ",", "path2", ":", "Optional", "[", "str", "]", ")", "->", "Optional", "[", "str", "]", ":", "if", "path1", "is", "not", "None", "and", "path2", "is", "not", "None", ":", "return"...
Joins two paths if neither of them is None
[ "Joins", "two", "paths", "if", "neither", "of", "them", "is", "None" ]
python
train
54.5