repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
remram44/rpaths | rpaths.py | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1078-L1085 | def matches(self, path):
"""Tests if the given path matches the pattern.
Note that the unicode translation of the patch is matched, so
replacement characters might have been added.
"""
path = self._prepare_path(path)
return self.full_regex.search(path) is not None | [
"def",
"matches",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_prepare_path",
"(",
"path",
")",
"return",
"self",
".",
"full_regex",
".",
"search",
"(",
"path",
")",
"is",
"not",
"None"
] | Tests if the given path matches the pattern.
Note that the unicode translation of the patch is matched, so
replacement characters might have been added. | [
"Tests",
"if",
"the",
"given",
"path",
"matches",
"the",
"pattern",
"."
] | python | train |
wright-group/WrightTools | WrightTools/data/_data.py | https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/data/_data.py#L153-L160 | def shape(self) -> tuple:
"""Shape."""
try:
assert self._shape is not None
except (AssertionError, AttributeError):
self._shape = wt_kit.joint_shape(*self.variables)
finally:
return self._shape | [
"def",
"shape",
"(",
"self",
")",
"->",
"tuple",
":",
"try",
":",
"assert",
"self",
".",
"_shape",
"is",
"not",
"None",
"except",
"(",
"AssertionError",
",",
"AttributeError",
")",
":",
"self",
".",
"_shape",
"=",
"wt_kit",
".",
"joint_shape",
"(",
"*"... | Shape. | [
"Shape",
"."
] | python | train |
Fizzadar/pyinfra | pyinfra/modules/server.py | https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/modules/server.py#L316-L453 | def user(
state, host, name,
present=True, home=None, shell=None, group=None, groups=None,
public_keys=None, delete_keys=False, ensure_home=True,
system=False, uid=None,
):
'''
Add/remove/update system users & their ssh `authorized_keys`.
+ name: name of the user to ensure
+ present: wh... | [
"def",
"user",
"(",
"state",
",",
"host",
",",
"name",
",",
"present",
"=",
"True",
",",
"home",
"=",
"None",
",",
"shell",
"=",
"None",
",",
"group",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"public_keys",
"=",
"None",
",",
"delete_keys",
"="... | Add/remove/update system users & their ssh `authorized_keys`.
+ name: name of the user to ensure
+ present: whether this user should exist
+ home: the users home directory
+ shell: the users shell
+ group: the users primary group
+ groups: the users secondary groups
+ public_keys: list of p... | [
"Add",
"/",
"remove",
"/",
"update",
"system",
"users",
"&",
"their",
"ssh",
"authorized_keys",
"."
] | python | train |
LinkCareServices/period | period/main.py | https://github.com/LinkCareServices/period/blob/014f3c766940658904c52547d8cf8c12d4895e07/period/main.py#L149-L203 | def flatten(self, lst=None):
"""syntax.flatten(token_stream) - compile period tokens
This turns a stream of tokens into p-code for the trivial
stack machine that evaluates period expressions in in_period.
"""
tree = []
uops = [] # accumulated unary ... | [
"def",
"flatten",
"(",
"self",
",",
"lst",
"=",
"None",
")",
":",
"tree",
"=",
"[",
"]",
"uops",
"=",
"[",
"]",
"# accumulated unary operations",
"s",
"=",
"Stack",
"(",
")",
"group_len",
"=",
"0",
"# in current precendence group",
"for",
"item",
"in",
"... | syntax.flatten(token_stream) - compile period tokens
This turns a stream of tokens into p-code for the trivial
stack machine that evaluates period expressions in in_period. | [
"syntax",
".",
"flatten",
"(",
"token_stream",
")",
"-",
"compile",
"period",
"tokens"
] | python | train |
wecatch/app-turbo | turbo/register.py | https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/register.py#L14-L25 | def register_app(app_name, app_setting, web_application_setting, mainfile, package_space):
"""insert current project root path into sys path
"""
from turbo import log
app_config.app_name = app_name
app_config.app_setting = app_setting
app_config.project_name = os.path.basename(get_base_dir(mainf... | [
"def",
"register_app",
"(",
"app_name",
",",
"app_setting",
",",
"web_application_setting",
",",
"mainfile",
",",
"package_space",
")",
":",
"from",
"turbo",
"import",
"log",
"app_config",
".",
"app_name",
"=",
"app_name",
"app_config",
".",
"app_setting",
"=",
... | insert current project root path into sys path | [
"insert",
"current",
"project",
"root",
"path",
"into",
"sys",
"path"
] | python | train |
MycroftAI/mycroft-skills-manager | msm/skill_entry.py | https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skill_entry.py#L136-L142 | def attach(self, remote_entry):
"""Attach a remote entry to a local entry"""
self.name = remote_entry.name
self.sha = remote_entry.sha
self.url = remote_entry.url
self.author = remote_entry.author
return self | [
"def",
"attach",
"(",
"self",
",",
"remote_entry",
")",
":",
"self",
".",
"name",
"=",
"remote_entry",
".",
"name",
"self",
".",
"sha",
"=",
"remote_entry",
".",
"sha",
"self",
".",
"url",
"=",
"remote_entry",
".",
"url",
"self",
".",
"author",
"=",
... | Attach a remote entry to a local entry | [
"Attach",
"a",
"remote",
"entry",
"to",
"a",
"local",
"entry"
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/states/execution_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/execution_state.py#L132-L173 | def run(self):
""" This defines the sequence of actions that are taken when the execution state is executed
:return:
"""
if self.is_root_state:
self.execution_history.push_call_history_item(self, CallType.EXECUTE, None, self.input_data)
logger.debug("Running {0}{1}"... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root_state",
":",
"self",
".",
"execution_history",
".",
"push_call_history_item",
"(",
"self",
",",
"CallType",
".",
"EXECUTE",
",",
"None",
",",
"self",
".",
"input_data",
")",
"logger",
".",
... | This defines the sequence of actions that are taken when the execution state is executed
:return: | [
"This",
"defines",
"the",
"sequence",
"of",
"actions",
"that",
"are",
"taken",
"when",
"the",
"execution",
"state",
"is",
"executed"
] | python | train |
cloudant/python-cloudant | src/cloudant/database.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/database.py#L1378-L1401 | def unshare_database(self, username):
"""
Removes all sharing with the named user for the current remote database.
This will remove the entry for the user from the security document.
To modify permissions, use the
:func:`~cloudant.database.CloudantDatabase.share_database` method
... | [
"def",
"unshare_database",
"(",
"self",
",",
"username",
")",
":",
"doc",
"=",
"self",
".",
"security_document",
"(",
")",
"data",
"=",
"doc",
".",
"get",
"(",
"'cloudant'",
",",
"{",
"}",
")",
"if",
"username",
"in",
"data",
":",
"del",
"data",
"[",... | Removes all sharing with the named user for the current remote database.
This will remove the entry for the user from the security document.
To modify permissions, use the
:func:`~cloudant.database.CloudantDatabase.share_database` method
instead.
:param str username: Cloudant us... | [
"Removes",
"all",
"sharing",
"with",
"the",
"named",
"user",
"for",
"the",
"current",
"remote",
"database",
".",
"This",
"will",
"remove",
"the",
"entry",
"for",
"the",
"user",
"from",
"the",
"security",
"document",
".",
"To",
"modify",
"permissions",
"use",... | python | train |
box/genty | genty/genty.py | https://github.com/box/genty/blob/85f7c960a2b67cf9e58e0d9e677e4a0bc4f05081/genty/genty.py#L338-L366 | def _build_dataset_method(method, dataset):
"""
Return a fabricated method that marshals the dataset into parameters
for given 'method'
:param method:
The underlying test method.
:type method:
`callable`
:param dataset:
Tuple or GentyArgs instance containing the args of t... | [
"def",
"_build_dataset_method",
"(",
"method",
",",
"dataset",
")",
":",
"if",
"isinstance",
"(",
"dataset",
",",
"GentyArgs",
")",
":",
"test_method",
"=",
"lambda",
"my_self",
":",
"method",
"(",
"my_self",
",",
"*",
"dataset",
".",
"args",
",",
"*",
"... | Return a fabricated method that marshals the dataset into parameters
for given 'method'
:param method:
The underlying test method.
:type method:
`callable`
:param dataset:
Tuple or GentyArgs instance containing the args of the dataset.
:type dataset:
`tuple` or :class... | [
"Return",
"a",
"fabricated",
"method",
"that",
"marshals",
"the",
"dataset",
"into",
"parameters",
"for",
"given",
"method",
":",
"param",
"method",
":",
"The",
"underlying",
"test",
"method",
".",
":",
"type",
"method",
":",
"callable",
":",
"param",
"datas... | python | train |
pantsbuild/pants | src/python/pants/build_graph/injectables_mixin.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/injectables_mixin.py#L58-L70 | def injectables_spec_for_key(self, key):
"""Given a key, yield a singular spec representing that key.
:API: public
"""
specs = self.injectables_specs_for_key(key)
specs_len = len(specs)
if specs_len == 0:
return None
if specs_len != 1:
raise self.TooManySpecsForKey('injectables ... | [
"def",
"injectables_spec_for_key",
"(",
"self",
",",
"key",
")",
":",
"specs",
"=",
"self",
".",
"injectables_specs_for_key",
"(",
"key",
")",
"specs_len",
"=",
"len",
"(",
"specs",
")",
"if",
"specs_len",
"==",
"0",
":",
"return",
"None",
"if",
"specs_len... | Given a key, yield a singular spec representing that key.
:API: public | [
"Given",
"a",
"key",
"yield",
"a",
"singular",
"spec",
"representing",
"that",
"key",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/controllers/state_editor/outcomes.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_editor/outcomes.py#L125-L171 | def on_to_state_edited(self, renderer, path, new_state_identifier):
"""Connects the outcome with a transition to the newly set state
:param Gtk.CellRendererText renderer: The cell renderer that was edited
:param str path: The path string of the renderer
:param str new_state_identifier: ... | [
"def",
"on_to_state_edited",
"(",
"self",
",",
"renderer",
",",
"path",
",",
"new_state_identifier",
")",
":",
"def",
"do_self_transition_check",
"(",
"t_id",
",",
"new_state_identifier",
")",
":",
"# add self transition meta data",
"if",
"'self'",
"in",
"new_state_id... | Connects the outcome with a transition to the newly set state
:param Gtk.CellRendererText renderer: The cell renderer that was edited
:param str path: The path string of the renderer
:param str new_state_identifier: An identifier for the new state that was selected | [
"Connects",
"the",
"outcome",
"with",
"a",
"transition",
"to",
"the",
"newly",
"set",
"state"
] | python | train |
agramian/subprocess-manager | subprocess_manager/nbstream_readerwriter.py | https://github.com/agramian/subprocess-manager/blob/fff9ff2ddab644a86f96e1ccf5df142c482a8247/subprocess_manager/nbstream_readerwriter.py#L54-L61 | def readline(self, timeout = 0.1):
"""Try to read a line from the stream queue.
"""
try:
return self._q.get(block = timeout is not None,
timeout = timeout)
except Empty:
return None | [
"def",
"readline",
"(",
"self",
",",
"timeout",
"=",
"0.1",
")",
":",
"try",
":",
"return",
"self",
".",
"_q",
".",
"get",
"(",
"block",
"=",
"timeout",
"is",
"not",
"None",
",",
"timeout",
"=",
"timeout",
")",
"except",
"Empty",
":",
"return",
"No... | Try to read a line from the stream queue. | [
"Try",
"to",
"read",
"a",
"line",
"from",
"the",
"stream",
"queue",
"."
] | python | train |
secdev/scapy | scapy/modules/krack/automaton.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L72-L155 | def parse_args(self, ap_mac, ssid, passphrase,
channel=None,
# KRACK attack options
double_3handshake=True,
encrypt_3handshake=True,
wait_3handshake=0,
double_gtk_refresh=True,
arp_target... | [
"def",
"parse_args",
"(",
"self",
",",
"ap_mac",
",",
"ssid",
",",
"passphrase",
",",
"channel",
"=",
"None",
",",
"# KRACK attack options",
"double_3handshake",
"=",
"True",
",",
"encrypt_3handshake",
"=",
"True",
",",
"wait_3handshake",
"=",
"0",
",",
"doubl... | Mandatory arguments:
@iface: interface to use (must be in monitor mode)
@ap_mac: AP's MAC
@ssid: AP's SSID
@passphrase: AP's Passphrase (min 8 char.)
Optional arguments:
@channel: used by the interface. Default 6, autodetected on windows
Krack attacks options:
... | [
"Mandatory",
"arguments",
":",
"@iface",
":",
"interface",
"to",
"use",
"(",
"must",
"be",
"in",
"monitor",
"mode",
")",
"@ap_mac",
":",
"AP",
"s",
"MAC",
"@ssid",
":",
"AP",
"s",
"SSID",
"@passphrase",
":",
"AP",
"s",
"Passphrase",
"(",
"min",
"8",
... | python | train |
pymc-devs/pymc | pymc/StepMethods.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1488-L1496 | def trace2array(self, sl):
"""Return an array with the trace of all stochastics, sliced by sl."""
chain = []
for stochastic in self.stochastics:
tr = stochastic.trace.gettrace(slicing=sl)
if tr is None:
raise AttributeError
chain.append(tr)
... | [
"def",
"trace2array",
"(",
"self",
",",
"sl",
")",
":",
"chain",
"=",
"[",
"]",
"for",
"stochastic",
"in",
"self",
".",
"stochastics",
":",
"tr",
"=",
"stochastic",
".",
"trace",
".",
"gettrace",
"(",
"slicing",
"=",
"sl",
")",
"if",
"tr",
"is",
"N... | Return an array with the trace of all stochastics, sliced by sl. | [
"Return",
"an",
"array",
"with",
"the",
"trace",
"of",
"all",
"stochastics",
"sliced",
"by",
"sl",
"."
] | python | train |
jrief/djangocms-cascade | cmsplugin_cascade/apps.py | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L97-L110 | def revoke_permissions(self, ctype):
"""
Remove all permissions for the content type to be removed
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
Permission = apps.get_model('auth', 'Permission')
except LookupError:
return
... | [
"def",
"revoke_permissions",
"(",
"self",
",",
"ctype",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes'",
",",
"'ContentType'",
")",
"try",
":",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth'",
",",
"'Permission'",
")"... | Remove all permissions for the content type to be removed | [
"Remove",
"all",
"permissions",
"for",
"the",
"content",
"type",
"to",
"be",
"removed"
] | python | train |
qacafe/cdrouter.py | cdrouter/users.py | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/users.py#L188-L195 | def bulk_copy(self, ids):
"""Bulk copy a set of users.
:param ids: Int list of user IDs.
:return: :class:`users.User <users.User>` list
"""
schema = UserSchema()
return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema) | [
"def",
"bulk_copy",
"(",
"self",
",",
"ids",
")",
":",
"schema",
"=",
"UserSchema",
"(",
")",
"return",
"self",
".",
"service",
".",
"bulk_copy",
"(",
"self",
".",
"base",
",",
"self",
".",
"RESOURCE",
",",
"ids",
",",
"schema",
")"
] | Bulk copy a set of users.
:param ids: Int list of user IDs.
:return: :class:`users.User <users.User>` list | [
"Bulk",
"copy",
"a",
"set",
"of",
"users",
"."
] | python | train |
nicferrier/md | src/mdlib/client.py | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/client.py#L187-L197 | def _get(self, msgid):
"""Yields the message header against each part from the message."""
foldername, msgkey = msgid.split(SEPERATOR)
folder = self.folder if foldername == "INBOX" else self._getfolder(foldername)
# Now look up the message
msg = folder[msgkey]
msg.is_seen... | [
"def",
"_get",
"(",
"self",
",",
"msgid",
")",
":",
"foldername",
",",
"msgkey",
"=",
"msgid",
".",
"split",
"(",
"SEPERATOR",
")",
"folder",
"=",
"self",
".",
"folder",
"if",
"foldername",
"==",
"\"INBOX\"",
"else",
"self",
".",
"_getfolder",
"(",
"fo... | Yields the message header against each part from the message. | [
"Yields",
"the",
"message",
"header",
"against",
"each",
"part",
"from",
"the",
"message",
"."
] | python | train |
Gandi/gandi.cli | gandi/cli/modules/domain.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/domain.py#L80-L101 | def renew(cls, fqdn, duration, background):
"""Renew a domain."""
fqdn = fqdn.lower()
if not background and not cls.intty():
background = True
domain_info = cls.info(fqdn)
current_year = domain_info['date_registry_end'].year
domain_params = {
'du... | [
"def",
"renew",
"(",
"cls",
",",
"fqdn",
",",
"duration",
",",
"background",
")",
":",
"fqdn",
"=",
"fqdn",
".",
"lower",
"(",
")",
"if",
"not",
"background",
"and",
"not",
"cls",
".",
"intty",
"(",
")",
":",
"background",
"=",
"True",
"domain_info",... | Renew a domain. | [
"Renew",
"a",
"domain",
"."
] | python | train |
wreckage/django-happenings | happenings/utils/handlers.py | https://github.com/wreckage/django-happenings/blob/7bca5576efa6cd4c4e87356bf9e5b8cd538ae91d/happenings/utils/handlers.py#L244-L272 | def _handle_weekly_repeat_out(self):
"""
Handles repeating an event weekly (or biweekly) if the current
year and month are outside of its start year and month.
It takes care of cases 3 and 4 in _handle_weekly_repeat_in() comments.
"""
start_d = _first_weekday(
... | [
"def",
"_handle_weekly_repeat_out",
"(",
"self",
")",
":",
"start_d",
"=",
"_first_weekday",
"(",
"self",
".",
"event",
".",
"l_start_date",
".",
"weekday",
"(",
")",
",",
"date",
"(",
"self",
".",
"year",
",",
"self",
".",
"month",
",",
"1",
")",
")",... | Handles repeating an event weekly (or biweekly) if the current
year and month are outside of its start year and month.
It takes care of cases 3 and 4 in _handle_weekly_repeat_in() comments. | [
"Handles",
"repeating",
"an",
"event",
"weekly",
"(",
"or",
"biweekly",
")",
"if",
"the",
"current",
"year",
"and",
"month",
"are",
"outside",
"of",
"its",
"start",
"year",
"and",
"month",
".",
"It",
"takes",
"care",
"of",
"cases",
"3",
"and",
"4",
"in... | python | test |
libvips/pyvips | pyvips/error.py | https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/error.py#L33-L47 | def _to_string(x):
"""Convert to a unicode string.
If x is a byte string, assume it is utf-8 and decode to a Python unicode
string. You must call this on text strings you get back from libvips.
"""
if x == ffi.NULL:
x = 'NULL'
else:
x = ffi.string(x)
if isinstance(x, by... | [
"def",
"_to_string",
"(",
"x",
")",
":",
"if",
"x",
"==",
"ffi",
".",
"NULL",
":",
"x",
"=",
"'NULL'",
"else",
":",
"x",
"=",
"ffi",
".",
"string",
"(",
"x",
")",
"if",
"isinstance",
"(",
"x",
",",
"byte_type",
")",
":",
"x",
"=",
"x",
".",
... | Convert to a unicode string.
If x is a byte string, assume it is utf-8 and decode to a Python unicode
string. You must call this on text strings you get back from libvips. | [
"Convert",
"to",
"a",
"unicode",
"string",
"."
] | python | train |
stevearc/dql | dql/grammar/common.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/grammar/common.py#L27-L44 | def function(name, *args, **kwargs):
""" Construct a parser for a standard function format """
if kwargs.get("caseless"):
name = upkey(name)
else:
name = Word(name)
fxn_args = None
for i, arg in enumerate(args):
if i == 0:
fxn_args = arg
else:
... | [
"def",
"function",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"caseless\"",
")",
":",
"name",
"=",
"upkey",
"(",
"name",
")",
"else",
":",
"name",
"=",
"Word",
"(",
"name",
")",
"fxn_args"... | Construct a parser for a standard function format | [
"Construct",
"a",
"parser",
"for",
"a",
"standard",
"function",
"format"
] | python | train |
Netflix-Skunkworks/swag-client | swag_client/backends/s3.py | https://github.com/Netflix-Skunkworks/swag-client/blob/e43816a85c4f48011cf497a4eae14f9df71fee0f/swag_client/backends/s3.py#L126-L132 | def get_all(self):
"""Gets all items in file."""
logger.debug('Fetching items. Path: {data_file}'.format(
data_file=self.data_file
))
return load_file(self.client, self.bucket_name, self.data_file) | [
"def",
"get_all",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Fetching items. Path: {data_file}'",
".",
"format",
"(",
"data_file",
"=",
"self",
".",
"data_file",
")",
")",
"return",
"load_file",
"(",
"self",
".",
"client",
",",
"self",
".",
"buc... | Gets all items in file. | [
"Gets",
"all",
"items",
"in",
"file",
"."
] | python | train |
ynop/audiomate | audiomate/formats/audacity.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/formats/audacity.py#L45-L73 | def read_label_file(path):
"""
Read the labels from an audacity label file.
Args:
path (str): Path to the label file.
Returns:
list: List of labels (start [sec], end [sec], label)
Example::
>>> read_label_file('/path/to/label/file.txt')
[
[0.0, 0.2, 's... | [
"def",
"read_label_file",
"(",
"path",
")",
":",
"labels",
"=",
"[",
"]",
"for",
"record",
"in",
"textfile",
".",
"read_separated_lines_generator",
"(",
"path",
",",
"separator",
"=",
"'\\t'",
",",
"max_columns",
"=",
"3",
")",
":",
"value",
"=",
"''",
"... | Read the labels from an audacity label file.
Args:
path (str): Path to the label file.
Returns:
list: List of labels (start [sec], end [sec], label)
Example::
>>> read_label_file('/path/to/label/file.txt')
[
[0.0, 0.2, 'sie'],
[0.2, 2.2, 'hallo']
... | [
"Read",
"the",
"labels",
"from",
"an",
"audacity",
"label",
"file",
"."
] | python | train |
limpyd/redis-limpyd | limpyd/indexes.py | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L1324-L1332 | def unstore(self, key, pk, value):
"""Remove the value/pk from the sorted set index
For the parameters, see BaseRangeIndex.store
We simple remove the pk as a member from the sorted set
"""
self.connection.zrem(key, pk) | [
"def",
"unstore",
"(",
"self",
",",
"key",
",",
"pk",
",",
"value",
")",
":",
"self",
".",
"connection",
".",
"zrem",
"(",
"key",
",",
"pk",
")"
] | Remove the value/pk from the sorted set index
For the parameters, see BaseRangeIndex.store
We simple remove the pk as a member from the sorted set | [
"Remove",
"the",
"value",
"/",
"pk",
"from",
"the",
"sorted",
"set",
"index"
] | python | train |
dcos/shakedown | shakedown/dcos/docker.py | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/docker.py#L12-L39 | def docker_version(host=None, component='server'):
""" Return the version of Docker [Server]
:param host: host or IP of the machine Docker is running on
:type host: str
:param component: Docker component
:type component: str
:return: Docker version
:rtype: str
""... | [
"def",
"docker_version",
"(",
"host",
"=",
"None",
",",
"component",
"=",
"'server'",
")",
":",
"if",
"component",
".",
"lower",
"(",
")",
"==",
"'client'",
":",
"component",
"=",
"'Client'",
"else",
":",
"component",
"=",
"'Server'",
"# sudo is required for... | Return the version of Docker [Server]
:param host: host or IP of the machine Docker is running on
:type host: str
:param component: Docker component
:type component: str
:return: Docker version
:rtype: str | [
"Return",
"the",
"version",
"of",
"Docker",
"[",
"Server",
"]"
] | python | train |
Capitains/Nautilus | capitains_nautilus/flask_ext.py | https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/flask_ext.py#L160-L183 | def init_blueprint(self, app):
""" Properly generates the blueprint, registering routes and filters and connecting the app and the blueprint
:return: Blueprint of the extension
:rtype: Blueprint
"""
self.blueprint = Blueprint(
self.name,
self.name,
... | [
"def",
"init_blueprint",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"blueprint",
"=",
"Blueprint",
"(",
"self",
".",
"name",
",",
"self",
".",
"name",
",",
"template_folder",
"=",
"resource_filename",
"(",
"\"capitains_nautilus\"",
",",
"\"data/templates\... | Properly generates the blueprint, registering routes and filters and connecting the app and the blueprint
:return: Blueprint of the extension
:rtype: Blueprint | [
"Properly",
"generates",
"the",
"blueprint",
"registering",
"routes",
"and",
"filters",
"and",
"connecting",
"the",
"app",
"and",
"the",
"blueprint"
] | python | train |
jilljenn/tryalgo | tryalgo/gale_shapley.py | https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/gale_shapley.py#L12-L40 | def gale_shapley(men, women):
"""Stable matching by Gale-Shapley
:param men: table of size n, men[i] is preference list of women for men i
:param women: similar
:returns: matching table, from women to men
:complexity: :math:`O(n^2)`
"""
n = len(men)
assert n == len(women)
current_su... | [
"def",
"gale_shapley",
"(",
"men",
",",
"women",
")",
":",
"n",
"=",
"len",
"(",
"men",
")",
"assert",
"n",
"==",
"len",
"(",
"women",
")",
"current_suitor",
"=",
"[",
"0",
"]",
"*",
"n",
"spouse",
"=",
"[",
"None",
"]",
"*",
"n",
"rank",
"=",
... | Stable matching by Gale-Shapley
:param men: table of size n, men[i] is preference list of women for men i
:param women: similar
:returns: matching table, from women to men
:complexity: :math:`O(n^2)` | [
"Stable",
"matching",
"by",
"Gale",
"-",
"Shapley"
] | python | train |
SpriteLink/NIPAP | nipap-www/nipapwww/controllers/prefix.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap-www/nipapwww/controllers/prefix.py#L51-L104 | def edit(self, id):
""" Edit a prefix.
"""
# find prefix
c.prefix = Prefix.get(int(id))
# we got a HTTP POST - edit object
if request.method == 'POST':
c.prefix.prefix = request.params['prefix_prefix']
c.prefix.description = request.params['prefi... | [
"def",
"edit",
"(",
"self",
",",
"id",
")",
":",
"# find prefix",
"c",
".",
"prefix",
"=",
"Prefix",
".",
"get",
"(",
"int",
"(",
"id",
")",
")",
"# we got a HTTP POST - edit object",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"c",
".",
"pref... | Edit a prefix. | [
"Edit",
"a",
"prefix",
"."
] | python | train |
aio-libs/aioftp | ftpbench.py | https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/ftpbench.py#L159-L174 | def human2bytes(s):
"""
>>> human2bytes('1M')
1048576
>>> human2bytes('1G')
1073741824
"""
symbols = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
letter = s[-1:].strip().upper()
num = s[:-1]
assert num.isdigit() and letter in symbols, s
num = float(num)
prefix = {symbols... | [
"def",
"human2bytes",
"(",
"s",
")",
":",
"symbols",
"=",
"(",
"'B'",
",",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'T'",
",",
"'P'",
",",
"'E'",
",",
"'Z'",
",",
"'Y'",
")",
"letter",
"=",
"s",
"[",
"-",
"1",
":",
"]",
".",
"strip",
"(",
")",
... | >>> human2bytes('1M')
1048576
>>> human2bytes('1G')
1073741824 | [
">>>",
"human2bytes",
"(",
"1M",
")",
"1048576",
">>>",
"human2bytes",
"(",
"1G",
")",
"1073741824"
] | python | valid |
ynop/audiomate | audiomate/corpus/corpus.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/corpus.py#L550-L566 | def merge_corpora(cls, corpora):
"""
Merge a list of corpora into one.
Args:
corpora (Iterable): An iterable of :py:class:`audiomate.corpus.CorpusView`.
Returns:
Corpus: A corpus with the data from all given corpora merged into one.
"""
ds = Cor... | [
"def",
"merge_corpora",
"(",
"cls",
",",
"corpora",
")",
":",
"ds",
"=",
"Corpus",
"(",
")",
"for",
"merging_corpus",
"in",
"corpora",
":",
"ds",
".",
"merge_corpus",
"(",
"merging_corpus",
")",
"return",
"ds"
] | Merge a list of corpora into one.
Args:
corpora (Iterable): An iterable of :py:class:`audiomate.corpus.CorpusView`.
Returns:
Corpus: A corpus with the data from all given corpora merged into one. | [
"Merge",
"a",
"list",
"of",
"corpora",
"into",
"one",
"."
] | python | train |
tanghaibao/jcvi | jcvi/apps/gmap.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/gmap.py#L104-L119 | def index(args):
"""
%prog index database.fasta
`
Wrapper for `gmap_build`. Same interface.
"""
p = OptionParser(index.__doc__)
p.add_option("--supercat", default=False, action="store_true",
help="Concatenate reference to speed up alignment")
opts, args = p.parse_args(args)
... | [
"def",
"index",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"index",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--supercat\"",
",",
"default",
"=",
"False",
",",
"action",
"=",
"\"store_true\"",
",",
"help",
"=",
"\"Concatenate referenc... | %prog index database.fasta
`
Wrapper for `gmap_build`. Same interface. | [
"%prog",
"index",
"database",
".",
"fasta",
"Wrapper",
"for",
"gmap_build",
".",
"Same",
"interface",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/account.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/account.py#L78-L92 | def get_event(self, event_id):
"""Gets details about a maintenance event
:param int event_id: Notification_Occurrence_Event ID
:return: Notification_Occurrence_Event
"""
mask = """mask[
acknowledgedFlag,
attachments,
impactedResources,
... | [
"def",
"get_event",
"(",
"self",
",",
"event_id",
")",
":",
"mask",
"=",
"\"\"\"mask[\n acknowledgedFlag,\n attachments,\n impactedResources,\n statusCode,\n updates,\n notificationOccurrenceEventType]\n \"\"\"",
"return"... | Gets details about a maintenance event
:param int event_id: Notification_Occurrence_Event ID
:return: Notification_Occurrence_Event | [
"Gets",
"details",
"about",
"a",
"maintenance",
"event"
] | python | train |
Clinical-Genomics/scout | scout/adapter/mongo/event.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/event.py#L74-L135 | def events(self, institute, case=None, variant_id=None, level=None,
comments=False, panel=None):
"""Fetch events from the database.
Args:
institute (dict): A institute
case (dict): A case
variant_id (str, optional): global variant id
leve... | [
"def",
"events",
"(",
"self",
",",
"institute",
",",
"case",
"=",
"None",
",",
"variant_id",
"=",
"None",
",",
"level",
"=",
"None",
",",
"comments",
"=",
"False",
",",
"panel",
"=",
"None",
")",
":",
"query",
"=",
"{",
"}",
"if",
"variant_id",
":"... | Fetch events from the database.
Args:
institute (dict): A institute
case (dict): A case
variant_id (str, optional): global variant id
level (str, optional): restrict comments to 'specific' or 'global'
comments (bool, optional): restrict events to in... | [
"Fetch",
"events",
"from",
"the",
"database",
"."
] | python | test |
googledatalab/pydatalab | datalab/data/_sql_statement.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/_sql_statement.py#L69-L120 | def _find_recursive_dependencies(sql, values, code, resolved_vars, resolving_vars=None):
""" Recursive helper method for expanding variables including transitive dependencies.
Placeholders in SQL are represented as $<name>. If '$' must appear within
the SQL statement literally, then it can be escaped as '$... | [
"def",
"_find_recursive_dependencies",
"(",
"sql",
",",
"values",
",",
"code",
",",
"resolved_vars",
",",
"resolving_vars",
"=",
"None",
")",
":",
"# Get the set of $var references in this SQL.",
"dependencies",
"=",
"SqlStatement",
".",
"_get_dependencies",
"(",
"sql",... | Recursive helper method for expanding variables including transitive dependencies.
Placeholders in SQL are represented as $<name>. If '$' must appear within
the SQL statement literally, then it can be escaped as '$$'.
Args:
sql: the raw SQL statement with named placeholders.
values: the user-s... | [
"Recursive",
"helper",
"method",
"for",
"expanding",
"variables",
"including",
"transitive",
"dependencies",
"."
] | python | train |
manns/pyspread | pyspread/src/lib/fileio.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/fileio.py#L88-L101 | def next(self):
"""Next that shows progress in statusbar for each <freq> cells"""
self.progress_status()
# Check abortes state and raise StopIteration if aborted
if self.aborted:
statustext = _("File loading aborted.")
post_command_event(self.main_window, self.... | [
"def",
"next",
"(",
"self",
")",
":",
"self",
".",
"progress_status",
"(",
")",
"# Check abortes state and raise StopIteration if aborted",
"if",
"self",
".",
"aborted",
":",
"statustext",
"=",
"_",
"(",
"\"File loading aborted.\"",
")",
"post_command_event",
"(",
"... | Next that shows progress in statusbar for each <freq> cells | [
"Next",
"that",
"shows",
"progress",
"in",
"statusbar",
"for",
"each",
"<freq",
">",
"cells"
] | python | train |
anthok/overwatch-api | overwatch_api/core.py | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L226-L235 | async def _async_get(self, session: aiohttp.ClientSession, *args, _async_timeout_seconds: int = 5,
**kwargs):
"""Uses aiohttp to make a get request asynchronously.
Will raise asyncio.TimeoutError if the request could not be completed
within _async_timeout_seconds (defa... | [
"async",
"def",
"_async_get",
"(",
"self",
",",
"session",
":",
"aiohttp",
".",
"ClientSession",
",",
"*",
"args",
",",
"_async_timeout_seconds",
":",
"int",
"=",
"5",
",",
"*",
"*",
"kwargs",
")",
":",
"# Taken almost directly from the aiohttp tutorial",
"with"... | Uses aiohttp to make a get request asynchronously.
Will raise asyncio.TimeoutError if the request could not be completed
within _async_timeout_seconds (default 5) seconds. | [
"Uses",
"aiohttp",
"to",
"make",
"a",
"get",
"request",
"asynchronously",
".",
"Will",
"raise",
"asyncio",
".",
"TimeoutError",
"if",
"the",
"request",
"could",
"not",
"be",
"completed",
"within",
"_async_timeout_seconds",
"(",
"default",
"5",
")",
"seconds",
... | python | train |
spulec/moto | moto/packages/httpretty/core.py | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L1089-L1116 | def httprettified(test):
"A decorator tests that use HTTPretty"
def decorate_class(klass):
for attr in dir(klass):
if not attr.startswith('test_'):
continue
attr_value = getattr(klass, attr)
if not hasattr(attr_value, "__call__"):
cont... | [
"def",
"httprettified",
"(",
"test",
")",
":",
"def",
"decorate_class",
"(",
"klass",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"klass",
")",
":",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'test_'",
")",
":",
"continue",
"attr_value",
"=",
"getatt... | A decorator tests that use HTTPretty | [
"A",
"decorator",
"tests",
"that",
"use",
"HTTPretty"
] | python | train |
dopefishh/pympi | pympi/Elan.py | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L582-L598 | def get_annotation_data_before_time(self, id_tier, time):
"""Give the annotation before a given time. When the tier contains
reference annotations this will be returned, check
:func:`get_ref_annotation_data_before_time` for the format. If an
annotation overlaps with ``time`` that annotat... | [
"def",
"get_annotation_data_before_time",
"(",
"self",
",",
"id_tier",
",",
"time",
")",
":",
"if",
"self",
".",
"tiers",
"[",
"id_tier",
"]",
"[",
"1",
"]",
":",
"return",
"self",
".",
"get_ref_annotation_before_time",
"(",
"id_tier",
",",
"time",
")",
"b... | Give the annotation before a given time. When the tier contains
reference annotations this will be returned, check
:func:`get_ref_annotation_data_before_time` for the format. If an
annotation overlaps with ``time`` that annotation will be returned.
:param str id_tier: Name of the tier.
... | [
"Give",
"the",
"annotation",
"before",
"a",
"given",
"time",
".",
"When",
"the",
"tier",
"contains",
"reference",
"annotations",
"this",
"will",
"be",
"returned",
"check",
":",
"func",
":",
"get_ref_annotation_data_before_time",
"for",
"the",
"format",
".",
"If"... | python | test |
tgbugs/pyontutils | pyontutils/combinators.py | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/combinators.py#L17-L26 | def make_predicate_object_combinator(function, p, o):
""" Combinator to hold predicate object pairs until a subject is supplied and then
call a function that accepts a subject, predicate, and object.
Create a combinator to defer production of a triple until the missing pieces are supplied.
... | [
"def",
"make_predicate_object_combinator",
"(",
"function",
",",
"p",
",",
"o",
")",
":",
"def",
"predicate_object_combinator",
"(",
"subject",
")",
":",
"return",
"function",
"(",
"subject",
",",
"p",
",",
"o",
")",
"return",
"predicate_object_combinator"
] | Combinator to hold predicate object pairs until a subject is supplied and then
call a function that accepts a subject, predicate, and object.
Create a combinator to defer production of a triple until the missing pieces are supplied.
Note that the naming here tells you what is stored IN the comb... | [
"Combinator",
"to",
"hold",
"predicate",
"object",
"pairs",
"until",
"a",
"subject",
"is",
"supplied",
"and",
"then",
"call",
"a",
"function",
"that",
"accepts",
"a",
"subject",
"predicate",
"and",
"object",
"."
] | python | train |
pandas-dev/pandas | pandas/core/internals/managers.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L1792-L1803 | def _simple_blockify(tuples, dtype):
""" return a single array of a block that has a single dtype; if dtype is
not None, coerce to this dtype
"""
values, placement = _stack_arrays(tuples, dtype)
# CHECK DTYPE?
if dtype is not None and values.dtype != dtype: # pragma: no cover
values = ... | [
"def",
"_simple_blockify",
"(",
"tuples",
",",
"dtype",
")",
":",
"values",
",",
"placement",
"=",
"_stack_arrays",
"(",
"tuples",
",",
"dtype",
")",
"# CHECK DTYPE?",
"if",
"dtype",
"is",
"not",
"None",
"and",
"values",
".",
"dtype",
"!=",
"dtype",
":",
... | return a single array of a block that has a single dtype; if dtype is
not None, coerce to this dtype | [
"return",
"a",
"single",
"array",
"of",
"a",
"block",
"that",
"has",
"a",
"single",
"dtype",
";",
"if",
"dtype",
"is",
"not",
"None",
"coerce",
"to",
"this",
"dtype"
] | python | train |
tadashi-aikawa/owlmixin | owlmixin/transformers.py | https://github.com/tadashi-aikawa/owlmixin/blob/7c4a042c3008abddc56a8e8e55ae930d276071f5/owlmixin/transformers.py#L304-L312 | def to_yamlf(self, fpath: str, encoding: str='utf8', ignore_none: bool=True, ignore_empty: bool=False) -> str:
"""From instance to yaml file
:param ignore_none: Properties which is None are excluded if True
:param fpath: Yaml file path
:param encoding: Yaml file encoding
:return... | [
"def",
"to_yamlf",
"(",
"self",
",",
"fpath",
":",
"str",
",",
"encoding",
":",
"str",
"=",
"'utf8'",
",",
"ignore_none",
":",
"bool",
"=",
"True",
",",
"ignore_empty",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"return",
"util",
".",
"save_ya... | From instance to yaml file
:param ignore_none: Properties which is None are excluded if True
:param fpath: Yaml file path
:param encoding: Yaml file encoding
:return: Yaml file path | [
"From",
"instance",
"to",
"yaml",
"file"
] | python | train |
ggravlingen/pytradfri | pytradfri/api/libcoap_api.py | https://github.com/ggravlingen/pytradfri/blob/63750fa8fb27158c013d24865cdaa7fb82b3ab53/pytradfri/api/libcoap_api.py#L198-L210 | def retry_timeout(api, retries=3):
"""Retry API call when a timeout occurs."""
@wraps(api)
def retry_api(*args, **kwargs):
"""Retrying API."""
for i in range(1, retries + 1):
try:
return api(*args, **kwargs)
except RequestTimeout:
if i ... | [
"def",
"retry_timeout",
"(",
"api",
",",
"retries",
"=",
"3",
")",
":",
"@",
"wraps",
"(",
"api",
")",
"def",
"retry_api",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Retrying API.\"\"\"",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"... | Retry API call when a timeout occurs. | [
"Retry",
"API",
"call",
"when",
"a",
"timeout",
"occurs",
"."
] | python | train |
gawel/irc3 | irc3/dec.py | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dec.py#L85-L89 | def dcc_event(regexp, callback=None, iotype='in',
venusian_category='irc3.dcc'):
"""Work like :class:`~irc3.dec.event` but occurs during DCC CHATs"""
return event(regexp, callback=callback, iotype='dcc_' + iotype,
venusian_category=venusian_category) | [
"def",
"dcc_event",
"(",
"regexp",
",",
"callback",
"=",
"None",
",",
"iotype",
"=",
"'in'",
",",
"venusian_category",
"=",
"'irc3.dcc'",
")",
":",
"return",
"event",
"(",
"regexp",
",",
"callback",
"=",
"callback",
",",
"iotype",
"=",
"'dcc_'",
"+",
"io... | Work like :class:`~irc3.dec.event` but occurs during DCC CHATs | [
"Work",
"like",
":",
"class",
":",
"~irc3",
".",
"dec",
".",
"event",
"but",
"occurs",
"during",
"DCC",
"CHATs"
] | python | train |
seb-m/tss | tss.py | https://github.com/seb-m/tss/blob/ab45176b8585ba6bbbcaeffd21ec0c63f615dce0/tss.py#L53-L63 | def encode(value, encoding='utf-8', encoding_errors='strict'):
"""
Return a bytestring representation of the value.
"""
if isinstance(value, bytes):
return value
if not isinstance(value, basestring):
value = str(value)
if isinstance(value, unicode):
value = value.encode(e... | [
"def",
"encode",
"(",
"value",
",",
"encoding",
"=",
"'utf-8'",
",",
"encoding_errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
"if",
"not",
"isinstance",
"(",
"value",
",",
"basestring",
")... | Return a bytestring representation of the value. | [
"Return",
"a",
"bytestring",
"representation",
"of",
"the",
"value",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/vqa_self_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L560-L651 | def decoder(decoder_input,
encoder_output,
decoder_self_attention_bias,
encoder_decoder_attention_bias,
hparams,
name="decoder",
save_weights_to=None,
make_image_summary=True,):
"""A stack of transformer layers.
Args:
decoder_i... | [
"def",
"decoder",
"(",
"decoder_input",
",",
"encoder_output",
",",
"decoder_self_attention_bias",
",",
"encoder_decoder_attention_bias",
",",
"hparams",
",",
"name",
"=",
"\"decoder\"",
",",
"save_weights_to",
"=",
"None",
",",
"make_image_summary",
"=",
"True",
",",... | A stack of transformer layers.
Args:
decoder_input: a Tensor
encoder_output: a Tensor
decoder_self_attention_bias: bias Tensor for self-attention
(see common_attention.attention_bias())
encoder_decoder_attention_bias: bias Tensor for encoder-decoder attention
(see common_attention.attenti... | [
"A",
"stack",
"of",
"transformer",
"layers",
"."
] | python | train |
bambinos/bambi | bambi/models.py | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L374-L496 | def _add(self, fixed=None, random=None, priors=None, family='gaussian',
link=None, categorical=None, append=True):
'''Internal version of add(), with the same arguments.
Runs during Model.build()
'''
# use cleaned data with NAs removed (if user requested)
data = se... | [
"def",
"_add",
"(",
"self",
",",
"fixed",
"=",
"None",
",",
"random",
"=",
"None",
",",
"priors",
"=",
"None",
",",
"family",
"=",
"'gaussian'",
",",
"link",
"=",
"None",
",",
"categorical",
"=",
"None",
",",
"append",
"=",
"True",
")",
":",
"# use... | Internal version of add(), with the same arguments.
Runs during Model.build() | [
"Internal",
"version",
"of",
"add",
"()",
"with",
"the",
"same",
"arguments",
"."
] | python | train |
CamDavidsonPilon/lifelines | lifelines/utils/__init__.py | https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/__init__.py#L737-L770 | def _additive_estimate(events, timeline, _additive_f, _additive_var, reverse):
"""
Called to compute the Kaplan Meier and Nelson-Aalen estimates.
"""
if reverse:
events = events.sort_index(ascending=False)
at_risk = events["entrance"].sum() - events["removed"].cumsum().shift(1).fillna(0... | [
"def",
"_additive_estimate",
"(",
"events",
",",
"timeline",
",",
"_additive_f",
",",
"_additive_var",
",",
"reverse",
")",
":",
"if",
"reverse",
":",
"events",
"=",
"events",
".",
"sort_index",
"(",
"ascending",
"=",
"False",
")",
"at_risk",
"=",
"events",
... | Called to compute the Kaplan Meier and Nelson-Aalen estimates. | [
"Called",
"to",
"compute",
"the",
"Kaplan",
"Meier",
"and",
"Nelson",
"-",
"Aalen",
"estimates",
"."
] | python | train |
gmr/rejected | rejected/mcp.py | https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/mcp.py#L305-L328 | def kill_processes(self):
"""Gets called on shutdown by the timer when too much time has gone by,
calling the terminate method instead of nicely asking for the consumers
to stop.
"""
LOGGER.critical('Max shutdown exceeded, forcibly exiting')
processes = self.active_proce... | [
"def",
"kill_processes",
"(",
"self",
")",
":",
"LOGGER",
".",
"critical",
"(",
"'Max shutdown exceeded, forcibly exiting'",
")",
"processes",
"=",
"self",
".",
"active_processes",
"(",
"False",
")",
"while",
"processes",
":",
"for",
"proc",
"in",
"self",
".",
... | Gets called on shutdown by the timer when too much time has gone by,
calling the terminate method instead of nicely asking for the consumers
to stop. | [
"Gets",
"called",
"on",
"shutdown",
"by",
"the",
"timer",
"when",
"too",
"much",
"time",
"has",
"gone",
"by",
"calling",
"the",
"terminate",
"method",
"instead",
"of",
"nicely",
"asking",
"for",
"the",
"consumers",
"to",
"stop",
"."
] | python | train |
lxc/python2-lxc | lxc/__init__.py | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L452-L465 | def attach_run_command(cmd):
"""
Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container.
"""
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
el... | [
"def",
"attach_run_command",
"(",
"cmd",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"tuple",
")",
":",
"return",
"_lxc",
".",
"attach_run_command",
"(",
"cmd",
")",
"elif",
"isinstance",
"(",
"cmd",
",",
"list",
")",
":",
"return",
"_lxc",
".",
"at... | Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container. | [
"Run",
"a",
"command",
"when",
"attaching"
] | python | train |
SpikeInterface/spikeextractors | spikeextractors/extractors/biocamrecordingextractor/biocamrecordingextractor.py | https://github.com/SpikeInterface/spikeextractors/blob/cbe3b8778a215f0bbd743af8b306856a87e438e1/spikeextractors/extractors/biocamrecordingextractor/biocamrecordingextractor.py#L94-L143 | def openBiocamFile(filename, verbose=False):
"""Open a Biocam hdf5 file, read and return the recording info, pick te correct method to access raw data, and return this to the caller."""
rf = h5py.File(filename, 'r')
# Read recording variables
recVars = rf.require_group('3BRecInfo/3BRecVars/')
# bitD... | [
"def",
"openBiocamFile",
"(",
"filename",
",",
"verbose",
"=",
"False",
")",
":",
"rf",
"=",
"h5py",
".",
"File",
"(",
"filename",
",",
"'r'",
")",
"# Read recording variables",
"recVars",
"=",
"rf",
".",
"require_group",
"(",
"'3BRecInfo/3BRecVars/'",
")",
... | Open a Biocam hdf5 file, read and return the recording info, pick te correct method to access raw data, and return this to the caller. | [
"Open",
"a",
"Biocam",
"hdf5",
"file",
"read",
"and",
"return",
"the",
"recording",
"info",
"pick",
"te",
"correct",
"method",
"to",
"access",
"raw",
"data",
"and",
"return",
"this",
"to",
"the",
"caller",
"."
] | python | train |
silver-castle/mach9 | mach9/response.py | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/response.py#L325-L335 | def raw(body, status=200, headers=None,
content_type='application/octet-stream'):
'''
Returns response object without encoding the body.
:param body: Response data.
:param status: Response code.
:param headers: Custom Headers.
:param content_type: the content type (string) of the respons... | [
"def",
"raw",
"(",
"body",
",",
"status",
"=",
"200",
",",
"headers",
"=",
"None",
",",
"content_type",
"=",
"'application/octet-stream'",
")",
":",
"return",
"HTTPResponse",
"(",
"body_bytes",
"=",
"body",
",",
"status",
"=",
"status",
",",
"headers",
"="... | Returns response object without encoding the body.
:param body: Response data.
:param status: Response code.
:param headers: Custom Headers.
:param content_type: the content type (string) of the response. | [
"Returns",
"response",
"object",
"without",
"encoding",
"the",
"body",
".",
":",
"param",
"body",
":",
"Response",
"data",
".",
":",
"param",
"status",
":",
"Response",
"code",
".",
":",
"param",
"headers",
":",
"Custom",
"Headers",
".",
":",
"param",
"c... | python | train |
onelogin/python-saml | src/onelogin/saml2/settings.py | https://github.com/onelogin/python-saml/blob/9fe7a72da5b4caa1529c1640b52d2649447ce49b/src/onelogin/saml2/settings.py#L389-L495 | def check_sp_settings(self, settings):
"""
Checks the SP settings info.
:param settings: Dict with settings data
:type settings: dict
:returns: Errors found on the SP settings data
:rtype: list
"""
assert isinstance(settings, dict)
errors = []
... | [
"def",
"check_sp_settings",
"(",
"self",
",",
"settings",
")",
":",
"assert",
"isinstance",
"(",
"settings",
",",
"dict",
")",
"errors",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"settings",
",",
"dict",
")",
"or",
"not",
"settings",
":",
"errors",
... | Checks the SP settings info.
:param settings: Dict with settings data
:type settings: dict
:returns: Errors found on the SP settings data
:rtype: list | [
"Checks",
"the",
"SP",
"settings",
"info",
"."
] | python | train |
astropy/photutils | photutils/isophote/geometry.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/geometry.py#L275-L344 | def initialize_sector_geometry(self, phi):
"""
Initialize geometry attributes associated with an elliptical
sector at the given polar angle ``phi``.
This function computes:
* the four vertices that define the elliptical sector on the
pixel array.
* the sector ... | [
"def",
"initialize_sector_geometry",
"(",
"self",
",",
"phi",
")",
":",
"# These polar radii bound the region between the inner",
"# and outer ellipses that define the sector.",
"sma1",
",",
"sma2",
"=",
"self",
".",
"bounding_ellipses",
"(",
")",
"eps_",
"=",
"1.",
"-",
... | Initialize geometry attributes associated with an elliptical
sector at the given polar angle ``phi``.
This function computes:
* the four vertices that define the elliptical sector on the
pixel array.
* the sector area (saved in the ``sector_area`` attribute)
* the sec... | [
"Initialize",
"geometry",
"attributes",
"associated",
"with",
"an",
"elliptical",
"sector",
"at",
"the",
"given",
"polar",
"angle",
"phi",
"."
] | python | train |
sighingnow/parsec.py | src/parsec/__init__.py | https://github.com/sighingnow/parsec.py/blob/ed50e1e259142757470b925f8d20dfe5ad223af0/src/parsec/__init__.py#L231-L243 | def mark(self):
'''Mark the line and column information of the result of this parser.'''
def pos(text, index):
return ParseError.loc_info(text, index)
@Parser
def mark_parser(text, index):
res = self(text, index)
if res.status:
return ... | [
"def",
"mark",
"(",
"self",
")",
":",
"def",
"pos",
"(",
"text",
",",
"index",
")",
":",
"return",
"ParseError",
".",
"loc_info",
"(",
"text",
",",
"index",
")",
"@",
"Parser",
"def",
"mark_parser",
"(",
"text",
",",
"index",
")",
":",
"res",
"=",
... | Mark the line and column information of the result of this parser. | [
"Mark",
"the",
"line",
"and",
"column",
"information",
"of",
"the",
"result",
"of",
"this",
"parser",
"."
] | python | train |
senaite/senaite.core | bika/lims/browser/srtemplate/artemplates.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/srtemplate/artemplates.py#L141-L169 | def _buildFromPerPartition(self, item, partition):
"""
This function will get the partition info and then it'll write the container and preservation data
to the dictionary 'item'
:param item: a dict which contains the ARTeplate data columns
:param partition: a dict with some part... | [
"def",
"_buildFromPerPartition",
"(",
"self",
",",
"item",
",",
"partition",
")",
":",
"uc",
"=",
"getToolByName",
"(",
"self",
",",
"'uid_catalog'",
")",
"container",
"=",
"uc",
"(",
"UID",
"=",
"partition",
".",
"get",
"(",
"'container_uid'",
",",
"''",
... | This function will get the partition info and then it'll write the container and preservation data
to the dictionary 'item'
:param item: a dict which contains the ARTeplate data columns
:param partition: a dict with some partition info
:returns: the item dict with the partition's data | [
"This",
"function",
"will",
"get",
"the",
"partition",
"info",
"and",
"then",
"it",
"ll",
"write",
"the",
"container",
"and",
"preservation",
"data",
"to",
"the",
"dictionary",
"item",
":",
"param",
"item",
":",
"a",
"dict",
"which",
"contains",
"the",
"AR... | python | train |
randomir/plucky | plucky/structural.py | https://github.com/randomir/plucky/blob/16b7b59aa19d619d8e619dc15dc7eeffc9fe078a/plucky/structural.py#L99-L107 | def _filtered_list(self, selector):
"""Iterate over `self.obj` list, extracting `selector` from each
element. The `selector` can be a simple integer index, or any valid
key (hashable object).
"""
res = []
for elem in self.obj:
self._append(elem, selector, res)... | [
"def",
"_filtered_list",
"(",
"self",
",",
"selector",
")",
":",
"res",
"=",
"[",
"]",
"for",
"elem",
"in",
"self",
".",
"obj",
":",
"self",
".",
"_append",
"(",
"elem",
",",
"selector",
",",
"res",
")",
"return",
"res"
] | Iterate over `self.obj` list, extracting `selector` from each
element. The `selector` can be a simple integer index, or any valid
key (hashable object). | [
"Iterate",
"over",
"self",
".",
"obj",
"list",
"extracting",
"selector",
"from",
"each",
"element",
".",
"The",
"selector",
"can",
"be",
"a",
"simple",
"integer",
"index",
"or",
"any",
"valid",
"key",
"(",
"hashable",
"object",
")",
"."
] | python | train |
tropo/tropo-webapi-python | build/lib/tropo.py | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L654-L664 | def getInterpretation(self):
"""
Get the value of the previously POSTed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[0]
else:
dict = actions
return dict['interpretation'] | [
"def",
"getInterpretation",
"(",
"self",
")",
":",
"actions",
"=",
"self",
".",
"_actions",
"if",
"(",
"type",
"(",
"actions",
")",
"is",
"list",
")",
":",
"dict",
"=",
"actions",
"[",
"0",
"]",
"else",
":",
"dict",
"=",
"actions",
"return",
"dict",
... | Get the value of the previously POSTed Tropo action. | [
"Get",
"the",
"value",
"of",
"the",
"previously",
"POSTed",
"Tropo",
"action",
"."
] | python | train |
jayclassless/tidypy | src/tidypy/progress.py | https://github.com/jayclassless/tidypy/blob/3c3497ca377fbbe937103b77b02b326c860c748f/src/tidypy/progress.py#L41-L52 | def on_tool_finish(self, tool):
"""
Called when an individual tool completes execution.
:param tool: the name of the tool that completed
:type tool: str
"""
with self._lock:
if tool in self.current_tools:
self.current_tools.remove(tool)
... | [
"def",
"on_tool_finish",
"(",
"self",
",",
"tool",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"tool",
"in",
"self",
".",
"current_tools",
":",
"self",
".",
"current_tools",
".",
"remove",
"(",
"tool",
")",
"self",
".",
"completed_tools",
".",
"... | Called when an individual tool completes execution.
:param tool: the name of the tool that completed
:type tool: str | [
"Called",
"when",
"an",
"individual",
"tool",
"completes",
"execution",
"."
] | python | valid |
Duke-GCB/DukeDSClient | ddsc/core/ddsapi.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/ddsapi.py#L620-L635 | def get_users(self, full_name=None, email=None, username=None):
"""
Send GET request to /users for users with optional full_name, email, and/or username filtering.
:param full_name: str name of the user we are searching for
:param email: str: optional email to filter by
:param us... | [
"def",
"get_users",
"(",
"self",
",",
"full_name",
"=",
"None",
",",
"email",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"data",
"=",
"{",
"}",
"if",
"full_name",
":",
"data",
"[",
"'full_name_contains'",
"]",
"=",
"full_name",
"if",
"email",... | Send GET request to /users for users with optional full_name, email, and/or username filtering.
:param full_name: str name of the user we are searching for
:param email: str: optional email to filter by
:param username: str: optional username to filter by
:return: requests.Response conta... | [
"Send",
"GET",
"request",
"to",
"/",
"users",
"for",
"users",
"with",
"optional",
"full_name",
"email",
"and",
"/",
"or",
"username",
"filtering",
".",
":",
"param",
"full_name",
":",
"str",
"name",
"of",
"the",
"user",
"we",
"are",
"searching",
"for",
"... | python | train |
Miserlou/SoundScrape | soundscrape/soundscrape.py | https://github.com/Miserlou/SoundScrape/blob/efc63b99ce7e78b352e2ba22d5e51f83445546d7/soundscrape/soundscrape.py#L654-L703 | def get_bandcamp_metadata(url):
"""
Read information from the Bandcamp JavaScript object.
The method may return a list of URLs (indicating this is probably a "main" page which links to one or more albums),
or a JSON if we can already parse album/track info from the given url.
The JSON is "sloppy". T... | [
"def",
"get_bandcamp_metadata",
"(",
"url",
")",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"try",
":",
"sloppy_json",
"=",
"request",
".",
"text",
".",
"split",
"(",
"\"var TralbumData = \"",
")",
"sloppy_json",
"=",
"sloppy_json",
"[",
... | Read information from the Bandcamp JavaScript object.
The method may return a list of URLs (indicating this is probably a "main" page which links to one or more albums),
or a JSON if we can already parse album/track info from the given url.
The JSON is "sloppy". The native python JSON parser often can't dea... | [
"Read",
"information",
"from",
"the",
"Bandcamp",
"JavaScript",
"object",
".",
"The",
"method",
"may",
"return",
"a",
"list",
"of",
"URLs",
"(",
"indicating",
"this",
"is",
"probably",
"a",
"main",
"page",
"which",
"links",
"to",
"one",
"or",
"more",
"albu... | python | train |
teaearlgraycold/puni | puni/decorators.py | https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/decorators.py#L21-L46 | def update_cache(func):
"""Decorate functions that modify the internally stored usernotes JSON.
Ensures that updates are mirrored onto reddit.
Arguments:
func: the function being decorated
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
"""The wrapper function."""
... | [
"def",
"update_cache",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"The wrapper function.\"\"\"",
"lazy",
"=",
"kwargs",
".",
"get",
"(",
"'lazy'",
","... | Decorate functions that modify the internally stored usernotes JSON.
Ensures that updates are mirrored onto reddit.
Arguments:
func: the function being decorated | [
"Decorate",
"functions",
"that",
"modify",
"the",
"internally",
"stored",
"usernotes",
"JSON",
"."
] | python | train |
lappis-unb/salic-ml | src/salicml/metrics/base.py | https://github.com/lappis-unb/salic-ml/blob/1b3ebc4f8067740999897ccffd9892dc94482a93/src/salicml/metrics/base.py#L5-L11 | def get_info(df, group, info=['mean', 'std']):
"""
Aggregate mean and std with the given group.
"""
agg = df.groupby(group).agg(info)
agg.columns = agg.columns.droplevel(0)
return agg | [
"def",
"get_info",
"(",
"df",
",",
"group",
",",
"info",
"=",
"[",
"'mean'",
",",
"'std'",
"]",
")",
":",
"agg",
"=",
"df",
".",
"groupby",
"(",
"group",
")",
".",
"agg",
"(",
"info",
")",
"agg",
".",
"columns",
"=",
"agg",
".",
"columns",
".",... | Aggregate mean and std with the given group. | [
"Aggregate",
"mean",
"and",
"std",
"with",
"the",
"given",
"group",
"."
] | python | train |
urbn/Caesium | caesium/handler.py | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L167-L180 | def arg_as_array(self, arg, split_char="|"):
"""Turns an argument into an array, split by the splitChar
:param str arg: The name of the query param you want to turn into an array based on the value
:param str split_char: The character the value should be split on.
:returns: A list of va... | [
"def",
"arg_as_array",
"(",
"self",
",",
"arg",
",",
"split_char",
"=",
"\"|\"",
")",
":",
"valuesString",
"=",
"self",
".",
"get_argument",
"(",
"arg",
",",
"default",
"=",
"None",
")",
"if",
"valuesString",
":",
"valuesArray",
"=",
"valuesString",
".",
... | Turns an argument into an array, split by the splitChar
:param str arg: The name of the query param you want to turn into an array based on the value
:param str split_char: The character the value should be split on.
:returns: A list of values
:rtype: list | [
"Turns",
"an",
"argument",
"into",
"an",
"array",
"split",
"by",
"the",
"splitChar"
] | python | train |
juicer/juicer | juicer/utils/__init__.py | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L270-L281 | def flatten(x):
"""
Flatten an arbitrary depth nested list.
"""
# Lifted from: http://stackoverflow.com/a/406822/263969
result = []
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(flatten(el))
else:
result.append(e... | [
"def",
"flatten",
"(",
"x",
")",
":",
"# Lifted from: http://stackoverflow.com/a/406822/263969",
"result",
"=",
"[",
"]",
"for",
"el",
"in",
"x",
":",
"if",
"hasattr",
"(",
"el",
",",
"\"__iter__\"",
")",
"and",
"not",
"isinstance",
"(",
"el",
",",
"basestri... | Flatten an arbitrary depth nested list. | [
"Flatten",
"an",
"arbitrary",
"depth",
"nested",
"list",
"."
] | python | train |
apache/airflow | airflow/contrib/hooks/qubole_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L164-L190 | def get_results(self, ti=None, fp=None, inline=True, delim=None, fetch=True):
"""
Get results (or just s3 locations) of a command from Qubole and save into a file
:param ti: Task Instance of the dag, used to determine the Quboles command id
:param fp: Optional file pointer, will create o... | [
"def",
"get_results",
"(",
"self",
",",
"ti",
"=",
"None",
",",
"fp",
"=",
"None",
",",
"inline",
"=",
"True",
",",
"delim",
"=",
"None",
",",
"fetch",
"=",
"True",
")",
":",
"if",
"fp",
"is",
"None",
":",
"iso",
"=",
"datetime",
".",
"datetime",... | Get results (or just s3 locations) of a command from Qubole and save into a file
:param ti: Task Instance of the dag, used to determine the Quboles command id
:param fp: Optional file pointer, will create one and return if None passed
:param inline: True to download actual results, False to get ... | [
"Get",
"results",
"(",
"or",
"just",
"s3",
"locations",
")",
"of",
"a",
"command",
"from",
"Qubole",
"and",
"save",
"into",
"a",
"file",
":",
"param",
"ti",
":",
"Task",
"Instance",
"of",
"the",
"dag",
"used",
"to",
"determine",
"the",
"Quboles",
"comm... | python | test |
fossasia/knittingpattern | knittingpattern/Loader.py | https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/Loader.py#L122-L136 | def relative_file(self, module, file):
"""Load a file relative to a module.
:param str module: can be
- a path to a folder
- a path to a file
- a module name
:param str folder: the path of a folder relative to :paramref:`module`
:return: the result of the... | [
"def",
"relative_file",
"(",
"self",
",",
"module",
",",
"file",
")",
":",
"path",
"=",
"self",
".",
"_relative_to_absolute",
"(",
"module",
",",
"file",
")",
"return",
"self",
".",
"path",
"(",
"path",
")"
] | Load a file relative to a module.
:param str module: can be
- a path to a folder
- a path to a file
- a module name
:param str folder: the path of a folder relative to :paramref:`module`
:return: the result of the processing | [
"Load",
"a",
"file",
"relative",
"to",
"a",
"module",
"."
] | python | valid |
GetmeUK/MongoFrames | snippets/comparable.py | https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/snippets/comparable.py#L73-L82 | def is_diff(self):
"""Return True if there are any differences logged"""
if not isinstance(self.details, dict):
return False
for key in ['additions', 'updates', 'deletions']:
if self.details.get(key, None):
return True
return False | [
"def",
"is_diff",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"details",
",",
"dict",
")",
":",
"return",
"False",
"for",
"key",
"in",
"[",
"'additions'",
",",
"'updates'",
",",
"'deletions'",
"]",
":",
"if",
"self",
".",
"det... | Return True if there are any differences logged | [
"Return",
"True",
"if",
"there",
"are",
"any",
"differences",
"logged"
] | python | train |
ingolemo/python-lenses | examples/robots.py | https://github.com/ingolemo/python-lenses/blob/a3a6ed0a31f6674451e542e7380a8aa16e6f8edf/examples/robots.py#L113-L125 | def advance_robots(self):
'''Produces a new game state in which the robots have advanced
towards the player by one step. Handles the robots crashing into
one another too.'''
# move the robots towards the player
self = lens.robots.Each().call_step_towards(self.player)(self)
... | [
"def",
"advance_robots",
"(",
"self",
")",
":",
"# move the robots towards the player",
"self",
"=",
"lens",
".",
"robots",
".",
"Each",
"(",
")",
".",
"call_step_towards",
"(",
"self",
".",
"player",
")",
"(",
"self",
")",
"# robots in the same place are crashes"... | Produces a new game state in which the robots have advanced
towards the player by one step. Handles the robots crashing into
one another too. | [
"Produces",
"a",
"new",
"game",
"state",
"in",
"which",
"the",
"robots",
"have",
"advanced",
"towards",
"the",
"player",
"by",
"one",
"step",
".",
"Handles",
"the",
"robots",
"crashing",
"into",
"one",
"another",
"too",
"."
] | python | test |
MonashBI/arcana | arcana/study/base.py | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L636-L651 | def unhandled_branch(self, name):
"""
Convenient method for raising exception if a pipeline doesn't
handle a particular switch value
Parameters
----------
name : str
Name of the switch
value : str
Value of the switch which hasn't been hand... | [
"def",
"unhandled_branch",
"(",
"self",
",",
"name",
")",
":",
"raise",
"ArcanaDesignError",
"(",
"\"'{}' value of '{}' switch in {} is not handled\"",
".",
"format",
"(",
"self",
".",
"_get_parameter",
"(",
"name",
")",
",",
"name",
",",
"self",
".",
"_param_erro... | Convenient method for raising exception if a pipeline doesn't
handle a particular switch value
Parameters
----------
name : str
Name of the switch
value : str
Value of the switch which hasn't been handled | [
"Convenient",
"method",
"for",
"raising",
"exception",
"if",
"a",
"pipeline",
"doesn",
"t",
"handle",
"a",
"particular",
"switch",
"value"
] | python | train |
jbaiter/gphoto2-cffi | gphoto2cffi/gphoto2.py | https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L369-L388 | def iter_data(self, chunk_size=2**16, ftype='normal'):
""" Get an iterator that yields chunks of the file content.
:param chunk_size: Size of yielded chunks in bytes
:type chunk_size: int
:param ftype: Select 'view' on file.
:type ftype: str
:return: ... | [
"def",
"iter_data",
"(",
"self",
",",
"chunk_size",
"=",
"2",
"**",
"16",
",",
"ftype",
"=",
"'normal'",
")",
":",
"self",
".",
"_check_type_supported",
"(",
"ftype",
")",
"buf_p",
"=",
"ffi",
".",
"new",
"(",
"\"char[{0}]\"",
".",
"format",
"(",
"chun... | Get an iterator that yields chunks of the file content.
:param chunk_size: Size of yielded chunks in bytes
:type chunk_size: int
:param ftype: Select 'view' on file.
:type ftype: str
:return: Iterator | [
"Get",
"an",
"iterator",
"that",
"yields",
"chunks",
"of",
"the",
"file",
"content",
"."
] | python | train |
pedrotgn/pyactor | pyactor/context.py | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/context.py#L178-L233 | def spawn(self, aid, klass, *param, **kparam):
'''
This method creates an actor attached to this host. It will be
an instance of the class *klass* and it will be assigned an ID
that identifies it among the host.
This method can be called remotely synchronously.
:param s... | [
"def",
"spawn",
"(",
"self",
",",
"aid",
",",
"klass",
",",
"*",
"param",
",",
"*",
"*",
"kparam",
")",
":",
"if",
"param",
"is",
"None",
":",
"param",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"alive",
":",
"raise",
"HostDownError",
"(",
")",
"... | This method creates an actor attached to this host. It will be
an instance of the class *klass* and it will be assigned an ID
that identifies it among the host.
This method can be called remotely synchronously.
:param str. aid: identifier for the spawning actor. Unique within
... | [
"This",
"method",
"creates",
"an",
"actor",
"attached",
"to",
"this",
"host",
".",
"It",
"will",
"be",
"an",
"instance",
"of",
"the",
"class",
"*",
"klass",
"*",
"and",
"it",
"will",
"be",
"assigned",
"an",
"ID",
"that",
"identifies",
"it",
"among",
"t... | python | train |
luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1225-L1242 | def to_array(self):
"""
Serializes this VideoNote to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(VideoNote, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array[... | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"VideoNote",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"["... | Serializes this VideoNote to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"VideoNote",
"to",
"a",
"dictionary",
"."
] | python | train |
bambinos/bambi | bambi/models.py | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L83-L93 | def reset(self):
'''
Reset list of terms and y-variable.
'''
self.terms = OrderedDict()
self.y = None
self.backend = None
self.added_terms = []
self._added_priors = {}
self.completes = []
self.clean_data = None | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"terms",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"y",
"=",
"None",
"self",
".",
"backend",
"=",
"None",
"self",
".",
"added_terms",
"=",
"[",
"]",
"self",
".",
"_added_priors",
"=",
"{",
"}",
... | Reset list of terms and y-variable. | [
"Reset",
"list",
"of",
"terms",
"and",
"y",
"-",
"variable",
"."
] | python | train |
pantsbuild/pants | src/python/pants/java/distribution/distribution.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/java/distribution/distribution.py#L500-L534 | def _locate(self, minimum_version=None, maximum_version=None, jdk=False):
"""Finds a java distribution that meets any given constraints and returns it.
:param minimum_version: minimum jvm version to look for (eg, 1.7).
:param maximum_version: maximum jvm version to look for (eg, 1.7.9999).
:param bool ... | [
"def",
"_locate",
"(",
"self",
",",
"minimum_version",
"=",
"None",
",",
"maximum_version",
"=",
"None",
",",
"jdk",
"=",
"False",
")",
":",
"for",
"location",
"in",
"itertools",
".",
"chain",
"(",
"self",
".",
"_distribution_environment",
".",
"jvm_location... | Finds a java distribution that meets any given constraints and returns it.
:param minimum_version: minimum jvm version to look for (eg, 1.7).
:param maximum_version: maximum jvm version to look for (eg, 1.7.9999).
:param bool jdk: whether the found java distribution is required to have a jdk.
:return: ... | [
"Finds",
"a",
"java",
"distribution",
"that",
"meets",
"any",
"given",
"constraints",
"and",
"returns",
"it",
"."
] | python | train |
robhowley/nhlscrapi | nhlscrapi/games/events.py | https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/events.py#L167-L183 | def Create(event_type):
"""
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event... | [
"def",
"Create",
"(",
"event_type",
")",
":",
"if",
"event_type",
"in",
"EventType",
".",
"Name",
":",
"# unknown event type gets base class",
"if",
"EventType",
".",
"Name",
"[",
"event_type",
"]",
"==",
"Event",
".",
"__name__",
":",
"return",
"Event",
"(",
... | Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event` | [
"Factory",
"method",
"creates",
"objects",
"derived",
"from",
":",
"py",
":",
"class",
".",
"Event",
"with",
"class",
"name",
"matching",
"the",
":",
"py",
":",
"class",
".",
"EventType",
".",
":",
"param",
"event_type",
":",
"number",
"for",
"type",
"of... | python | train |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/__init__.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/__init__.py#L58-L101 | def get_plink_version():
"""Gets the Plink version from the binary.
:returns: the version of the Plink software
:rtype: str
This function uses :py:class:`subprocess.Popen` to gather the version of
the Plink binary. Since executing the software to gather the version
creates an output file, it i... | [
"def",
"get_plink_version",
"(",
")",
":",
"# Running the command",
"tmp_fn",
"=",
"None",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"as",
"tmpfile",
":",
"tmp_fn",
"=",
"tmpfile",
".",
"name",
"+",
"\"_pyGenClean\"",
"# ... | Gets the Plink version from the binary.
:returns: the version of the Plink software
:rtype: str
This function uses :py:class:`subprocess.Popen` to gather the version of
the Plink binary. Since executing the software to gather the version
creates an output file, it is deleted.
.. warning::
... | [
"Gets",
"the",
"Plink",
"version",
"from",
"the",
"binary",
"."
] | python | train |
zetaops/zengine | zengine/current.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L116-L132 | def set_message(self, title, msg, typ, url=None):
"""
Sets user notification message.
Args:
title: Msg. title
msg: Msg. text
typ: Msg. type
url: Additional URL (if exists)
Returns:
Message ID.
"""
return self.... | [
"def",
"set_message",
"(",
"self",
",",
"title",
",",
"msg",
",",
"typ",
",",
"url",
"=",
"None",
")",
":",
"return",
"self",
".",
"user",
".",
"send_notification",
"(",
"title",
"=",
"title",
",",
"message",
"=",
"msg",
",",
"typ",
"=",
"typ",
","... | Sets user notification message.
Args:
title: Msg. title
msg: Msg. text
typ: Msg. type
url: Additional URL (if exists)
Returns:
Message ID. | [
"Sets",
"user",
"notification",
"message",
"."
] | python | train |
log2timeline/dfvfs | dfvfs/helpers/source_scanner.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/helpers/source_scanner.py#L290-L303 | def LockScanNode(self, path_spec):
"""Marks a scan node as locked.
Args:
path_spec (PathSpec): path specification.
Raises:
KeyError: if the scan node does not exists.
"""
scan_node = self._scan_nodes.get(path_spec, None)
if not scan_node:
raise KeyError('Scan node does not ex... | [
"def",
"LockScanNode",
"(",
"self",
",",
"path_spec",
")",
":",
"scan_node",
"=",
"self",
".",
"_scan_nodes",
".",
"get",
"(",
"path_spec",
",",
"None",
")",
"if",
"not",
"scan_node",
":",
"raise",
"KeyError",
"(",
"'Scan node does not exist.'",
")",
"self",... | Marks a scan node as locked.
Args:
path_spec (PathSpec): path specification.
Raises:
KeyError: if the scan node does not exists. | [
"Marks",
"a",
"scan",
"node",
"as",
"locked",
"."
] | python | train |
datadesk/python-documentcloud | documentcloud/__init__.py | https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L866-L876 | def get_small_image_url(self, page=1):
"""
Returns the URL for the small sized image of a single page.
The page kwarg specifies which page to return. One is the default.
"""
template = self.resources.page.get('image')
return template.replace(
"{page}",
... | [
"def",
"get_small_image_url",
"(",
"self",
",",
"page",
"=",
"1",
")",
":",
"template",
"=",
"self",
".",
"resources",
".",
"page",
".",
"get",
"(",
"'image'",
")",
"return",
"template",
".",
"replace",
"(",
"\"{page}\"",
",",
"str",
"(",
"page",
")",
... | Returns the URL for the small sized image of a single page.
The page kwarg specifies which page to return. One is the default. | [
"Returns",
"the",
"URL",
"for",
"the",
"small",
"sized",
"image",
"of",
"a",
"single",
"page",
"."
] | python | train |
wangwenpei/fantasy | fantasy/utils.py | https://github.com/wangwenpei/fantasy/blob/0fe92059bd868f14da84235beb05b217b1d46e4a/fantasy/utils.py#L14-L26 | def get_config(app, prefix='hive_'):
"""Conveniently get the security configuration for the specified
application without the annoying 'SECURITY_' prefix.
:param app: The application to inspect
"""
items = app.config.items()
prefix = prefix.upper()
def strip_prefix(tup):
return (tu... | [
"def",
"get_config",
"(",
"app",
",",
"prefix",
"=",
"'hive_'",
")",
":",
"items",
"=",
"app",
".",
"config",
".",
"items",
"(",
")",
"prefix",
"=",
"prefix",
".",
"upper",
"(",
")",
"def",
"strip_prefix",
"(",
"tup",
")",
":",
"return",
"(",
"tup"... | Conveniently get the security configuration for the specified
application without the annoying 'SECURITY_' prefix.
:param app: The application to inspect | [
"Conveniently",
"get",
"the",
"security",
"configuration",
"for",
"the",
"specified",
"application",
"without",
"the",
"annoying",
"SECURITY_",
"prefix",
"."
] | python | test |
saltstack/salt | salt/modules/azurearm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L155-L199 | def default_security_rule_get(name, security_group, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Get details about a default security rule within a security group.
:param name: The name of the security rule to query.
:param security_group: The network security group containing the
... | [
"def",
"default_security_rule_get",
"(",
"name",
",",
"security_group",
",",
"resource_group",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"{",
"}",
"default_rules",
"=",
"default_security_rules_list",
"(",
"security_group",
"=",
"security_group",
",",
"reso... | .. versionadded:: 2019.2.0
Get details about a default security rule within a security group.
:param name: The name of the security rule to query.
:param security_group: The network security group containing the
security rule.
:param resource_group: The resource group name assigned to the
... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
CivicSpleen/ambry | ambry/metadata/proptree.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/metadata/proptree.py#L304-L317 | def register_members(self):
"""Collect the names of the class member and convert them to object
members.
Unlike Terms, the Group class members are converted into object
members, so the configuration data
"""
self._members = {
name: attr for name, attr in it... | [
"def",
"register_members",
"(",
"self",
")",
":",
"self",
".",
"_members",
"=",
"{",
"name",
":",
"attr",
"for",
"name",
",",
"attr",
"in",
"iteritems",
"(",
"type",
"(",
"self",
")",
".",
"__dict__",
")",
"if",
"isinstance",
"(",
"attr",
",",
"Group... | Collect the names of the class member and convert them to object
members.
Unlike Terms, the Group class members are converted into object
members, so the configuration data | [
"Collect",
"the",
"names",
"of",
"the",
"class",
"member",
"and",
"convert",
"them",
"to",
"object",
"members",
"."
] | python | train |
latchset/custodia | src/custodia/server/__init__.py | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/server/__init__.py#L34-L57 | def _load_plugin_class(menu, name):
"""Load Custodia plugin
Entry points are preferred over dotted import path.
"""
group = 'custodia.{}'.format(menu)
eps = list(pkg_resources.iter_entry_points(group, name))
if len(eps) > 1:
raise ValueError(
"Multiple entry points for {} {}... | [
"def",
"_load_plugin_class",
"(",
"menu",
",",
"name",
")",
":",
"group",
"=",
"'custodia.{}'",
".",
"format",
"(",
"menu",
")",
"eps",
"=",
"list",
"(",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
",",
"name",
")",
")",
"if",
"len",
"(",
... | Load Custodia plugin
Entry points are preferred over dotted import path. | [
"Load",
"Custodia",
"plugin"
] | python | train |
jonathanslenders/textfsm | jtextfsm.py | https://github.com/jonathanslenders/textfsm/blob/cca5084512d14bc367205aceb34c938ac1c65daf/jtextfsm.py#L251-L291 | def Parse(self, value):
"""Parse a 'Value' declaration.
Args:
value: String line from a template file, must begin with 'Value '.
Raises:
TextFSMTemplateError: Value declaration contains an error.
"""
value_line = value.split(' ')
if len(value_line) < 3:
raise TextFSMTemplat... | [
"def",
"Parse",
"(",
"self",
",",
"value",
")",
":",
"value_line",
"=",
"value",
".",
"split",
"(",
"' '",
")",
"if",
"len",
"(",
"value_line",
")",
"<",
"3",
":",
"raise",
"TextFSMTemplateError",
"(",
"'Expect at least 3 tokens on line.'",
")",
"if",
"not... | Parse a 'Value' declaration.
Args:
value: String line from a template file, must begin with 'Value '.
Raises:
TextFSMTemplateError: Value declaration contains an error. | [
"Parse",
"a",
"Value",
"declaration",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/transformer_nat.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_nat.py#L31-L48 | def init_vq_bottleneck(bottleneck_size, hidden_size):
"""Get lookup table for VQ bottleneck."""
means = tf.get_variable(
name="means",
shape=[bottleneck_size, hidden_size],
initializer=tf.uniform_unit_scaling_initializer())
ema_count = tf.get_variable(
name="ema_count",
shape=[bottle... | [
"def",
"init_vq_bottleneck",
"(",
"bottleneck_size",
",",
"hidden_size",
")",
":",
"means",
"=",
"tf",
".",
"get_variable",
"(",
"name",
"=",
"\"means\"",
",",
"shape",
"=",
"[",
"bottleneck_size",
",",
"hidden_size",
"]",
",",
"initializer",
"=",
"tf",
".",... | Get lookup table for VQ bottleneck. | [
"Get",
"lookup",
"table",
"for",
"VQ",
"bottleneck",
"."
] | python | train |
widdowquinn/pyADHoRe | pyadhore/iadhore.py | https://github.com/widdowquinn/pyADHoRe/blob/b2ebbf6ae9c6afe9262eb0e3d9cf395970e38533/pyadhore/iadhore.py#L333-L336 | def db_file(self, value):
""" Setter for _db_file attribute """
assert not os.path.isfile(value), "%s already exists" % value
self._db_file = value | [
"def",
"db_file",
"(",
"self",
",",
"value",
")",
":",
"assert",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"value",
")",
",",
"\"%s already exists\"",
"%",
"value",
"self",
".",
"_db_file",
"=",
"value"
] | Setter for _db_file attribute | [
"Setter",
"for",
"_db_file",
"attribute"
] | python | train |
StyXman/ayrton | ayrton/parser/error.py | https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/error.py#L14-L17 | def strerror(errno):
"""Translate an error code to a message string."""
from pypy.module._codecs.locale import str_decode_locale_surrogateescape
return str_decode_locale_surrogateescape(os.strerror(errno)) | [
"def",
"strerror",
"(",
"errno",
")",
":",
"from",
"pypy",
".",
"module",
".",
"_codecs",
".",
"locale",
"import",
"str_decode_locale_surrogateescape",
"return",
"str_decode_locale_surrogateescape",
"(",
"os",
".",
"strerror",
"(",
"errno",
")",
")"
] | Translate an error code to a message string. | [
"Translate",
"an",
"error",
"code",
"to",
"a",
"message",
"string",
"."
] | python | train |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L154-L175 | def open(self):
"""
Open a connection to an IOS-XR device.
Connects to the device using SSH and drops into XML mode.
"""
try:
self.device = ConnectHandler(device_type='cisco_xr',
ip=self.hostname,
... | [
"def",
"open",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"device",
"=",
"ConnectHandler",
"(",
"device_type",
"=",
"'cisco_xr'",
",",
"ip",
"=",
"self",
".",
"hostname",
",",
"port",
"=",
"self",
".",
"port",
",",
"username",
"=",
"self",
".",
... | Open a connection to an IOS-XR device.
Connects to the device using SSH and drops into XML mode. | [
"Open",
"a",
"connection",
"to",
"an",
"IOS",
"-",
"XR",
"device",
"."
] | python | train |
hsolbrig/PyShEx | pyshex/sparql11_query/p17_1_operand_data_types.py | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/sparql11_query/p17_1_operand_data_types.py#L20-L22 | def is_simple_literal(n: Node) -> bool:
""" simple literal denotes a plain literal with no language tag. """
return is_typed_literal(n) and cast(Literal, n).datatype is None and cast(Literal, n).language is None | [
"def",
"is_simple_literal",
"(",
"n",
":",
"Node",
")",
"->",
"bool",
":",
"return",
"is_typed_literal",
"(",
"n",
")",
"and",
"cast",
"(",
"Literal",
",",
"n",
")",
".",
"datatype",
"is",
"None",
"and",
"cast",
"(",
"Literal",
",",
"n",
")",
".",
... | simple literal denotes a plain literal with no language tag. | [
"simple",
"literal",
"denotes",
"a",
"plain",
"literal",
"with",
"no",
"language",
"tag",
"."
] | python | train |
buriburisuri/sugartensor | sugartensor/sg_logging.py | https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_logging.py#L59-L78 | def sg_summary_gradient(tensor, gradient, prefix=None, name=None):
r"""Register `tensor` to summary report as `gradient`
Args:
tensor: A `Tensor` to log as gradient
gradient: A 0-D `Tensor`. A gradient to log
prefix: A `string`. A prefix to display in the tensor board web UI.
name: A `s... | [
"def",
"sg_summary_gradient",
"(",
"tensor",
",",
"gradient",
",",
"prefix",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# defaults",
"prefix",
"=",
"''",
"if",
"prefix",
"is",
"None",
"else",
"prefix",
"+",
"'/'",
"# summary name",
"name",
"=",
"p... | r"""Register `tensor` to summary report as `gradient`
Args:
tensor: A `Tensor` to log as gradient
gradient: A 0-D `Tensor`. A gradient to log
prefix: A `string`. A prefix to display in the tensor board web UI.
name: A `string`. A name to display in the tensor board web UI.
Returns:
... | [
"r",
"Register",
"tensor",
"to",
"summary",
"report",
"as",
"gradient"
] | python | train |
nickstenning/tagalog | tagalog/shipper.py | https://github.com/nickstenning/tagalog/blob/c6847a957dc4f96836a5cf13c4eb664fccafaac2/tagalog/shipper.py#L136-L145 | def purge(self, connection):
"""Remove the connection from rotation"""
self._checkpid()
if connection.pid == self.pid:
idx = connection._pattern_idx
if connection in self._in_use_connections[idx]:
self._in_use_connections[idx].remove(connection)
... | [
"def",
"purge",
"(",
"self",
",",
"connection",
")",
":",
"self",
".",
"_checkpid",
"(",
")",
"if",
"connection",
".",
"pid",
"==",
"self",
".",
"pid",
":",
"idx",
"=",
"connection",
".",
"_pattern_idx",
"if",
"connection",
"in",
"self",
".",
"_in_use_... | Remove the connection from rotation | [
"Remove",
"the",
"connection",
"from",
"rotation"
] | python | train |
apache/spark | python/pyspark/mllib/linalg/distributed.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L811-L828 | def entries(self):
"""
Entries of the CoordinateMatrix stored as an RDD of
MatrixEntries.
>>> mat = CoordinateMatrix(sc.parallelize([MatrixEntry(0, 0, 1.2),
... MatrixEntry(6, 4, 2.1)]))
>>> entries = mat.entries
>>> entries... | [
"def",
"entries",
"(",
"self",
")",
":",
"# We use DataFrames for serialization of MatrixEntry entries",
"# from Java, so we first convert the RDD of entries to a",
"# DataFrame on the Scala/Java side. Then we map each Row in",
"# the DataFrame back to a MatrixEntry on this side.",
"entries_df",... | Entries of the CoordinateMatrix stored as an RDD of
MatrixEntries.
>>> mat = CoordinateMatrix(sc.parallelize([MatrixEntry(0, 0, 1.2),
... MatrixEntry(6, 4, 2.1)]))
>>> entries = mat.entries
>>> entries.first()
MatrixEntry(0, 0, 1.2) | [
"Entries",
"of",
"the",
"CoordinateMatrix",
"stored",
"as",
"an",
"RDD",
"of",
"MatrixEntries",
"."
] | python | train |
scivision/sciencedates | sciencedates/findnearest.py | https://github.com/scivision/sciencedates/blob/a713389e027b42d26875cf227450a5d7c6696000/sciencedates/findnearest.py#L6-L42 | def find_nearest(x, x0) -> Tuple[int, Any]:
"""
This find_nearest function does NOT assume sorted input
inputs:
x: array (float, int, datetime, h5py.Dataset) within which to search for x0
x0: singleton or array of values to search for in x
outputs:
idx: index of flattened x nearest to x0 ... | [
"def",
"find_nearest",
"(",
"x",
",",
"x0",
")",
"->",
"Tuple",
"[",
"int",
",",
"Any",
"]",
":",
"x",
"=",
"np",
".",
"asanyarray",
"(",
"x",
")",
"# for indexing upon return",
"x0",
"=",
"np",
".",
"atleast_1d",
"(",
"x0",
")",
"# %%",
"if",
"x",... | This find_nearest function does NOT assume sorted input
inputs:
x: array (float, int, datetime, h5py.Dataset) within which to search for x0
x0: singleton or array of values to search for in x
outputs:
idx: index of flattened x nearest to x0 (i.e. works with higher than 1-D arrays also)
xidx: ... | [
"This",
"find_nearest",
"function",
"does",
"NOT",
"assume",
"sorted",
"input"
] | python | train |
libtcod/python-tcod | build_libtcod.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/build_libtcod.py#L145-L157 | def fix_header(filepath):
"""Removes leading whitespace from a MacOS header file.
This whitespace is causing issues with directives on some platforms.
"""
with open(filepath, "r+") as f:
current = f.read()
fixed = "\n".join(line.strip() for line in current.split("\n"))
if curren... | [
"def",
"fix_header",
"(",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"\"r+\"",
")",
"as",
"f",
":",
"current",
"=",
"f",
".",
"read",
"(",
")",
"fixed",
"=",
"\"\\n\"",
".",
"join",
"(",
"line",
".",
"strip",
"(",
")",
"for",
"li... | Removes leading whitespace from a MacOS header file.
This whitespace is causing issues with directives on some platforms. | [
"Removes",
"leading",
"whitespace",
"from",
"a",
"MacOS",
"header",
"file",
"."
] | python | train |
Xion/taipan | taipan/strings.py | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/strings.py#L188-L245 | def join(delimiter, iterable, **kwargs):
"""Returns a string which is a concatenation of strings in ``iterable``,
separated by given ``delimiter``.
:param delimiter: Delimiter to put between strings
:param iterable: Iterable to join
Optional keyword arguments control the exact joining strategy:
... | [
"def",
"join",
"(",
"delimiter",
",",
"iterable",
",",
"*",
"*",
"kwargs",
")",
":",
"ensure_string",
"(",
"delimiter",
")",
"ensure_iterable",
"(",
"iterable",
")",
"ensure_keyword_args",
"(",
"kwargs",
",",
"optional",
"=",
"(",
"'errors'",
",",
"'with_'",... | Returns a string which is a concatenation of strings in ``iterable``,
separated by given ``delimiter``.
:param delimiter: Delimiter to put between strings
:param iterable: Iterable to join
Optional keyword arguments control the exact joining strategy:
:param errors:
What to do with errone... | [
"Returns",
"a",
"string",
"which",
"is",
"a",
"concatenation",
"of",
"strings",
"in",
"iterable",
"separated",
"by",
"given",
"delimiter",
"."
] | python | train |
FulcrumTechnologies/pyconfluence | pyconfluence/actions.py | https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/actions.py#L281-L294 | def delete_page_full(id):
"""Delete a page from Confluence, along with its children.
Parameters:
- id: id of a Confluence page.
Notes:
- Getting a 204 error is expected! It means the page can no longer be found.
"""
children = _json.loads(get_page_children(id))
for i in children["resul... | [
"def",
"delete_page_full",
"(",
"id",
")",
":",
"children",
"=",
"_json",
".",
"loads",
"(",
"get_page_children",
"(",
"id",
")",
")",
"for",
"i",
"in",
"children",
"[",
"\"results\"",
"]",
":",
"delete_page_full",
"(",
"i",
"[",
"\"id\"",
"]",
")",
"r... | Delete a page from Confluence, along with its children.
Parameters:
- id: id of a Confluence page.
Notes:
- Getting a 204 error is expected! It means the page can no longer be found. | [
"Delete",
"a",
"page",
"from",
"Confluence",
"along",
"with",
"its",
"children",
".",
"Parameters",
":",
"-",
"id",
":",
"id",
"of",
"a",
"Confluence",
"page",
".",
"Notes",
":",
"-",
"Getting",
"a",
"204",
"error",
"is",
"expected!",
"It",
"means",
"t... | python | train |
pygobject/pgi | pgi/overrides/Gtk.py | https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2178-L2193 | def get_selected(self):
"""
:returns:
:model: the :obj:`Gtk.TreeModel`
:iter: The :obj:`Gtk.TreeIter` or :obj:`None`
:rtype: (**model**: :obj:`Gtk.TreeModel`, **iter**: :obj:`Gtk.TreeIter` or :obj:`None`)
{{ docs }}
"""
success, model, aiter = s... | [
"def",
"get_selected",
"(",
"self",
")",
":",
"success",
",",
"model",
",",
"aiter",
"=",
"super",
"(",
"TreeSelection",
",",
"self",
")",
".",
"get_selected",
"(",
")",
"if",
"success",
":",
"return",
"(",
"model",
",",
"aiter",
")",
"else",
":",
"r... | :returns:
:model: the :obj:`Gtk.TreeModel`
:iter: The :obj:`Gtk.TreeIter` or :obj:`None`
:rtype: (**model**: :obj:`Gtk.TreeModel`, **iter**: :obj:`Gtk.TreeIter` or :obj:`None`)
{{ docs }} | [
":",
"returns",
":",
":",
"model",
":",
"the",
":",
"obj",
":",
"Gtk",
".",
"TreeModel",
":",
"iter",
":",
"The",
":",
"obj",
":",
"Gtk",
".",
"TreeIter",
"or",
":",
"obj",
":",
"None"
] | python | train |
cocoakekeyu/cancan | cancan/ability.py | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L37-L41 | def addnot(self, action=None, subject=None, **conditions):
"""
Defines an ability which cannot be done.
"""
self.add_rule(Rule(False, action, subject, **conditions)) | [
"def",
"addnot",
"(",
"self",
",",
"action",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"*",
"*",
"conditions",
")",
":",
"self",
".",
"add_rule",
"(",
"Rule",
"(",
"False",
",",
"action",
",",
"subject",
",",
"*",
"*",
"conditions",
")",
")"
] | Defines an ability which cannot be done. | [
"Defines",
"an",
"ability",
"which",
"cannot",
"be",
"done",
"."
] | python | train |
NASA-AMMOS/AIT-Core | ait/core/table.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L593-L596 | def add (self, defn):
"""Adds the given Command Definition to this Command Dictionary."""
self[defn.name] = defn
self.colnames[defn.name] = defn | [
"def",
"add",
"(",
"self",
",",
"defn",
")",
":",
"self",
"[",
"defn",
".",
"name",
"]",
"=",
"defn",
"self",
".",
"colnames",
"[",
"defn",
".",
"name",
"]",
"=",
"defn"
] | Adds the given Command Definition to this Command Dictionary. | [
"Adds",
"the",
"given",
"Command",
"Definition",
"to",
"this",
"Command",
"Dictionary",
"."
] | python | train |
globality-corp/microcosm | microcosm/loaders/environment.py | https://github.com/globality-corp/microcosm/blob/6856200ca295da4269c8c1c9de7db0b97c1f4523/microcosm/loaders/environment.py#L13-L43 | def _load_from_environ(metadata, value_func=None):
"""
Load configuration from environment variables.
Any environment variable prefixed with the metadata's name will be
used to recursively set dictionary keys, splitting on '__'.
:param value_func: a mutator for the envvar's value (if any)
"""... | [
"def",
"_load_from_environ",
"(",
"metadata",
",",
"value_func",
"=",
"None",
")",
":",
"# We'll match the ennvar name against the metadata's name. The ennvar",
"# name must be uppercase and hyphens in names converted to underscores.",
"#",
"# | envar | name | matches? |",
"# +-... | Load configuration from environment variables.
Any environment variable prefixed with the metadata's name will be
used to recursively set dictionary keys, splitting on '__'.
:param value_func: a mutator for the envvar's value (if any) | [
"Load",
"configuration",
"from",
"environment",
"variables",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.