repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
blaix/tdubs
tdubs/verifications.py
https://github.com/blaix/tdubs/blob/5df4ee32bb973dbf52baa4f10640505394089b78/tdubs/verifications.py#L50-L61
def called_with(self, *args, **kwargs): """Return True if the spy was called with the specified args/kwargs. Otherwise raise VerificationError. """ expected_call = Call(*args, **kwargs) if expected_call in calls(self.spy): return True raise VerificationError...
[ "def", "called_with", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "expected_call", "=", "Call", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "expected_call", "in", "calls", "(", "self", ".", "spy", ")", ":", "return",...
Return True if the spy was called with the specified args/kwargs. Otherwise raise VerificationError.
[ "Return", "True", "if", "the", "spy", "was", "called", "with", "the", "specified", "args", "/", "kwargs", "." ]
python
train
smarie/python-parsyfiles
parsyfiles/plugins_base/support_for_collections.py
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/plugins_base/support_for_collections.py#L421-L432
def get_default_collection_parsers(parser_finder: ParserFinder, conversion_finder: ConversionFinder) -> List[AnyParser]: """ Utility method to return the default parsers able to parse a dictionary from a file. :return: """ return [SingleFileParserFunction(parser_function=read_dict_or_list_from_json,...
[ "def", "get_default_collection_parsers", "(", "parser_finder", ":", "ParserFinder", ",", "conversion_finder", ":", "ConversionFinder", ")", "->", "List", "[", "AnyParser", "]", ":", "return", "[", "SingleFileParserFunction", "(", "parser_function", "=", "read_dict_or_li...
Utility method to return the default parsers able to parse a dictionary from a file. :return:
[ "Utility", "method", "to", "return", "the", "default", "parsers", "able", "to", "parse", "a", "dictionary", "from", "a", "file", ".", ":", "return", ":" ]
python
train
inasafe/inasafe
safe/gui/widgets/dock.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L872-L880
def show_busy(self): """Hide the question group box and enable the busy cursor.""" self.progress_bar.show() self.question_group.setEnabled(False) self.question_group.setVisible(False) enable_busy_cursor() self.repaint() qApp.processEvents() self.busy = Tru...
[ "def", "show_busy", "(", "self", ")", ":", "self", ".", "progress_bar", ".", "show", "(", ")", "self", ".", "question_group", ".", "setEnabled", "(", "False", ")", "self", ".", "question_group", ".", "setVisible", "(", "False", ")", "enable_busy_cursor", "...
Hide the question group box and enable the busy cursor.
[ "Hide", "the", "question", "group", "box", "and", "enable", "the", "busy", "cursor", "." ]
python
train
Clivern/PyLogging
pylogging/pylogging.py
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L209-L213
def _execFilters(self, type, msg): """ Execute Registered Filters """ for filter in self.FILTERS: msg = filter(type, msg) return msg
[ "def", "_execFilters", "(", "self", ",", "type", ",", "msg", ")", ":", "for", "filter", "in", "self", ".", "FILTERS", ":", "msg", "=", "filter", "(", "type", ",", "msg", ")", "return", "msg" ]
Execute Registered Filters
[ "Execute", "Registered", "Filters" ]
python
train
nerdvegas/rez
src/rez/rex.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/rex.py#L564-L571
def apply_environ(self): """Apply changes to target environ. """ if self.manager is None: raise RezSystemError("You must call 'set_manager' on a Python rex " "interpreter before using it.") self.target_environ.update(self.manager.environ)
[ "def", "apply_environ", "(", "self", ")", ":", "if", "self", ".", "manager", "is", "None", ":", "raise", "RezSystemError", "(", "\"You must call 'set_manager' on a Python rex \"", "\"interpreter before using it.\"", ")", "self", ".", "target_environ", ".", "update", "...
Apply changes to target environ.
[ "Apply", "changes", "to", "target", "environ", "." ]
python
train
fudge-py/fudge
fudge/__init__.py
https://github.com/fudge-py/fudge/blob/b283fbc1a41900f3f5845b10b8c2ef9136a67ebc/fudge/__init__.py#L1112-L1139
def returns_fake(self, *args, **kwargs): """Set the last call to return a new :class:`fudge.Fake`. Any given arguments are passed to the :class:`fudge.Fake` constructor Take note that this is different from the cascading nature of other methods. This will return an instance of the *ne...
[ "def", "returns_fake", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "exp", "=", "self", ".", "_get_current_call", "(", ")", "endpoint", "=", "kwargs", ".", "get", "(", "'name'", ",", "exp", ".", "call_name", ")", "name", "=", "...
Set the last call to return a new :class:`fudge.Fake`. Any given arguments are passed to the :class:`fudge.Fake` constructor Take note that this is different from the cascading nature of other methods. This will return an instance of the *new* Fake, not self, so you should be careful ...
[ "Set", "the", "last", "call", "to", "return", "a", "new", ":", "class", ":", "fudge", ".", "Fake", "." ]
python
train
NicolasLM/spinach
spinach/brokers/redis.py
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/redis.py#L203-L213
def register_periodic_tasks(self, tasks: Iterable[Task]): """Register tasks that need to be scheduled periodically.""" tasks = [task.serialize() for task in tasks] self._number_periodic_tasks = len(tasks) self._run_script( self._register_periodic_tasks, math.ceil(...
[ "def", "register_periodic_tasks", "(", "self", ",", "tasks", ":", "Iterable", "[", "Task", "]", ")", ":", "tasks", "=", "[", "task", ".", "serialize", "(", ")", "for", "task", "in", "tasks", "]", "self", ".", "_number_periodic_tasks", "=", "len", "(", ...
Register tasks that need to be scheduled periodically.
[ "Register", "tasks", "that", "need", "to", "be", "scheduled", "periodically", "." ]
python
train
jupyterhub/jupyter-server-proxy
contrib/rstudio/jupyter_rsession_proxy/__init__.py
https://github.com/jupyterhub/jupyter-server-proxy/blob/f12a090babe3c6e37a777b7e54c7b415de5c7e18/contrib/rstudio/jupyter_rsession_proxy/__init__.py#L8-L40
def setup_shiny(): '''Manage a Shiny instance.''' name = 'shiny' def _get_shiny_cmd(port): conf = dedent(""" run_as {user}; server {{ listen {port}; location / {{ site_dir {site_dir}; log_dir {site_dir}/...
[ "def", "setup_shiny", "(", ")", ":", "name", "=", "'shiny'", "def", "_get_shiny_cmd", "(", "port", ")", ":", "conf", "=", "dedent", "(", "\"\"\"\n run_as {user};\n server {{\n listen {port};\n location / {{\n ...
Manage a Shiny instance.
[ "Manage", "a", "Shiny", "instance", "." ]
python
train
cggh/scikit-allel
allel/model/ndarray.py
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L714-L724
def count_hom_ref(self, axis=None): """Count homozygous reference genotypes. Parameters ---------- axis : int, optional Axis over which to count, or None to perform overall count. """ b = self.is_hom_ref() return np.sum(b, axis=axis)
[ "def", "count_hom_ref", "(", "self", ",", "axis", "=", "None", ")", ":", "b", "=", "self", ".", "is_hom_ref", "(", ")", "return", "np", ".", "sum", "(", "b", ",", "axis", "=", "axis", ")" ]
Count homozygous reference genotypes. Parameters ---------- axis : int, optional Axis over which to count, or None to perform overall count.
[ "Count", "homozygous", "reference", "genotypes", "." ]
python
train
python-cmd2/cmd2
examples/pirate.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/examples/pirate.py#L93-L98
def do_yo(self, args): """Compose a yo-ho-ho type chant with flexible options.""" chant = ['yo'] + ['ho'] * args.ho separator = ', ' if args.commas else ' ' chant = separator.join(chant) self.poutput('{0} and a bottle of {1}'.format(chant, args.beverage))
[ "def", "do_yo", "(", "self", ",", "args", ")", ":", "chant", "=", "[", "'yo'", "]", "+", "[", "'ho'", "]", "*", "args", ".", "ho", "separator", "=", "', '", "if", "args", ".", "commas", "else", "' '", "chant", "=", "separator", ".", "join", "(", ...
Compose a yo-ho-ho type chant with flexible options.
[ "Compose", "a", "yo", "-", "ho", "-", "ho", "type", "chant", "with", "flexible", "options", "." ]
python
train
gtaylor/django-dynamodb-sessions
dynamodb_sessions/backends/dynamodb.py
https://github.com/gtaylor/django-dynamodb-sessions/blob/434031aa483b26b0b7b5acbdf683bbe1575956f1/dynamodb_sessions/backends/dynamodb.py#L181-L194
def delete(self, session_key=None): """ Deletes the current session, or the one specified in ``session_key``. :keyword str session_key: Optionally, override the session key to delete. """ if session_key is None: if self.session_key is None: ...
[ "def", "delete", "(", "self", ",", "session_key", "=", "None", ")", ":", "if", "session_key", "is", "None", ":", "if", "self", ".", "session_key", "is", "None", ":", "return", "session_key", "=", "self", ".", "session_key", "self", ".", "table", ".", "...
Deletes the current session, or the one specified in ``session_key``. :keyword str session_key: Optionally, override the session key to delete.
[ "Deletes", "the", "current", "session", "or", "the", "one", "specified", "in", "session_key", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/variation/validate.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L93-L102
def _pick_lead_item(items): """Choose lead item for a set of samples. Picks tumors for tumor/normal pairs and first sample for batch groups. """ paired = vcfutils.get_paired(items) if paired: return paired.tumor_data else: return list(items)[0]
[ "def", "_pick_lead_item", "(", "items", ")", ":", "paired", "=", "vcfutils", ".", "get_paired", "(", "items", ")", "if", "paired", ":", "return", "paired", ".", "tumor_data", "else", ":", "return", "list", "(", "items", ")", "[", "0", "]" ]
Choose lead item for a set of samples. Picks tumors for tumor/normal pairs and first sample for batch groups.
[ "Choose", "lead", "item", "for", "a", "set", "of", "samples", "." ]
python
train
log2timeline/plaso
plaso/analyzers/hashing_analyzer.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/analyzers/hashing_analyzer.py#L64-L77
def SetHasherNames(self, hasher_names_string): """Sets the hashers that should be enabled. Args: hasher_names_string (str): comma separated names of hashers to enable. """ hasher_names = hashers_manager.HashersManager.GetHasherNamesFromString( hasher_names_string) debug_hasher_names ...
[ "def", "SetHasherNames", "(", "self", ",", "hasher_names_string", ")", ":", "hasher_names", "=", "hashers_manager", ".", "HashersManager", ".", "GetHasherNamesFromString", "(", "hasher_names_string", ")", "debug_hasher_names", "=", "', '", ".", "join", "(", "hasher_na...
Sets the hashers that should be enabled. Args: hasher_names_string (str): comma separated names of hashers to enable.
[ "Sets", "the", "hashers", "that", "should", "be", "enabled", "." ]
python
train
objectrocket/python-client
objectrocket/acls.py
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/acls.py#L93-L108
def delete(self, instance, acl): """Delete an ACL by ID belonging to the instance specified by name. :param str instance: The name of the instance on which the ACL exists. :param str acll: The ID of the ACL to delete. """ base_url = self._url.format(instance=instance) ur...
[ "def", "delete", "(", "self", ",", "instance", ",", "acl", ")", ":", "base_url", "=", "self", ".", "_url", ".", "format", "(", "instance", "=", "instance", ")", "url", "=", "'{base}{aclid}/'", ".", "format", "(", "base", "=", "base_url", ",", "aclid", ...
Delete an ACL by ID belonging to the instance specified by name. :param str instance: The name of the instance on which the ACL exists. :param str acll: The ID of the ACL to delete.
[ "Delete", "an", "ACL", "by", "ID", "belonging", "to", "the", "instance", "specified", "by", "name", "." ]
python
train
casacore/python-casacore
casacore/tables/tablecolumn.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/tables/tablecolumn.py#L149-L152
def putcell(self, rownr, value): """Put a value into one or more table cells. (see :func:`table.putcell`)""" return self._table.putcell(self._column, rownr, value)
[ "def", "putcell", "(", "self", ",", "rownr", ",", "value", ")", ":", "return", "self", ".", "_table", ".", "putcell", "(", "self", ".", "_column", ",", "rownr", ",", "value", ")" ]
Put a value into one or more table cells. (see :func:`table.putcell`)
[ "Put", "a", "value", "into", "one", "or", "more", "table", "cells", ".", "(", "see", ":", "func", ":", "table", ".", "putcell", ")" ]
python
train
bcbio/bcbio-nextgen
bcbio/install.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/install.py#L699-L730
def _datatarget_defaults(args, default_args): """Set data installation targets, handling defaults. Sets variation, rnaseq, smallrna as default targets if we're not isolated to a single method. Provides back compatibility for toolplus specifications. """ default_data = default_args.get("datatar...
[ "def", "_datatarget_defaults", "(", "args", ",", "default_args", ")", ":", "default_data", "=", "default_args", ".", "get", "(", "\"datatarget\"", ",", "[", "]", ")", "# back-compatible toolplus specifications", "for", "x", "in", "default_args", ".", "get", "(", ...
Set data installation targets, handling defaults. Sets variation, rnaseq, smallrna as default targets if we're not isolated to a single method. Provides back compatibility for toolplus specifications.
[ "Set", "data", "installation", "targets", "handling", "defaults", "." ]
python
train
apache/airflow
airflow/contrib/hooks/sftp_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/sftp_hook.py#L92-L115
def get_conn(self): """ Returns an SFTP connection object """ if self.conn is None: cnopts = pysftp.CnOpts() if self.no_host_key_check: cnopts.hostkeys = None cnopts.compression = self.compress conn_params = { ...
[ "def", "get_conn", "(", "self", ")", ":", "if", "self", ".", "conn", "is", "None", ":", "cnopts", "=", "pysftp", ".", "CnOpts", "(", ")", "if", "self", ".", "no_host_key_check", ":", "cnopts", ".", "hostkeys", "=", "None", "cnopts", ".", "compression",...
Returns an SFTP connection object
[ "Returns", "an", "SFTP", "connection", "object" ]
python
test
trevisanj/f311
f311/hapi.py
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/hapi.py#L2265-L2295
def describeTable(TableName): """ INPUT PARAMETERS: TableName: name of the table to describe OUTPUT PARAMETERS: none --- DESCRIPTION: Print information about table, including parameter names, formats and wavenumber range. --- EXAMPLE OF USAGE: descr...
[ "def", "describeTable", "(", "TableName", ")", ":", "print", "(", "'-----------------------------------------'", ")", "print", "(", "TableName", "+", "' summary:'", ")", "try", ":", "print", "(", "'-----------------------------------------'", ")", "print", "(", "'Comm...
INPUT PARAMETERS: TableName: name of the table to describe OUTPUT PARAMETERS: none --- DESCRIPTION: Print information about table, including parameter names, formats and wavenumber range. --- EXAMPLE OF USAGE: describeTable('sampletab') ---
[ "INPUT", "PARAMETERS", ":", "TableName", ":", "name", "of", "the", "table", "to", "describe", "OUTPUT", "PARAMETERS", ":", "none", "---", "DESCRIPTION", ":", "Print", "information", "about", "table", "including", "parameter", "names", "formats", "and", "wavenumb...
python
train
jjgomera/iapws
iapws/iapws08.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws08.py#L275-L323
def _waterSupp(cls, T, P): """Get properties of pure water using the supplementary release SR7-09, Table4 pag 6""" tau = (T-273.15)/40 pi = (P-0.101325)/100 J = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,...
[ "def", "_waterSupp", "(", "cls", ",", "T", ",", "P", ")", ":", "tau", "=", "(", "T", "-", "273.15", ")", "/", "40", "pi", "=", "(", "P", "-", "0.101325", ")", "/", "100", "J", "=", "[", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", ...
Get properties of pure water using the supplementary release SR7-09, Table4 pag 6
[ "Get", "properties", "of", "pure", "water", "using", "the", "supplementary", "release", "SR7", "-", "09", "Table4", "pag", "6" ]
python
train
Min-ops/cruddy
cruddy/scripts/cli.py
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L142-L147
def delete(handler, item_id, id_name): """Delete an item""" data = {'operation': 'delete', 'id': item_id, 'id_name': id_name} handler.invoke(data)
[ "def", "delete", "(", "handler", ",", "item_id", ",", "id_name", ")", ":", "data", "=", "{", "'operation'", ":", "'delete'", ",", "'id'", ":", "item_id", ",", "'id_name'", ":", "id_name", "}", "handler", ".", "invoke", "(", "data", ")" ]
Delete an item
[ "Delete", "an", "item" ]
python
train
saltstack/salt
salt/modules/cpan.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L152-L214
def show(module): ''' Show information about a specific Perl module CLI Example: .. code-block:: bash salt '*' cpan.show Template::Alloy ''' ret = {} ret['name'] = module # This section parses out details from CPAN, if possible cmd = 'cpan -D {0}'.format(module) out =...
[ "def", "show", "(", "module", ")", ":", "ret", "=", "{", "}", "ret", "[", "'name'", "]", "=", "module", "# This section parses out details from CPAN, if possible", "cmd", "=", "'cpan -D {0}'", ".", "format", "(", "module", ")", "out", "=", "__salt__", "[", "...
Show information about a specific Perl module CLI Example: .. code-block:: bash salt '*' cpan.show Template::Alloy
[ "Show", "information", "about", "a", "specific", "Perl", "module" ]
python
train
hyperledger/indy-sdk
wrappers/python/indy/crypto.py
https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/crypto.py#L199-L253
async def auth_crypt(wallet_handle: int, sender_vk: str, recipient_vk: str, msg: bytes) -> bytes: """ **** THIS FUNCTION WILL BE DEPRECATED USE pack_message INSTEAD **** Encrypt a message by authenticated-encryption scheme. Sender can encr...
[ "async", "def", "auth_crypt", "(", "wallet_handle", ":", "int", ",", "sender_vk", ":", "str", ",", "recipient_vk", ":", "str", ",", "msg", ":", "bytes", ")", "->", "bytes", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ...
**** THIS FUNCTION WILL BE DEPRECATED USE pack_message INSTEAD **** Encrypt a message by authenticated-encryption scheme. Sender can encrypt a confidential message specifically for Recipient, using Sender's public key. Using Recipient's public key, Sender can compute a shared secret key. Using Sender'...
[ "****", "THIS", "FUNCTION", "WILL", "BE", "DEPRECATED", "USE", "pack_message", "INSTEAD", "****" ]
python
train
aio-libs/aioodbc
aioodbc/connection.py
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L15-L40
def connect(*, dsn, autocommit=False, ansi=False, timeout=0, loop=None, executor=None, echo=False, after_created=None, **kwargs): """Accepts an ODBC connection string and returns a new Connection object. The connection string can be passed as the string `str`, as a list of keywords,or a combina...
[ "def", "connect", "(", "*", ",", "dsn", ",", "autocommit", "=", "False", ",", "ansi", "=", "False", ",", "timeout", "=", "0", ",", "loop", "=", "None", ",", "executor", "=", "None", ",", "echo", "=", "False", ",", "after_created", "=", "None", ",",...
Accepts an ODBC connection string and returns a new Connection object. The connection string can be passed as the string `str`, as a list of keywords,or a combination of the two. Any keywords except autocommit, ansi, and timeout are simply added to the connection string. :param autocommit bool: False...
[ "Accepts", "an", "ODBC", "connection", "string", "and", "returns", "a", "new", "Connection", "object", "." ]
python
train
erocarrera/pefile
peutils.py
https://github.com/erocarrera/pefile/blob/8a78a2e251a3f2336c232bf411133927b479edf2/peutils.py#L381-L387
def load(self , filename=None, data=None): """Load a PEiD signature file. Invoking this method on different files combines the signatures. """ self.__load(filename=filename, data=data)
[ "def", "load", "(", "self", ",", "filename", "=", "None", ",", "data", "=", "None", ")", ":", "self", ".", "__load", "(", "filename", "=", "filename", ",", "data", "=", "data", ")" ]
Load a PEiD signature file. Invoking this method on different files combines the signatures.
[ "Load", "a", "PEiD", "signature", "file", "." ]
python
train
contains-io/rcli
rcli/autodetect.py
https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L124-L148
def _append_commands(dct, # type: typing.Dict[str, typing.Set[str]] module_name, # type: str commands # type:typing.Iterable[_EntryPoint] ): # type: (...) -> None """Append entry point strings representing the given Command objects. Args: ...
[ "def", "_append_commands", "(", "dct", ",", "# type: typing.Dict[str, typing.Set[str]]", "module_name", ",", "# type: str", "commands", "# type:typing.Iterable[_EntryPoint]", ")", ":", "# type: (...) -> None", "for", "command", "in", "commands", ":", "entry_point", "=", "'{...
Append entry point strings representing the given Command objects. Args: dct: The dictionary to append with entry point strings. Each key will be a primary command with a value containing a list of entry point strings representing a Command. module_name: The name of the modu...
[ "Append", "entry", "point", "strings", "representing", "the", "given", "Command", "objects", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/diffraction/core.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/diffraction/core.py#L181-L213
def get_unique_families(hkls): """ Returns unique families of Miller indices. Families must be permutations of each other. Args: hkls ([h, k, l]): List of Miller indices. Returns: {hkl: multiplicity}: A dict with unique hkl and multiplicity. """ # TODO: Definitely can be sp...
[ "def", "get_unique_families", "(", "hkls", ")", ":", "# TODO: Definitely can be sped up.", "def", "is_perm", "(", "hkl1", ",", "hkl2", ")", ":", "h1", "=", "np", ".", "abs", "(", "hkl1", ")", "h2", "=", "np", ".", "abs", "(", "hkl2", ")", "return", "al...
Returns unique families of Miller indices. Families must be permutations of each other. Args: hkls ([h, k, l]): List of Miller indices. Returns: {hkl: multiplicity}: A dict with unique hkl and multiplicity.
[ "Returns", "unique", "families", "of", "Miller", "indices", ".", "Families", "must", "be", "permutations", "of", "each", "other", "." ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/slurm.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/slurm.py#L66-L211
def launch_slurm(jobname: str, cmd: str, memory_mb: int, project: str, qos: str, email: str, duration: timedelta, tasks_per_node: int, cpus_per_task: int, partition: s...
[ "def", "launch_slurm", "(", "jobname", ":", "str", ",", "cmd", ":", "str", ",", "memory_mb", ":", "int", ",", "project", ":", "str", ",", "qos", ":", "str", ",", "email", ":", "str", ",", "duration", ":", "timedelta", ",", "tasks_per_node", ":", "int...
Launch a job into the SLURM environment. Args: jobname: name of the job cmd: command to be executed memory_mb: maximum memory requirement per process (Mb) project: project name qos: quality-of-service name email: user's e-mail address duration: maximum durati...
[ "Launch", "a", "job", "into", "the", "SLURM", "environment", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py#L219-L238
def _BuildMessageFromTypeName(type_name, descriptor_pool): """Returns a protobuf message instance. Args: type_name: Fully-qualified protobuf message type name string. descriptor_pool: DescriptorPool instance. Returns: A Message instance of type matching type_name, or None if the a Descriptor wa...
[ "def", "_BuildMessageFromTypeName", "(", "type_name", ",", "descriptor_pool", ")", ":", "# pylint: disable=g-import-not-at-top", "from", "google", ".", "protobuf", "import", "symbol_database", "database", "=", "symbol_database", ".", "Default", "(", ")", "try", ":", "...
Returns a protobuf message instance. Args: type_name: Fully-qualified protobuf message type name string. descriptor_pool: DescriptorPool instance. Returns: A Message instance of type matching type_name, or None if the a Descriptor wasn't found matching type_name.
[ "Returns", "a", "protobuf", "message", "instance", "." ]
python
train
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/zeromq/driver.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/zeromq/driver.py#L162-L171
def on_stop(self): """ stop subscriber """ LOGGER.debug("zeromq.Subscriber.on_stop") self.running = False while self.is_started: time.sleep(0.1) self.zmqsocket.close() self.zmqcontext.destroy()
[ "def", "on_stop", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"zeromq.Subscriber.on_stop\"", ")", "self", ".", "running", "=", "False", "while", "self", ".", "is_started", ":", "time", ".", "sleep", "(", "0.1", ")", "self", ".", "zmqsocket", "....
stop subscriber
[ "stop", "subscriber" ]
python
train
kytos/kytos-utils
kytos/utils/users.py
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/users.py#L81-L116
def ask_question(self, field_name, pattern=NAME_PATTERN, is_required=False, password=False): """Ask a question and get the input values. This method will validade the input values. Args: field_name(string): Field name used to ask for input value. pat...
[ "def", "ask_question", "(", "self", ",", "field_name", ",", "pattern", "=", "NAME_PATTERN", ",", "is_required", "=", "False", ",", "password", "=", "False", ")", ":", "input_value", "=", "\"\"", "question", "=", "(", "\"Insert the field using the pattern below:\""...
Ask a question and get the input values. This method will validade the input values. Args: field_name(string): Field name used to ask for input value. pattern(tuple): Pattern to validate the input value. is_required(bool): Boolean value if the input value is required...
[ "Ask", "a", "question", "and", "get", "the", "input", "values", "." ]
python
train
loli/medpy
medpy/metric/histogram.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L865-L909
def noelle_5(h1, h2): # 26 us @array, 52 us @list \w 100 bins r""" Extension of `fidelity_based` proposed by [1]_. .. math:: d_{\sin F}(H, H') = \sqrt{1 -d_{F}^2(H, H')} See `fidelity_based` for the definition of :math:`d_{F}(H, H')`. *Attributes:* - metr...
[ "def", "noelle_5", "(", "h1", ",", "h2", ")", ":", "# 26 us @array, 52 us @list \\w 100 bins", "return", "math", ".", "sqrt", "(", "1", "-", "math", ".", "pow", "(", "fidelity_based", "(", "h1", ",", "h2", ")", ",", "2", ")", ")" ]
r""" Extension of `fidelity_based` proposed by [1]_. .. math:: d_{\sin F}(H, H') = \sqrt{1 -d_{F}^2(H, H')} See `fidelity_based` for the definition of :math:`d_{F}(H, H')`. *Attributes:* - metric *Attributes for normalized histograms:* - :math:`...
[ "r", "Extension", "of", "fidelity_based", "proposed", "by", "[", "1", "]", "_", ".", "..", "math", "::", "d_", "{", "\\", "sin", "F", "}", "(", "H", "H", ")", "=", "\\", "sqrt", "{", "1", "-", "d_", "{", "F", "}", "^2", "(", "H", "H", ")", ...
python
train
pypa/setuptools
setuptools/command/easy_install.py
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2145-L2149
def get_header(cls, script_text="", executable=None): """Create a #! line, getting options (if any) from script_text""" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header()
[ "def", "get_header", "(", "cls", ",", "script_text", "=", "\"\"", ",", "executable", "=", "None", ")", ":", "cmd", "=", "cls", ".", "command_spec_class", ".", "best", "(", ")", ".", "from_param", "(", "executable", ")", "cmd", ".", "install_options", "("...
Create a #! line, getting options (if any) from script_text
[ "Create", "a", "#!", "line", "getting", "options", "(", "if", "any", ")", "from", "script_text" ]
python
train
annoviko/pyclustering
pyclustering/nnet/som.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/som.py#L211-L224
def awards(self): """! @brief Return amount of captured objects by each neuron after training. @return (list) Amount of captured objects by each neuron. @see train() """ if self.__ccore_som_pointer is not None: self._award = wrap...
[ "def", "awards", "(", "self", ")", ":", "if", "self", ".", "__ccore_som_pointer", "is", "not", "None", ":", "self", ".", "_award", "=", "wrapper", ".", "som_get_awards", "(", "self", ".", "__ccore_som_pointer", ")", "return", "self", ".", "_award" ]
! @brief Return amount of captured objects by each neuron after training. @return (list) Amount of captured objects by each neuron. @see train()
[ "!" ]
python
valid
globocom/GloboNetworkAPI-client-python
networkapiclient/rest.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L371-L376
def get_full_url(self, parsed_url): """ Returns url path with querystring """ full_path = parsed_url.path if parsed_url.query: full_path = '%s?%s' % (full_path, parsed_url.query) return full_path
[ "def", "get_full_url", "(", "self", ",", "parsed_url", ")", ":", "full_path", "=", "parsed_url", ".", "path", "if", "parsed_url", ".", "query", ":", "full_path", "=", "'%s?%s'", "%", "(", "full_path", ",", "parsed_url", ".", "query", ")", "return", "full_p...
Returns url path with querystring
[ "Returns", "url", "path", "with", "querystring" ]
python
train
Cue/scales
src/greplin/scales/loop.py
https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/loop.py#L22-L34
def installStatsLoop(statsFile, statsDelay): """Installs an interval loop that dumps stats to a file.""" def dumpStats(): """Actual stats dump function.""" scales.dumpStatsTo(statsFile) reactor.callLater(statsDelay, dumpStats) def startStats(): """Starts the stats dump in "statsDelay" seconds.""...
[ "def", "installStatsLoop", "(", "statsFile", ",", "statsDelay", ")", ":", "def", "dumpStats", "(", ")", ":", "\"\"\"Actual stats dump function.\"\"\"", "scales", ".", "dumpStatsTo", "(", "statsFile", ")", "reactor", ".", "callLater", "(", "statsDelay", ",", "dumpS...
Installs an interval loop that dumps stats to a file.
[ "Installs", "an", "interval", "loop", "that", "dumps", "stats", "to", "a", "file", "." ]
python
train
SciTools/biggus
biggus/_init.py
https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L115-L124
def output(self, chunk): """ Dispatch the given Chunk onto all the registered output queues. If the chunk is None, it is silently ignored. """ if chunk is not None: for queue in self.output_queues: queue.put(chunk)
[ "def", "output", "(", "self", ",", "chunk", ")", ":", "if", "chunk", "is", "not", "None", ":", "for", "queue", "in", "self", ".", "output_queues", ":", "queue", ".", "put", "(", "chunk", ")" ]
Dispatch the given Chunk onto all the registered output queues. If the chunk is None, it is silently ignored.
[ "Dispatch", "the", "given", "Chunk", "onto", "all", "the", "registered", "output", "queues", "." ]
python
train
ChrisCummins/labm8
dirhashcache.py
https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/dirhashcache.py#L65-L105
def dirhash(self, path, **dirhash_opts): """ Compute the hash of a directory. Arguments: path: Directory. **dirhash_opts: Additional options to checksumdir.dirhash(). Returns: str: Checksum of directory. """ path = fs.path(path) ...
[ "def", "dirhash", "(", "self", ",", "path", ",", "*", "*", "dirhash_opts", ")", ":", "path", "=", "fs", ".", "path", "(", "path", ")", "last_modified", "=", "time", ".", "ctime", "(", "max", "(", "max", "(", "os", ".", "path", ".", "getmtime", "(...
Compute the hash of a directory. Arguments: path: Directory. **dirhash_opts: Additional options to checksumdir.dirhash(). Returns: str: Checksum of directory.
[ "Compute", "the", "hash", "of", "a", "directory", "." ]
python
train
phoebe-project/phoebe2
phoebe/backend/universe.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/universe.py#L913-L925
def reset_time(self, time, true_anom, elongan, eincl): """ TODO: add documentation """ self.true_anom = true_anom self.elongan = elongan self.eincl = eincl self.time = time self.populated_at_time = [] self.reset() return
[ "def", "reset_time", "(", "self", ",", "time", ",", "true_anom", ",", "elongan", ",", "eincl", ")", ":", "self", ".", "true_anom", "=", "true_anom", "self", ".", "elongan", "=", "elongan", "self", ".", "eincl", "=", "eincl", "self", ".", "time", "=", ...
TODO: add documentation
[ "TODO", ":", "add", "documentation" ]
python
train
mottosso/be
be/vendor/click/core.py
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L1071-L1078
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') self.commands[name...
[ "def", "add_command", "(", "self", ",", "cmd", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "cmd", ".", "name", "if", "name", "is", "None", ":", "raise", "TypeError", "(", "'Command has no name.'", ")", "self", ".", "commands", "[", ...
Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used.
[ "Registers", "another", ":", "class", ":", "Command", "with", "this", "group", ".", "If", "the", "name", "is", "not", "provided", "the", "name", "of", "the", "command", "is", "used", "." ]
python
train
Aluriak/tergraw
tergraw/graphutils.py
https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/graphutils.py#L21-L34
def process_input_graph(func): """Decorator, ensuring first argument is a networkx graph object. If the first arg is a dict {node: succs}, a networkx graph equivalent to the dict will be send in place of it.""" @wraps(func) def wrapped_func(*args, **kwargs): input_graph = args[0] if ...
[ "def", "process_input_graph", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "input_graph", "=", "args", "[", "0", "]", "if", "isinstance", "(", "input_graph", ",", "...
Decorator, ensuring first argument is a networkx graph object. If the first arg is a dict {node: succs}, a networkx graph equivalent to the dict will be send in place of it.
[ "Decorator", "ensuring", "first", "argument", "is", "a", "networkx", "graph", "object", ".", "If", "the", "first", "arg", "is", "a", "dict", "{", "node", ":", "succs", "}", "a", "networkx", "graph", "equivalent", "to", "the", "dict", "will", "be", "send"...
python
train
odlgroup/odl
odl/trafos/util/ft_utils.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/trafos/util/ft_utils.py#L393-L547
def dft_postprocess_data(arr, real_grid, recip_grid, shift, axes, interp, sign='-', op='multiply', out=None): """Post-process the Fourier-space data after DFT. This function multiplies the given data with the separable function:: q(xi) = exp(+- 1j * dot(x[0], xi)) * s * ph...
[ "def", "dft_postprocess_data", "(", "arr", ",", "real_grid", ",", "recip_grid", ",", "shift", ",", "axes", ",", "interp", ",", "sign", "=", "'-'", ",", "op", "=", "'multiply'", ",", "out", "=", "None", ")", ":", "arr", "=", "np", ".", "asarray", "(",...
Post-process the Fourier-space data after DFT. This function multiplies the given data with the separable function:: q(xi) = exp(+- 1j * dot(x[0], xi)) * s * phi_hat(xi_bar) where ``x[0]`` and ``s`` are the minimum point and the stride of the real-space grid, respectively, and ``phi_hat(xi_ba...
[ "Post", "-", "process", "the", "Fourier", "-", "space", "data", "after", "DFT", "." ]
python
train
ptrus/suffix-trees
suffix_trees/STree.py
https://github.com/ptrus/suffix-trees/blob/e7439c93a7b895523fad36c8c65a781710320b57/suffix_trees/STree.py#L124-L132
def _label_generalized(self, node): """Helper method that labels the nodes of GST with indexes of strings found in their descendants. """ if node.is_leaf(): x = {self._get_word_start_index(node.idx)} else: x = {n for ns in node.transition_links for n in ns...
[ "def", "_label_generalized", "(", "self", ",", "node", ")", ":", "if", "node", ".", "is_leaf", "(", ")", ":", "x", "=", "{", "self", ".", "_get_word_start_index", "(", "node", ".", "idx", ")", "}", "else", ":", "x", "=", "{", "n", "for", "ns", "i...
Helper method that labels the nodes of GST with indexes of strings found in their descendants.
[ "Helper", "method", "that", "labels", "the", "nodes", "of", "GST", "with", "indexes", "of", "strings", "found", "in", "their", "descendants", "." ]
python
valid
doakey3/DashTable
dashtable/data2rst/cell/get_merge_direction.py
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_merge_direction.py#L1-L74
def get_merge_direction(cell1, cell2): """ Determine the side of cell1 that can be merged with cell2. This is based on the location of the two cells in the table as well as the compatability of their height and width. For example these cells can merge:: cell1 cell2 merge "RIGHT" ...
[ "def", "get_merge_direction", "(", "cell1", ",", "cell2", ")", ":", "cell1_left", "=", "cell1", ".", "column", "cell1_right", "=", "cell1", ".", "column", "+", "cell1", ".", "column_count", "cell1_top", "=", "cell1", ".", "row", "cell1_bottom", "=", "cell1",...
Determine the side of cell1 that can be merged with cell2. This is based on the location of the two cells in the table as well as the compatability of their height and width. For example these cells can merge:: cell1 cell2 merge "RIGHT" +-----+ +------+ +-----+------+ ...
[ "Determine", "the", "side", "of", "cell1", "that", "can", "be", "merged", "with", "cell2", "." ]
python
train
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L130-L134
def agent_show(self, agent_id, **kwargs): "https://developer.zendesk.com/rest_api/docs/chat/agents#get-agent-by-id" api_path = "/api/v2/agents/{agent_id}" api_path = api_path.format(agent_id=agent_id) return self.call(api_path, **kwargs)
[ "def", "agent_show", "(", "self", ",", "agent_id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/agents/{agent_id}\"", "api_path", "=", "api_path", ".", "format", "(", "agent_id", "=", "agent_id", ")", "return", "self", ".", "call", "(", "...
https://developer.zendesk.com/rest_api/docs/chat/agents#get-agent-by-id
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "chat", "/", "agents#get", "-", "agent", "-", "by", "-", "id" ]
python
train
aio-libs/aiohttp-devtools
aiohttp_devtools/start/template/app/views.py
https://github.com/aio-libs/aiohttp-devtools/blob/e9ea6feb43558e6e64595ea0ea5613f226cba81f/aiohttp_devtools/start/template/app/views.py#L60-L91
async def index(request): """ This is the view handler for the "/" url. **Note: returning html without a template engine like jinja2 is ugly, no way around that.** :param request: the request object see http://aiohttp.readthedocs.io/en/stable/web_reference.html#request :return: aiohttp.web.Respons...
[ "async", "def", "index", "(", "request", ")", ":", "# {% if database.is_none and example.is_message_board %}", "# app.router allows us to generate urls based on their names,", "# see http://aiohttp.readthedocs.io/en/stable/web.html#reverse-url-constructing-using-named-resources", "message_url", ...
This is the view handler for the "/" url. **Note: returning html without a template engine like jinja2 is ugly, no way around that.** :param request: the request object see http://aiohttp.readthedocs.io/en/stable/web_reference.html#request :return: aiohttp.web.Response object
[ "This", "is", "the", "view", "handler", "for", "the", "/", "url", "." ]
python
train
hotdoc/hotdoc
hotdoc/extensions/c/clang/cindex.py
https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L1727-L1735
def walk_preorder(self): """Depth-first preorder walk over the cursor and its descendants. Yields cursors. """ yield self for child in self.get_children(): for descendant in child.walk_preorder(): yield descendant
[ "def", "walk_preorder", "(", "self", ")", ":", "yield", "self", "for", "child", "in", "self", ".", "get_children", "(", ")", ":", "for", "descendant", "in", "child", ".", "walk_preorder", "(", ")", ":", "yield", "descendant" ]
Depth-first preorder walk over the cursor and its descendants. Yields cursors.
[ "Depth", "-", "first", "preorder", "walk", "over", "the", "cursor", "and", "its", "descendants", "." ]
python
train
maartenbreddels/ipyvolume
ipyvolume/utils.py
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/utils.py#L122-L193
def download_to_file(url, filepath, resume=False, overwrite=False, chunk_size=1024 * 1024 * 10, loadbar_length=10): """Download a url. prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :type url: str :type filepath: str :param filepath: path to download to ...
[ "def", "download_to_file", "(", "url", ",", "filepath", ",", "resume", "=", "False", ",", "overwrite", "=", "False", ",", "chunk_size", "=", "1024", "*", "1024", "*", "10", ",", "loadbar_length", "=", "10", ")", ":", "resume_header", "=", "None", "loaded...
Download a url. prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :type url: str :type filepath: str :param filepath: path to download to :param resume: if True resume download from existing file chunk :param overwrite: if True remove any existing filepa...
[ "Download", "a", "url", "." ]
python
train
welchbj/sublemon
sublemon/runtime.py
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/runtime.py#L80-L98
async def iter_lines( self, *cmds: str, stream: str='both') -> AsyncGenerator[str, None]: """Coroutine to spawn commands and yield text lines from stdout.""" sps = self.spawn(*cmds) if stream == 'both': agen = amerge( amerge(*[sp.st...
[ "async", "def", "iter_lines", "(", "self", ",", "*", "cmds", ":", "str", ",", "stream", ":", "str", "=", "'both'", ")", "->", "AsyncGenerator", "[", "str", ",", "None", "]", ":", "sps", "=", "self", ".", "spawn", "(", "*", "cmds", ")", "if", "str...
Coroutine to spawn commands and yield text lines from stdout.
[ "Coroutine", "to", "spawn", "commands", "and", "yield", "text", "lines", "from", "stdout", "." ]
python
train
saltstack/salt
salt/modules/boto_lambda.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_lambda.py#L737-L758
def alias_exists(FunctionName, Name, region=None, key=None, keyid=None, profile=None): ''' Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .....
[ "def", "alias_exists", "(", "FunctionName", ",", "Name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "alias", "=", "_find_alias", "(", "FunctionName", ",", "Name", ...
Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.alias_exists myfunction myalias
[ "Given", "a", "function", "name", "and", "alias", "name", "check", "to", "see", "if", "the", "given", "alias", "exists", "." ]
python
train
sbg/sevenbridges-python
sevenbridges/models/task.py
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/task.py#L381-L389
def get_batch_children(self): """ Retrieves batch child tasks for this task if its a batch task. :return: Collection instance. :raises SbError if task is not a batch task. """ if not self.batch: raise SbgError("This task is not a batch task.") return s...
[ "def", "get_batch_children", "(", "self", ")", ":", "if", "not", "self", ".", "batch", ":", "raise", "SbgError", "(", "\"This task is not a batch task.\"", ")", "return", "self", ".", "query", "(", "parent", "=", "self", ".", "id", ",", "api", "=", "self",...
Retrieves batch child tasks for this task if its a batch task. :return: Collection instance. :raises SbError if task is not a batch task.
[ "Retrieves", "batch", "child", "tasks", "for", "this", "task", "if", "its", "a", "batch", "task", ".", ":", "return", ":", "Collection", "instance", ".", ":", "raises", "SbError", "if", "task", "is", "not", "a", "batch", "task", "." ]
python
train
bokeh/bokeh
bokeh/core/property/descriptors.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/descriptors.py#L671-L697
def _get(self, obj): ''' Internal implementation of instance attribute access for the ``BasicPropertyDescriptor`` getter. If the value has not been explicitly set by a user, return that value. Otherwise, return the default. Args: obj (HasProps) : the instance to get...
[ "def", "_get", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_property_values'", ")", ":", "raise", "RuntimeError", "(", "\"Cannot get a property value '%s' from a %s instance before HasProps.__init__\"", "%", "(", "self", ".", "name"...
Internal implementation of instance attribute access for the ``BasicPropertyDescriptor`` getter. If the value has not been explicitly set by a user, return that value. Otherwise, return the default. Args: obj (HasProps) : the instance to get a value of this property for ...
[ "Internal", "implementation", "of", "instance", "attribute", "access", "for", "the", "BasicPropertyDescriptor", "getter", "." ]
python
train
willkg/everett
everett/sphinxext.py
https://github.com/willkg/everett/blob/5653134af59f439d2b33f3939fab2b8544428f11/everett/sphinxext.py#L216-L237
def add_target_and_index(self, name, sig, signode): """Add a target and index for this thing.""" targetname = '%s-%s' % (self.objtype, name) if targetname not in self.state.document.ids: signode['names'].append(targetname) signode['ids'].append(targetname) si...
[ "def", "add_target_and_index", "(", "self", ",", "name", ",", "sig", ",", "signode", ")", ":", "targetname", "=", "'%s-%s'", "%", "(", "self", ".", "objtype", ",", "name", ")", "if", "targetname", "not", "in", "self", ".", "state", ".", "document", "."...
Add a target and index for this thing.
[ "Add", "a", "target", "and", "index", "for", "this", "thing", "." ]
python
train
laplacesdemon/django-social-friends-finder
social_friends_finder/models.py
https://github.com/laplacesdemon/django-social-friends-finder/blob/cad63349b19b3c301626c24420ace13c63f45ad7/social_friends_finder/models.py#L68-L90
def get_or_create_with_social_auth(self, social_auth): """ creates and saves model instance with collection of UserSocialAuth Raise: NotImplemetedError """ # Type check self.assert_user_is_social_auth_user(social_auth) # Fetch the record try:...
[ "def", "get_or_create_with_social_auth", "(", "self", ",", "social_auth", ")", ":", "# Type check", "self", ".", "assert_user_is_social_auth_user", "(", "social_auth", ")", "# Fetch the record", "try", ":", "social_friend_list", "=", "self", ".", "filter", "(", "user_...
creates and saves model instance with collection of UserSocialAuth Raise: NotImplemetedError
[ "creates", "and", "saves", "model", "instance", "with", "collection", "of", "UserSocialAuth" ]
python
train
ricequant/rqalpha
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L411-L455
def apply_trade(self, trade): """ 应用成交,并计算交易产生的现金变动。 开仓: delta_cash = -1 * margin = -1 * quantity * contract_multiplier * price * margin_rate 平仓: delta_cash = old_margin - margin + delta_realized_pnl = (sum of (cost_price * quantity) of c...
[ "def", "apply_trade", "(", "self", ",", "trade", ")", ":", "# close_trade: delta_cash = old_margin - margin + delta_realized_pnl", "trade_quantity", "=", "trade", ".", "last_quantity", "if", "trade", ".", "side", "==", "SIDE", ".", "BUY", ":", "if", "trade", ".", ...
应用成交,并计算交易产生的现金变动。 开仓: delta_cash = -1 * margin = -1 * quantity * contract_multiplier * price * margin_rate 平仓: delta_cash = old_margin - margin + delta_realized_pnl = (sum of (cost_price * quantity) of closed trade) * contract_multiplier * margin_rate +...
[ "应用成交,并计算交易产生的现金变动。" ]
python
train
psd-tools/packbits
src/packbits.py
https://github.com/psd-tools/packbits/blob/38909758005abfb891770996f321a630f3c9ece2/src/packbits.py#L29-L101
def encode(data): """ Encodes data using PackBits encoding. """ if len(data) == 0: return data if len(data) == 1: return b'\x00' + data data = bytearray(data) result = bytearray() buf = bytearray() pos = 0 repeat_count = 0 MAX_LENGTH = 127 # we can saf...
[ "def", "encode", "(", "data", ")", ":", "if", "len", "(", "data", ")", "==", "0", ":", "return", "data", "if", "len", "(", "data", ")", "==", "1", ":", "return", "b'\\x00'", "+", "data", "data", "=", "bytearray", "(", "data", ")", "result", "=", ...
Encodes data using PackBits encoding.
[ "Encodes", "data", "using", "PackBits", "encoding", "." ]
python
test
odlgroup/odl
odl/operator/pspace_ops.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/pspace_ops.py#L810-L849
def derivative(self, x): """Derivative of the broadcast operator. Parameters ---------- x : `domain` element The point to take the derivative in Returns ------- adjoint : linear `BroadcastOperator` The derivative Examples ...
[ "def", "derivative", "(", "self", ",", "x", ")", ":", "return", "BroadcastOperator", "(", "*", "[", "op", ".", "derivative", "(", "x", ")", "for", "op", "in", "self", ".", "operators", "]", ")" ]
Derivative of the broadcast operator. Parameters ---------- x : `domain` element The point to take the derivative in Returns ------- adjoint : linear `BroadcastOperator` The derivative Examples -------- Example with an af...
[ "Derivative", "of", "the", "broadcast", "operator", "." ]
python
train
dmlc/gluon-nlp
src/gluonnlp/data/utils.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/data/utils.py#L92-L133
def count_tokens(tokens, to_lower=False, counter=None): r"""Counts tokens in the specified string. For token_delim='(td)' and seq_delim='(sd)', a specified string of two sequences of tokens may look like:: (td)token1(td)token2(td)token3(td)(sd)(td)token4(td)token5(td)(sd) Parameters ----...
[ "def", "count_tokens", "(", "tokens", ",", "to_lower", "=", "False", ",", "counter", "=", "None", ")", ":", "if", "to_lower", ":", "tokens", "=", "[", "t", ".", "lower", "(", ")", "for", "t", "in", "tokens", "]", "if", "counter", "is", "None", ":",...
r"""Counts tokens in the specified string. For token_delim='(td)' and seq_delim='(sd)', a specified string of two sequences of tokens may look like:: (td)token1(td)token2(td)token3(td)(sd)(td)token4(td)token5(td)(sd) Parameters ---------- tokens : list of str A source list of tok...
[ "r", "Counts", "tokens", "in", "the", "specified", "string", "." ]
python
train
J535D165/recordlinkage
recordlinkage/api.py
https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/api.py#L42-L56
def block(self, *args, **kwargs): """Add a block index. Shortcut of :class:`recordlinkage.index.Block`:: from recordlinkage.index import Block indexer = recordlinkage.Index() indexer.add(Block()) """ indexer = Block(*args, **kwargs) self.ad...
[ "def", "block", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "indexer", "=", "Block", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "add", "(", "indexer", ")", "return", "self" ]
Add a block index. Shortcut of :class:`recordlinkage.index.Block`:: from recordlinkage.index import Block indexer = recordlinkage.Index() indexer.add(Block())
[ "Add", "a", "block", "index", "." ]
python
train
pydata/xarray
xarray/core/dataarray.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1034-L1080
def interp_like(self, other, method='linear', assume_sorted=False, kwargs={}): """Interpolate this object onto the coordinates of another object, filling out of range values with NaN. Parameters ---------- other : Dataset or DataArray Object with ...
[ "def", "interp_like", "(", "self", ",", "other", ",", "method", "=", "'linear'", ",", "assume_sorted", "=", "False", ",", "kwargs", "=", "{", "}", ")", ":", "if", "self", ".", "dtype", ".", "kind", "not", "in", "'uifc'", ":", "raise", "TypeError", "(...
Interpolate this object onto the coordinates of another object, filling out of range values with NaN. Parameters ---------- other : Dataset or DataArray Object with an 'indexes' attribute giving a mapping from dimension names to an 1d array-like, which provides c...
[ "Interpolate", "this", "object", "onto", "the", "coordinates", "of", "another", "object", "filling", "out", "of", "range", "values", "with", "NaN", "." ]
python
train
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L1726-L1739
def _disks_equal(disk1, disk2): ''' Test if two disk elements should be considered like the same device ''' target1 = disk1.find('target') target2 = disk2.find('target') source1 = ElementTree.tostring(disk1.find('source')) if disk1.find('source') is not None else None source2 = ElementTree.t...
[ "def", "_disks_equal", "(", "disk1", ",", "disk2", ")", ":", "target1", "=", "disk1", ".", "find", "(", "'target'", ")", "target2", "=", "disk2", ".", "find", "(", "'target'", ")", "source1", "=", "ElementTree", ".", "tostring", "(", "disk1", ".", "fin...
Test if two disk elements should be considered like the same device
[ "Test", "if", "two", "disk", "elements", "should", "be", "considered", "like", "the", "same", "device" ]
python
train
androguard/androguard
androguard/core/bytecodes/dvm.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L7987-L7998
def get_fields(self): """ Return all field objects :rtype: a list of :class:`EncodedField` objects """ if self.__cache_all_fields is None: self.__cache_all_fields = [] for i in self.get_classes(): for j in i.get_fields(): ...
[ "def", "get_fields", "(", "self", ")", ":", "if", "self", ".", "__cache_all_fields", "is", "None", ":", "self", ".", "__cache_all_fields", "=", "[", "]", "for", "i", "in", "self", ".", "get_classes", "(", ")", ":", "for", "j", "in", "i", ".", "get_fi...
Return all field objects :rtype: a list of :class:`EncodedField` objects
[ "Return", "all", "field", "objects" ]
python
train
ejeschke/ginga
ginga/web/pgw/ipg.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L168-L197
def build_gui(self, container): """ This is responsible for building the viewer's UI. It should place the UI in `container`. """ vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) w = Viewers.GingaViewerWidget(viewer=self) vbox.ad...
[ "def", "build_gui", "(", "self", ",", "container", ")", ":", "vbox", "=", "Widgets", ".", "VBox", "(", ")", "vbox", ".", "set_border_width", "(", "2", ")", "vbox", ".", "set_spacing", "(", "1", ")", "w", "=", "Viewers", ".", "GingaViewerWidget", "(", ...
This is responsible for building the viewer's UI. It should place the UI in `container`.
[ "This", "is", "responsible", "for", "building", "the", "viewer", "s", "UI", ".", "It", "should", "place", "the", "UI", "in", "container", "." ]
python
train
dvdotsenko/jsonrpc.py
jsonrpcparts/serializers.py
https://github.com/dvdotsenko/jsonrpc.py/blob/19673edd77a9518ac5655bd407f6b93ffbb2cafc/jsonrpcparts/serializers.py#L206-L240
def parse_request(cls, jsonrpc_message): """We take apart JSON-RPC-formatted message as a string and decompose it into a dictionary object, emitting errors if parsing detects issues with the format of the message. :Returns: | [method_name, params, id] or [method_name, params] ...
[ "def", "parse_request", "(", "cls", ",", "jsonrpc_message", ")", ":", "try", ":", "data", "=", "cls", ".", "json_loads", "(", "jsonrpc_message", ")", "except", "ValueError", ",", "err", ":", "raise", "errors", ".", "RPCParseError", "(", "\"No valid JSON. (%s)\...
We take apart JSON-RPC-formatted message as a string and decompose it into a dictionary object, emitting errors if parsing detects issues with the format of the message. :Returns: | [method_name, params, id] or [method_name, params] | params is a tuple/list ...
[ "We", "take", "apart", "JSON", "-", "RPC", "-", "formatted", "message", "as", "a", "string", "and", "decompose", "it", "into", "a", "dictionary", "object", "emitting", "errors", "if", "parsing", "detects", "issues", "with", "the", "format", "of", "the", "m...
python
train
Becksteinlab/GromacsWrapper
gromacs/setup.py
https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/setup.py#L535-L627
def solvate(struct='top/protein.pdb', top='top/system.top', distance=0.9, boxtype='dodecahedron', concentration=0, cation='NA', anion='CL', water='tip4p', solvent_name='SOL', with_membrane=False, ndx = 'main.ndx', mainselection = '"Protein"', dirname='solvate'...
[ "def", "solvate", "(", "struct", "=", "'top/protein.pdb'", ",", "top", "=", "'top/system.top'", ",", "distance", "=", "0.9", ",", "boxtype", "=", "'dodecahedron'", ",", "concentration", "=", "0", ",", "cation", "=", "'NA'", ",", "anion", "=", "'CL'", ",", ...
Put protein into box, add water, add counter-ions. Currently this really only supports solutes in water. If you need to embedd a protein in a membrane then you will require more sophisticated approaches. However, you *can* supply a protein already inserted in a bilayer. In this case you will proba...
[ "Put", "protein", "into", "box", "add", "water", "add", "counter", "-", "ions", "." ]
python
valid
google/transitfeed
transitfeed/shapelib.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L160-L167
def CrossProd(self, other): """ Returns the cross product of self and other. """ return Point( self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
[ "def", "CrossProd", "(", "self", ",", "other", ")", ":", "return", "Point", "(", "self", ".", "y", "*", "other", ".", "z", "-", "self", ".", "z", "*", "other", ".", "y", ",", "self", ".", "z", "*", "other", ".", "x", "-", "self", ".", "x", ...
Returns the cross product of self and other.
[ "Returns", "the", "cross", "product", "of", "self", "and", "other", "." ]
python
train
dropbox/stone
stone/backends/obj_c_client.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/obj_c_client.py#L275-L333
def _generate_routes_m(self, namespace): """Generates implementation file for namespace object that has as methods all routes within the namespace.""" with self.block_m( fmt_routes_class(namespace.name, self.args.auth_type)): init_args = fmt_func_args_declaration([( ...
[ "def", "_generate_routes_m", "(", "self", ",", "namespace", ")", ":", "with", "self", ".", "block_m", "(", "fmt_routes_class", "(", "namespace", ".", "name", ",", "self", ".", "args", ".", "auth_type", ")", ")", ":", "init_args", "=", "fmt_func_args_declarat...
Generates implementation file for namespace object that has as methods all routes within the namespace.
[ "Generates", "implementation", "file", "for", "namespace", "object", "that", "has", "as", "methods", "all", "routes", "within", "the", "namespace", "." ]
python
train
phoebe-project/phoebe2
phoebe/backend/universe.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/universe.py#L1507-L1535
def _fill_loggs(self, mesh=None, ignore_effects=False): """ TODO: add documentation Calculate local surface gravity GMSunNom = 1.3271244e20 m**3 s**-2 RSunNom = 6.597e8 m """ logger.debug("{}._fill_loggs".format(self.component)) if mesh is None: ...
[ "def", "_fill_loggs", "(", "self", ",", "mesh", "=", "None", ",", "ignore_effects", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"{}._fill_loggs\"", ".", "format", "(", "self", ".", "component", ")", ")", "if", "mesh", "is", "None", ":", "mes...
TODO: add documentation Calculate local surface gravity GMSunNom = 1.3271244e20 m**3 s**-2 RSunNom = 6.597e8 m
[ "TODO", ":", "add", "documentation" ]
python
train
sdss/sdss_access
python/sdss_access/path/path.py
https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L419-L451
def random(self, filetype, **kwargs): ''' Returns random number of the given type of file Parameters ---------- filetype : str File type parameter. num : int The number of files to return as_url: bool Boolean to return SAS urls ...
[ "def", "random", "(", "self", ",", "filetype", ",", "*", "*", "kwargs", ")", ":", "expanded_files", "=", "self", ".", "expand", "(", "filetype", ",", "*", "*", "kwargs", ")", "isany", "=", "self", ".", "any", "(", "filetype", ",", "*", "*", "kwargs...
Returns random number of the given type of file Parameters ---------- filetype : str File type parameter. num : int The number of files to return as_url: bool Boolean to return SAS urls refine: str Regular expression str...
[ "Returns", "random", "number", "of", "the", "given", "type", "of", "file" ]
python
train
ionelmc/python-tblib
src/tblib/__init__.py
https://github.com/ionelmc/python-tblib/blob/00be69aa97e1eb1c09282b1cdb72539c947d4515/src/tblib/__init__.py#L141-L160
def to_dict(self): """Convert a Traceback into a dictionary representation""" if self.tb_next is None: tb_next = None else: tb_next = self.tb_next.to_dict() code = { 'co_filename': self.tb_frame.f_code.co_filename, 'co_name': self.tb_frame...
[ "def", "to_dict", "(", "self", ")", ":", "if", "self", ".", "tb_next", "is", "None", ":", "tb_next", "=", "None", "else", ":", "tb_next", "=", "self", ".", "tb_next", ".", "to_dict", "(", ")", "code", "=", "{", "'co_filename'", ":", "self", ".", "t...
Convert a Traceback into a dictionary representation
[ "Convert", "a", "Traceback", "into", "a", "dictionary", "representation" ]
python
test
stephan-mclean/KickassTorrentsAPI
kat.py
https://github.com/stephan-mclean/KickassTorrentsAPI/blob/4d867a090c06ce95b9ed996b48092cb5bfe28bbd/kat.py#L98-L110
def print_details(self): """Print torrent details""" print("Title:", self.title) print("Category:", self.category) print("Page: ", self.page) print("Size: ", self.size) print("Files: ", self.files) print("Age: ", self.age) print("Seeds:", self.seeders) print("Leechers: ", self.leechers) print("Magne...
[ "def", "print_details", "(", "self", ")", ":", "print", "(", "\"Title:\"", ",", "self", ".", "title", ")", "print", "(", "\"Category:\"", ",", "self", ".", "category", ")", "print", "(", "\"Page: \"", ",", "self", ".", "page", ")", "print", "(", "\"Siz...
Print torrent details
[ "Print", "torrent", "details" ]
python
train
saltstack/salt
salt/modules/zypperpkg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zypperpkg.py#L707-L726
def version_cmp(ver1, ver2, ignore_epoch=False, **kwargs): ''' .. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ...
[ "def", "version_cmp", "(", "ver1", ",", "ver2", ",", "ignore_epoch", "=", "False", ",", "*", "*", "kwargs", ")", ":", "return", "__salt__", "[", "'lowpkg.version_cmp'", "]", "(", "ver1", ",", "ver2", ",", "ignore_epoch", "=", "ignore_epoch", ")" ]
.. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ``True`` to ignore the epoch when comparing versions .. versio...
[ "..", "versionadded", "::", "2015", ".", "5", ".", "4" ]
python
train
softlayer/softlayer-python
SoftLayer/managers/network.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L257-L283
def edit_rwhois(self, abuse_email=None, address1=None, address2=None, city=None, company_name=None, country=None, first_name=None, last_name=None, postal_code=None, private_residence=None, state=None): """Edit rwhois record.""" update = {} ...
[ "def", "edit_rwhois", "(", "self", ",", "abuse_email", "=", "None", ",", "address1", "=", "None", ",", "address2", "=", "None", ",", "city", "=", "None", ",", "company_name", "=", "None", ",", "country", "=", "None", ",", "first_name", "=", "None", ","...
Edit rwhois record.
[ "Edit", "rwhois", "record", "." ]
python
train
O365/python-o365
O365/utils/utils.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/utils/utils.py#L275-L281
def _recipients_from_cloud(self, recipients, field=None): """ Transform a recipient from cloud data to object data """ recipients_data = [] for recipient in recipients: recipients_data.append( self._recipient_from_cloud(recipient, field=field)) return Recipien...
[ "def", "_recipients_from_cloud", "(", "self", ",", "recipients", ",", "field", "=", "None", ")", ":", "recipients_data", "=", "[", "]", "for", "recipient", "in", "recipients", ":", "recipients_data", ".", "append", "(", "self", ".", "_recipient_from_cloud", "(...
Transform a recipient from cloud data to object data
[ "Transform", "a", "recipient", "from", "cloud", "data", "to", "object", "data" ]
python
train
FujiMakoto/IPS-Vagrant
ips_vagrant/downloaders/downloader.py
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/downloaders/downloader.py#L147-L179
def download(self): """ Download the latest IPS release @return: Download file path @rtype: str """ # Submit a download request and test the response self.log.debug('Submitting request: %s', self.request) response = self.session.request(*self.reques...
[ "def", "download", "(", "self", ")", ":", "# Submit a download request and test the response", "self", ".", "log", ".", "debug", "(", "'Submitting request: %s'", ",", "self", ".", "request", ")", "response", "=", "self", ".", "session", ".", "request", "(", "*",...
Download the latest IPS release @return: Download file path @rtype: str
[ "Download", "the", "latest", "IPS", "release" ]
python
train
iotile/coretools
transport_plugins/native_ble/iotile_transport_native_ble/device_adapter.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/native_ble/iotile_transport_native_ble/device_adapter.py#L228-L284
def connect_async(self, connection_id, connection_string, callback, retries=4, context=None): """Connect to a device by its connection_string This function asynchronously connects to a device by its BLE address + address type passed in the connection_string parameter and calls callback when fin...
[ "def", "connect_async", "(", "self", ",", "connection_id", ",", "connection_string", ",", "callback", ",", "retries", "=", "4", ",", "context", "=", "None", ")", ":", "if", "context", "is", "None", ":", "# It is the first attempt to connect: begin a new connection",...
Connect to a device by its connection_string This function asynchronously connects to a device by its BLE address + address type passed in the connection_string parameter and calls callback when finished. Callback is called on either success or failure with the signature: callback(c...
[ "Connect", "to", "a", "device", "by", "its", "connection_string" ]
python
train
Opentrons/opentrons
api/src/opentrons/deck_calibration/dc_main.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/deck_calibration/dc_main.py#L365-L395
def validate( self, point: Tuple[float, float, float], point_num: int, pipette_mount) -> str: """ :param point: Expected values from mechanical drawings :param point_num: The current position attempting to be validated :param pipette: 'Z' f...
[ "def", "validate", "(", "self", ",", "point", ":", "Tuple", "[", "float", ",", "float", ",", "float", "]", ",", "point_num", ":", "int", ",", "pipette_mount", ")", "->", "str", ":", "_", ",", "_", ",", "cz", "=", "self", ".", "_driver_to_deck_coords"...
:param point: Expected values from mechanical drawings :param point_num: The current position attempting to be validated :param pipette: 'Z' for left mount or 'A' for right mount :return:
[ ":", "param", "point", ":", "Expected", "values", "from", "mechanical", "drawings", ":", "param", "point_num", ":", "The", "current", "position", "attempting", "to", "be", "validated", ":", "param", "pipette", ":", "Z", "for", "left", "mount", "or", "A", "...
python
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1199-L1226
def random_processor(M, N, L, qubit_yield, num_evil=0): """A utility function that generates a random :math:`C_{M,N,L}` missing some percentage of its qubits. INPUTS: M,N,L: the chimera parameters qubit_yield: ratio (0 <= qubit_yield <= 1) of #{qubits}/(2*M*N*L) num_evil: number of ...
[ "def", "random_processor", "(", "M", ",", "N", ",", "L", ",", "qubit_yield", ",", "num_evil", "=", "0", ")", ":", "# replacement for lambda in edge filter below that works with bot h", "def", "edge_filter", "(", "pq", ")", ":", "# we have to unpack the (p,q) edge", "p...
A utility function that generates a random :math:`C_{M,N,L}` missing some percentage of its qubits. INPUTS: M,N,L: the chimera parameters qubit_yield: ratio (0 <= qubit_yield <= 1) of #{qubits}/(2*M*N*L) num_evil: number of broken in-cell couplers between working qubits OUTPUT: ...
[ "A", "utility", "function", "that", "generates", "a", "random", ":", "math", ":", "C_", "{", "M", "N", "L", "}", "missing", "some", "percentage", "of", "its", "qubits", "." ]
python
train
ska-sa/hypercube
hypercube/base_cube.py
https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L439-L497
def register_property(self, name, dtype, default, **kwargs): """ Registers a property with this Solver object .. code-block:: python cube.register_property("reference_frequency", np.float64, 1.4e9) Parameters ---------- name : str The name of th...
[ "def", "register_property", "(", "self", ",", "name", ",", "dtype", ",", "default", ",", "*", "*", "kwargs", ")", ":", "if", "name", "in", "self", ".", "_properties", ":", "raise", "ValueError", "(", "(", "'Property %s is already registered '", "'on this cube ...
Registers a property with this Solver object .. code-block:: python cube.register_property("reference_frequency", np.float64, 1.4e9) Parameters ---------- name : str The name of this property. dtype : Numpy data type Numpy data type ...
[ "Registers", "a", "property", "with", "this", "Solver", "object" ]
python
train
CityOfZion/neo-python
neo/Core/State/AccountState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/AccountState.py#L83-L90
def Size(self): """ Get the total size in bytes of the object. Returns: int: size. """ return super(AccountState, self).Size() + s.uint160 + s.uint8 + GetVarSize(self.Votes) + GetVarSize(len(self.Balances)) + (len(self.Balances) * (32 + 8))
[ "def", "Size", "(", "self", ")", ":", "return", "super", "(", "AccountState", ",", "self", ")", ".", "Size", "(", ")", "+", "s", ".", "uint160", "+", "s", ".", "uint8", "+", "GetVarSize", "(", "self", ".", "Votes", ")", "+", "GetVarSize", "(", "l...
Get the total size in bytes of the object. Returns: int: size.
[ "Get", "the", "total", "size", "in", "bytes", "of", "the", "object", "." ]
python
train
thombashi/SimpleSQLite
simplesqlite/converter.py
https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/converter.py#L21-L47
def to_record(cls, attr_names, values): """ Convert values to a record to be inserted into a database. :param list attr_names: List of attributes for the converting record. :param values: Values to be converted. :type values: |dict|/|namedtuple|/|list|/|tuple| ...
[ "def", "to_record", "(", "cls", ",", "attr_names", ",", "values", ")", ":", "try", ":", "# from a namedtuple to a dict", "values", "=", "values", ".", "_asdict", "(", ")", "except", "AttributeError", ":", "pass", "try", ":", "# from a dictionary to a list", "ret...
Convert values to a record to be inserted into a database. :param list attr_names: List of attributes for the converting record. :param values: Values to be converted. :type values: |dict|/|namedtuple|/|list|/|tuple| :raises ValueError: If the ``values`` is invalid.
[ "Convert", "values", "to", "a", "record", "to", "be", "inserted", "into", "a", "database", "." ]
python
train
pop/pageup
pageup/pageup.py
https://github.com/pop/pageup/blob/e78471d50517e1779e6e2a5ea961f2a2def7e5e8/pageup/pageup.py#L77-L86
def grab(filename, directory): """ Copy dist files from their installed path to cwd/directory/filename cwd is the current directory, directory is their custom site name dir, filename is the name of the example file being copied over. """ r = requests.get('https://raw.githubusercontent.com/El...
[ "def", "grab", "(", "filename", ",", "directory", ")", ":", "r", "=", "requests", ".", "get", "(", "'https://raw.githubusercontent.com/ElijahCaine/pageup/master/pageup/data/'", "+", "filename", ")", "with", "open", "(", "path", ".", "join", "(", "directory", ",", ...
Copy dist files from their installed path to cwd/directory/filename cwd is the current directory, directory is their custom site name dir, filename is the name of the example file being copied over.
[ "Copy", "dist", "files", "from", "their", "installed", "path", "to", "cwd", "/", "directory", "/", "filename", "cwd", "is", "the", "current", "directory", "directory", "is", "their", "custom", "site", "name", "dir", "filename", "is", "the", "name", "of", "...
python
train
lord63/v2ex_daily_mission
v2ex_daily_mission/v2ex.py
https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L88-L93
def get_last(self): """Get to know how long you have kept signing in.""" response = self.session.get(self.mission_url, verify=False) soup = BeautifulSoup(response.text, 'html.parser') last = soup.select('#Main div')[-1].text return last
[ "def", "get_last", "(", "self", ")", ":", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "mission_url", ",", "verify", "=", "False", ")", "soup", "=", "BeautifulSoup", "(", "response", ".", "text", ",", "'html.parser'", ")", "la...
Get to know how long you have kept signing in.
[ "Get", "to", "know", "how", "long", "you", "have", "kept", "signing", "in", "." ]
python
train
mongodb/mongo-python-driver
pymongo/pool.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/pool.py#L696-L710
def validate_session(self, client, session): """Validate this session before use with client. Raises error if this session is logged in as a different user or the client is not the one that created the session. """ if session: if session._client is not client: ...
[ "def", "validate_session", "(", "self", ",", "client", ",", "session", ")", ":", "if", "session", ":", "if", "session", ".", "_client", "is", "not", "client", ":", "raise", "InvalidOperation", "(", "'Can only use session with the MongoClient that'", "' started it'",...
Validate this session before use with client. Raises error if this session is logged in as a different user or the client is not the one that created the session.
[ "Validate", "this", "session", "before", "use", "with", "client", "." ]
python
train
brentp/cruzdb
cruzdb/models.py
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L665-L709
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
[ "def", "localize", "(", "self", ",", "*", "positions", ",", "*", "*", "kwargs", ")", ":", "cdna", "=", "kwargs", ".", "get", "(", "'cdna'", ",", "False", ")", "# TODO: account for strand ?? add kwarg ??", "# if it's to the CDNA, then it's based on the cdsStart", "st...
convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg
[ "convert", "global", "coordinate", "(", "s", ")", "to", "local", "taking", "introns", "into", "account", "and", "cds", "/", "tx", "-", "Start", "depending", "on", "cdna", "=", "True", "kwarg" ]
python
train
simion/pip-upgrader
pip_upgrader/packages_status_detector.py
https://github.com/simion/pip-upgrader/blob/716adca65d9ed56d4d416f94ede8a8e4fa8d640a/pip_upgrader/packages_status_detector.py#L188-L227
def _parse_pypi_json_package_info(self, package_name, current_version, response): """ :type package_name: str :type current_version: version.Version :type response: requests.models.Response """ data = response.json() all_versions = [version.parse(vers) for vers i...
[ "def", "_parse_pypi_json_package_info", "(", "self", ",", "package_name", ",", "current_version", ",", "response", ")", ":", "data", "=", "response", ".", "json", "(", ")", "all_versions", "=", "[", "version", ".", "parse", "(", "vers", ")", "for", "vers", ...
:type package_name: str :type current_version: version.Version :type response: requests.models.Response
[ ":", "type", "package_name", ":", "str", ":", "type", "current_version", ":", "version", ".", "Version", ":", "type", "response", ":", "requests", ".", "models", ".", "Response" ]
python
test
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L438-L448
def _insert_new_layers(self, new_layers, start_node_id, end_node_id): """Insert the new_layers after the node with start_node_id.""" new_node_id = self._add_node(deepcopy(self.node_list[end_node_id])) temp_output_id = new_node_id for layer in new_layers[:-1]: temp_output_id =...
[ "def", "_insert_new_layers", "(", "self", ",", "new_layers", ",", "start_node_id", ",", "end_node_id", ")", ":", "new_node_id", "=", "self", ".", "_add_node", "(", "deepcopy", "(", "self", ".", "node_list", "[", "end_node_id", "]", ")", ")", "temp_output_id", ...
Insert the new_layers after the node with start_node_id.
[ "Insert", "the", "new_layers", "after", "the", "node", "with", "start_node_id", "." ]
python
train
timmahrt/ProMo
promo/duration_morph.py
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/duration_morph.py#L35-L87
def changeDuration(fromWavFN, durationParameters, stepList, outputName, outputMinPitch, outputMaxPitch, praatEXE): ''' Uses praat to morph duration in one file to duration in another Praat uses the PSOLA algorithm ''' rootPath = os.path.split(fromWavFN)[0] # Prep output dir...
[ "def", "changeDuration", "(", "fromWavFN", ",", "durationParameters", ",", "stepList", ",", "outputName", ",", "outputMinPitch", ",", "outputMaxPitch", ",", "praatEXE", ")", ":", "rootPath", "=", "os", ".", "path", ".", "split", "(", "fromWavFN", ")", "[", "...
Uses praat to morph duration in one file to duration in another Praat uses the PSOLA algorithm
[ "Uses", "praat", "to", "morph", "duration", "in", "one", "file", "to", "duration", "in", "another" ]
python
train
HPAC/matchpy
matchpy/matching/syntactic.py
https://github.com/HPAC/matchpy/blob/06b2ec50ee0efdf3dd183768c0ffdb51b7efc393/matchpy/matching/syntactic.py#L40-L42
def is_operation(term: Any) -> bool: """Return True iff the given term is a subclass of :class:`.Operation`.""" return isinstance(term, type) and issubclass(term, Operation)
[ "def", "is_operation", "(", "term", ":", "Any", ")", "->", "bool", ":", "return", "isinstance", "(", "term", ",", "type", ")", "and", "issubclass", "(", "term", ",", "Operation", ")" ]
Return True iff the given term is a subclass of :class:`.Operation`.
[ "Return", "True", "iff", "the", "given", "term", "is", "a", "subclass", "of", ":", "class", ":", ".", "Operation", "." ]
python
train
NetEaseGame/ATX
atx/strutils.py
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/strutils.py#L40-L52
def to_string(s, encoding='utf-8'): """ Accept unicode(py2) or bytes(py3) Returns: py2 type: str py3 type: str """ if six.PY2: return s.encode(encoding) if isinstance(s, bytes): return s.decode(encoding) return s
[ "def", "to_string", "(", "s", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "six", ".", "PY2", ":", "return", "s", ".", "encode", "(", "encoding", ")", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "return", "s", ".", "decode", "(", "e...
Accept unicode(py2) or bytes(py3) Returns: py2 type: str py3 type: str
[ "Accept", "unicode", "(", "py2", ")", "or", "bytes", "(", "py3", ")" ]
python
train
tjguk/winshell
winshell.py
https://github.com/tjguk/winshell/blob/1509d211ab3403dd1cff6113e4e13462d6dec35b/winshell.py#L87-L89
def dumped(text, level, indent=2): """Put curly brackets round an indented text""" return indented("{\n%s\n}" % indented(text, level + 1, indent) or "None", level, indent) + "\n"
[ "def", "dumped", "(", "text", ",", "level", ",", "indent", "=", "2", ")", ":", "return", "indented", "(", "\"{\\n%s\\n}\"", "%", "indented", "(", "text", ",", "level", "+", "1", ",", "indent", ")", "or", "\"None\"", ",", "level", ",", "indent", ")", ...
Put curly brackets round an indented text
[ "Put", "curly", "brackets", "round", "an", "indented", "text" ]
python
train
Qiskit/qiskit-terra
qiskit/dagcircuit/dagcircuit.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L641-L652
def depth(self): """Return the circuit depth. Returns: int: the circuit depth Raises: DAGCircuitError: if not a directed acyclic graph """ if not nx.is_directed_acyclic_graph(self._multi_graph): raise DAGCircuitError("not a DAG") depth...
[ "def", "depth", "(", "self", ")", ":", "if", "not", "nx", ".", "is_directed_acyclic_graph", "(", "self", ".", "_multi_graph", ")", ":", "raise", "DAGCircuitError", "(", "\"not a DAG\"", ")", "depth", "=", "nx", ".", "dag_longest_path_length", "(", "self", "....
Return the circuit depth. Returns: int: the circuit depth Raises: DAGCircuitError: if not a directed acyclic graph
[ "Return", "the", "circuit", "depth", ".", "Returns", ":", "int", ":", "the", "circuit", "depth", "Raises", ":", "DAGCircuitError", ":", "if", "not", "a", "directed", "acyclic", "graph" ]
python
test
MacHu-GWU/windtalker-project
windtalker/cipher.py
https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/cipher.py#L161-L198
def encrypt_dir(self, path, output_path=None, overwrite=False, stream=True, enable_verbose=True): """ Encrypt everything in a directory. :param path: path of the dir you need to encrypt :...
[ "def", "encrypt_dir", "(", "self", ",", "path", ",", "output_path", "=", "None", ",", "overwrite", "=", "False", ",", "stream", "=", "True", ",", "enable_verbose", "=", "True", ")", ":", "path", ",", "output_path", "=", "files", ".", "process_dst_overwrite...
Encrypt everything in a directory. :param path: path of the dir you need to encrypt :param output_path: encrypted dir output path :param overwrite: if True, then silently overwrite output file if exists :param stream: if it is a very big file, stream mode can avoid using too m...
[ "Encrypt", "everything", "in", "a", "directory", "." ]
python
train
LionelAuroux/pyrser
pyrser/passes/topython.py
https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/passes/topython.py#L14-L32
def __exit_scope(self) -> ast.stmt: """Create the appropriate scope exiting statement. The documentation only shows one level and always uses 'return False' in examples. 'raise AltFalse()' within a try. 'break' within a loop. 'return False' otherwise. """ ...
[ "def", "__exit_scope", "(", "self", ")", "->", "ast", ".", "stmt", ":", "if", "self", ".", "in_optional", ":", "return", "ast", ".", "Pass", "(", ")", "if", "self", ".", "in_try", ":", "return", "ast", ".", "Raise", "(", "ast", ".", "Call", "(", ...
Create the appropriate scope exiting statement. The documentation only shows one level and always uses 'return False' in examples. 'raise AltFalse()' within a try. 'break' within a loop. 'return False' otherwise.
[ "Create", "the", "appropriate", "scope", "exiting", "statement", "." ]
python
test
google/grumpy
third_party/stdlib/difflib.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L295-L319
def set_seq1(self, a): """Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMat...
[ "def", "set_seq1", "(", "self", ",", "a", ")", ":", "if", "a", "is", "self", ".", "a", ":", "return", "self", ".", "a", "=", "a", "self", ".", "matching_blocks", "=", "self", ".", "opcodes", "=", "None" ]
Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed ...
[ "Set", "the", "first", "sequence", "to", "be", "compared", "." ]
python
valid
tensorflow/datasets
tensorflow_datasets/core/tf_compat.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/tf_compat.py#L70-L89
def _patch_tf(tf): """Patch TF to maintain compatibility across versions.""" global TF_PATCH if TF_PATCH: return v_1_12 = distutils.version.LooseVersion("1.12.0") v_1_13 = distutils.version.LooseVersion("1.13.0") v_2 = distutils.version.LooseVersion("2.0.0") tf_version = distutils.version.LooseVersio...
[ "def", "_patch_tf", "(", "tf", ")", ":", "global", "TF_PATCH", "if", "TF_PATCH", ":", "return", "v_1_12", "=", "distutils", ".", "version", ".", "LooseVersion", "(", "\"1.12.0\"", ")", "v_1_13", "=", "distutils", ".", "version", ".", "LooseVersion", "(", "...
Patch TF to maintain compatibility across versions.
[ "Patch", "TF", "to", "maintain", "compatibility", "across", "versions", "." ]
python
train
pywbem/pywbem
pywbem/_subscription_manager.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/_subscription_manager.py#L916-L1021
def add_subscriptions(self, server_id, filter_path, destination_paths=None, owned=True): # pylint: disable=line-too-long """ Add subscriptions to a WBEM server for a particular set of indications defined by an indication filter and for a particular set of WBEM ...
[ "def", "add_subscriptions", "(", "self", ",", "server_id", ",", "filter_path", ",", "destination_paths", "=", "None", ",", "owned", "=", "True", ")", ":", "# pylint: disable=line-too-long", "# noqa: E501", "# server_id is validated in _create_...() method.", "owned_destinat...
Add subscriptions to a WBEM server for a particular set of indications defined by an indication filter and for a particular set of WBEM listeners defined by the instance paths of their listener destinations, by creating indication subscription instances (of CIM class "CIM_IndicationSubsc...
[ "Add", "subscriptions", "to", "a", "WBEM", "server", "for", "a", "particular", "set", "of", "indications", "defined", "by", "an", "indication", "filter", "and", "for", "a", "particular", "set", "of", "WBEM", "listeners", "defined", "by", "the", "instance", "...
python
train
pmacosta/pexdoc
pexdoc/exh.py
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1065-L1070
def _get_ex_data(self): """Return hierarchical function name.""" func_id, func_name = self._get_callable_path() if self._full_cname: func_name = self.encode_call(func_name) return func_id, func_name
[ "def", "_get_ex_data", "(", "self", ")", ":", "func_id", ",", "func_name", "=", "self", ".", "_get_callable_path", "(", ")", "if", "self", ".", "_full_cname", ":", "func_name", "=", "self", ".", "encode_call", "(", "func_name", ")", "return", "func_id", ",...
Return hierarchical function name.
[ "Return", "hierarchical", "function", "name", "." ]
python
train
raphaelvallat/pingouin
pingouin/bayesian.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/bayesian.py#L124-L192
def bayesfactor_pearson(r, n): """ Bayes Factor of a Pearson correlation. Parameters ---------- r : float Pearson correlation coefficient n : int Sample size Returns ------- bf : str Bayes Factor (BF10). The Bayes Factor quantifies the evidence in fa...
[ "def", "bayesfactor_pearson", "(", "r", ",", "n", ")", ":", "from", "scipy", ".", "special", "import", "gamma", "# Function to be integrated", "def", "fun", "(", "g", ",", "r", ",", "n", ")", ":", "return", "np", ".", "exp", "(", "(", "(", "n", "-", ...
Bayes Factor of a Pearson correlation. Parameters ---------- r : float Pearson correlation coefficient n : int Sample size Returns ------- bf : str Bayes Factor (BF10). The Bayes Factor quantifies the evidence in favour of the alternative hypothesis....
[ "Bayes", "Factor", "of", "a", "Pearson", "correlation", "." ]
python
train
sibirrer/lenstronomy
lenstronomy/LensModel/Profiles/gaussian_kappa.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L62-L80
def hessian(self, x, y, amp, sigma, center_x=0, center_y=0): """ returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy """ x_ = x - center_x y_ = y - center_y r = np.sqrt(x_**2 + y_**2) sigma_x, sigma_y = sigma, sigma if isinstance(r, int) or is...
[ "def", "hessian", "(", "self", ",", "x", ",", "y", ",", "amp", ",", "sigma", ",", "center_x", "=", "0", ",", "center_y", "=", "0", ")", ":", "x_", "=", "x", "-", "center_x", "y_", "=", "y", "-", "center_y", "r", "=", "np", ".", "sqrt", "(", ...
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
[ "returns", "Hessian", "matrix", "of", "function", "d^2f", "/", "dx^2", "d^f", "/", "dy^2", "d^2", "/", "dxdy" ]
python
train
saltstack/salt
salt/modules/elasticsearch.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/elasticsearch.py#L917-L937
def search_template_get(id, hosts=None, profile=None): ''' .. versionadded:: 2017.7.0 Obtain existing search template definition. id Template ID CLI example:: salt myminion elasticsearch.search_template_get mytemplate ''' es = _get_instance(hosts, profile) try: ...
[ "def", "search_template_get", "(", "id", ",", "hosts", "=", "None", ",", "profile", "=", "None", ")", ":", "es", "=", "_get_instance", "(", "hosts", ",", "profile", ")", "try", ":", "return", "es", ".", "get_template", "(", "id", "=", "id", ")", "exc...
.. versionadded:: 2017.7.0 Obtain existing search template definition. id Template ID CLI example:: salt myminion elasticsearch.search_template_get mytemplate
[ "..", "versionadded", "::", "2017", ".", "7", ".", "0" ]
python
train