repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
tehmaze/ipcalc | ipcalc.py | https://github.com/tehmaze/ipcalc/blob/d436b95d2783347c3e0084d76ec3c52d1f5d2f0b/ipcalc.py#L309-L320 | def _itodq(self, n):
"""Convert long to dotquad or hextet."""
if self.v == 4:
return '.'.join(map(str, [
(n >> 24) & 0xff,
(n >> 16) & 0xff,
(n >> 8) & 0xff,
n & 0xff,
]))
else:
n = '%032x' % n
... | [
"def",
"_itodq",
"(",
"self",
",",
"n",
")",
":",
"if",
"self",
".",
"v",
"==",
"4",
":",
"return",
"'.'",
".",
"join",
"(",
"map",
"(",
"str",
",",
"[",
"(",
"n",
">>",
"24",
")",
"&",
"0xff",
",",
"(",
"n",
">>",
"16",
")",
"&",
"0xff",... | Convert long to dotquad or hextet. | [
"Convert",
"long",
"to",
"dotquad",
"or",
"hextet",
"."
] | python | train | 31.25 |
wummel/linkchecker | linkcheck/logger/sitemapxml.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/logger/sitemapxml.py#L67-L73 | def start_output (self):
"""Write start of checking info as xml comment."""
super(SitemapXmlLogger, self).start_output()
self.xml_start_output()
attrs = {u"xmlns": u"http://www.sitemaps.org/schemas/sitemap/0.9"}
self.xml_starttag(u'urlset', attrs)
self.flush() | [
"def",
"start_output",
"(",
"self",
")",
":",
"super",
"(",
"SitemapXmlLogger",
",",
"self",
")",
".",
"start_output",
"(",
")",
"self",
".",
"xml_start_output",
"(",
")",
"attrs",
"=",
"{",
"u\"xmlns\"",
":",
"u\"http://www.sitemaps.org/schemas/sitemap/0.9\"",
... | Write start of checking info as xml comment. | [
"Write",
"start",
"of",
"checking",
"info",
"as",
"xml",
"comment",
"."
] | python | train | 43.142857 |
arne-cl/discoursegraphs | src/discoursegraphs/merging.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/merging.py#L20-L128 | def merging_cli(debug=False):
"""
simple commandline interface of the merging module.
This function is called when you use the ``discoursegraphs`` application
directly on the command line.
"""
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--tiger-file',
... | [
"def",
"merging_cli",
"(",
"debug",
"=",
"False",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-t'",
",",
"'--tiger-file'",
",",
"help",
"=",
"'TigerXML (syntax) file to be merged'",
")",
"parser",
... | simple commandline interface of the merging module.
This function is called when you use the ``discoursegraphs`` application
directly on the command line. | [
"simple",
"commandline",
"interface",
"of",
"the",
"merging",
"module",
"."
] | python | train | 43.165138 |
jay-johnson/spylunking | spylunking/splunk_publisher.py | https://github.com/jay-johnson/spylunking/blob/95cc86776f04ec5935cf04e291cf18798345d6cb/spylunking/splunk_publisher.py#L74-L121 | def perform_exit():
"""perform_exit
Handling at-the-exit events
---------------------------
This will cleanup each worker process which
could be in the middle of a request/sleep/block
action. This has been tested on python 3 with
Celery and single processes.
"""
if SPLUNK_DEBUG:
... | [
"def",
"perform_exit",
"(",
")",
":",
"if",
"SPLUNK_DEBUG",
":",
"print",
"(",
"'{} -------------------------------'",
".",
"format",
"(",
"rnow",
"(",
")",
")",
")",
"print",
"(",
"'{} splunkpub: atexit.register - start'",
".",
"format",
"(",
"rnow",
"(",
")",
... | perform_exit
Handling at-the-exit events
---------------------------
This will cleanup each worker process which
could be in the middle of a request/sleep/block
action. This has been tested on python 3 with
Celery and single processes. | [
"perform_exit"
] | python | train | 30.895833 |
DheerendraRathor/django-auth-ldap-ng | django_auth_ldap/backend.py | https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L677-L690 | def _populate_profile_flags_from_dn_regex(self, profile):
"""
Populate the given profile object flags from AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX.
Returns True if the profile was modified
"""
save_profile = True
for field, regex in self.settings.PROFILE_FLAGS_BY_DN_REGEX.ite... | [
"def",
"_populate_profile_flags_from_dn_regex",
"(",
"self",
",",
"profile",
")",
":",
"save_profile",
"=",
"True",
"for",
"field",
",",
"regex",
"in",
"self",
".",
"settings",
".",
"PROFILE_FLAGS_BY_DN_REGEX",
".",
"items",
"(",
")",
":",
"field_value",
"=",
... | Populate the given profile object flags from AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX.
Returns True if the profile was modified | [
"Populate",
"the",
"given",
"profile",
"object",
"flags",
"from",
"AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX",
".",
"Returns",
"True",
"if",
"the",
"profile",
"was",
"modified"
] | python | train | 39.857143 |
saltstack/salt | salt/modules/bsd_shadow.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bsd_shadow.py#L133-L157 | def set_expire(name, expire):
'''
Sets the time at which the account expires (in seconds since the UNIX
epoch). See ``man 8 usermod`` on NetBSD and OpenBSD or ``man 8 pw`` on
FreeBSD.
A value of ``0`` sets the account to never expire.
CLI Example:
.. code-block:: bash
salt '*' sh... | [
"def",
"set_expire",
"(",
"name",
",",
"expire",
")",
":",
"pre_info",
"=",
"info",
"(",
"name",
")",
"if",
"expire",
"==",
"pre_info",
"[",
"'expire'",
"]",
":",
"return",
"True",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'FreeBSD'",
":",
"cmd"... | Sets the time at which the account expires (in seconds since the UNIX
epoch). See ``man 8 usermod`` on NetBSD and OpenBSD or ``man 8 pw`` on
FreeBSD.
A value of ``0`` sets the account to never expire.
CLI Example:
.. code-block:: bash
salt '*' shadow.set_expire username 1419980400 | [
"Sets",
"the",
"time",
"at",
"which",
"the",
"account",
"expires",
"(",
"in",
"seconds",
"since",
"the",
"UNIX",
"epoch",
")",
".",
"See",
"man",
"8",
"usermod",
"on",
"NetBSD",
"and",
"OpenBSD",
"or",
"man",
"8",
"pw",
"on",
"FreeBSD",
"."
] | python | train | 29.88 |
PyCQA/pylint | pylint/message/message_handler_mix_in.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L95-L100 | def disable(self, msgid, scope="package", line=None, ignore_unknown=False):
"""don't output message of the given id"""
self._set_msg_status(
msgid, enable=False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line) | [
"def",
"disable",
"(",
"self",
",",
"msgid",
",",
"scope",
"=",
"\"package\"",
",",
"line",
"=",
"None",
",",
"ignore_unknown",
"=",
"False",
")",
":",
"self",
".",
"_set_msg_status",
"(",
"msgid",
",",
"enable",
"=",
"False",
",",
"scope",
"=",
"scope... | don't output message of the given id | [
"don",
"t",
"output",
"message",
"of",
"the",
"given",
"id"
] | python | test | 50.333333 |
assemblerflow/flowcraft | flowcraft/generator/recipe.py | https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/recipe.py#L649-L688 | def brew_recipe(recipe_name):
"""Returns a pipeline string from a recipe name.
Parameters
----------
recipe_name : str
Name of the recipe. Must match the name attribute in one of the classes
defined in :mod:`flowcraft.generator.recipes`
Returns
-------
str
Pipeline ... | [
"def",
"brew_recipe",
"(",
"recipe_name",
")",
":",
"# This will iterate over all modules included in the recipes subpackage",
"# It will return the import class and the module name, algon with the",
"# correct prefix",
"prefix",
"=",
"\"{}.\"",
".",
"format",
"(",
"recipes",
".",
... | Returns a pipeline string from a recipe name.
Parameters
----------
recipe_name : str
Name of the recipe. Must match the name attribute in one of the classes
defined in :mod:`flowcraft.generator.recipes`
Returns
-------
str
Pipeline string ready for parsing and processi... | [
"Returns",
"a",
"pipeline",
"string",
"from",
"a",
"recipe",
"name",
"."
] | python | test | 34.85 |
oczkers/pyllegro | pyllegro/core.py | https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L164-L179 | def getBuyerInfo(self, auction_id, buyer_id):
"""Return buyer info."""
# TODO: add price from getBids
rc = self.__ask__('doGetPostBuyData', itemsArray=self.ArrayOfLong([auction_id]), buyerFilterArray=self.ArrayOfLong([buyer_id]))
rc = rc[0]['usersPostBuyData']['item'][0]['userData']
... | [
"def",
"getBuyerInfo",
"(",
"self",
",",
"auction_id",
",",
"buyer_id",
")",
":",
"# TODO: add price from getBids",
"rc",
"=",
"self",
".",
"__ask__",
"(",
"'doGetPostBuyData'",
",",
"itemsArray",
"=",
"self",
".",
"ArrayOfLong",
"(",
"[",
"auction_id",
"]",
"... | Return buyer info. | [
"Return",
"buyer",
"info",
"."
] | python | train | 56.125 |
iotile/coretools | iotileemulate/iotile/emulate/reference/controller_features/remote_bridge.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/remote_bridge.py#L129-L137 | def reset_script(self):
"""Clear any partially received script."""
self.remote_bridge.status = BRIDGE_STATUS.IDLE
self.remote_bridge.error = 0
self.remote_bridge.parsed_script = None
self._device.script = bytearray()
return [0] | [
"def",
"reset_script",
"(",
"self",
")",
":",
"self",
".",
"remote_bridge",
".",
"status",
"=",
"BRIDGE_STATUS",
".",
"IDLE",
"self",
".",
"remote_bridge",
".",
"error",
"=",
"0",
"self",
".",
"remote_bridge",
".",
"parsed_script",
"=",
"None",
"self",
"."... | Clear any partially received script. | [
"Clear",
"any",
"partially",
"received",
"script",
"."
] | python | train | 29.888889 |
pymc-devs/pymc | pymc/examples/disaster_model.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/examples/disaster_model.py#L43-L48 | def rate(s=switchpoint, e=early_mean, l=late_mean):
''' Concatenate Poisson means '''
out = empty(len(disasters_array))
out[:s] = e
out[s:] = l
return out | [
"def",
"rate",
"(",
"s",
"=",
"switchpoint",
",",
"e",
"=",
"early_mean",
",",
"l",
"=",
"late_mean",
")",
":",
"out",
"=",
"empty",
"(",
"len",
"(",
"disasters_array",
")",
")",
"out",
"[",
":",
"s",
"]",
"=",
"e",
"out",
"[",
"s",
":",
"]",
... | Concatenate Poisson means | [
"Concatenate",
"Poisson",
"means"
] | python | train | 28.166667 |
nimeshkverma/mongo_joins | mongojoin/mongojoin.py | https://github.com/nimeshkverma/mongo_joins/blob/64c416c3402d5906f707b73867fbc55e28d5ec37/mongojoin/mongojoin.py#L18-L35 | def change_dict_keys(self, data_dict, prefix):
"""
Prefixes 'L_'/'R_' to the collection keys
:param data_dict: dictionary which is to be altered
:type data_dict: dict
:param prefix: prefix to be attached before every key
:type prefix: string
... | [
"def",
"change_dict_keys",
"(",
"self",
",",
"data_dict",
",",
"prefix",
")",
":",
"keys",
"=",
"data_dict",
".",
"keys",
"(",
")",
"dummy_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"data_dict",
")",
"changed_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"k... | Prefixes 'L_'/'R_' to the collection keys
:param data_dict: dictionary which is to be altered
:type data_dict: dict
:param prefix: prefix to be attached before every key
:type prefix: string
:return dict_: dict | [
"Prefixes",
"L_",
"/",
"R_",
"to",
"the",
"collection",
"keys",
":",
"param",
"data_dict",
":",
"dictionary",
"which",
"is",
"to",
"be",
"altered",
":",
"type",
"data_dict",
":",
"dict"
] | python | train | 31.333333 |
zeth/inputs | inputs.py | https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L2485-L2491 | def _get_total_read_size(self):
"""How much event data to process at once."""
if self.read_size:
read_size = EVENT_SIZE * self.read_size
else:
read_size = EVENT_SIZE
return read_size | [
"def",
"_get_total_read_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"read_size",
":",
"read_size",
"=",
"EVENT_SIZE",
"*",
"self",
".",
"read_size",
"else",
":",
"read_size",
"=",
"EVENT_SIZE",
"return",
"read_size"
] | How much event data to process at once. | [
"How",
"much",
"event",
"data",
"to",
"process",
"at",
"once",
"."
] | python | train | 33.142857 |
mcieslik-mctp/papy | src/numap/NuMap.py | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L424-L447 | def _start_managers(self):
"""
(internal) starts input and output pool queue manager threads.
"""
self._task_queue = _Weave(self._tasks, self.stride)
# here we determine the size of the maximum memory consumption
self._semaphore_value = (self.buffer or (len(self._tasks) *... | [
"def",
"_start_managers",
"(",
"self",
")",
":",
"self",
".",
"_task_queue",
"=",
"_Weave",
"(",
"self",
".",
"_tasks",
",",
"self",
".",
"stride",
")",
"# here we determine the size of the maximum memory consumption",
"self",
".",
"_semaphore_value",
"=",
"(",
"s... | (internal) starts input and output pool queue manager threads. | [
"(",
"internal",
")",
"starts",
"input",
"and",
"output",
"pool",
"queue",
"manager",
"threads",
"."
] | python | train | 44.458333 |
Erotemic/utool | utool/util_alg.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_alg.py#L2002-L2009 | def almost_eq(arr1, arr2, thresh=1E-11, ret_error=False):
""" checks if floating point number are equal to a threshold
"""
error = np.abs(arr1 - arr2)
passed = error < thresh
if ret_error:
return passed, error
return passed | [
"def",
"almost_eq",
"(",
"arr1",
",",
"arr2",
",",
"thresh",
"=",
"1E-11",
",",
"ret_error",
"=",
"False",
")",
":",
"error",
"=",
"np",
".",
"abs",
"(",
"arr1",
"-",
"arr2",
")",
"passed",
"=",
"error",
"<",
"thresh",
"if",
"ret_error",
":",
"retu... | checks if floating point number are equal to a threshold | [
"checks",
"if",
"floating",
"point",
"number",
"are",
"equal",
"to",
"a",
"threshold"
] | python | train | 31 |
joanvila/aioredlock | aioredlock/redis.py | https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L164-L195 | async def unset_lock(self, resource, lock_identifier):
"""
Unlock this instance
:param resource: redis key to set
:param lock_identifier: uniquie id of lock
:raises: LockError if the lock resource acquired with different lock_identifier
"""
try:
with a... | [
"async",
"def",
"unset_lock",
"(",
"self",
",",
"resource",
",",
"lock_identifier",
")",
":",
"try",
":",
"with",
"await",
"self",
".",
"connect",
"(",
")",
"as",
"redis",
":",
"await",
"redis",
".",
"eval",
"(",
"self",
".",
"unset_lock_script",
",",
... | Unlock this instance
:param resource: redis key to set
:param lock_identifier: uniquie id of lock
:raises: LockError if the lock resource acquired with different lock_identifier | [
"Unlock",
"this",
"instance",
":",
"param",
"resource",
":",
"redis",
"key",
"to",
"set",
":",
"param",
"lock_identifier",
":",
"uniquie",
"id",
"of",
"lock",
":",
"raises",
":",
"LockError",
"if",
"the",
"lock",
"resource",
"acquired",
"with",
"different",
... | python | train | 43.75 |
calve/prof | prof/session.py | https://github.com/calve/prof/blob/c6e034f45ab60908dea661e8271bc44758aeedcf/prof/session.py#L98-L118 | def credentials(login=None):
"""
Find user credentials. We should have parsed the command line for a ``--login`` option.
We will try to find credentials in environment variables.
We will ask user if we cannot find any in arguments nor environment
"""
if not login:
login = environ.get("PR... | [
"def",
"credentials",
"(",
"login",
"=",
"None",
")",
":",
"if",
"not",
"login",
":",
"login",
"=",
"environ",
".",
"get",
"(",
"\"PROF_LOGIN\"",
")",
"password",
"=",
"environ",
".",
"get",
"(",
"\"PROF_PASSWORD\"",
")",
"if",
"not",
"login",
":",
"tr... | Find user credentials. We should have parsed the command line for a ``--login`` option.
We will try to find credentials in environment variables.
We will ask user if we cannot find any in arguments nor environment | [
"Find",
"user",
"credentials",
".",
"We",
"should",
"have",
"parsed",
"the",
"command",
"line",
"for",
"a",
"--",
"login",
"option",
".",
"We",
"will",
"try",
"to",
"find",
"credentials",
"in",
"environment",
"variables",
".",
"We",
"will",
"ask",
"user",
... | python | train | 36.666667 |
readbeyond/aeneas | aeneas/ttswrappers/basettswrapper.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L639-L668 | def _read_audio_data(self, file_path):
"""
Read audio data from file.
:rtype: tuple (True, (duration, sample_rate, codec, data)) or (False, None) on exception
"""
try:
self.log(u"Reading audio data...")
# if we know the TTS outputs to PCM16 mono WAVE
... | [
"def",
"_read_audio_data",
"(",
"self",
",",
"file_path",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"u\"Reading audio data...\"",
")",
"# if we know the TTS outputs to PCM16 mono WAVE",
"# with the correct sample rate,",
"# we can read samples directly from it,",
"# withou... | Read audio data from file.
:rtype: tuple (True, (duration, sample_rate, codec, data)) or (False, None) on exception | [
"Read",
"audio",
"data",
"from",
"file",
"."
] | python | train | 41.7 |
KE-works/pykechain | pykechain/models/service.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L128-L142 | def upload(self, pkg_path):
"""
Upload a python script (or kecpkg) to the service.
.. versionadded:: 1.13
:param pkg_path: path to the python script or kecpkg to upload.
:type pkg_path: basestring
:raises APIError: if the python package could not be uploaded.
:r... | [
"def",
"upload",
"(",
"self",
",",
"pkg_path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"pkg_path",
")",
":",
"self",
".",
"_upload",
"(",
"pkg_path",
"=",
"pkg_path",
")",
"else",
":",
"raise",
"OSError",
"(",
"\"Could not locate python pa... | Upload a python script (or kecpkg) to the service.
.. versionadded:: 1.13
:param pkg_path: path to the python script or kecpkg to upload.
:type pkg_path: basestring
:raises APIError: if the python package could not be uploaded.
:raises OSError: if the python package could not b... | [
"Upload",
"a",
"python",
"script",
"(",
"or",
"kecpkg",
")",
"to",
"the",
"service",
"."
] | python | train | 38.333333 |
coleifer/walrus | walrus/models.py | https://github.com/coleifer/walrus/blob/82bf15a6613487b5b5fefeb488f186d7e0106547/walrus/models.py#L770-L784 | def get(cls, expression):
"""
Retrieve the model instance matching the given expression.
If the number of matching results is not equal to one, then
a ``ValueError`` will be raised.
:param expression: A boolean expression to filter by.
:returns: The matching :py:class:`M... | [
"def",
"get",
"(",
"cls",
",",
"expression",
")",
":",
"executor",
"=",
"Executor",
"(",
"cls",
".",
"__database__",
")",
"result",
"=",
"executor",
".",
"execute",
"(",
"expression",
")",
"if",
"len",
"(",
"result",
")",
"!=",
"1",
":",
"raise",
"Va... | Retrieve the model instance matching the given expression.
If the number of matching results is not equal to one, then
a ``ValueError`` will be raised.
:param expression: A boolean expression to filter by.
:returns: The matching :py:class:`Model` instance.
:raises: ``ValueError`... | [
"Retrieve",
"the",
"model",
"instance",
"matching",
"the",
"given",
"expression",
".",
"If",
"the",
"number",
"of",
"matching",
"results",
"is",
"not",
"equal",
"to",
"one",
"then",
"a",
"ValueError",
"will",
"be",
"raised",
"."
] | python | train | 43.733333 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_aaa.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_aaa.py#L848-L864 | def rule_command_cmdlist_interface_u_interface_fe_leaf_interface_fortygigabitethernet_leaf(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
rule = ET.SubElement(config, "rule", xmlns="urn:brocade.com:mgmt:brocade-aaa")
index_key = ET.SubElement(rule, "ind... | [
"def",
"rule_command_cmdlist_interface_u_interface_fe_leaf_interface_fortygigabitethernet_leaf",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"rule",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 54 |
shapiromatron/bmds | bmds/models/base.py | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L333-L351 | def _get_option_value(self, key):
"""
Get option value(s), or use default value if no override value.
Two output values for 'p' type values (parameters), else one.
Returns a single value or tuple of two values
"""
fn_name = "set_{}_value".format(key)
if key in se... | [
"def",
"_get_option_value",
"(",
"self",
",",
"key",
")",
":",
"fn_name",
"=",
"\"set_{}_value\"",
".",
"format",
"(",
"key",
")",
"if",
"key",
"in",
"self",
".",
"overrides",
":",
"val",
"=",
"self",
".",
"overrides",
"[",
"key",
"]",
"elif",
"hasattr... | Get option value(s), or use default value if no override value.
Two output values for 'p' type values (parameters), else one.
Returns a single value or tuple of two values | [
"Get",
"option",
"value",
"(",
"s",
")",
"or",
"use",
"default",
"value",
"if",
"no",
"override",
"value",
"."
] | python | train | 32.578947 |
hughsie/python-appstream | appstream/component.py | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L459-L465 | def get_provides_by_kind(self, kind):
""" Returns an array of provides of a certain kind """
provs = []
for p in self.provides:
if p.kind == kind:
provs.append(p)
return provs | [
"def",
"get_provides_by_kind",
"(",
"self",
",",
"kind",
")",
":",
"provs",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"provides",
":",
"if",
"p",
".",
"kind",
"==",
"kind",
":",
"provs",
".",
"append",
"(",
"p",
")",
"return",
"provs"
] | Returns an array of provides of a certain kind | [
"Returns",
"an",
"array",
"of",
"provides",
"of",
"a",
"certain",
"kind"
] | python | train | 32.714286 |
peterjc/flake8-rst-docstrings | flake8_rst_docstrings.py | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L881-L888 | def parse_from_import_statement(self):
"""Parse a 'from x import y' statement.
The purpose is to find __future__ statements.
"""
self.log.debug("parsing from/import statement.")
is_future_import = self._parse_from_import_source()
self._parse_from_import_names(is_future_i... | [
"def",
"parse_from_import_statement",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"parsing from/import statement.\"",
")",
"is_future_import",
"=",
"self",
".",
"_parse_from_import_source",
"(",
")",
"self",
".",
"_parse_from_import_names",
"(",
... | Parse a 'from x import y' statement.
The purpose is to find __future__ statements. | [
"Parse",
"a",
"from",
"x",
"import",
"y",
"statement",
"."
] | python | valid | 39.875 |
duniter/duniter-python-api | duniterpy/documents/membership.py | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/documents/membership.py#L76-L95 | def from_inline(cls: Type[MembershipType], version: int, currency: str, membership_type: str,
inline: str) -> MembershipType:
"""
Return Membership instance from inline format
:param version: Version of the document
:param currency: Name of the currency
:para... | [
"def",
"from_inline",
"(",
"cls",
":",
"Type",
"[",
"MembershipType",
"]",
",",
"version",
":",
"int",
",",
"currency",
":",
"str",
",",
"membership_type",
":",
"str",
",",
"inline",
":",
"str",
")",
"->",
"MembershipType",
":",
"data",
"=",
"Membership"... | Return Membership instance from inline format
:param version: Version of the document
:param currency: Name of the currency
:param membership_type: "IN" or "OUT" to enter or exit membership
:param inline: Inline string format
:return: | [
"Return",
"Membership",
"instance",
"from",
"inline",
"format"
] | python | train | 45.2 |
saltstack/salt | salt/cloud/clouds/digitalocean.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L694-L717 | def show_keypair(kwargs=None, call=None):
'''
Show the details of an SSH keypair
'''
if call != 'function':
log.error(
'The show_keypair function must be called with -f or --function.'
)
return False
if not kwargs:
kwargs = {}
if 'keyname' not in kwa... | [
"def",
"show_keypair",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The show_keypair function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"not",
"kwa... | Show the details of an SSH keypair | [
"Show",
"the",
"details",
"of",
"an",
"SSH",
"keypair"
] | python | train | 23.958333 |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L472-L482 | async def _deferred_init(self):
"""
Run those things in a sepearate tasks as they are not required for the
bot to work and they take a lot of time to run.
"""
await self._check_subscriptions()
await self._set_whitelist()
await self._set_get_started()
awai... | [
"async",
"def",
"_deferred_init",
"(",
"self",
")",
":",
"await",
"self",
".",
"_check_subscriptions",
"(",
")",
"await",
"self",
".",
"_set_whitelist",
"(",
")",
"await",
"self",
".",
"_set_get_started",
"(",
")",
"await",
"self",
".",
"_set_greeting_text",
... | Run those things in a sepearate tasks as they are not required for the
bot to work and they take a lot of time to run. | [
"Run",
"those",
"things",
"in",
"a",
"sepearate",
"tasks",
"as",
"they",
"are",
"not",
"required",
"for",
"the",
"bot",
"to",
"work",
"and",
"they",
"take",
"a",
"lot",
"of",
"time",
"to",
"run",
"."
] | python | train | 34.454545 |
gwastro/pycbc | pycbc/waveform/utils.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/waveform/utils.py#L320-L355 | def taper_timeseries(tsdata, tapermethod=None, return_lal=False):
"""
Taper either or both ends of a time series using wrapped
LALSimulation functions
Parameters
----------
tsdata : TimeSeries
Series to be tapered, dtype must be either float32 or float64
tapermethod : string
... | [
"def",
"taper_timeseries",
"(",
"tsdata",
",",
"tapermethod",
"=",
"None",
",",
"return_lal",
"=",
"False",
")",
":",
"if",
"tapermethod",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Must specify a tapering method (function was called\"",
"\"with tapermethod=None)... | Taper either or both ends of a time series using wrapped
LALSimulation functions
Parameters
----------
tsdata : TimeSeries
Series to be tapered, dtype must be either float32 or float64
tapermethod : string
Should be one of ('TAPER_NONE', 'TAPER_START', 'TAPER_END',
'TAPER_ST... | [
"Taper",
"either",
"or",
"both",
"ends",
"of",
"a",
"time",
"series",
"using",
"wrapped",
"LALSimulation",
"functions"
] | python | train | 42.055556 |
openpermissions/perch | perch/model.py | https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L541-L549 | def update(self, user, **kwargs):
"""If parent resource is not an editable state, should not be able to update"""
yield self.get_parent()
if not self.parent.editable:
err = 'Cannot update child of {} resource'.format(self.parent.state.name)
raise exceptions.Unauthorized(... | [
"def",
"update",
"(",
"self",
",",
"user",
",",
"*",
"*",
"kwargs",
")",
":",
"yield",
"self",
".",
"get_parent",
"(",
")",
"if",
"not",
"self",
".",
"parent",
".",
"editable",
":",
"err",
"=",
"'Cannot update child of {} resource'",
".",
"format",
"(",
... | If parent resource is not an editable state, should not be able to update | [
"If",
"parent",
"resource",
"is",
"not",
"an",
"editable",
"state",
"should",
"not",
"be",
"able",
"to",
"update"
] | python | train | 42.111111 |
sorgerlab/indra | indra/sources/hume/processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L165-L175 | def _get_event_and_context(self, event, arg_type):
"""Return an INDRA Event based on an event entry."""
eid = _choose_id(event, arg_type)
ev = self.concept_dict[eid]
concept, metadata = self._make_concept(ev)
ev_delta = {'adjectives': [],
'states': get_states(... | [
"def",
"_get_event_and_context",
"(",
"self",
",",
"event",
",",
"arg_type",
")",
":",
"eid",
"=",
"_choose_id",
"(",
"event",
",",
"arg_type",
")",
"ev",
"=",
"self",
".",
"concept_dict",
"[",
"eid",
"]",
"concept",
",",
"metadata",
"=",
"self",
".",
... | Return an INDRA Event based on an event entry. | [
"Return",
"an",
"INDRA",
"Event",
"based",
"on",
"an",
"event",
"entry",
"."
] | python | train | 45.272727 |
jxtech/wechatpy | wechatpy/client/api/wxa.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/wxa.py#L315-L335 | def list_templates(self, offset=0, count=20):
"""
获取本账号内所有模板
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR
:param offset: 用于分页,表示起始量,最小值为0
:type offset: int
:param count: 用于分页,表示拉取数量,最大值为20
:type count: int
... | [
"def",
"list_templates",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"count",
"=",
"20",
")",
":",
"return",
"self",
".",
"_post",
"(",
"'cgi-bin/wxopen/template/list'",
",",
"data",
"=",
"{",
"'offset'",
":",
"offset",
",",
"'count'",
":",
"count",
",",
... | 获取本账号内所有模板
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR
:param offset: 用于分页,表示起始量,最小值为0
:type offset: int
:param count: 用于分页,表示拉取数量,最大值为20
:type count: int
:return: 模板列表
:rtype: list[dict] | [
"获取本账号内所有模板",
"详情请参考",
"https",
":",
"//",
"open",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"cgi",
"-",
"bin",
"/",
"showdocument?action",
"=",
"dir_list&id",
"=",
"open1500465446_j4CgR"
] | python | train | 28.142857 |
bitesofcode/projexui | projexui/widgets/xsnapshotwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsnapshotwidget.py#L94-L102 | def mousePressEvent(self, event):
"""
Starts the selection process for this widget and snapshot area.
:param event | <QMousePressEvent>
"""
self._region.setX(event.pos().x())
self._region.setY(event.pos().y())
super(XSnapshotWidget, self).mou... | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_region",
".",
"setX",
"(",
"event",
".",
"pos",
"(",
")",
".",
"x",
"(",
")",
")",
"self",
".",
"_region",
".",
"setY",
"(",
"event",
".",
"pos",
"(",
")",
".",
"y",
... | Starts the selection process for this widget and snapshot area.
:param event | <QMousePressEvent> | [
"Starts",
"the",
"selection",
"process",
"for",
"this",
"widget",
"and",
"snapshot",
"area",
".",
":",
"param",
"event",
"|",
"<QMousePressEvent",
">"
] | python | train | 36.777778 |
shaiguitar/snowclient.py | snowclient/api.py | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/api.py#L132-L136 | def table_api_get(self, *paths, **kparams):
""" helper to make GET /api/now/v1/table requests """
url = self.flattened_params_url("/api/now/v1/table", *paths, **kparams)
rjson = self.req("get", url).text
return json.loads(rjson) | [
"def",
"table_api_get",
"(",
"self",
",",
"*",
"paths",
",",
"*",
"*",
"kparams",
")",
":",
"url",
"=",
"self",
".",
"flattened_params_url",
"(",
"\"/api/now/v1/table\"",
",",
"*",
"paths",
",",
"*",
"*",
"kparams",
")",
"rjson",
"=",
"self",
".",
"req... | helper to make GET /api/now/v1/table requests | [
"helper",
"to",
"make",
"GET",
"/",
"api",
"/",
"now",
"/",
"v1",
"/",
"table",
"requests"
] | python | train | 51.2 |
PaulHancock/Aegean | AegeanTools/BANE.py | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L105-L124 | def _sf2(args):
"""
A shallow wrapper for sigma_filter.
Parameters
----------
args : list
A list of arguments for sigma_filter
Returns
-------
None
"""
# an easier to debug traceback when multiprocessing
# thanks to https://stackoverflow.com/a/16618842/1710603
t... | [
"def",
"_sf2",
"(",
"args",
")",
":",
"# an easier to debug traceback when multiprocessing",
"# thanks to https://stackoverflow.com/a/16618842/1710603",
"try",
":",
"return",
"sigma_filter",
"(",
"*",
"args",
")",
"except",
":",
"import",
"traceback",
"raise",
"Exception",
... | A shallow wrapper for sigma_filter.
Parameters
----------
args : list
A list of arguments for sigma_filter
Returns
-------
None | [
"A",
"shallow",
"wrapper",
"for",
"sigma_filter",
"."
] | python | train | 22.7 |
prawn-cake/vk-requests | vk_requests/session.py | https://github.com/prawn-cake/vk-requests/blob/dde01c1ed06f13de912506163a35d8c7e06a8f62/vk_requests/session.py#L179-L211 | def do_direct_authorization(self, session):
""" Direct Authorization, more info: https://vk.com/dev/auth_direct """
logger.info('Doing direct authorization, app_id=%s', self.app_id)
auth_data = {
'client_id': self.app_id,
'client_secret': self._client_secret,
... | [
"def",
"do_direct_authorization",
"(",
"self",
",",
"session",
")",
":",
"logger",
".",
"info",
"(",
"'Doing direct authorization, app_id=%s'",
",",
"self",
".",
"app_id",
")",
"auth_data",
"=",
"{",
"'client_id'",
":",
"self",
".",
"app_id",
",",
"'client_secre... | Direct Authorization, more info: https://vk.com/dev/auth_direct | [
"Direct",
"Authorization",
"more",
"info",
":",
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"auth_direct"
] | python | train | 45.060606 |
CI-WATER/gsshapy | gsshapy/grid/grid_to_gssha.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/grid_to_gssha.py#L660-L679 | def _load_lsm_data(self, data_var,
conversion_factor=1,
calc_4d_method=None,
calc_4d_dim=None,
time_step=None):
"""
This extracts the LSM data from a folder of netcdf files
"""
data = self.xd.lsm.... | [
"def",
"_load_lsm_data",
"(",
"self",
",",
"data_var",
",",
"conversion_factor",
"=",
"1",
",",
"calc_4d_method",
"=",
"None",
",",
"calc_4d_dim",
"=",
"None",
",",
"time_step",
"=",
"None",
")",
":",
"data",
"=",
"self",
".",
"xd",
".",
"lsm",
".",
"g... | This extracts the LSM data from a folder of netcdf files | [
"This",
"extracts",
"the",
"LSM",
"data",
"from",
"a",
"folder",
"of",
"netcdf",
"files"
] | python | train | 42.8 |
lcharleux/argiope | argiope/mesh.py | https://github.com/lcharleux/argiope/blob/8170e431362dc760589f7d141090fd133dece259/argiope/mesh.py#L577-L583 | def fields_metadata(self):
"""
Returns fields metadata as a dataframe.
"""
return (pd.concat([f.metadata() for f in self.fields], axis = 1)
.transpose()
.sort_values(["step_num", "frame", "label", "position"])) | [
"def",
"fields_metadata",
"(",
"self",
")",
":",
"return",
"(",
"pd",
".",
"concat",
"(",
"[",
"f",
".",
"metadata",
"(",
")",
"for",
"f",
"in",
"self",
".",
"fields",
"]",
",",
"axis",
"=",
"1",
")",
".",
"transpose",
"(",
")",
".",
"sort_values... | Returns fields metadata as a dataframe. | [
"Returns",
"fields",
"metadata",
"as",
"a",
"dataframe",
"."
] | python | test | 35.142857 |
ndf-zz/asfv1 | asfv1.py | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L797-L801 | def parsewarn(self, msg, line=None):
"""Emit parse warning."""
if line is None:
line = self.sline
self.dowarn('warning: ' + msg + ' on line {}'.format(line)) | [
"def",
"parsewarn",
"(",
"self",
",",
"msg",
",",
"line",
"=",
"None",
")",
":",
"if",
"line",
"is",
"None",
":",
"line",
"=",
"self",
".",
"sline",
"self",
".",
"dowarn",
"(",
"'warning: '",
"+",
"msg",
"+",
"' on line {}'",
".",
"format",
"(",
"l... | Emit parse warning. | [
"Emit",
"parse",
"warning",
"."
] | python | train | 37.8 |
peri-source/peri | peri/viz/render.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/render.py#L12-L16 | def norm(field, vmin=0, vmax=255):
"""Truncates field to 0,1; then normalizes to a uin8 on [0,255]"""
field = 255*np.clip(field, 0, 1)
field = field.astype('uint8')
return field | [
"def",
"norm",
"(",
"field",
",",
"vmin",
"=",
"0",
",",
"vmax",
"=",
"255",
")",
":",
"field",
"=",
"255",
"*",
"np",
".",
"clip",
"(",
"field",
",",
"0",
",",
"1",
")",
"field",
"=",
"field",
".",
"astype",
"(",
"'uint8'",
")",
"return",
"f... | Truncates field to 0,1; then normalizes to a uin8 on [0,255] | [
"Truncates",
"field",
"to",
"0",
"1",
";",
"then",
"normalizes",
"to",
"a",
"uin8",
"on",
"[",
"0",
"255",
"]"
] | python | valid | 37.8 |
F-Secure/see | see/context/resources/network.py | https://github.com/F-Secure/see/blob/3e053e52a45229f96a12db9e98caf7fb3880e811/see/context/resources/network.py#L209-L226 | def active_network_addresses(hypervisor):
"""Query libvirt for the already reserved addresses."""
active = []
for network in hypervisor.listNetworks():
try:
xml = hypervisor.networkLookupByName(network).XMLDesc(0)
except libvirt.libvirtError: # network has been destroyed meanwh... | [
"def",
"active_network_addresses",
"(",
"hypervisor",
")",
":",
"active",
"=",
"[",
"]",
"for",
"network",
"in",
"hypervisor",
".",
"listNetworks",
"(",
")",
":",
"try",
":",
"xml",
"=",
"hypervisor",
".",
"networkLookupByName",
"(",
"network",
")",
".",
"... | Query libvirt for the already reserved addresses. | [
"Query",
"libvirt",
"for",
"the",
"already",
"reserved",
"addresses",
"."
] | python | train | 36.666667 |
arachnidlabs/mcp2210 | build/lib/mcp2210/device.py | https://github.com/arachnidlabs/mcp2210/blob/ee15973d66697feb3b8a685ab59c774bee55d10b/build/lib/mcp2210/device.py#L199-L220 | def transfer(self, data):
"""Transfers data over SPI.
Arguments:
data: The data to transfer.
Returns:
The data returned by the SPI device.
"""
settings = self.transfer_settings
settings.spi_tx_size = len(data)
self.transfer_settings = set... | [
"def",
"transfer",
"(",
"self",
",",
"data",
")",
":",
"settings",
"=",
"self",
".",
"transfer_settings",
"settings",
".",
"spi_tx_size",
"=",
"len",
"(",
"data",
")",
"self",
".",
"transfer_settings",
"=",
"settings",
"response",
"=",
"''",
"for",
"i",
... | Transfers data over SPI.
Arguments:
data: The data to transfer.
Returns:
The data returned by the SPI device. | [
"Transfers",
"data",
"over",
"SPI",
"."
] | python | train | 29.272727 |
ConsenSys/mythril-classic | mythril/ethereum/interface/rpc/base_client.py | https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/ethereum/interface/rpc/base_client.py#L73-L83 | def eth_getCode(self, address, default_block=BLOCK_TAG_LATEST):
"""TODO: documentation
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
NEEDS TESTING
"""
if isinstance(default_block, str):
if default_block not in BLOCK_TAGS:
raise ValueErro... | [
"def",
"eth_getCode",
"(",
"self",
",",
"address",
",",
"default_block",
"=",
"BLOCK_TAG_LATEST",
")",
":",
"if",
"isinstance",
"(",
"default_block",
",",
"str",
")",
":",
"if",
"default_block",
"not",
"in",
"BLOCK_TAGS",
":",
"raise",
"ValueError",
"return",
... | TODO: documentation
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
NEEDS TESTING | [
"TODO",
":",
"documentation"
] | python | train | 34.363636 |
saltstack/salt | salt/modules/arista_pyeapi.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/arista_pyeapi.py#L284-L393 | def run_commands(*commands, **kwargs):
'''
Sends the commands over the transport to the device.
This function sends the commands to the device using the nodes
transport. This is a lower layer function that shouldn't normally
need to be used, preferring instead to use ``config()`` or ``enable()``.
... | [
"def",
"run_commands",
"(",
"*",
"commands",
",",
"*",
"*",
"kwargs",
")",
":",
"encoding",
"=",
"kwargs",
".",
"pop",
"(",
"'encoding'",
",",
"'json'",
")",
"send_enable",
"=",
"kwargs",
".",
"pop",
"(",
"'send_enable'",
",",
"True",
")",
"output",
"=... | Sends the commands over the transport to the device.
This function sends the commands to the device using the nodes
transport. This is a lower layer function that shouldn't normally
need to be used, preferring instead to use ``config()`` or ``enable()``.
transport: ``https``
Specifies the typ... | [
"Sends",
"the",
"commands",
"over",
"the",
"transport",
"to",
"the",
"device",
"."
] | python | train | 30.645455 |
jxtech/wechatpy | wechatpy/client/api/card.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/card.py#L592-L609 | def get_activate_url(self, card_id, outer_str=None):
"""
获取开卡插件 Url, 内含调用开卡插件所需的参数
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1499332673_Unm7V
:param card_id: 会员卡的card_id
:param outer_str: 渠道值,用于统计本次领取的渠道参数
:return: 内含调用开卡插件所需的参数的 Url
"""
return sel... | [
"def",
"get_activate_url",
"(",
"self",
",",
"card_id",
",",
"outer_str",
"=",
"None",
")",
":",
"return",
"self",
".",
"_post",
"(",
"'card/membercard/activate/geturl'",
",",
"data",
"=",
"{",
"'card_id'",
":",
"card_id",
",",
"'outer_str'",
":",
"outer_str",... | 获取开卡插件 Url, 内含调用开卡插件所需的参数
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1499332673_Unm7V
:param card_id: 会员卡的card_id
:param outer_str: 渠道值,用于统计本次领取的渠道参数
:return: 内含调用开卡插件所需的参数的 Url | [
"获取开卡插件",
"Url",
"内含调用开卡插件所需的参数",
"详情请参考",
"https",
":",
"//",
"mp",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"wiki?id",
"=",
"mp1499332673_Unm7V"
] | python | train | 29.277778 |
collectiveacuity/labPack | labpack/platforms/docker.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/docker.py#L430-L453 | def rm(self, container_alias):
'''
a method to remove an active container
:param container_alias: string with name or id of container
:return: string with container id
'''
title = '%s.rm' % self.__class__.__name__
# validate inputs
... | [
"def",
"rm",
"(",
"self",
",",
"container_alias",
")",
":",
"title",
"=",
"'%s.rm'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'container_alias'",
":",
"container_alias",
"}",
"for",
"key",
",",
"value",
... | a method to remove an active container
:param container_alias: string with name or id of container
:return: string with container id | [
"a",
"method",
"to",
"remove",
"an",
"active",
"container",
":",
"param",
"container_alias",
":",
"string",
"with",
"name",
"or",
"id",
"of",
"container",
":",
"return",
":",
"string",
"with",
"container",
"id"
] | python | train | 30.666667 |
pycontribs/pyrax | pyrax/clouddns.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddns.py#L750-L756 | def list_records(self, domain, limit=None, offset=None):
"""
Returns a list of all records configured for the specified domain.
"""
uri = "/domains/%s/records%s" % (utils.get_id(domain),
self._get_pagination_qs(limit, offset))
return self._list_records(uri) | [
"def",
"list_records",
"(",
"self",
",",
"domain",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"uri",
"=",
"\"/domains/%s/records%s\"",
"%",
"(",
"utils",
".",
"get_id",
"(",
"domain",
")",
",",
"self",
".",
"_get_pagination_qs",
"("... | Returns a list of all records configured for the specified domain. | [
"Returns",
"a",
"list",
"of",
"all",
"records",
"configured",
"for",
"the",
"specified",
"domain",
"."
] | python | train | 43.857143 |
Unidata/siphon | siphon/ncss_dataset.py | https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss_dataset.py#L26-L114 | def handle_typed_values(val, type_name, value_type):
"""Translate typed values into the appropriate python object.
Takes an element name, value, and type and returns a list
with the string value(s) properly converted to a python type.
TypedValues are handled in ucar.ma2.DataType in net... | [
"def",
"handle_typed_values",
"(",
"val",
",",
"type_name",
",",
"value_type",
")",
":",
"if",
"value_type",
"in",
"[",
"'byte'",
",",
"'short'",
",",
"'int'",
",",
"'long'",
"]",
":",
"try",
":",
"val",
"=",
"[",
"int",
"(",
"v",
")",
"for",
"v",
... | Translate typed values into the appropriate python object.
Takes an element name, value, and type and returns a list
with the string value(s) properly converted to a python type.
TypedValues are handled in ucar.ma2.DataType in netcdfJava
in the DataType enum. Possibilities are:
... | [
"Translate",
"typed",
"values",
"into",
"the",
"appropriate",
"python",
"object",
"."
] | python | train | 34.382022 |
datajoint/datajoint-python | datajoint/expression.py | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L369-L377 | def attributes_in_restriction(self):
"""
:return: list of attributes that are probably used in the restriction.
The function errs on the side of false positives.
For example, if the restriction is "val='id'", then the attribute 'id' would be flagged.
This is used inte... | [
"def",
"attributes_in_restriction",
"(",
"self",
")",
":",
"return",
"set",
"(",
"name",
"for",
"name",
"in",
"self",
".",
"heading",
".",
"names",
"if",
"re",
".",
"search",
"(",
"r'\\b'",
"+",
"name",
"+",
"r'\\b'",
",",
"self",
".",
"where_clause",
... | :return: list of attributes that are probably used in the restriction.
The function errs on the side of false positives.
For example, if the restriction is "val='id'", then the attribute 'id' would be flagged.
This is used internally for optimizing SQL statements. | [
":",
"return",
":",
"list",
"of",
"attributes",
"that",
"are",
"probably",
"used",
"in",
"the",
"restriction",
".",
"The",
"function",
"errs",
"on",
"the",
"side",
"of",
"false",
"positives",
".",
"For",
"example",
"if",
"the",
"restriction",
"is",
"val",
... | python | train | 54.444444 |
numberoverzero/bloop | bloop/stream/buffer.py | https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/stream/buffer.py#L48-L58 | def push_all(self, record_shard_pairs):
"""Push multiple (record, shard) pairs at once, with only one :meth:`heapq.heapify` call to maintain order.
:param record_shard_pairs: list of ``(record, shard)`` tuples
(see :func:`~bloop.stream.buffer.RecordBuffer.push`).
"""
# Faste... | [
"def",
"push_all",
"(",
"self",
",",
"record_shard_pairs",
")",
":",
"# Faster than inserting one at a time; the heap is sorted once after all inserts.",
"for",
"record",
",",
"shard",
"in",
"record_shard_pairs",
":",
"item",
"=",
"heap_item",
"(",
"self",
".",
"clock",
... | Push multiple (record, shard) pairs at once, with only one :meth:`heapq.heapify` call to maintain order.
:param record_shard_pairs: list of ``(record, shard)`` tuples
(see :func:`~bloop.stream.buffer.RecordBuffer.push`). | [
"Push",
"multiple",
"(",
"record",
"shard",
")",
"pairs",
"at",
"once",
"with",
"only",
"one",
":",
"meth",
":",
"heapq",
".",
"heapify",
"call",
"to",
"maintain",
"order",
"."
] | python | train | 50.636364 |
Azure/azure-cosmos-python | azure/cosmos/partition.py | https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/partition.py#L48-L61 | def CompareTo(self, other_hash_value):
"""Compares the passed hash value with the hash value of this object
"""
if len(self.hash_value) != len(other_hash_value):
raise ValueError("Length of hashes doesn't match.")
# The hash byte array that is returned from ComputeHash metho... | [
"def",
"CompareTo",
"(",
"self",
",",
"other_hash_value",
")",
":",
"if",
"len",
"(",
"self",
".",
"hash_value",
")",
"!=",
"len",
"(",
"other_hash_value",
")",
":",
"raise",
"ValueError",
"(",
"\"Length of hashes doesn't match.\"",
")",
"# The hash byte array tha... | Compares the passed hash value with the hash value of this object | [
"Compares",
"the",
"passed",
"hash",
"value",
"with",
"the",
"hash",
"value",
"of",
"this",
"object"
] | python | train | 54.071429 |
nerdvegas/rez | src/rez/vendor/pygraph/mixins/common.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/mixins/common.py#L137-L146 | def complete(self):
"""
Make the graph a complete graph.
@attention: This will modify the current graph.
"""
for each in self.nodes():
for other in self.nodes():
if (each != other and not self.has_edge((each, other))):
self... | [
"def",
"complete",
"(",
"self",
")",
":",
"for",
"each",
"in",
"self",
".",
"nodes",
"(",
")",
":",
"for",
"other",
"in",
"self",
".",
"nodes",
"(",
")",
":",
"if",
"(",
"each",
"!=",
"other",
"and",
"not",
"self",
".",
"has_edge",
"(",
"(",
"e... | Make the graph a complete graph.
@attention: This will modify the current graph. | [
"Make",
"the",
"graph",
"a",
"complete",
"graph",
"."
] | python | train | 33.5 |
klen/zeta-library | zetalibrary/scss/__init__.py | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1075-L1130 | def _do_include(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name):
"""
Implements @include, for @mixins
"""
funct, params, _ = name.partition('(')
funct = funct.strip()
funct = self.do_glob_math(
funct, ... | [
"def",
"_do_include",
"(",
"self",
",",
"rule",
",",
"p_selectors",
",",
"p_parents",
",",
"p_children",
",",
"scope",
",",
"media",
",",
"c_lineno",
",",
"c_property",
",",
"c_codestr",
",",
"code",
",",
"name",
")",
":",
"funct",
",",
"params",
",",
... | Implements @include, for @mixins | [
"Implements"
] | python | train | 41.446429 |
rosenbrockc/fortpy | fortpy/msg.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/msg.py#L83-L88 | def warn(msg, level=0, prefix=True):
"""Prints the specified message as a warning; prepends "WARNING" to
the message, so that can be left off.
"""
if will_print(level):
printer(("WARNING: " if prefix else "") + msg, "yellow") | [
"def",
"warn",
"(",
"msg",
",",
"level",
"=",
"0",
",",
"prefix",
"=",
"True",
")",
":",
"if",
"will_print",
"(",
"level",
")",
":",
"printer",
"(",
"(",
"\"WARNING: \"",
"if",
"prefix",
"else",
"\"\"",
")",
"+",
"msg",
",",
"\"yellow\"",
")"
] | Prints the specified message as a warning; prepends "WARNING" to
the message, so that can be left off. | [
"Prints",
"the",
"specified",
"message",
"as",
"a",
"warning",
";",
"prepends",
"WARNING",
"to",
"the",
"message",
"so",
"that",
"can",
"be",
"left",
"off",
"."
] | python | train | 40.666667 |
Phylliade/ikpy | contrib/transformations.py | https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/contrib/transformations.py#L222-L232 | def list_to_raw_list(poselist):
"""
Flatten a normal pose list into a raw list
:param poselist: a formatted list [[x,y,z], [x,y,z,w]]
:return: a raw list [x, y, z, x, y, z, w]
"""
if not (isinstance(poselist, list) or isinstance(poselist, tuple)):
raise TypeError(
"flatten_po... | [
"def",
"list_to_raw_list",
"(",
"poselist",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"poselist",
",",
"list",
")",
"or",
"isinstance",
"(",
"poselist",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"flatten_pose({}) does not accept this type of... | Flatten a normal pose list into a raw list
:param poselist: a formatted list [[x,y,z], [x,y,z,w]]
:return: a raw list [x, y, z, x, y, z, w] | [
"Flatten",
"a",
"normal",
"pose",
"list",
"into",
"a",
"raw",
"list",
":",
"param",
"poselist",
":",
"a",
"formatted",
"list",
"[[",
"x",
"y",
"z",
"]",
"[",
"x",
"y",
"z",
"w",
"]]",
":",
"return",
":",
"a",
"raw",
"list",
"[",
"x",
"y",
"z",
... | python | train | 41.727273 |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L2029-L2032 | def p_function_statement(self, p):
'function_statement : funcvardecls function_calc'
p[0] = p[1] + (p[2],)
p.set_lineno(0, p.lineno(1)) | [
"def",
"p_function_statement",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",
"(",
"p",
"[",
"2",
"]",
",",
")",
"p",
".",
"set_lineno",
"(",
"0",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | function_statement : funcvardecls function_calc | [
"function_statement",
":",
"funcvardecls",
"function_calc"
] | python | train | 39 |
capnproto/pycapnp | buildutils/bundle.py | https://github.com/capnproto/pycapnp/blob/cb3f190b955bdb1bfb6e0ac0b2f9306a5c79f7b5/buildutils/bundle.py#L103-L138 | def stage_platform_hpp(capnproot):
"""stage platform.hpp into libcapnp sources
Tries ./configure first (except on Windows),
then falls back on included platform.hpp previously generated.
"""
platform_hpp = pjoin(capnproot, 'src', 'platform.hpp')
if os.path.exists(platform_hpp):
info("a... | [
"def",
"stage_platform_hpp",
"(",
"capnproot",
")",
":",
"platform_hpp",
"=",
"pjoin",
"(",
"capnproot",
",",
"'src'",
",",
"'platform.hpp'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"platform_hpp",
")",
":",
"info",
"(",
"\"already have platform.hpp\... | stage platform.hpp into libcapnp sources
Tries ./configure first (except on Windows),
then falls back on included platform.hpp previously generated. | [
"stage",
"platform",
".",
"hpp",
"into",
"libcapnp",
"sources"
] | python | train | 36.527778 |
python-openxml/python-docx | docx/blkcntnr.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/blkcntnr.py#L62-L68 | def tables(self):
"""
A list containing the tables in this container, in document order.
Read-only.
"""
from .table import Table
return [Table(tbl, self) for tbl in self._element.tbl_lst] | [
"def",
"tables",
"(",
"self",
")",
":",
"from",
".",
"table",
"import",
"Table",
"return",
"[",
"Table",
"(",
"tbl",
",",
"self",
")",
"for",
"tbl",
"in",
"self",
".",
"_element",
".",
"tbl_lst",
"]"
] | A list containing the tables in this container, in document order.
Read-only. | [
"A",
"list",
"containing",
"the",
"tables",
"in",
"this",
"container",
"in",
"document",
"order",
".",
"Read",
"-",
"only",
"."
] | python | train | 32.714286 |
seleniumbase/SeleniumBase | seleniumbase/fixtures/base_case.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L1241-L1273 | def play_tour(self, name=None, interval=0):
""" Plays a tour on the current website.
@Params
name - If creating multiple tours at the same time,
use this to select the tour you wish to add steps to.
interval - The delay time between autoplaying tour steps.
... | [
"def",
"play_tour",
"(",
"self",
",",
"name",
"=",
"None",
",",
"interval",
"=",
"0",
")",
":",
"if",
"self",
".",
"headless",
":",
"return",
"# Tours should not run in headless mode.",
"if",
"not",
"name",
":",
"name",
"=",
"\"default\"",
"if",
"name",
"n... | Plays a tour on the current website.
@Params
name - If creating multiple tours at the same time,
use this to select the tour you wish to add steps to.
interval - The delay time between autoplaying tour steps.
If set to 0 (default), the tour i... | [
"Plays",
"a",
"tour",
"on",
"the",
"current",
"website",
"."
] | python | train | 45.636364 |
molmod/molmod | molmod/graphs.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/graphs.py#L1588-L1595 | def print_debug(self, text, indent=0):
"""Only prints debug info on screen when self.debug == True."""
if self.debug:
if indent > 0:
print(" "*self.debug, text)
self.debug += indent
if indent <= 0:
print(" "*self.debug, text) | [
"def",
"print_debug",
"(",
"self",
",",
"text",
",",
"indent",
"=",
"0",
")",
":",
"if",
"self",
".",
"debug",
":",
"if",
"indent",
">",
"0",
":",
"print",
"(",
"\" \"",
"*",
"self",
".",
"debug",
",",
"text",
")",
"self",
".",
"debug",
"+=",
"... | Only prints debug info on screen when self.debug == True. | [
"Only",
"prints",
"debug",
"info",
"on",
"screen",
"when",
"self",
".",
"debug",
"==",
"True",
"."
] | python | train | 37.75 |
FNNDSC/med2image | med2image/systemMisc.py | https://github.com/FNNDSC/med2image/blob/638d5d230de47608af20f9764acf8e382c2bf2ff/med2image/systemMisc.py#L737-L766 | def arr_base10toN(anum10, aradix, *args):
"""
ARGS
anum10 in number in base 10
aradix in convert <anum10> to number in base
+ <aradix>
OPTIONAL
forcelength in if nonzero, indicates the length
... | [
"def",
"arr_base10toN",
"(",
"anum10",
",",
"aradix",
",",
"*",
"args",
")",
":",
"new_num_arr",
"=",
"array",
"(",
"(",
")",
")",
"current",
"=",
"anum10",
"while",
"current",
"!=",
"0",
":",
"remainder",
"=",
"current",
"%",
"aradix",
"new_num_arr",
... | ARGS
anum10 in number in base 10
aradix in convert <anum10> to number in base
+ <aradix>
OPTIONAL
forcelength in if nonzero, indicates the length
+ of the return array. Useful ... | [
"ARGS",
"anum10",
"in",
"number",
"in",
"base",
"10",
"aradix",
"in",
"convert",
"<anum10",
">",
"to",
"number",
"in",
"base",
"+",
"<aradix",
">"
] | python | train | 31.6 |
saltstack/salt | salt/cloud/clouds/softlayer.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer.py#L526-L542 | def list_nodes_full(mask='mask[id]', call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
ret = {}
conn = get_conn(service='SoftLay... | [
"def",
"list_nodes_full",
"(",
"mask",
"=",
"'mask[id]'",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes_full function must be called with -f or --function.'",
")",
"ret",
"=",
"{",
"}",... | Return a list of the VMs that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider"
] | python | train | 33.176471 |
waqasbhatti/astrobase | astrobase/hatsurveys/hatlc.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/hatsurveys/hatlc.py#L1377-L1459 | def read_csvlc(lcfile):
'''This reads a HAT data server or LCC-Server produced CSV light curve
into an lcdict.
This will automatically figure out the format of the file
provided. Currently, it can read:
- legacy HAT data server CSV LCs (e.g. from
https://hatsouth.org/planets/lightcurves.html... | [
"def",
"read_csvlc",
"(",
"lcfile",
")",
":",
"# read in the file and split by lines",
"if",
"'.gz'",
"in",
"os",
".",
"path",
".",
"basename",
"(",
"lcfile",
")",
":",
"LOGINFO",
"(",
"'reading gzipped HATLC: %s'",
"%",
"lcfile",
")",
"infd",
"=",
"gzip",
"."... | This reads a HAT data server or LCC-Server produced CSV light curve
into an lcdict.
This will automatically figure out the format of the file
provided. Currently, it can read:
- legacy HAT data server CSV LCs (e.g. from
https://hatsouth.org/planets/lightcurves.html) with an extension of the
... | [
"This",
"reads",
"a",
"HAT",
"data",
"server",
"or",
"LCC",
"-",
"Server",
"produced",
"CSV",
"light",
"curve",
"into",
"an",
"lcdict",
"."
] | python | valid | 29.759036 |
PyGithub/PyGithub | github/Branch.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Branch.py#L108-L180 | def edit_protection(self, strict=github.GithubObject.NotSet, contexts=github.GithubObject.NotSet, enforce_admins=github.GithubObject.NotSet, dismissal_users=github.GithubObject.NotSet, dismissal_teams=github.GithubObject.NotSet, dismiss_stale_reviews=github.GithubObject.NotSet, require_code_owner_reviews=github.GithubO... | [
"def",
"edit_protection",
"(",
"self",
",",
"strict",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"contexts",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"enforce_admins",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"dismi... | :calls: `PUT /repos/:owner/:repo/branches/:branch/protection <https://developer.github.com/v3/repos/branches>`_
:strict: bool
:contexts: list of strings
:enforce_admins: bool
:dismissal_users: list of strings
:dismissal_teams: list of strings
:dismiss_stale_reviews: bool
... | [
":",
"calls",
":",
"PUT",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"branches",
"/",
":",
"branch",
"/",
"protection",
"<https",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"repos",
"/",
"branches",
">",
"_",
... | python | train | 74.60274 |
aliyun/aliyun-odps-python-sdk | odps/tunnel/pb/encoder.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/tunnel/pb/encoder.py#L42-L44 | def append_tag(self, field_number, wire_type):
"""Appends a tag containing field number and wire type information."""
self._stream.append_var_uint32(wire_format.pack_tag(field_number, wire_type)) | [
"def",
"append_tag",
"(",
"self",
",",
"field_number",
",",
"wire_type",
")",
":",
"self",
".",
"_stream",
".",
"append_var_uint32",
"(",
"wire_format",
".",
"pack_tag",
"(",
"field_number",
",",
"wire_type",
")",
")"
] | Appends a tag containing field number and wire type information. | [
"Appends",
"a",
"tag",
"containing",
"field",
"number",
"and",
"wire",
"type",
"information",
"."
] | python | train | 69.666667 |
uw-it-aca/uw-restclients-sdbmyuw | uw_sdbmyuw/__init__.py | https://github.com/uw-it-aca/uw-restclients-sdbmyuw/blob/b54317f8bcff1fd226a91e085fd6fe59757db07c/uw_sdbmyuw/__init__.py#L17-L40 | def get_app_status(system_key):
"""
Get Undergraduate application status
@return ApplicationStatus object
@InvalidSystemKey if system_key is not valid
"""
if invalid_system_key(system_key):
raise InvalidSystemKey(
"Invalid system key in get_app_status({})".format(system_key))... | [
"def",
"get_app_status",
"(",
"system_key",
")",
":",
"if",
"invalid_system_key",
"(",
"system_key",
")",
":",
"raise",
"InvalidSystemKey",
"(",
"\"Invalid system key in get_app_status({})\"",
".",
"format",
"(",
"system_key",
")",
")",
"url",
"=",
"get_appstatus_url"... | Get Undergraduate application status
@return ApplicationStatus object
@InvalidSystemKey if system_key is not valid | [
"Get",
"Undergraduate",
"application",
"status"
] | python | train | 34.625 |
javipalanca/spade | spade/agent.py | https://github.com/javipalanca/spade/blob/59942bd1a1edae4c807d06cabb178d5630cbf61b/spade/agent.py#L76-L84 | def start(self, auto_register=True):
"""
Tells the container to start this agent.
It returns a coroutine or a future depending on whether it is called from a coroutine or a synchronous method.
Args:
auto_register (bool): register the agent in the server (Default value = True... | [
"def",
"start",
"(",
"self",
",",
"auto_register",
"=",
"True",
")",
":",
"return",
"self",
".",
"container",
".",
"start_agent",
"(",
"agent",
"=",
"self",
",",
"auto_register",
"=",
"auto_register",
")"
] | Tells the container to start this agent.
It returns a coroutine or a future depending on whether it is called from a coroutine or a synchronous method.
Args:
auto_register (bool): register the agent in the server (Default value = True) | [
"Tells",
"the",
"container",
"to",
"start",
"this",
"agent",
".",
"It",
"returns",
"a",
"coroutine",
"or",
"a",
"future",
"depending",
"on",
"whether",
"it",
"is",
"called",
"from",
"a",
"coroutine",
"or",
"a",
"synchronous",
"method",
"."
] | python | train | 45.333333 |
markovmodel/PyEMMA | pyemma/_base/serialization/serialization.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/_base/serialization/serialization.py#L82-L126 | def apply(modifications, state):
""" applies modifications to given state
Parameters
----------
modifications: list of tuples
created by this class.list method.
state: dict
state dictionary
"""
count = 0
for a in modifications:
... | [
"def",
"apply",
"(",
"modifications",
",",
"state",
")",
":",
"count",
"=",
"0",
"for",
"a",
"in",
"modifications",
":",
"if",
"_debug",
":",
"assert",
"a",
"[",
"0",
"]",
"in",
"(",
"'set'",
",",
"'mv'",
",",
"'map'",
",",
"'rm'",
")",
"logger",
... | applies modifications to given state
Parameters
----------
modifications: list of tuples
created by this class.list method.
state: dict
state dictionary | [
"applies",
"modifications",
"to",
"given",
"state",
"Parameters",
"----------",
"modifications",
":",
"list",
"of",
"tuples",
"created",
"by",
"this",
"class",
".",
"list",
"method",
".",
"state",
":",
"dict",
"state",
"dictionary"
] | python | train | 38.333333 |
googleapis/google-cloud-python | pubsub/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py#L96-L106 | def min(self):
"""Return the minimum value in this histogram.
If there are no values in the histogram at all, return 10.
Returns:
int: The minimum value in the histogram.
"""
if len(self._data) == 0:
return 10
return next(iter(sorted(self._data.k... | [
"def",
"min",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_data",
")",
"==",
"0",
":",
"return",
"10",
"return",
"next",
"(",
"iter",
"(",
"sorted",
"(",
"self",
".",
"_data",
".",
"keys",
"(",
")",
")",
")",
")"
] | Return the minimum value in this histogram.
If there are no values in the histogram at all, return 10.
Returns:
int: The minimum value in the histogram. | [
"Return",
"the",
"minimum",
"value",
"in",
"this",
"histogram",
"."
] | python | train | 28.909091 |
bigchaindb/bigchaindb | bigchaindb/common/transaction.py | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L846-L869 | def _sign_input(cls, input_, message, key_pairs):
"""Signs a single Input.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256.
Args:
in... | [
"def",
"_sign_input",
"(",
"cls",
",",
"input_",
",",
"message",
",",
"key_pairs",
")",
":",
"if",
"isinstance",
"(",
"input_",
".",
"fulfillment",
",",
"Ed25519Sha256",
")",
":",
"return",
"cls",
".",
"_sign_simple_signature_fulfillment",
"(",
"input_",
",",
... | Signs a single Input.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
... | [
"Signs",
"a",
"single",
"Input",
"."
] | python | train | 45.666667 |
moble/quaternion | __init__.py | https://github.com/moble/quaternion/blob/7a323e81b391d6892e2874073e495e0beb057e85/__init__.py#L424-L479 | def from_euler_angles(alpha_beta_gamma, beta=None, gamma=None):
"""Improve your life drastically
Assumes the Euler angles correspond to the quaternion R via
R = exp(alpha*z/2) * exp(beta*y/2) * exp(gamma*z/2)
The angles naturally must be in radians for this to make any sense.
NOTE: Before op... | [
"def",
"from_euler_angles",
"(",
"alpha_beta_gamma",
",",
"beta",
"=",
"None",
",",
"gamma",
"=",
"None",
")",
":",
"# Figure out the input angles from either type of input",
"if",
"gamma",
"is",
"None",
":",
"alpha_beta_gamma",
"=",
"np",
".",
"asarray",
"(",
"al... | Improve your life drastically
Assumes the Euler angles correspond to the quaternion R via
R = exp(alpha*z/2) * exp(beta*y/2) * exp(gamma*z/2)
The angles naturally must be in radians for this to make any sense.
NOTE: Before opening an issue reporting something "wrong" with this
function, be s... | [
"Improve",
"your",
"life",
"drastically"
] | python | train | 42.321429 |
ssalentin/plip | plip/modules/webservices.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/webservices.py#L22-L34 | def check_pdb_status(pdbid):
"""Returns the status and up-to-date entry in the PDB for a given PDB ID"""
url = 'http://www.rcsb.org/pdb/rest/idStatus?structureId=%s' % pdbid
xmlf = urlopen(url)
xml = et.parse(xmlf)
xmlf.close()
status = None
current_pdbid = pdbid
for df in xml.xpath('//r... | [
"def",
"check_pdb_status",
"(",
"pdbid",
")",
":",
"url",
"=",
"'http://www.rcsb.org/pdb/rest/idStatus?structureId=%s'",
"%",
"pdbid",
"xmlf",
"=",
"urlopen",
"(",
"url",
")",
"xml",
"=",
"et",
".",
"parse",
"(",
"xmlf",
")",
"xmlf",
".",
"close",
"(",
")",
... | Returns the status and up-to-date entry in the PDB for a given PDB ID | [
"Returns",
"the",
"status",
"and",
"up",
"-",
"to",
"-",
"date",
"entry",
"in",
"the",
"PDB",
"for",
"a",
"given",
"PDB",
"ID"
] | python | train | 46.769231 |
NaPs/Kolekto | kolekto/tmdb_proxy.py | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/tmdb_proxy.py#L50-L72 | def search():
""" Search a movie on TMDB.
"""
redis_key = 's_%s' % request.args['query'].lower()
cached = redis_ro_conn.get(redis_key)
if cached:
return Response(cached)
else:
try:
found = get_on_tmdb(u'/search/movie', query=request.args['query'])
movies =... | [
"def",
"search",
"(",
")",
":",
"redis_key",
"=",
"'s_%s'",
"%",
"request",
".",
"args",
"[",
"'query'",
"]",
".",
"lower",
"(",
")",
"cached",
"=",
"redis_ro_conn",
".",
"get",
"(",
"redis_key",
")",
"if",
"cached",
":",
"return",
"Response",
"(",
"... | Search a movie on TMDB. | [
"Search",
"a",
"movie",
"on",
"TMDB",
"."
] | python | train | 49.652174 |
theonion/django-bulbs | bulbs/special_coverage/models.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/special_coverage/models.py#L203-L212 | def custom_template_name(self):
"""
Returns the path for the custom special coverage template we want.
"""
base_path = getattr(settings, "CUSTOM_SPECIAL_COVERAGE_PATH", "special_coverage/custom")
if base_path is None:
base_path = ""
return "{0}/{1}_custom.html... | [
"def",
"custom_template_name",
"(",
"self",
")",
":",
"base_path",
"=",
"getattr",
"(",
"settings",
",",
"\"CUSTOM_SPECIAL_COVERAGE_PATH\"",
",",
"\"special_coverage/custom\"",
")",
"if",
"base_path",
"is",
"None",
":",
"base_path",
"=",
"\"\"",
"return",
"\"{0}/{1}... | Returns the path for the custom special coverage template we want. | [
"Returns",
"the",
"path",
"for",
"the",
"custom",
"special",
"coverage",
"template",
"we",
"want",
"."
] | python | train | 39.3 |
TUT-ARG/sed_eval | sed_eval/scene.py | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/scene.py#L198-L287 | def evaluate(self, reference_scene_list, estimated_scene_list=None, estimated_scene_probabilities=None):
"""Evaluate file pair (reference and estimated)
Parameters
----------
reference_scene_list : list of dict or dcase_util.containers.MetaDataContainer
Reference scene list... | [
"def",
"evaluate",
"(",
"self",
",",
"reference_scene_list",
",",
"estimated_scene_list",
"=",
"None",
",",
"estimated_scene_probabilities",
"=",
"None",
")",
":",
"if",
"estimated_scene_list",
"is",
"None",
"and",
"estimated_scene_probabilities",
"is",
"None",
":",
... | Evaluate file pair (reference and estimated)
Parameters
----------
reference_scene_list : list of dict or dcase_util.containers.MetaDataContainer
Reference scene list.
Default value None
estimated_scene_list : list of dict or dcase_util.containers.MetaDataConta... | [
"Evaluate",
"file",
"pair",
"(",
"reference",
"and",
"estimated",
")"
] | python | train | 40.211111 |
weld-project/weld | python/grizzly/grizzly/dataframeweld.py | https://github.com/weld-project/weld/blob/8ddd6db6b28878bef0892da44b1d2002b564389c/python/grizzly/grizzly/dataframeweld.py#L421-L455 | def evaluate(self, verbose=True, passes=None):
"""Summary
Returns:
TYPE: Description
"""
if self.is_pivot:
index, pivot, columns = LazyOpResult(
self.expr,
self.weld_type,
0
).evaluate(verbose=verbose, p... | [
"def",
"evaluate",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"passes",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_pivot",
":",
"index",
",",
"pivot",
",",
"columns",
"=",
"LazyOpResult",
"(",
"self",
".",
"expr",
",",
"self",
".",
"weld_type"... | Summary
Returns:
TYPE: Description | [
"Summary"
] | python | train | 32.057143 |
monkeython/scriba | scriba/schemes/scriba_ftp.py | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/scriba_ftp.py#L84-L87 | def write(url, content, **args):
"""Put an object into a ftp URL."""
with FTPResource(url, **args) as resource:
resource.write(content) | [
"def",
"write",
"(",
"url",
",",
"content",
",",
"*",
"*",
"args",
")",
":",
"with",
"FTPResource",
"(",
"url",
",",
"*",
"*",
"args",
")",
"as",
"resource",
":",
"resource",
".",
"write",
"(",
"content",
")"
] | Put an object into a ftp URL. | [
"Put",
"an",
"object",
"into",
"a",
"ftp",
"URL",
"."
] | python | train | 37 |
spyder-ide/spyder | spyder/plugins/plots/widgets/figurebrowser.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L819-L823 | def emit_save_figure(self):
"""
Emit a signal when the toolbutton to save the figure is clicked.
"""
self.sig_save_figure.emit(self.canvas.fig, self.canvas.fmt) | [
"def",
"emit_save_figure",
"(",
"self",
")",
":",
"self",
".",
"sig_save_figure",
".",
"emit",
"(",
"self",
".",
"canvas",
".",
"fig",
",",
"self",
".",
"canvas",
".",
"fmt",
")"
] | Emit a signal when the toolbutton to save the figure is clicked. | [
"Emit",
"a",
"signal",
"when",
"the",
"toolbutton",
"to",
"save",
"the",
"figure",
"is",
"clicked",
"."
] | python | train | 37.6 |
mitsei/dlkit | dlkit/services/logging_.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/logging_.py#L1080-L1088 | def use_comparative_log_entry_view(self):
"""Pass through to provider LogEntryLookupSession.use_comparative_log_entry_view"""
self._object_views['log_entry'] = COMPARATIVE
# self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked
for session in self._... | [
"def",
"use_comparative_log_entry_view",
"(",
"self",
")",
":",
"self",
".",
"_object_views",
"[",
"'log_entry'",
"]",
"=",
"COMPARATIVE",
"# self._get_provider_session('log_entry_lookup_session') # To make sure the session is tracked",
"for",
"session",
"in",
"self",
".",
"_... | Pass through to provider LogEntryLookupSession.use_comparative_log_entry_view | [
"Pass",
"through",
"to",
"provider",
"LogEntryLookupSession",
".",
"use_comparative_log_entry_view"
] | python | train | 51.777778 |
gagneurlab/concise | concise/legacy/concise.py | https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/concise.py#L412-L427 | def get_weights(self):
"""
Returns:
dict: Model's trained weights.
"""
if self.is_trained() is False:
# print("Model not fitted yet. Use object.fit() to fit the model.")
return None
var_res = self._var_res
weights = self._var_res_to_we... | [
"def",
"get_weights",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_trained",
"(",
")",
"is",
"False",
":",
"# print(\"Model not fitted yet. Use object.fit() to fit the model.\")",
"return",
"None",
"var_res",
"=",
"self",
".",
"_var_res",
"weights",
"=",
"self",
... | Returns:
dict: Model's trained weights. | [
"Returns",
":",
"dict",
":",
"Model",
"s",
"trained",
"weights",
"."
] | python | train | 31 |
mitsei/dlkit | dlkit/services/learning.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/learning.py#L660-L668 | def use_plenary_objective_bank_view(self):
"""Pass through to provider ObjectiveObjectiveBankSession.use_plenary_objective_bank_view"""
self._objective_bank_view = PLENARY
# self._get_provider_session('objective_objective_bank_session') # To make sure the session is tracked
for session i... | [
"def",
"use_plenary_objective_bank_view",
"(",
"self",
")",
":",
"self",
".",
"_objective_bank_view",
"=",
"PLENARY",
"# self._get_provider_session('objective_objective_bank_session') # To make sure the session is tracked",
"for",
"session",
"in",
"self",
".",
"_get_provider_sessio... | Pass through to provider ObjectiveObjectiveBankSession.use_plenary_objective_bank_view | [
"Pass",
"through",
"to",
"provider",
"ObjectiveObjectiveBankSession",
".",
"use_plenary_objective_bank_view"
] | python | train | 52.777778 |
ejeschke/ginga | ginga/misc/ParamSet.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/ParamSet.py#L131-L138 | def update_params(self, param_d):
"""Update the attributes in self.obj that match the keys in
`param_d`.
"""
for param in self.paramlst:
if param.name in param_d:
value = param_d[param.name]
setattr(self.obj, param.name, value) | [
"def",
"update_params",
"(",
"self",
",",
"param_d",
")",
":",
"for",
"param",
"in",
"self",
".",
"paramlst",
":",
"if",
"param",
".",
"name",
"in",
"param_d",
":",
"value",
"=",
"param_d",
"[",
"param",
".",
"name",
"]",
"setattr",
"(",
"self",
".",... | Update the attributes in self.obj that match the keys in
`param_d`. | [
"Update",
"the",
"attributes",
"in",
"self",
".",
"obj",
"that",
"match",
"the",
"keys",
"in",
"param_d",
"."
] | python | train | 37 |
saltstack/salt | salt/modules/napalm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2333-L2473 | def replace_pattern(pattern,
repl,
count=0,
flags=8,
bufsize=1,
append_if_not_found=False,
prepend_if_not_found=False,
not_found_content=None,
search_only=False... | [
"def",
"replace_pattern",
"(",
"pattern",
",",
"repl",
",",
"count",
"=",
"0",
",",
"flags",
"=",
"8",
",",
"bufsize",
"=",
"1",
",",
"append_if_not_found",
"=",
"False",
",",
"prepend_if_not_found",
"=",
"False",
",",
"not_found_content",
"=",
"None",
","... | .. versionadded:: 2019.2.0
Replace occurrences of a pattern in the configuration source. If
``show_changes`` is ``True``, then a diff of what changed will be returned,
otherwise a ``True`` will be returned when changes are made, and ``False``
when no changes are made.
This is a pure Python implemen... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train | 41.156028 |
scanny/python-pptx | pptx/chart/series.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/series.py#L140-L150 | def smooth(self):
"""
Read/write boolean specifying whether to use curve smoothing to
form the line connecting the data points in this series into
a continuous curve. If |False|, a series of straight line segments
are used to connect the points.
"""
smooth = self.... | [
"def",
"smooth",
"(",
"self",
")",
":",
"smooth",
"=",
"self",
".",
"_element",
".",
"smooth",
"if",
"smooth",
"is",
"None",
":",
"return",
"True",
"return",
"smooth",
".",
"val"
] | Read/write boolean specifying whether to use curve smoothing to
form the line connecting the data points in this series into
a continuous curve. If |False|, a series of straight line segments
are used to connect the points. | [
"Read",
"/",
"write",
"boolean",
"specifying",
"whether",
"to",
"use",
"curve",
"smoothing",
"to",
"form",
"the",
"line",
"connecting",
"the",
"data",
"points",
"in",
"this",
"series",
"into",
"a",
"continuous",
"curve",
".",
"If",
"|False|",
"a",
"series",
... | python | train | 36.545455 |
stevepeak/timestring | timestring/__init__.py | https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/__init__.py#L54-L70 | def findall(text):
"""Find all the timestrings within a block of text.
>>> timestring.findall("once upon a time, about 3 weeks ago, there was a boy whom was born on august 15th at 7:20 am. epic.")
[
('3 weeks ago,', <timestring.Date 2014-02-09 00:00:00 4483019280>),
('august 15th at 7:20 am', <ti... | [
"def",
"findall",
"(",
"text",
")",
":",
"results",
"=",
"TIMESTRING_RE",
".",
"findall",
"(",
"text",
")",
"dates",
"=",
"[",
"]",
"for",
"date",
"in",
"results",
":",
"if",
"re",
".",
"compile",
"(",
"'((next|last)\\s(\\d+|couple(\\sof))\\s(weeks|months|quar... | Find all the timestrings within a block of text.
>>> timestring.findall("once upon a time, about 3 weeks ago, there was a boy whom was born on august 15th at 7:20 am. epic.")
[
('3 weeks ago,', <timestring.Date 2014-02-09 00:00:00 4483019280>),
('august 15th at 7:20 am', <timestring.Date 2014-08-15 0... | [
"Find",
"all",
"the",
"timestrings",
"within",
"a",
"block",
"of",
"text",
"."
] | python | valid | 42.529412 |
hydpy-dev/hydpy | hydpy/core/modeltools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/modeltools.py#L751-L780 | def extrapolate_error(self):
"""Estimate the numerical error to be expected when applying all
methods available based on the results of the current and the
last method.
Note that this expolation strategy cannot be applied on the first
method. If the current method is the first ... | [
"def",
"extrapolate_error",
"(",
"self",
")",
":",
"if",
"self",
".",
"numvars",
".",
"idx_method",
">",
"2",
":",
"self",
".",
"numvars",
".",
"extrapolated_error",
"=",
"modelutils",
".",
"exp",
"(",
"modelutils",
".",
"log",
"(",
"self",
".",
"numvars... | Estimate the numerical error to be expected when applying all
methods available based on the results of the current and the
last method.
Note that this expolation strategy cannot be applied on the first
method. If the current method is the first one, `-999.9` is returned.
>>> ... | [
"Estimate",
"the",
"numerical",
"error",
"to",
"be",
"expected",
"when",
"applying",
"all",
"methods",
"available",
"based",
"on",
"the",
"results",
"of",
"the",
"current",
"and",
"the",
"last",
"method",
"."
] | python | train | 40.766667 |
IAMconsortium/pyam | pyam/timeseries.py | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/timeseries.py#L10-L32 | def fill_series(x, year):
"""Returns the value of a timeseries (indexed over years) for a year
by linear interpolation.
Parameters
----------
x: pandas.Series
a timeseries to be interpolated
year: int
year of interpolation
"""
x = x.dropna()
if year in x.index and no... | [
"def",
"fill_series",
"(",
"x",
",",
"year",
")",
":",
"x",
"=",
"x",
".",
"dropna",
"(",
")",
"if",
"year",
"in",
"x",
".",
"index",
"and",
"not",
"np",
".",
"isnan",
"(",
"x",
"[",
"year",
"]",
")",
":",
"return",
"x",
"[",
"year",
"]",
"... | Returns the value of a timeseries (indexed over years) for a year
by linear interpolation.
Parameters
----------
x: pandas.Series
a timeseries to be interpolated
year: int
year of interpolation | [
"Returns",
"the",
"value",
"of",
"a",
"timeseries",
"(",
"indexed",
"over",
"years",
")",
"for",
"a",
"year",
"by",
"linear",
"interpolation",
"."
] | python | train | 27.434783 |
ungarj/mapchete | mapchete/formats/default/tile_directory.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/tile_directory.py#L288-L330 | def read(
self,
validity_check=False,
indexes=None,
resampling=None,
dst_nodata=None,
gdal_opts=None,
**kwargs
):
"""
Read reprojected & resampled input data.
Parameters
----------
validity_check : bool
vect... | [
"def",
"read",
"(",
"self",
",",
"validity_check",
"=",
"False",
",",
"indexes",
"=",
"None",
",",
"resampling",
"=",
"None",
",",
"dst_nodata",
"=",
"None",
",",
"gdal_opts",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_r... | Read reprojected & resampled input data.
Parameters
----------
validity_check : bool
vector file: also run checks if reprojected geometry is valid,
otherwise throw RuntimeError (default: True)
indexes : list or int
raster file: a list of band numbers... | [
"Read",
"reprojected",
"&",
"resampled",
"input",
"data",
"."
] | python | valid | 31.488372 |
oanda/v20-python | src/v20/account.py | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/account.py#L873-L983 | def from_dict(data, ctx):
"""
Instantiate a new AccountSummary from a dict (generally from loading a
JSON response). The data used to instantiate the AccountSummary is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""
... | [
"def",
"from_dict",
"(",
"data",
",",
"ctx",
")",
":",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"data",
".",
"get",
"(",
"'balance'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'balance'",
"]",
"=",
"ctx",
".",
"convert_decimal_number",
... | Instantiate a new AccountSummary from a dict (generally from loading a
JSON response). The data used to instantiate the AccountSummary is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately. | [
"Instantiate",
"a",
"new",
"AccountSummary",
"from",
"a",
"dict",
"(",
"generally",
"from",
"loading",
"a",
"JSON",
"response",
")",
".",
"The",
"data",
"used",
"to",
"instantiate",
"the",
"AccountSummary",
"is",
"a",
"shallow",
"copy",
"of",
"the",
"dict",
... | python | train | 34.144144 |
bitesofcode/projexui | projexui/widgets/xorbquerywidget/xorbqueryplugin.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbquerywidget/xorbqueryplugin.py#L186-L195 | def register(self, plugin, columnType=None, columnName=None):
"""
Registers a plugin to handle particular column types and column names
based on user selection.
:param plugin | <XOrbQueryPlugin>
columnType | <orb.ColumnType> || None
... | [
"def",
"register",
"(",
"self",
",",
"plugin",
",",
"columnType",
"=",
"None",
",",
"columnName",
"=",
"None",
")",
":",
"self",
".",
"_plugins",
"[",
"(",
"columnType",
",",
"columnName",
")",
"]",
"=",
"plugin"
] | Registers a plugin to handle particular column types and column names
based on user selection.
:param plugin | <XOrbQueryPlugin>
columnType | <orb.ColumnType> || None
columnName | <str> || None | [
"Registers",
"a",
"plugin",
"to",
"handle",
"particular",
"column",
"types",
"and",
"column",
"names",
"based",
"on",
"user",
"selection",
".",
":",
"param",
"plugin",
"|",
"<XOrbQueryPlugin",
">",
"columnType",
"|",
"<orb",
".",
"ColumnType",
">",
"||",
"No... | python | train | 41.8 |
MartinThoma/mpu | mpu/math.py | https://github.com/MartinThoma/mpu/blob/61bc36d0192ca90c0bcf9b8a5d7d0d8520e20ff6/mpu/math.py#L64-L101 | def factorize(number):
"""
Get the prime factors of an integer except for 1.
Parameters
----------
number : int
Returns
-------
primes : iterable
Examples
--------
>>> factorize(-17)
[-1, 17]
>>> factorize(8)
[2, 2, 2]
>>> factorize(3**25)
[3, 3, 3, 3, ... | [
"def",
"factorize",
"(",
"number",
")",
":",
"if",
"not",
"isinstance",
"(",
"number",
",",
"int",
")",
":",
"raise",
"ValueError",
"(",
"'integer expected, but type(number)={}'",
".",
"format",
"(",
"type",
"(",
"number",
")",
")",
")",
"if",
"number",
"<... | Get the prime factors of an integer except for 1.
Parameters
----------
number : int
Returns
-------
primes : iterable
Examples
--------
>>> factorize(-17)
[-1, 17]
>>> factorize(8)
[2, 2, 2]
>>> factorize(3**25)
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,... | [
"Get",
"the",
"prime",
"factors",
"of",
"an",
"integer",
"except",
"for",
"1",
"."
] | python | train | 25.184211 |
useblocks/groundwork | groundwork/docstring.py | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L44-L56 | def from_meta(cls, meta, meta_all=None):
"""Copy DocstringMeta from another instance."""
if len(meta.args) == 2:
name = meta.args[1]
meta_type = None
for x in meta_all:
if x.args[1] == name and x.args[0] == 'type':
meta_type = x.des... | [
"def",
"from_meta",
"(",
"cls",
",",
"meta",
",",
"meta_all",
"=",
"None",
")",
":",
"if",
"len",
"(",
"meta",
".",
"args",
")",
"==",
"2",
":",
"name",
"=",
"meta",
".",
"args",
"[",
"1",
"]",
"meta_type",
"=",
"None",
"for",
"x",
"in",
"meta_... | Copy DocstringMeta from another instance. | [
"Copy",
"DocstringMeta",
"from",
"another",
"instance",
"."
] | python | train | 39.307692 |
markchil/gptools | gptools/gaussian_process.py | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L376-L499 | def add_data(self, X, y, err_y=0, n=0, T=None):
"""Add data to the training data set of the GaussianProcess instance.
Parameters
----------
X : array, (`M`, `D`)
`M` input values of dimension `D`.
y : array, (`M`,)
`M` target values.
er... | [
"def",
"add_data",
"(",
"self",
",",
"X",
",",
"y",
",",
"err_y",
"=",
"0",
",",
"n",
"=",
"0",
",",
"T",
"=",
"None",
")",
":",
"# Verify y has only one non-trivial dimension:",
"y",
"=",
"scipy",
".",
"atleast_1d",
"(",
"scipy",
".",
"asarray",
"(",
... | Add data to the training data set of the GaussianProcess instance.
Parameters
----------
X : array, (`M`, `D`)
`M` input values of dimension `D`.
y : array, (`M`,)
`M` target values.
err_y : array, (`M`,) or scalar float, optional
Non-... | [
"Add",
"data",
"to",
"the",
"training",
"data",
"set",
"of",
"the",
"GaussianProcess",
"instance",
".",
"Parameters",
"----------",
"X",
":",
"array",
"(",
"M",
"D",
")",
"M",
"input",
"values",
"of",
"dimension",
"D",
".",
"y",
":",
"array",
"(",
"M",... | python | train | 43.814516 |
ChristianTremblay/BAC0 | BAC0/core/devices/Device.py | https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/devices/Device.py#L468-L482 | def df(self, list_of_points, force_read=True):
"""
When connected, calling DF should force a reading on the network.
"""
his = []
for point in list_of_points:
try:
his.append(self._findPoint(point, force_read=force_read).history)
... | [
"def",
"df",
"(",
"self",
",",
"list_of_points",
",",
"force_read",
"=",
"True",
")",
":",
"his",
"=",
"[",
"]",
"for",
"point",
"in",
"list_of_points",
":",
"try",
":",
"his",
".",
"append",
"(",
"self",
".",
"_findPoint",
"(",
"point",
",",
"force_... | When connected, calling DF should force a reading on the network. | [
"When",
"connected",
"calling",
"DF",
"should",
"force",
"a",
"reading",
"on",
"the",
"network",
"."
] | python | train | 36.2 |
quantopian/zipline | zipline/finance/position.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/position.py#L164-L203 | def adjust_commission_cost_basis(self, asset, cost):
"""
A note about cost-basis in zipline: all positions are considered
to share a cost basis, even if they were executed in different
transactions with different commission costs, different prices, etc.
Due to limitations about ... | [
"def",
"adjust_commission_cost_basis",
"(",
"self",
",",
"asset",
",",
"cost",
")",
":",
"if",
"asset",
"!=",
"self",
".",
"asset",
":",
"raise",
"Exception",
"(",
"'Updating a commission for a different asset?'",
")",
"if",
"cost",
"==",
"0.0",
":",
"return",
... | A note about cost-basis in zipline: all positions are considered
to share a cost basis, even if they were executed in different
transactions with different commission costs, different prices, etc.
Due to limitations about how zipline handles positions, zipline will
currently spread an e... | [
"A",
"note",
"about",
"cost",
"-",
"basis",
"in",
"zipline",
":",
"all",
"positions",
"are",
"considered",
"to",
"share",
"a",
"cost",
"basis",
"even",
"if",
"they",
"were",
"executed",
"in",
"different",
"transactions",
"with",
"different",
"commission",
"c... | python | train | 39.675 |
materialsproject/pymatgen | pymatgen/alchemy/transmuters.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/alchemy/transmuters.py#L350-L387 | def batch_write_vasp_input(transformed_structures, vasp_input_set=MPRelaxSet,
output_dir=".", create_directory=True,
subfolder=None,
include_cif=False, **kwargs):
"""
Batch write vasp input for a sequence of transformed structures ... | [
"def",
"batch_write_vasp_input",
"(",
"transformed_structures",
",",
"vasp_input_set",
"=",
"MPRelaxSet",
",",
"output_dir",
"=",
"\".\"",
",",
"create_directory",
"=",
"True",
",",
"subfolder",
"=",
"None",
",",
"include_cif",
"=",
"False",
",",
"*",
"*",
"kwar... | Batch write vasp input for a sequence of transformed structures to
output_dir, following the format output_dir/{group}/{formula}_{number}.
Args:
transformed_structures: Sequence of TransformedStructures.
vasp_input_set: pymatgen.io.vaspio_set.VaspInputSet to creates
vasp input files... | [
"Batch",
"write",
"vasp",
"input",
"for",
"a",
"sequence",
"of",
"transformed",
"structures",
"to",
"output_dir",
"following",
"the",
"format",
"output_dir",
"/",
"{",
"group",
"}",
"/",
"{",
"formula",
"}",
"_",
"{",
"number",
"}",
"."
] | python | train | 47.052632 |
saltstack/salt | salt/modules/win_iis.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_iis.py#L56-L73 | def _get_binding_info(host_header='', ip_address='*', port=80):
'''
Combine the host header, IP address, and TCP port into bindingInformation
format. Binding Information specifies information to communicate with a
site. It includes the IP address, the port number, and an optional host
header (usuall... | [
"def",
"_get_binding_info",
"(",
"host_header",
"=",
"''",
",",
"ip_address",
"=",
"'*'",
",",
"port",
"=",
"80",
")",
":",
"return",
"':'",
".",
"join",
"(",
"[",
"ip_address",
",",
"six",
".",
"text_type",
"(",
"port",
")",
",",
"host_header",
".",
... | Combine the host header, IP address, and TCP port into bindingInformation
format. Binding Information specifies information to communicate with a
site. It includes the IP address, the port number, and an optional host
header (usually a host name) to communicate with the site.
Args:
host_header ... | [
"Combine",
"the",
"host",
"header",
"IP",
"address",
"and",
"TCP",
"port",
"into",
"bindingInformation",
"format",
".",
"Binding",
"Information",
"specifies",
"information",
"to",
"communicate",
"with",
"a",
"site",
".",
"It",
"includes",
"the",
"IP",
"address",... | python | train | 40.555556 |
inasafe/inasafe | safe/common/signals.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/signals.py#L60-L78 | def send_dynamic_message(sender, message):
"""Send a dynamic message to the listeners.
Dynamic messages represents a progress. Usually it will be appended to
the previous messages.
.. versionadded:: 3.3
:param sender: The sender.
:type sender: object
:param message: An instance of our ri... | [
"def",
"send_dynamic_message",
"(",
"sender",
",",
"message",
")",
":",
"dispatcher",
".",
"send",
"(",
"signal",
"=",
"DYNAMIC_MESSAGE_SIGNAL",
",",
"sender",
"=",
"sender",
",",
"message",
"=",
"message",
")"
] | Send a dynamic message to the listeners.
Dynamic messages represents a progress. Usually it will be appended to
the previous messages.
.. versionadded:: 3.3
:param sender: The sender.
:type sender: object
:param message: An instance of our rich message class.
:type message: safe.messagin... | [
"Send",
"a",
"dynamic",
"message",
"to",
"the",
"listeners",
"."
] | python | train | 25.157895 |
rbarrois/django-batchform | batchform/forms.py | https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/forms.py#L59-L67 | def clean(self):
"""Global cleanup."""
super(LineFormSet, self).clean()
if any(self.errors):
# Already seen errors, let's skip.
return
self.clean_unique_fields() | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
"LineFormSet",
",",
"self",
")",
".",
"clean",
"(",
")",
"if",
"any",
"(",
"self",
".",
"errors",
")",
":",
"# Already seen errors, let's skip.",
"return",
"self",
".",
"clean_unique_fields",
"(",
")"
] | Global cleanup. | [
"Global",
"cleanup",
"."
] | python | train | 23.444444 |
Fortran-FOSS-Programmers/ford | ford/sourceform.py | https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L1138-L1188 | def get_used_entities(self,use_specs):
"""
Returns the entities which are imported by a use statement. These
are contained in dicts.
"""
if len(use_specs.strip()) == 0:
return (self.pub_procs, self.pub_absints, self.pub_types, self.pub_vars)
only = bool(self.O... | [
"def",
"get_used_entities",
"(",
"self",
",",
"use_specs",
")",
":",
"if",
"len",
"(",
"use_specs",
".",
"strip",
"(",
")",
")",
"==",
"0",
":",
"return",
"(",
"self",
".",
"pub_procs",
",",
"self",
".",
"pub_absints",
",",
"self",
".",
"pub_types",
... | Returns the entities which are imported by a use statement. These
are contained in dicts. | [
"Returns",
"the",
"entities",
"which",
"are",
"imported",
"by",
"a",
"use",
"statement",
".",
"These",
"are",
"contained",
"in",
"dicts",
"."
] | python | train | 34.647059 |
hvac/hvac | hvac/api/system_backend/init.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/system_backend/init.py#L31-L104 | def initialize(self, secret_shares=5, secret_threshold=3, pgp_keys=None, root_token_pgp_key=None,
stored_shares=None, recovery_shares=None, recovery_threshold=None, recovery_pgp_keys=None):
"""Initialize a new Vault.
The Vault must not have been previously initialized. The recovery o... | [
"def",
"initialize",
"(",
"self",
",",
"secret_shares",
"=",
"5",
",",
"secret_threshold",
"=",
"3",
",",
"pgp_keys",
"=",
"None",
",",
"root_token_pgp_key",
"=",
"None",
",",
"stored_shares",
"=",
"None",
",",
"recovery_shares",
"=",
"None",
",",
"recovery_... | Initialize a new Vault.
The Vault must not have been previously initialized. The recovery options, as well as the stored shares option,
are only available when using Vault HSM.
Supported methods:
PUT: /sys/init. Produces: 200 application/json
:param secret_shares: The numb... | [
"Initialize",
"a",
"new",
"Vault",
"."
] | python | train | 53.445946 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.