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 |
|---|---|---|---|---|---|---|---|---|
tensorflow/tensor2tensor | tensor2tensor/data_generators/multi_problem_v2.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem_v2.py#L183-L197 | def generate_data_with_shared_vocab(self, data_dir, tmp_dir, task_id=-1):
"""Generates TF-Records for problems using a global vocabulary file."""
global_vocab_filename = os.path.join(data_dir, self.vocab_filename)
if not tf.gfile.Exists(global_vocab_filename):
raise ValueError(
'Global vocab... | [
"def",
"generate_data_with_shared_vocab",
"(",
"self",
",",
"data_dir",
",",
"tmp_dir",
",",
"task_id",
"=",
"-",
"1",
")",
":",
"global_vocab_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"self",
".",
"vocab_filename",
")",
"if",
"... | Generates TF-Records for problems using a global vocabulary file. | [
"Generates",
"TF",
"-",
"Records",
"for",
"problems",
"using",
"a",
"global",
"vocabulary",
"file",
"."
] | python | train |
Yelp/venv-update | pip_faster.py | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L230-L241 | def pip_get_installed():
"""Code extracted from the middle of the pip freeze command.
FIXME: does not list anything installed via -e
"""
from pip._internal.utils.misc import dist_is_local
return tuple(
dist_to_req(dist)
for dist in fresh_working_set()
if dist_is_local(dist)
... | [
"def",
"pip_get_installed",
"(",
")",
":",
"from",
"pip",
".",
"_internal",
".",
"utils",
".",
"misc",
"import",
"dist_is_local",
"return",
"tuple",
"(",
"dist_to_req",
"(",
"dist",
")",
"for",
"dist",
"in",
"fresh_working_set",
"(",
")",
"if",
"dist_is_loca... | Code extracted from the middle of the pip freeze command.
FIXME: does not list anything installed via -e | [
"Code",
"extracted",
"from",
"the",
"middle",
"of",
"the",
"pip",
"freeze",
"command",
".",
"FIXME",
":",
"does",
"not",
"list",
"anything",
"installed",
"via",
"-",
"e"
] | python | train |
stuaxo/vext | vext/cmdline/__init__.py | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L32-L63 | def do_enable():
"""
Uncomment any lines that start with #import in the .pth file
"""
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if line.startswith('#') and line[1:].lstrip().startswith('import '):
_line... | [
"def",
"do_enable",
"(",
")",
":",
"try",
":",
"_lines",
"=",
"[",
"]",
"with",
"open",
"(",
"vext_pth",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
"if",
"line",
".",
"startswith",
"... | Uncomment any lines that start with #import in the .pth file | [
"Uncomment",
"any",
"lines",
"that",
"start",
"with",
"#import",
"in",
"the",
".",
"pth",
"file"
] | python | train |
DeepHorizons/iarm | iarm_kernel/iarmkernel.py | https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L183-L215 | def magic_memory(self, line):
"""
Print out the current value of memory
Usage:
Pass in the byte of memory to read, separated by spaced
A list of memory contents can be entered by separating them by a hyphen
`%mem 4 5`
or
`%mem 8-12`
"""
#... | [
"def",
"magic_memory",
"(",
"self",
",",
"line",
")",
":",
"# TODO add support for directives",
"message",
"=",
"\"\"",
"for",
"address",
"in",
"[",
"i",
".",
"strip",
"(",
")",
"for",
"i",
"in",
"line",
".",
"replace",
"(",
"','",
",",
"''",
")",
".",... | Print out the current value of memory
Usage:
Pass in the byte of memory to read, separated by spaced
A list of memory contents can be entered by separating them by a hyphen
`%mem 4 5`
or
`%mem 8-12` | [
"Print",
"out",
"the",
"current",
"value",
"of",
"memory"
] | python | train |
mabuchilab/QNET | src/qnet/algebra/core/super_operator_algebra.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/super_operator_algebra.py#L351-L367 | def anti_commutator(A, B=None):
"""If ``B != None``, return the anti-commutator :math:`\{A,B\}`, otherwise
return the super-operator :math:`\{A,\cdot\}`. The super-operator
:math:`\{A,\cdot\}` maps any other operator ``B`` to the anti-commutator
:math:`\{A, B\} = A B + B A`.
Args:
A: The f... | [
"def",
"anti_commutator",
"(",
"A",
",",
"B",
"=",
"None",
")",
":",
"if",
"B",
":",
"return",
"A",
"*",
"B",
"+",
"B",
"*",
"A",
"return",
"SPre",
"(",
"A",
")",
"+",
"SPost",
"(",
"A",
")"
] | If ``B != None``, return the anti-commutator :math:`\{A,B\}`, otherwise
return the super-operator :math:`\{A,\cdot\}`. The super-operator
:math:`\{A,\cdot\}` maps any other operator ``B`` to the anti-commutator
:math:`\{A, B\} = A B + B A`.
Args:
A: The first operator to form all anti-commutat... | [
"If",
"B",
"!",
"=",
"None",
"return",
"the",
"anti",
"-",
"commutator",
":",
"math",
":",
"\\",
"{",
"A",
"B",
"\\",
"}",
"otherwise",
"return",
"the",
"super",
"-",
"operator",
":",
"math",
":",
"\\",
"{",
"A",
"\\",
"cdot",
"\\",
"}",
".",
"... | python | train |
RedHatInsights/insights-core | insights/client/config.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/config.py#L456-L491 | def _load_command_line(self, conf_only=False):
'''
Load config from command line switches.
NOTE: Not all config is available on the command line.
'''
# did we already parse cli (i.e. to get conf file)? don't run twice
if self._cli_opts:
self._update_dict(self.... | [
"def",
"_load_command_line",
"(",
"self",
",",
"conf_only",
"=",
"False",
")",
":",
"# did we already parse cli (i.e. to get conf file)? don't run twice",
"if",
"self",
".",
"_cli_opts",
":",
"self",
".",
"_update_dict",
"(",
"self",
".",
"_cli_opts",
")",
"return",
... | Load config from command line switches.
NOTE: Not all config is available on the command line. | [
"Load",
"config",
"from",
"command",
"line",
"switches",
".",
"NOTE",
":",
"Not",
"all",
"config",
"is",
"available",
"on",
"the",
"command",
"line",
"."
] | python | train |
csparpa/pyowm | pyowm/weatherapi25/historian.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/historian.py#L58-L67 | def humidity_series(self):
"""Returns the humidity time series relative to the meteostation, in
the form of a list of tuples, each one containing the couple
timestamp-value
:returns: a list of tuples
"""
return [(tstamp, \
self._station_history.get_measur... | [
"def",
"humidity_series",
"(",
"self",
")",
":",
"return",
"[",
"(",
"tstamp",
",",
"self",
".",
"_station_history",
".",
"get_measurements",
"(",
")",
"[",
"tstamp",
"]",
"[",
"'humidity'",
"]",
")",
"for",
"tstamp",
"in",
"self",
".",
"_station_history",... | Returns the humidity time series relative to the meteostation, in
the form of a list of tuples, each one containing the couple
timestamp-value
:returns: a list of tuples | [
"Returns",
"the",
"humidity",
"time",
"series",
"relative",
"to",
"the",
"meteostation",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"tuples",
"each",
"one",
"containing",
"the",
"couple",
"timestamp",
"-",
"value"
] | python | train |
saltstack/salt | salt/modules/libcloud_storage.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/libcloud_storage.py#L152-L177 | def create_container(container_name, profile, **libcloud_kwargs):
'''
Create a container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's creat... | [
"def",
"create_container",
"(",
"container_name",
",",
"profile",
",",
"*",
"*",
"libcloud_kwargs",
")",
":",
"conn",
"=",
"_get_driver",
"(",
"profile",
"=",
"profile",
")",
"libcloud_kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"("... | Create a container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's create_container method
:type libcloud_kwargs: ``dict``
CLI Example:
... | [
"Create",
"a",
"container",
"in",
"the",
"cloud"
] | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3430-L3438 | def noNsProp(self, name):
"""Search and get the value of an attribute associated to a
node This does the entity substitution. This function looks
in DTD attribute declaration for #FIXED or default
declaration values unless DTD use has been turned off. This
function is sim... | [
"def",
"noNsProp",
"(",
"self",
",",
"name",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlGetNoNsProp",
"(",
"self",
".",
"_o",
",",
"name",
")",
"return",
"ret"
] | Search and get the value of an attribute associated to a
node This does the entity substitution. This function looks
in DTD attribute declaration for #FIXED or default
declaration values unless DTD use has been turned off. This
function is similar to xmlGetProp except it will acc... | [
"Search",
"and",
"get",
"the",
"value",
"of",
"an",
"attribute",
"associated",
"to",
"a",
"node",
"This",
"does",
"the",
"entity",
"substitution",
".",
"This",
"function",
"looks",
"in",
"DTD",
"attribute",
"declaration",
"for",
"#FIXED",
"or",
"default",
"d... | python | train |
shoeffner/pandoc-source-exec | pandoc_source_exec.py | https://github.com/shoeffner/pandoc-source-exec/blob/9a13b9054d629a60b63196a906fafe2673722d13/pandoc_source_exec.py#L60-L85 | def execute_code_block(elem, doc):
"""Executes a code block by passing it to the executor.
Args:
elem The AST element.
doc The document.
Returns:
The output of the command.
"""
command = select_executor(elem, doc).split(' ')
code = elem.text
if 'plt' in elem.attrib... | [
"def",
"execute_code_block",
"(",
"elem",
",",
"doc",
")",
":",
"command",
"=",
"select_executor",
"(",
"elem",
",",
"doc",
")",
".",
"split",
"(",
"' '",
")",
"code",
"=",
"elem",
".",
"text",
"if",
"'plt'",
"in",
"elem",
".",
"attributes",
"or",
"'... | Executes a code block by passing it to the executor.
Args:
elem The AST element.
doc The document.
Returns:
The output of the command. | [
"Executes",
"a",
"code",
"block",
"by",
"passing",
"it",
"to",
"the",
"executor",
"."
] | python | train |
Othernet-Project/hwd | hwd/network.py | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/network.py#L58-L67 | def _get_ipv6addrs(self):
"""
Returns the IPv6 addresses associated with this NIC. If no IPv6
addresses are used, empty dict is returned.
"""
addrs = self._get_addrs()
ipv6addrs = addrs.get(netifaces.AF_INET6)
if not ipv6addrs:
return {}
return... | [
"def",
"_get_ipv6addrs",
"(",
"self",
")",
":",
"addrs",
"=",
"self",
".",
"_get_addrs",
"(",
")",
"ipv6addrs",
"=",
"addrs",
".",
"get",
"(",
"netifaces",
".",
"AF_INET6",
")",
"if",
"not",
"ipv6addrs",
":",
"return",
"{",
"}",
"return",
"ipv6addrs",
... | Returns the IPv6 addresses associated with this NIC. If no IPv6
addresses are used, empty dict is returned. | [
"Returns",
"the",
"IPv6",
"addresses",
"associated",
"with",
"this",
"NIC",
".",
"If",
"no",
"IPv6",
"addresses",
"are",
"used",
"empty",
"dict",
"is",
"returned",
"."
] | python | train |
jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L35-L53 | def create_proxy_model(name, model_mixins, base_model, attrs=None, module=None):
"""
Create a Django Proxy Model on the fly, to be used by any Cascade Plugin.
"""
from django.apps import apps
class Meta:
proxy = True
app_label = 'cmsplugin_cascade'
name = str(name + 'Model')
... | [
"def",
"create_proxy_model",
"(",
"name",
",",
"model_mixins",
",",
"base_model",
",",
"attrs",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"from",
"django",
".",
"apps",
"import",
"apps",
"class",
"Meta",
":",
"proxy",
"=",
"True",
"app_label",
"... | Create a Django Proxy Model on the fly, to be used by any Cascade Plugin. | [
"Create",
"a",
"Django",
"Proxy",
"Model",
"on",
"the",
"fly",
"to",
"be",
"used",
"by",
"any",
"Cascade",
"Plugin",
"."
] | python | train |
globality-corp/microcosm | microcosm/loaders/keys.py | https://github.com/globality-corp/microcosm/blob/6856200ca295da4269c8c1c9de7db0b97c1f4523/microcosm/loaders/keys.py#L7-L37 | def expand_config(dct,
separator='.',
skip_to=0,
key_func=lambda key: key.lower(),
key_parts_filter=lambda key_parts: True,
value_func=lambda value: value):
"""
Expand a dictionary recursively by splitting keys along the s... | [
"def",
"expand_config",
"(",
"dct",
",",
"separator",
"=",
"'.'",
",",
"skip_to",
"=",
"0",
",",
"key_func",
"=",
"lambda",
"key",
":",
"key",
".",
"lower",
"(",
")",
",",
"key_parts_filter",
"=",
"lambda",
"key_parts",
":",
"True",
",",
"value_func",
... | Expand a dictionary recursively by splitting keys along the separator.
:param dct: a non-recursive dictionary
:param separator: a separator charactor for splitting dictionary keys
:param skip_to: index to start splitting keys on; can be used to skip over a key prefix
:param key_func: a key mapping func... | [
"Expand",
"a",
"dictionary",
"recursively",
"by",
"splitting",
"keys",
"along",
"the",
"separator",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py#L201-L213 | def snmp_server_user_ipv6_acl(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
snmp_server = ET.SubElement(config, "snmp-server", xmlns="urn:brocade.com:mgmt:brocade-snmp")
user = ET.SubElement(snmp_server, "user")
username_key = ET.SubElement(use... | [
"def",
"snmp_server_user_ipv6_acl",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"snmp_server",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"snmp-server\"",
",",
"xmlns",
"=",
"\"urn:b... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
pkgw/pwkit | pwkit/cli/latexdriver.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/latexdriver.py#L105-L123 | def write_bibtex_dict(stream, entries):
"""bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand.
"""
from bibtexparser.bwriter import BibTexWriter
writer = BibTexWriter()
wr... | [
"def",
"write_bibtex_dict",
"(",
"stream",
",",
"entries",
")",
":",
"from",
"bibtexparser",
".",
"bwriter",
"import",
"BibTexWriter",
"writer",
"=",
"BibTexWriter",
"(",
")",
"writer",
".",
"indent",
"=",
"' '",
"writer",
".",
"entry_separator",
"=",
"''",
... | bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand. | [
"bibtexparser",
".",
"write",
"converts",
"the",
"entire",
"database",
"to",
"one",
"big",
"string",
"and",
"writes",
"it",
"out",
"in",
"one",
"go",
".",
"I",
"m",
"sure",
"it",
"will",
"always",
"all",
"fit",
"in",
"RAM",
"but",
"some",
"things",
"ju... | python | train |
materialsproject/pymatgen | pymatgen/analysis/adsorption.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/adsorption.py#L503-L564 | def generate_substitution_structures(self, atom, target_species=[],
sub_both_sides=False, range_tol=1e-2,
dist_from_surf=0):
"""
Function that performs substitution-type doping on the surface and
returns all po... | [
"def",
"generate_substitution_structures",
"(",
"self",
",",
"atom",
",",
"target_species",
"=",
"[",
"]",
",",
"sub_both_sides",
"=",
"False",
",",
"range_tol",
"=",
"1e-2",
",",
"dist_from_surf",
"=",
"0",
")",
":",
"# Get symmetrized structure in case we want to ... | Function that performs substitution-type doping on the surface and
returns all possible configurations where one dopant is substituted
per surface. Can substitute one surface or both.
Args:
atom (str): atom corresponding to substitutional dopant
sub_both_sides (b... | [
"Function",
"that",
"performs",
"substitution",
"-",
"type",
"doping",
"on",
"the",
"surface",
"and",
"returns",
"all",
"possible",
"configurations",
"where",
"one",
"dopant",
"is",
"substituted",
"per",
"surface",
".",
"Can",
"substitute",
"one",
"surface",
"or... | python | train |
duointeractive/sea-cucumber | seacucumber/backend.py | https://github.com/duointeractive/sea-cucumber/blob/069637e2cbab561116e23b6723cfc30e779fce03/seacucumber/backend.py#L18-L42 | def send_messages(self, email_messages):
"""
Sends one or more EmailMessage objects and returns the number of
email messages sent.
:param EmailMessage email_messages: A list of Django's EmailMessage
object instances.
:rtype: int
:returns: The number of EmailM... | [
"def",
"send_messages",
"(",
"self",
",",
"email_messages",
")",
":",
"queue",
"=",
"getattr",
"(",
"settings",
",",
"'CUCUMBER_ROUTE_QUEUE'",
",",
"''",
")",
"num_sent",
"=",
"0",
"for",
"message",
"in",
"email_messages",
":",
"# Hand this off to a celery task.",... | Sends one or more EmailMessage objects and returns the number of
email messages sent.
:param EmailMessage email_messages: A list of Django's EmailMessage
object instances.
:rtype: int
:returns: The number of EmailMessage objects that were successfully
queued up. ... | [
"Sends",
"one",
"or",
"more",
"EmailMessage",
"objects",
"and",
"returns",
"the",
"number",
"of",
"email",
"messages",
"sent",
"."
] | python | train |
unt-libraries/codalib | codalib/bagatom.py | https://github.com/unt-libraries/codalib/blob/458d117bb48938c1a0e26d9161cb5f730461b4c7/codalib/bagatom.py#L71-L84 | def getOxum(dataPath):
"""
Calculate the oxum for a given path
"""
fileCount = 0L
fileSizeTotal = 0L
for root, dirs, files in os.walk(dataPath):
for fileName in files:
fullName = os.path.join(root, fileName)
stats = os.stat(fullName)
fileSizeTotal += ... | [
"def",
"getOxum",
"(",
"dataPath",
")",
":",
"fileCount",
"=",
"0L",
"fileSizeTotal",
"=",
"0L",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"dataPath",
")",
":",
"for",
"fileName",
"in",
"files",
":",
"fullName",
"=",
"os... | Calculate the oxum for a given path | [
"Calculate",
"the",
"oxum",
"for",
"a",
"given",
"path"
] | python | train |
taizilongxu/douban.fm | doubanfm/controller/manager_controller.py | https://github.com/taizilongxu/douban.fm/blob/d65126d3bd3e12d8a7109137caff8da0efc22b2f/doubanfm/controller/manager_controller.py#L29-L37 | def run(self, switch_queue):
"""
每个controller需要提供run方法, 来提供启动
"""
self.switch_queue = switch_queue
self.quit = False
Thread(target=self._watchdog_queue).start()
Thread(target=self._watchdog_time).start() | [
"def",
"run",
"(",
"self",
",",
"switch_queue",
")",
":",
"self",
".",
"switch_queue",
"=",
"switch_queue",
"self",
".",
"quit",
"=",
"False",
"Thread",
"(",
"target",
"=",
"self",
".",
"_watchdog_queue",
")",
".",
"start",
"(",
")",
"Thread",
"(",
"ta... | 每个controller需要提供run方法, 来提供启动 | [
"每个controller需要提供run方法",
"来提供启动"
] | python | train |
inveniosoftware/invenio-communities | invenio_communities/permissions.py | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/permissions.py#L46-L49 | def can(self):
"""Grant permission if owner or admin."""
return str(current_user.get_id()) == str(self.community.id_user) or \
DynamicPermission(ActionNeed('admin-access')).can() | [
"def",
"can",
"(",
"self",
")",
":",
"return",
"str",
"(",
"current_user",
".",
"get_id",
"(",
")",
")",
"==",
"str",
"(",
"self",
".",
"community",
".",
"id_user",
")",
"or",
"DynamicPermission",
"(",
"ActionNeed",
"(",
"'admin-access'",
")",
")",
"."... | Grant permission if owner or admin. | [
"Grant",
"permission",
"if",
"owner",
"or",
"admin",
"."
] | python | train |
MisterY/asset-allocation | asset_allocation/app.py | https://github.com/MisterY/asset-allocation/blob/72239aa20762cda67c091f27b86e65d61bf3b613/asset_allocation/app.py#L26-L39 | def add_stock_to_class(self, assetclass_id: int, symbol: str):
""" Add a stock link to an asset class """
assert isinstance(symbol, str)
assert isinstance(assetclass_id, int)
item = AssetClassStock()
item.assetclassid = assetclass_id
item.symbol = symbol
session... | [
"def",
"add_stock_to_class",
"(",
"self",
",",
"assetclass_id",
":",
"int",
",",
"symbol",
":",
"str",
")",
":",
"assert",
"isinstance",
"(",
"symbol",
",",
"str",
")",
"assert",
"isinstance",
"(",
"assetclass_id",
",",
"int",
")",
"item",
"=",
"AssetClass... | Add a stock link to an asset class | [
"Add",
"a",
"stock",
"link",
"to",
"an",
"asset",
"class"
] | python | train |
DeV1doR/aioethereum | aioethereum/management/eth.py | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/eth.py#L550-L575 | def eth_newFilter(self, from_block=BLOCK_TAG_LATEST,
to_block=BLOCK_TAG_LATEST, address=None, topics=None):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
:param from_block: Block tag or number (optional)
:type from_block: int or BLOCK_TAGS
:param... | [
"def",
"eth_newFilter",
"(",
"self",
",",
"from_block",
"=",
"BLOCK_TAG_LATEST",
",",
"to_block",
"=",
"BLOCK_TAG_LATEST",
",",
"address",
"=",
"None",
",",
"topics",
"=",
"None",
")",
":",
"obj",
"=",
"{",
"'fromBlock'",
":",
"validate_block",
"(",
"from_bl... | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
:param from_block: Block tag or number (optional)
:type from_block: int or BLOCK_TAGS
:param to_block: Block tag or number (optional)
:type to_block: int or BLOCK_TAGS
:param address: Contract address (optional)
... | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#eth_newfilter"
] | python | train |
prompt-toolkit/pymux | pymux/commands/completer.py | https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/commands/completer.py#L135-L182 | def parse(cls, text):
"""
Parse the given text. Returns a tuple:
(list_of_parts, start_pos_of_the_last_part).
"""
OUTSIDE, IN_DOUBLE, IN_SINGLE = 0, 1, 2
iterator = enumerate(text)
state = OUTSIDE
parts = []
current_part = ''
part_start_po... | [
"def",
"parse",
"(",
"cls",
",",
"text",
")",
":",
"OUTSIDE",
",",
"IN_DOUBLE",
",",
"IN_SINGLE",
"=",
"0",
",",
"1",
",",
"2",
"iterator",
"=",
"enumerate",
"(",
"text",
")",
"state",
"=",
"OUTSIDE",
"parts",
"=",
"[",
"]",
"current_part",
"=",
"'... | Parse the given text. Returns a tuple:
(list_of_parts, start_pos_of_the_last_part). | [
"Parse",
"the",
"given",
"text",
".",
"Returns",
"a",
"tuple",
":",
"(",
"list_of_parts",
"start_pos_of_the_last_part",
")",
"."
] | python | train |
rflamary/POT | ot/stochastic.py | https://github.com/rflamary/POT/blob/c5108efc7b6702e1af3928bef1032e6b37734d1c/ot/stochastic.py#L550-L642 | def sgd_entropic_regularization(a, b, M, reg, batch_size, numItermax, lr):
'''
Compute the sgd algorithm to solve the regularized discrete measures
optimal transport dual problem
The function solves the following optimization problem:
.. math::
\gamma = arg\min_\gamma <\gamma,M>_F + re... | [
"def",
"sgd_entropic_regularization",
"(",
"a",
",",
"b",
",",
"M",
",",
"reg",
",",
"batch_size",
",",
"numItermax",
",",
"lr",
")",
":",
"n_source",
"=",
"np",
".",
"shape",
"(",
"M",
")",
"[",
"0",
"]",
"n_target",
"=",
"np",
".",
"shape",
"(",
... | Compute the sgd algorithm to solve the regularized discrete measures
optimal transport dual problem
The function solves the following optimization problem:
.. math::
\gamma = arg\min_\gamma <\gamma,M>_F + reg\cdot\Omega(\gamma)
s.t. \gamma 1 = a
\gamma^T 1= b
... | [
"Compute",
"the",
"sgd",
"algorithm",
"to",
"solve",
"the",
"regularized",
"discrete",
"measures",
"optimal",
"transport",
"dual",
"problem"
] | python | train |
draperjames/qtpandas | qtpandas/models/DataFrameModel.py | https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/models/DataFrameModel.py#L36-L47 | def read_file(filepath, **kwargs):
"""
Read a data file into a DataFrameModel.
:param filepath: The rows/columns filepath to read.
:param kwargs:
xls/x files - see pandas.read_excel(**kwargs)
.csv/.txt/etc - see pandas.read_csv(**kwargs)
:return: DataFrameModel
"""
r... | [
"def",
"read_file",
"(",
"filepath",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DataFrameModel",
"(",
"dataFrame",
"=",
"superReadFile",
"(",
"filepath",
",",
"*",
"*",
"kwargs",
")",
",",
"filePath",
"=",
"filepath",
")"
] | Read a data file into a DataFrameModel.
:param filepath: The rows/columns filepath to read.
:param kwargs:
xls/x files - see pandas.read_excel(**kwargs)
.csv/.txt/etc - see pandas.read_csv(**kwargs)
:return: DataFrameModel | [
"Read",
"a",
"data",
"file",
"into",
"a",
"DataFrameModel",
"."
] | python | train |
soravux/scoop | scoop/broker/brokerzmq.py | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/broker/brokerzmq.py#L173-L182 | def processConfig(self, worker_config):
"""Update the pool configuration with a worker configuration.
"""
self.config['headless'] |= worker_config.get("headless", False)
if self.config['headless']:
# Launch discovery process
if not self.discovery_thread:
... | [
"def",
"processConfig",
"(",
"self",
",",
"worker_config",
")",
":",
"self",
".",
"config",
"[",
"'headless'",
"]",
"|=",
"worker_config",
".",
"get",
"(",
"\"headless\"",
",",
"False",
")",
"if",
"self",
".",
"config",
"[",
"'headless'",
"]",
":",
"# La... | Update the pool configuration with a worker configuration. | [
"Update",
"the",
"pool",
"configuration",
"with",
"a",
"worker",
"configuration",
"."
] | python | train |
django-danceschool/django-danceschool | danceschool/core/mixins.py | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L446-L457 | def get_ordering(self, reverseTime=False):
'''
This method provides the tuple for ordering of querysets. However, this will only
work if the annotations generated by the get_annotations() method above have been
added to the queryset. Otherwise, the use of this ordering tuple will f... | [
"def",
"get_ordering",
"(",
"self",
",",
"reverseTime",
"=",
"False",
")",
":",
"# Reverse ordering can be optionally specified in the view class definition.\r",
"reverseTime",
"=",
"getattr",
"(",
"self",
",",
"'reverse_time_ordering'",
",",
"reverseTime",
")",
"timeParame... | This method provides the tuple for ordering of querysets. However, this will only
work if the annotations generated by the get_annotations() method above have been
added to the queryset. Otherwise, the use of this ordering tuple will fail because
the appropriate column names will not exist ... | [
"This",
"method",
"provides",
"the",
"tuple",
"for",
"ordering",
"of",
"querysets",
".",
"However",
"this",
"will",
"only",
"work",
"if",
"the",
"annotations",
"generated",
"by",
"the",
"get_annotations",
"()",
"method",
"above",
"have",
"been",
"added",
"to",... | python | train |
saltstack/salt | salt/modules/boto_s3.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3.py#L135-L169 | def upload_file(
source,
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
... | [
"def",
"upload_file",
"(",
"source",
",",
"name",
",",
"extra_args",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
")",
":",
"bucket",
",",
"_",
",",
"s3_key",
"=",
... | Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
my_bucket/path/to/object \\
region=us-east-1 \\
key=key \\
... | [
"Upload",
"a",
"local",
"file",
"as",
"an",
"S3",
"object",
"."
] | python | train |
stevelittlefish/littlefish | littlefish/pager.py | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/pager.py#L171-L179 | def last_item_number(self):
"""
:return: The last "item number", used when displaying messages to the user
like "Displaying items 1 to 10 of 123" - in this example 10 would be returned
"""
n = self.first_item_number + self.page_size - 1
if n > self.total_items:
... | [
"def",
"last_item_number",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"first_item_number",
"+",
"self",
".",
"page_size",
"-",
"1",
"if",
"n",
">",
"self",
".",
"total_items",
":",
"return",
"self",
".",
"total_items",
"return",
"n"
] | :return: The last "item number", used when displaying messages to the user
like "Displaying items 1 to 10 of 123" - in this example 10 would be returned | [
":",
"return",
":",
"The",
"last",
"item",
"number",
"used",
"when",
"displaying",
"messages",
"to",
"the",
"user",
"like",
"Displaying",
"items",
"1",
"to",
"10",
"of",
"123",
"-",
"in",
"this",
"example",
"10",
"would",
"be",
"returned"
] | python | test |
CiscoTestAutomation/yang | ncdiff/src/yang/ncdiff/model.py | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/ncdiff/src/yang/ncdiff/model.py#L940-L970 | def process_attrib(element, msg):
'''process_attrib
High-level api: Delete four attributes from an ElementTree node if they
exist: operation, insert, value and key. Then a new attribute 'diff' is
added.
Parameters
----------
element : `Element`
A no... | [
"def",
"process_attrib",
"(",
"element",
",",
"msg",
")",
":",
"attrib_required",
"=",
"[",
"'type'",
",",
"'access'",
",",
"'mandatory'",
"]",
"for",
"node",
"in",
"element",
".",
"iter",
"(",
")",
":",
"for",
"attrib",
"in",
"node",
".",
"attrib",
".... | process_attrib
High-level api: Delete four attributes from an ElementTree node if they
exist: operation, insert, value and key. Then a new attribute 'diff' is
added.
Parameters
----------
element : `Element`
A node needs to be looked at.
msg : `str... | [
"process_attrib"
] | python | train |
boriel/zxbasic | zxbparser.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L196-L208 | def make_builtin(lineno, fname, operands, func=None, type_=None):
""" Wrapper: returns a Builtin function node.
Can be a Symbol, tuple or list of Symbols
If operand is an iterable, they will be expanded.
"""
if operands is None:
operands = []
assert isinstance(operands, Symbol) or isinst... | [
"def",
"make_builtin",
"(",
"lineno",
",",
"fname",
",",
"operands",
",",
"func",
"=",
"None",
",",
"type_",
"=",
"None",
")",
":",
"if",
"operands",
"is",
"None",
":",
"operands",
"=",
"[",
"]",
"assert",
"isinstance",
"(",
"operands",
",",
"Symbol",
... | Wrapper: returns a Builtin function node.
Can be a Symbol, tuple or list of Symbols
If operand is an iterable, they will be expanded. | [
"Wrapper",
":",
"returns",
"a",
"Builtin",
"function",
"node",
".",
"Can",
"be",
"a",
"Symbol",
"tuple",
"or",
"list",
"of",
"Symbols",
"If",
"operand",
"is",
"an",
"iterable",
"they",
"will",
"be",
"expanded",
"."
] | python | train |
molmod/molmod | molmod/minimizer.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/minimizer.py#L820-L835 | def get_header(self):
"""Returns the header for screen logging of the minimization"""
result = " "
if self.step_rms is not None:
result += " Step RMS"
if self.step_max is not None:
result += " Step MAX"
if self.grad_rms is not None:
resul... | [
"def",
"get_header",
"(",
"self",
")",
":",
"result",
"=",
"\" \"",
"if",
"self",
".",
"step_rms",
"is",
"not",
"None",
":",
"result",
"+=",
"\" Step RMS\"",
"if",
"self",
".",
"step_max",
"is",
"not",
"None",
":",
"result",
"+=",
"\" Step MAX\"",
... | Returns the header for screen logging of the minimization | [
"Returns",
"the",
"header",
"for",
"screen",
"logging",
"of",
"the",
"minimization"
] | python | train |
stevearc/dynamo3 | dynamo3/fields.py | https://github.com/stevearc/dynamo3/blob/f897c40ece28586272dbcab8f0d99a14a1831dda/dynamo3/fields.py#L174-L176 | def all(cls, name, hash_key, range_key=None, throughput=None):
""" Create an index that projects all attributes """
return cls(cls.ALL, name, hash_key, range_key, throughput=throughput) | [
"def",
"all",
"(",
"cls",
",",
"name",
",",
"hash_key",
",",
"range_key",
"=",
"None",
",",
"throughput",
"=",
"None",
")",
":",
"return",
"cls",
"(",
"cls",
".",
"ALL",
",",
"name",
",",
"hash_key",
",",
"range_key",
",",
"throughput",
"=",
"through... | Create an index that projects all attributes | [
"Create",
"an",
"index",
"that",
"projects",
"all",
"attributes"
] | python | train |
PyCQA/pylint | pylint/config.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/config.py#L240-L250 | def _validate(value, optdict, name=""):
"""return a validated value for an option according to its type
optional argument name is only used for error message formatting
"""
try:
_type = optdict["type"]
except KeyError:
# FIXME
return value
return _call_validator(_type, o... | [
"def",
"_validate",
"(",
"value",
",",
"optdict",
",",
"name",
"=",
"\"\"",
")",
":",
"try",
":",
"_type",
"=",
"optdict",
"[",
"\"type\"",
"]",
"except",
"KeyError",
":",
"# FIXME",
"return",
"value",
"return",
"_call_validator",
"(",
"_type",
",",
"opt... | return a validated value for an option according to its type
optional argument name is only used for error message formatting | [
"return",
"a",
"validated",
"value",
"for",
"an",
"option",
"according",
"to",
"its",
"type"
] | python | test |
rosenbrockc/fortpy | fortpy/scripts/analyze.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L185-L202 | def _redirect_split(self, args):
"""Determines whether the specified shell args have a redirect specification for
the output. Returns a tuple of (usable args, filename, append).
"""
if ">>" in args:
append = True
usable, filename = args.split(">>")
elif ">... | [
"def",
"_redirect_split",
"(",
"self",
",",
"args",
")",
":",
"if",
"\">>\"",
"in",
"args",
":",
"append",
"=",
"True",
"usable",
",",
"filename",
"=",
"args",
".",
"split",
"(",
"\">>\"",
")",
"elif",
"\">\"",
"in",
"args",
":",
"append",
"=",
"Fals... | Determines whether the specified shell args have a redirect specification for
the output. Returns a tuple of (usable args, filename, append). | [
"Determines",
"whether",
"the",
"specified",
"shell",
"args",
"have",
"a",
"redirect",
"specification",
"for",
"the",
"output",
".",
"Returns",
"a",
"tuple",
"of",
"(",
"usable",
"args",
"filename",
"append",
")",
"."
] | python | train |
ambitioninc/newrelic-api | newrelic_api/base.py | https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/base.py#L94-L112 | def _delete(self, *args, **kwargs):
"""
A wrapper for deleting things
:returns: The response of your delete
:rtype: dict
:raises: This will raise a
:class:`NewRelicAPIServerException<newrelic_api.exceptions.NewRelicAPIServerException>`
if there is an err... | [
"def",
"_delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"requests",
".",
"delete",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"response",
".",
"ok",
":",
"raise",
"NewRelicAPIServerExcept... | A wrapper for deleting things
:returns: The response of your delete
:rtype: dict
:raises: This will raise a
:class:`NewRelicAPIServerException<newrelic_api.exceptions.NewRelicAPIServerException>`
if there is an error from New Relic | [
"A",
"wrapper",
"for",
"deleting",
"things"
] | python | train |
markovmodel/PyEMMA | pyemma/coordinates/transform/vamp.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/transform/vamp.py#L264-L301 | def _diagonalize(self):
"""Performs SVD on covariance matrices and save left, right singular vectors and values in the model.
Parameters
----------
scaling : None or string, default=None
Scaling to be applied to the VAMP modes upon transformation
* None: no scali... | [
"def",
"_diagonalize",
"(",
"self",
")",
":",
"L0",
"=",
"spd_inv_split",
"(",
"self",
".",
"C00",
",",
"epsilon",
"=",
"self",
".",
"epsilon",
")",
"self",
".",
"_rank0",
"=",
"L0",
".",
"shape",
"[",
"1",
"]",
"if",
"L0",
".",
"ndim",
"==",
"2"... | Performs SVD on covariance matrices and save left, right singular vectors and values in the model.
Parameters
----------
scaling : None or string, default=None
Scaling to be applied to the VAMP modes upon transformation
* None: no scaling will be applied, variance of the... | [
"Performs",
"SVD",
"on",
"covariance",
"matrices",
"and",
"save",
"left",
"right",
"singular",
"vectors",
"and",
"values",
"in",
"the",
"model",
"."
] | python | train |
apache/incubator-heron | third_party/python/cpplint/cpplint.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L6308-L6407 | def ParseArguments(args):
"""Parses the command line arguments.
This may set the output format and verbosity level as side-effects.
Args:
args: The command line arguments:
Returns:
The list of filenames to lint.
"""
try:
(opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose... | [
"def",
"ParseArguments",
"(",
"args",
")",
":",
"try",
":",
"(",
"opts",
",",
"filenames",
")",
"=",
"getopt",
".",
"getopt",
"(",
"args",
",",
"''",
",",
"[",
"'help'",
",",
"'output='",
",",
"'verbose='",
",",
"'counting='",
",",
"'filter='",
",",
... | Parses the command line arguments.
This may set the output format and verbosity level as side-effects.
Args:
args: The command line arguments:
Returns:
The list of filenames to lint. | [
"Parses",
"the",
"command",
"line",
"arguments",
"."
] | python | valid |
allianceauth/allianceauth | allianceauth/timerboard/views.py | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/timerboard/views.py#L58-L64 | def get_form_kwargs(self):
"""
Inject the request user into the kwargs passed to the form
"""
kwargs = super(AddUpdateMixin, self).get_form_kwargs()
kwargs.update({'user': self.request.user})
return kwargs | [
"def",
"get_form_kwargs",
"(",
"self",
")",
":",
"kwargs",
"=",
"super",
"(",
"AddUpdateMixin",
",",
"self",
")",
".",
"get_form_kwargs",
"(",
")",
"kwargs",
".",
"update",
"(",
"{",
"'user'",
":",
"self",
".",
"request",
".",
"user",
"}",
")",
"return... | Inject the request user into the kwargs passed to the form | [
"Inject",
"the",
"request",
"user",
"into",
"the",
"kwargs",
"passed",
"to",
"the",
"form"
] | python | train |
StellarCN/py-stellar-base | stellar_base/operation.py | https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/operation.py#L1054-L1071 | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`ManageData`.
"""
data_name = bytearray(self.data_name, encoding='utf-8')
if self.data_value is not None:
if isinstance(self.data_value, bytes):
data_value = [byt... | [
"def",
"to_xdr_object",
"(",
"self",
")",
":",
"data_name",
"=",
"bytearray",
"(",
"self",
".",
"data_name",
",",
"encoding",
"=",
"'utf-8'",
")",
"if",
"self",
".",
"data_value",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"self",
".",
"data_valu... | Creates an XDR Operation object that represents this
:class:`ManageData`. | [
"Creates",
"an",
"XDR",
"Operation",
"object",
"that",
"represents",
"this",
":",
"class",
":",
"ManageData",
"."
] | python | train |
wummel/linkchecker | linkcheck/configuration/__init__.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/configuration/__init__.py#L637-L647 | def resolve_indirect (data, key, splithosts=False):
"""Replace name of environment variable with its value."""
value = data[key]
env_value = os.environ.get(value)
if env_value:
if splithosts:
data[key] = split_hosts(env_value)
else:
data[key] = env_value
else:... | [
"def",
"resolve_indirect",
"(",
"data",
",",
"key",
",",
"splithosts",
"=",
"False",
")",
":",
"value",
"=",
"data",
"[",
"key",
"]",
"env_value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"value",
")",
"if",
"env_value",
":",
"if",
"splithosts",
"... | Replace name of environment variable with its value. | [
"Replace",
"name",
"of",
"environment",
"variable",
"with",
"its",
"value",
"."
] | python | train |
cltk/cltk | cltk/utils/file_operations.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/utils/file_operations.py#L13-L27 | def make_cltk_path(*fp_list):
"""Take arbitrary number of str arguments (not list) and return expanded,
absolute path to a user's cltk_data dir.
Example:
In [8]: make_cltk_path('greek', 'model', 'greek_models_cltk')
Out[8]: '/Users/kyle/cltk_data/greek/model/greek_models_cltk'
:type fp_list: s... | [
"def",
"make_cltk_path",
"(",
"*",
"fp_list",
")",
":",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"home",
",",
"'cltk_data'",
",",
"*",
"fp_list",
")"
] | Take arbitrary number of str arguments (not list) and return expanded,
absolute path to a user's cltk_data dir.
Example:
In [8]: make_cltk_path('greek', 'model', 'greek_models_cltk')
Out[8]: '/Users/kyle/cltk_data/greek/model/greek_models_cltk'
:type fp_list: str positional arguments
:param: :... | [
"Take",
"arbitrary",
"number",
"of",
"str",
"arguments",
"(",
"not",
"list",
")",
"and",
"return",
"expanded",
"absolute",
"path",
"to",
"a",
"user",
"s",
"cltk_data",
"dir",
"."
] | python | train |
ianmiell/shutit | shutit_pexpect.py | https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L2656-L2933 | def send(self, sendspec):
"""Send string as a shell command, and wait until the expected output
is seen (either a string or any from a list of strings) before
returning. The expected string will default to the currently-set
default expected string (see get_default_shutit_pexpect_session_expect)
Returns the p... | [
"def",
"send",
"(",
"self",
",",
"sendspec",
")",
":",
"shutit",
"=",
"self",
".",
"shutit",
"shutit",
".",
"log",
"(",
"'In session: '",
"+",
"self",
".",
"pexpect_session_id",
"+",
"', trying to send: '",
"+",
"str",
"(",
"sendspec",
".",
"send",
")",
... | Send string as a shell command, and wait until the expected output
is seen (either a string or any from a list of strings) before
returning. The expected string will default to the currently-set
default expected string (see get_default_shutit_pexpect_session_expect)
Returns the pexpect return value (ie which e... | [
"Send",
"string",
"as",
"a",
"shell",
"command",
"and",
"wait",
"until",
"the",
"expected",
"output",
"is",
"seen",
"(",
"either",
"a",
"string",
"or",
"any",
"from",
"a",
"list",
"of",
"strings",
")",
"before",
"returning",
".",
"The",
"expected",
"stri... | python | train |
sony/nnabla | python/src/nnabla/utils/data_source.py | https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/utils/data_source.py#L181-L272 | def _save_cache_to_file(self):
'''
Store cache data into file.
Data will be stored as hdf5 format, placed at config..
Cache file name format is "cache_START_END.h5"
'''
if self._cache_dir is None:
raise DataSourceWithFileCacheError(
'Use this ... | [
"def",
"_save_cache_to_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cache_dir",
"is",
"None",
":",
"raise",
"DataSourceWithFileCacheError",
"(",
"'Use this class with \"with statement\" if you don\\'t specify cache dir.'",
")",
"cache_data",
"=",
"OrderedDict",
"(",
... | Store cache data into file.
Data will be stored as hdf5 format, placed at config..
Cache file name format is "cache_START_END.h5" | [
"Store",
"cache",
"data",
"into",
"file",
"."
] | python | train |
PSPC-SPAC-buyandsell/von_agent | von_agent/agent/issuer.py | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L139-L178 | async def _sync_revoc(self, rr_id: str, rr_size: int = None) -> None:
"""
Create revoc registry if need be for input revocation registry identifier;
open and cache tails file reader.
:param rr_id: revocation registry identifier
:param rr_size: if new revocation registry necessar... | [
"async",
"def",
"_sync_revoc",
"(",
"self",
",",
"rr_id",
":",
"str",
",",
"rr_size",
":",
"int",
"=",
"None",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer._sync_revoc >>> rr_id: %s, rr_size: %s'",
",",
"rr_id",
",",
"rr_size",
")",
"(",
"... | Create revoc registry if need be for input revocation registry identifier;
open and cache tails file reader.
:param rr_id: revocation registry identifier
:param rr_size: if new revocation registry necessary, its size (default as per _create_rev_reg()) | [
"Create",
"revoc",
"registry",
"if",
"need",
"be",
"for",
"input",
"revocation",
"registry",
"identifier",
";",
"open",
"and",
"cache",
"tails",
"file",
"reader",
"."
] | python | train |
BlueBrain/hpcbench | hpcbench/cli/bennett.py | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/cli/bennett.py#L19-L25 | def main(argv=None):
"""ben-nett entry point"""
arguments = cli_common(__doc__, argv=argv)
benet = BeNet(arguments['CAMPAIGN_FILE'])
benet.run()
if argv is not None:
return benet | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"arguments",
"=",
"cli_common",
"(",
"__doc__",
",",
"argv",
"=",
"argv",
")",
"benet",
"=",
"BeNet",
"(",
"arguments",
"[",
"'CAMPAIGN_FILE'",
"]",
")",
"benet",
".",
"run",
"(",
")",
"if",
"argv",
... | ben-nett entry point | [
"ben",
"-",
"nett",
"entry",
"point"
] | python | train |
bwohlberg/sporco | sporco/cnvrep.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cnvrep.py#L655-L677 | def normalise(v, dimN=2):
r"""Normalise vectors, corresponding to slices along specified number
of initial spatial dimensions of an array, to have unit
:math:`\ell_2` norm. The remaining axes enumerate the distinct
vectors to be normalised.
Parameters
----------
v : array_like
Array w... | [
"def",
"normalise",
"(",
"v",
",",
"dimN",
"=",
"2",
")",
":",
"axisN",
"=",
"tuple",
"(",
"range",
"(",
"0",
",",
"dimN",
")",
")",
"vn",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"sum",
"(",
"v",
"**",
"2",
",",
"axisN",
",",
"keepdims",
"=... | r"""Normalise vectors, corresponding to slices along specified number
of initial spatial dimensions of an array, to have unit
:math:`\ell_2` norm. The remaining axes enumerate the distinct
vectors to be normalised.
Parameters
----------
v : array_like
Array with components to be normalise... | [
"r",
"Normalise",
"vectors",
"corresponding",
"to",
"slices",
"along",
"specified",
"number",
"of",
"initial",
"spatial",
"dimensions",
"of",
"an",
"array",
"to",
"have",
"unit",
":",
"math",
":",
"\\",
"ell_2",
"norm",
".",
"The",
"remaining",
"axes",
"enum... | python | train |
Fuyukai/ConfigMaster | configmaster/ConfigFile.py | https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L81-L90 | def apply_defaults(self, other_config):
"""
Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject.
If there are any values in this object that are also in the default object, it will use the values from this object.
"""
if isinstance(other... | [
"def",
"apply_defaults",
"(",
"self",
",",
"other_config",
")",
":",
"if",
"isinstance",
"(",
"other_config",
",",
"self",
".",
"__class__",
")",
":",
"self",
".",
"config",
".",
"load_from_dict",
"(",
"other_config",
".",
"config",
",",
"overwrite",
"=",
... | Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject.
If there are any values in this object that are also in the default object, it will use the values from this object. | [
"Applies",
"default",
"values",
"from",
"a",
"different",
"ConfigObject",
"or",
"ConfigKey",
"object",
"to",
"this",
"ConfigObject",
"."
] | python | train |
google/grr | grr/server/grr_response_server/aff4.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L600-L627 | def Copy(self,
old_urn,
new_urn,
age=NEWEST_TIME,
limit=None,
update_timestamps=False):
"""Make a copy of one AFF4 object to a different URN."""
new_urn = rdfvalue.RDFURN(new_urn)
if update_timestamps and age != NEWEST_TIME:
raise ValueError(
... | [
"def",
"Copy",
"(",
"self",
",",
"old_urn",
",",
"new_urn",
",",
"age",
"=",
"NEWEST_TIME",
",",
"limit",
"=",
"None",
",",
"update_timestamps",
"=",
"False",
")",
":",
"new_urn",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"new_urn",
")",
"if",
"update_timesta... | Make a copy of one AFF4 object to a different URN. | [
"Make",
"a",
"copy",
"of",
"one",
"AFF4",
"object",
"to",
"a",
"different",
"URN",
"."
] | python | train |
tanghaibao/jcvi | jcvi/compara/synteny.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/compara/synteny.py#L379-L390 | def batch_scan(points, xdist=20, ydist=20, N=5):
"""
runs synteny_scan() per chromosome pair
"""
chr_pair_points = group_hits(points)
clusters = []
for chr_pair in sorted(chr_pair_points.keys()):
points = chr_pair_points[chr_pair]
clusters.extend(synteny_scan(points, xdist, ydis... | [
"def",
"batch_scan",
"(",
"points",
",",
"xdist",
"=",
"20",
",",
"ydist",
"=",
"20",
",",
"N",
"=",
"5",
")",
":",
"chr_pair_points",
"=",
"group_hits",
"(",
"points",
")",
"clusters",
"=",
"[",
"]",
"for",
"chr_pair",
"in",
"sorted",
"(",
"chr_pair... | runs synteny_scan() per chromosome pair | [
"runs",
"synteny_scan",
"()",
"per",
"chromosome",
"pair"
] | python | train |
LuminosoInsight/langcodes | langcodes/__init__.py | https://github.com/LuminosoInsight/langcodes/blob/0cedf9ca257ebf7250de5d3a63ec33a7d198db58/langcodes/__init__.py#L662-L727 | def describe(self, language=DEFAULT_LANGUAGE, min_score: int=75) -> dict:
"""
Return a dictionary that describes a given language tag in a specified
natural language.
See `language_name` and related methods for more specific versions of this.
The desired `language` will in fact... | [
"def",
"describe",
"(",
"self",
",",
"language",
"=",
"DEFAULT_LANGUAGE",
",",
"min_score",
":",
"int",
"=",
"75",
")",
"->",
"dict",
":",
"names",
"=",
"{",
"}",
"if",
"self",
".",
"language",
":",
"names",
"[",
"'language'",
"]",
"=",
"self",
".",
... | Return a dictionary that describes a given language tag in a specified
natural language.
See `language_name` and related methods for more specific versions of this.
The desired `language` will in fact be matched against the available
options using the matching technique that this modul... | [
"Return",
"a",
"dictionary",
"that",
"describes",
"a",
"given",
"language",
"tag",
"in",
"a",
"specified",
"natural",
"language",
"."
] | python | train |
ibis-project/ibis | ibis/impala/client.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/impala/client.py#L631-L664 | def alter(
self,
location=None,
format=None,
tbl_properties=None,
serde_properties=None,
):
"""
Change setting and parameters of the table.
Parameters
----------
location : string, optional
For partitioned tables, you may wan... | [
"def",
"alter",
"(",
"self",
",",
"location",
"=",
"None",
",",
"format",
"=",
"None",
",",
"tbl_properties",
"=",
"None",
",",
"serde_properties",
"=",
"None",
",",
")",
":",
"def",
"_run_ddl",
"(",
"*",
"*",
"kwds",
")",
":",
"stmt",
"=",
"ddl",
... | Change setting and parameters of the table.
Parameters
----------
location : string, optional
For partitioned tables, you may want the alter_partition function
format : string, optional
tbl_properties : dict, optional
serde_properties : dict, optional
... | [
"Change",
"setting",
"and",
"parameters",
"of",
"the",
"table",
"."
] | python | train |
pinax/pinax-cli | pinaxcli/cli.py | https://github.com/pinax/pinax-cli/blob/7dac21907a2ac22a0efd06054ddea56f562efbaf/pinaxcli/cli.py#L27-L30 | def list_commands(self, ctx):
"""Override for showing commands in particular order"""
commands = super(PinaxGroup, self).list_commands(ctx)
return [cmd for cmd in order_manually(commands)] | [
"def",
"list_commands",
"(",
"self",
",",
"ctx",
")",
":",
"commands",
"=",
"super",
"(",
"PinaxGroup",
",",
"self",
")",
".",
"list_commands",
"(",
"ctx",
")",
"return",
"[",
"cmd",
"for",
"cmd",
"in",
"order_manually",
"(",
"commands",
")",
"]"
] | Override for showing commands in particular order | [
"Override",
"for",
"showing",
"commands",
"in",
"particular",
"order"
] | python | train |
CyberZHG/keras-transformer | keras_transformer/transformer.py | https://github.com/CyberZHG/keras-transformer/blob/4c42baa030539c62ef5ace92df0408b13f26d928/keras_transformer/transformer.py#L95-L142 | def get_encoder_component(name,
input_layer,
head_num,
hidden_dim,
attention_activation=None,
feed_forward_activation='relu',
dropout_rate=0.0,
... | [
"def",
"get_encoder_component",
"(",
"name",
",",
"input_layer",
",",
"head_num",
",",
"hidden_dim",
",",
"attention_activation",
"=",
"None",
",",
"feed_forward_activation",
"=",
"'relu'",
",",
"dropout_rate",
"=",
"0.0",
",",
"trainable",
"=",
"True",
")",
":"... | Multi-head self-attention and feed-forward layer.
:param name: Prefix of names for internal layers.
:param input_layer: Input layer.
:param head_num: Number of heads in multi-head self-attention.
:param hidden_dim: Hidden dimension of feed forward layer.
:param attention_activation: Activation for ... | [
"Multi",
"-",
"head",
"self",
"-",
"attention",
"and",
"feed",
"-",
"forward",
"layer",
"."
] | python | train |
rwl/pylon | pylon/io/matpower.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L779-L804 | def write_bus_data(self, file):
""" Writes bus data in MATPOWER format.
"""
# labels = ["bus_id", "type", "Pd", "Qd", "Gs", "Bs", "area", "Vm", "Va",
# "baseKV", "Vmax", "Vmin"]
bus_attrs = ["_i", "type", "p_demand", "q_demand", "g_shunt","b_shunt",
"area", "v_magn... | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"# labels = [\"bus_id\", \"type\", \"Pd\", \"Qd\", \"Gs\", \"Bs\", \"area\", \"Vm\", \"Va\",",
"# \"baseKV\", \"Vmax\", \"Vmin\"]",
"bus_attrs",
"=",
"[",
"\"_i\"",
",",
"\"type\"",
",",
"\"p_demand\"",
... | Writes bus data in MATPOWER format. | [
"Writes",
"bus",
"data",
"in",
"MATPOWER",
"format",
"."
] | python | train |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L658-L674 | def get_enrollment(self, uuid, item_date):
""" Get the enrollment for the uuid when the item was done """
# item_date must be offset-naive (utc)
if item_date and item_date.tzinfo:
item_date = (item_date - item_date.utcoffset()).replace(tzinfo=None)
enrollments = self.get_enr... | [
"def",
"get_enrollment",
"(",
"self",
",",
"uuid",
",",
"item_date",
")",
":",
"# item_date must be offset-naive (utc)",
"if",
"item_date",
"and",
"item_date",
".",
"tzinfo",
":",
"item_date",
"=",
"(",
"item_date",
"-",
"item_date",
".",
"utcoffset",
"(",
")",
... | Get the enrollment for the uuid when the item was done | [
"Get",
"the",
"enrollment",
"for",
"the",
"uuid",
"when",
"the",
"item",
"was",
"done"
] | python | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L101-L129 | def start(self, *args, **kwargs):
r"""Starts the internal task in the event loop.
Parameters
------------
\*args
The arguments to to use.
\*\*kwargs
The keyword arguments to use.
Raises
--------
RuntimeError
A task has... | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_task",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Task is already launched.'",
")",
"if",
"self",
".",
"_injected",
"is",
"not",
"None... | r"""Starts the internal task in the event loop.
Parameters
------------
\*args
The arguments to to use.
\*\*kwargs
The keyword arguments to use.
Raises
--------
RuntimeError
A task has already been launched.
Returns
... | [
"r",
"Starts",
"the",
"internal",
"task",
"in",
"the",
"event",
"loop",
"."
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L867-L873 | def org_find_members(object_id, input_params={}, always_retry=True, **kwargs):
"""
Invokes the /org-xxxx/findMembers API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Organizations#API-method%3A-%2Forg-xxxx%2FfindMembers
"""
return DXHTTPRequest('/%s/findMembers' % ... | [
"def",
"org_find_members",
"(",
"object_id",
",",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/%s/findMembers'",
"%",
"object_id",
",",
"input_params",
",",
"always_retry... | Invokes the /org-xxxx/findMembers API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Organizations#API-method%3A-%2Forg-xxxx%2FfindMembers | [
"Invokes",
"the",
"/",
"org",
"-",
"xxxx",
"/",
"findMembers",
"API",
"method",
"."
] | python | train |
zetaops/zengine | zengine/wf_daemon.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L76-L87 | def clear_queue(self):
"""
clear outs all messages from INPUT_QUEUE_NAME
"""
def remove_message(ch, method, properties, body):
print("Removed message: %s" % body)
self.input_channel.basic_consume(remove_message, queue=self.INPUT_QUEUE_NAME, no_ack=True)
try:
... | [
"def",
"clear_queue",
"(",
"self",
")",
":",
"def",
"remove_message",
"(",
"ch",
",",
"method",
",",
"properties",
",",
"body",
")",
":",
"print",
"(",
"\"Removed message: %s\"",
"%",
"body",
")",
"self",
".",
"input_channel",
".",
"basic_consume",
"(",
"r... | clear outs all messages from INPUT_QUEUE_NAME | [
"clear",
"outs",
"all",
"messages",
"from",
"INPUT_QUEUE_NAME"
] | python | train |
myaooo/pysbrl | pysbrl/utils.py | https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/utils.py#L29-L97 | def categorical2pysbrl_data(
x,
y,
data_filename,
label_filename,
method='eclat',
supp=0.05,
zmin=1,
zmax=3):
"""
Run a frequent item mining algorithm to extract candidate rules.
:param x: 2D np.ndarray, categorical data of shape [n_instances, ... | [
"def",
"categorical2pysbrl_data",
"(",
"x",
",",
"y",
",",
"data_filename",
",",
"label_filename",
",",
"method",
"=",
"'eclat'",
",",
"supp",
"=",
"0.05",
",",
"zmin",
"=",
"1",
",",
"zmax",
"=",
"3",
")",
":",
"# Safely cast data types",
"x",
"=",
"x",... | Run a frequent item mining algorithm to extract candidate rules.
:param x: 2D np.ndarray, categorical data of shape [n_instances, n_features]
:param y: 1D np.ndarray, label array of shape [n_instances, ]
:param data_filename: the path to store data file
:param label_filename: the path to store label fil... | [
"Run",
"a",
"frequent",
"item",
"mining",
"algorithm",
"to",
"extract",
"candidate",
"rules",
".",
":",
"param",
"x",
":",
"2D",
"np",
".",
"ndarray",
"categorical",
"data",
"of",
"shape",
"[",
"n_instances",
"n_features",
"]",
":",
"param",
"y",
":",
"1... | python | train |
theislab/scvelo | scvelo/tools/velocity.py | https://github.com/theislab/scvelo/blob/c7a96d70edfe705e86bf364434a9527d4fd8df11/scvelo/tools/velocity.py#L186-L217 | def velocity_genes(data, vkey='velocity', min_r2=0.01, highly_variable=None, copy=False):
"""Estimates velocities in a gene-specific manner
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated data matrix.
vkey: `str` (default: `'velocity'`)
Name under which to refer to the... | [
"def",
"velocity_genes",
"(",
"data",
",",
"vkey",
"=",
"'velocity'",
",",
"min_r2",
"=",
"0.01",
",",
"highly_variable",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"adata",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"copy",
"else",
"data",
"if... | Estimates velocities in a gene-specific manner
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated data matrix.
vkey: `str` (default: `'velocity'`)
Name under which to refer to the computed velocities for `velocity_graph` and `velocity_embedding`.
min_r2: `float` (default:... | [
"Estimates",
"velocities",
"in",
"a",
"gene",
"-",
"specific",
"manner"
] | python | train |
google/grr | grr/server/grr_response_server/aff4.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L834-L866 | def MultiOpenOrdered(self, urns, **kwargs):
"""Opens many URNs and returns handles in the same order.
`MultiOpen` can return file handles in arbitrary order. This makes it more
efficient and in most cases the order does not matter. However, there are
cases where order is important and this function sho... | [
"def",
"MultiOpenOrdered",
"(",
"self",
",",
"urns",
",",
"*",
"*",
"kwargs",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"urns",
",",
"rdfvalue",
".",
"RDFURN",
")",
"urn_filedescs",
"=",
"{",
"}",
"for",
"filedesc",
"in",
"self",
".",
"Mu... | Opens many URNs and returns handles in the same order.
`MultiOpen` can return file handles in arbitrary order. This makes it more
efficient and in most cases the order does not matter. However, there are
cases where order is important and this function should be used instead.
Args:
urns: A list ... | [
"Opens",
"many",
"URNs",
"and",
"returns",
"handles",
"in",
"the",
"same",
"order",
"."
] | python | train |
F5Networks/f5-common-python | f5/bigip/tm/ltm/pool.py | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/pool.py#L86-L91 | def modify(self, **patch):
"""Custom modify method to implement monitor parameter formatting."""
if 'monitor' in patch:
value = self._format_monitor_parameter(patch['monitor'])
patch['monitor'] = value
return super(Pool, self)._modify(**patch) | [
"def",
"modify",
"(",
"self",
",",
"*",
"*",
"patch",
")",
":",
"if",
"'monitor'",
"in",
"patch",
":",
"value",
"=",
"self",
".",
"_format_monitor_parameter",
"(",
"patch",
"[",
"'monitor'",
"]",
")",
"patch",
"[",
"'monitor'",
"]",
"=",
"value",
"retu... | Custom modify method to implement monitor parameter formatting. | [
"Custom",
"modify",
"method",
"to",
"implement",
"monitor",
"parameter",
"formatting",
"."
] | python | train |
quantmind/pulsar | pulsar/apps/wsgi/wrappers.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/wrappers.py#L344-L351 | def get_client_address(self, use_x_forwarded=True):
"""Obtain the client IP address
"""
xfor = self.environ.get('HTTP_X_FORWARDED_FOR')
if use_x_forwarded and xfor:
return xfor.split(',')[-1].strip()
else:
return self.environ['REMOTE_ADDR'] | [
"def",
"get_client_address",
"(",
"self",
",",
"use_x_forwarded",
"=",
"True",
")",
":",
"xfor",
"=",
"self",
".",
"environ",
".",
"get",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
"if",
"use_x_forwarded",
"and",
"xfor",
":",
"return",
"xfor",
".",
"split",
"(",
... | Obtain the client IP address | [
"Obtain",
"the",
"client",
"IP",
"address"
] | python | train |
slickqa/python-client | slickqa/micromodels/packages/PySO8601/durations.py | https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/micromodels/packages/PySO8601/durations.py#L58-L83 | def parse_duration(duration):
"""Attepmts to parse an ISO8601 formatted ``duration``.
Returns a ``datetime.timedelta`` object.
"""
duration = str(duration).upper().strip()
elements = ELEMENTS.copy()
for pattern in (SIMPLE_DURATION, COMBINED_DURATION):
if pattern.match(duration):
... | [
"def",
"parse_duration",
"(",
"duration",
")",
":",
"duration",
"=",
"str",
"(",
"duration",
")",
".",
"upper",
"(",
")",
".",
"strip",
"(",
")",
"elements",
"=",
"ELEMENTS",
".",
"copy",
"(",
")",
"for",
"pattern",
"in",
"(",
"SIMPLE_DURATION",
",",
... | Attepmts to parse an ISO8601 formatted ``duration``.
Returns a ``datetime.timedelta`` object. | [
"Attepmts",
"to",
"parse",
"an",
"ISO8601",
"formatted",
"duration",
"."
] | python | train |
arkottke/pysra | pysra/site.py | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L129-L149 | def _update(self):
"""Initialize the 1D interpolation."""
if self.strains.size and self.strains.size == self.values.size:
x = np.log(self.strains)
y = self.values
if x.size < 4:
self._interpolater = interp1d(
x,
... | [
"def",
"_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"strains",
".",
"size",
"and",
"self",
".",
"strains",
".",
"size",
"==",
"self",
".",
"values",
".",
"size",
":",
"x",
"=",
"np",
".",
"log",
"(",
"self",
".",
"strains",
")",
"y",
"=... | Initialize the 1D interpolation. | [
"Initialize",
"the",
"1D",
"interpolation",
"."
] | python | train |
chimera0/accel-brain-code | Automatic-Summarization/pysummarization/vectorizabletoken/tfidf_vectorizer.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Automatic-Summarization/pysummarization/vectorizabletoken/tfidf_vectorizer.py#L22-L33 | def vectorize(self, token_list):
'''
Tokenize token list.
Args:
token_list: The list of tokens..
Returns:
[vector of token, vector of token, vector of token, ...]
'''
vector_list = [self.__collection.tf_idf(token, self.__collect... | [
"def",
"vectorize",
"(",
"self",
",",
"token_list",
")",
":",
"vector_list",
"=",
"[",
"self",
".",
"__collection",
".",
"tf_idf",
"(",
"token",
",",
"self",
".",
"__collection",
")",
"for",
"token",
"in",
"token_list",
"]",
"return",
"vector_list"
] | Tokenize token list.
Args:
token_list: The list of tokens..
Returns:
[vector of token, vector of token, vector of token, ...] | [
"Tokenize",
"token",
"list",
".",
"Args",
":",
"token_list",
":",
"The",
"list",
"of",
"tokens",
"..",
"Returns",
":",
"[",
"vector",
"of",
"token",
"vector",
"of",
"token",
"vector",
"of",
"token",
"...",
"]"
] | python | train |
facetoe/zenpy | zenpy/lib/cache.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/cache.py#L147-L156 | def get(self, object_type, cache_key):
""" Query the cache for a Zenpy object """
if object_type not in self.mapping or self.disabled:
return None
cache = self.mapping[object_type]
if cache_key in cache:
log.debug("Cache HIT: [%s %s]" % (object_type.capitalize(), ... | [
"def",
"get",
"(",
"self",
",",
"object_type",
",",
"cache_key",
")",
":",
"if",
"object_type",
"not",
"in",
"self",
".",
"mapping",
"or",
"self",
".",
"disabled",
":",
"return",
"None",
"cache",
"=",
"self",
".",
"mapping",
"[",
"object_type",
"]",
"i... | Query the cache for a Zenpy object | [
"Query",
"the",
"cache",
"for",
"a",
"Zenpy",
"object"
] | python | train |
ipinfo/python | ipinfo/handler.py | https://github.com/ipinfo/python/blob/62fef9136069eab280806cc772dc578d3f1d8d63/ipinfo/handler.py#L86-L93 | def _read_country_names(self, countries_file=None):
"""Read list of countries from specified country file or default file."""
if not countries_file:
countries_file = os.path.join(os.path.dirname(__file__), self.COUNTRY_FILE_DEFAULT)
with open(countries_file) as f:
countri... | [
"def",
"_read_country_names",
"(",
"self",
",",
"countries_file",
"=",
"None",
")",
":",
"if",
"not",
"countries_file",
":",
"countries_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"self",... | Read list of countries from specified country file or default file. | [
"Read",
"list",
"of",
"countries",
"from",
"specified",
"country",
"file",
"or",
"default",
"file",
"."
] | python | train |
authomatic/liveandletdie | liveandletdie/__init__.py | https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L411-L454 | def wrap(cls, app):
"""
Adds test live server capability to a Flask app module.
:param app:
A :class:`flask.Flask` app instance.
"""
host, port = cls.parse_args()
ssl = cls._argument_parser.parse_args().ssl
ssl_context = None
if host... | [
"def",
"wrap",
"(",
"cls",
",",
"app",
")",
":",
"host",
",",
"port",
"=",
"cls",
".",
"parse_args",
"(",
")",
"ssl",
"=",
"cls",
".",
"_argument_parser",
".",
"parse_args",
"(",
")",
".",
"ssl",
"ssl_context",
"=",
"None",
"if",
"host",
":",
"if",... | Adds test live server capability to a Flask app module.
:param app:
A :class:`flask.Flask` app instance. | [
"Adds",
"test",
"live",
"server",
"capability",
"to",
"a",
"Flask",
"app",
"module",
".",
":",
"param",
"app",
":",
"A",
":",
"class",
":",
"flask",
".",
"Flask",
"app",
"instance",
"."
] | python | train |
awslabs/sockeye | sockeye/lexicon.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/lexicon.py#L59-L85 | def read_lexicon(path: str, vocab_source: Dict[str, int], vocab_target: Dict[str, int]) -> np.ndarray:
"""
Loads lexical translation probabilities from a translation table of format: src, trg, logprob.
Source words unknown to vocab_source are discarded.
Target words unknown to vocab_target contribute to... | [
"def",
"read_lexicon",
"(",
"path",
":",
"str",
",",
"vocab_source",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
",",
"vocab_target",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
")",
"->",
"np",
".",
"ndarray",
":",
"src_unk_id",
"=",
"vocab_source",
"["... | Loads lexical translation probabilities from a translation table of format: src, trg, logprob.
Source words unknown to vocab_source are discarded.
Target words unknown to vocab_target contribute to p(unk|source_word).
See Incorporating Discrete Translation Lexicons into Neural Machine Translation, Section 3... | [
"Loads",
"lexical",
"translation",
"probabilities",
"from",
"a",
"translation",
"table",
"of",
"format",
":",
"src",
"trg",
"logprob",
".",
"Source",
"words",
"unknown",
"to",
"vocab_source",
"are",
"discarded",
".",
"Target",
"words",
"unknown",
"to",
"vocab_ta... | python | train |
polyaxon/polyaxon | polyaxon/event_manager/event_service.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/event_manager/event_service.py#L27-L46 | def record(self,
event_type: str,
event_data: Mapping = None,
instance: Any = None,
**kwargs) -> 'Event':
""" Validate and record an event.
>>> record('event.action', object_instance)
"""
if not self.is_setup:
retur... | [
"def",
"record",
"(",
"self",
",",
"event_type",
":",
"str",
",",
"event_data",
":",
"Mapping",
"=",
"None",
",",
"instance",
":",
"Any",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"'Event'",
":",
"if",
"not",
"self",
".",
"is_setup",
":",
"r... | Validate and record an event.
>>> record('event.action', object_instance) | [
"Validate",
"and",
"record",
"an",
"event",
"."
] | python | train |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/__init__.py | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/__init__.py#L43-L150 | def _raw_split(itxt):
"""
Parse HTML from text into array filled with tags end text.
Source code is little bit unintutive, because it is state machine parser.
For better understanding, look at http://bit.ly/1rXRcJj
Example::
>>> dhtmlparser._raw_split('<html><tag params="true"></html>')
... | [
"def",
"_raw_split",
"(",
"itxt",
")",
":",
"echr",
"=",
"\"\"",
"buff",
"=",
"[",
"\"\"",
",",
"\"\"",
",",
"\"\"",
",",
"\"\"",
"]",
"content",
"=",
"\"\"",
"array",
"=",
"[",
"]",
"next_state",
"=",
"0",
"inside_tag",
"=",
"False",
"escaped",
"=... | Parse HTML from text into array filled with tags end text.
Source code is little bit unintutive, because it is state machine parser.
For better understanding, look at http://bit.ly/1rXRcJj
Example::
>>> dhtmlparser._raw_split('<html><tag params="true"></html>')
['<html>', '<tag params="t... | [
"Parse",
"HTML",
"from",
"text",
"into",
"array",
"filled",
"with",
"tags",
"end",
"text",
"."
] | python | train |
earlye/nephele | nephele/AwsProcessor.py | https://github.com/earlye/nephele/blob/a7dadc68f4124671457f09119419978c4d22013e/nephele/AwsProcessor.py#L193-L219 | def do_profile(self,args):
"""
Select nephele profile
profile -h for more details
"""
parser = CommandArgumentParser("profile")
parser.add_argument(dest="profile",help="Profile name")
parser.add_argument('-v','--verbose',dest="verbose",action='store_true',help='v... | [
"def",
"do_profile",
"(",
"self",
",",
"args",
")",
":",
"parser",
"=",
"CommandArgumentParser",
"(",
"\"profile\"",
")",
"parser",
".",
"add_argument",
"(",
"dest",
"=",
"\"profile\"",
",",
"help",
"=",
"\"Profile name\"",
")",
"parser",
".",
"add_argument",
... | Select nephele profile
profile -h for more details | [
"Select",
"nephele",
"profile"
] | python | train |
rigetti/grove | grove/tomography/process_tomography.py | https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/tomography/process_tomography.py#L263-L272 | def plot(self):
"""
Visualize the process.
:return: The generated figure.
:rtype: matplotlib.Figure
"""
fig, (ax1) = plt.subplots(1, 1, figsize=(10, 8))
self.plot_pauli_transfer_matrix(ax1)
return fig | [
"def",
"plot",
"(",
"self",
")",
":",
"fig",
",",
"(",
"ax1",
")",
"=",
"plt",
".",
"subplots",
"(",
"1",
",",
"1",
",",
"figsize",
"=",
"(",
"10",
",",
"8",
")",
")",
"self",
".",
"plot_pauli_transfer_matrix",
"(",
"ax1",
")",
"return",
"fig"
] | Visualize the process.
:return: The generated figure.
:rtype: matplotlib.Figure | [
"Visualize",
"the",
"process",
"."
] | python | train |
sporsh/carnifex | carnifex/ssh/userauth.py | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/ssh/userauth.py#L20-L28 | def getGenericAnswers(self, name, instruction, prompts):
"""Called when the server requests keyboard interactive authentication
"""
responses = []
for prompt, _echo in prompts:
password = self.getPassword(prompt)
responses.append(password)
return defer.su... | [
"def",
"getGenericAnswers",
"(",
"self",
",",
"name",
",",
"instruction",
",",
"prompts",
")",
":",
"responses",
"=",
"[",
"]",
"for",
"prompt",
",",
"_echo",
"in",
"prompts",
":",
"password",
"=",
"self",
".",
"getPassword",
"(",
"prompt",
")",
"respons... | Called when the server requests keyboard interactive authentication | [
"Called",
"when",
"the",
"server",
"requests",
"keyboard",
"interactive",
"authentication"
] | python | train |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L3906-L3917 | def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data):
'''Register for an event notification.
@param p_event_manager: the event manager to which you want to attach to. Generally it is obtained by vlc_my_object_event_manager() where my_object is the object you want to listen to.
@para... | [
"def",
"libvlc_event_attach",
"(",
"p_event_manager",
",",
"i_event_type",
",",
"f_callback",
",",
"user_data",
")",
":",
"f",
"=",
"_Cfunctions",
".",
"get",
"(",
"'libvlc_event_attach'",
",",
"None",
")",
"or",
"_Cfunction",
"(",
"'libvlc_event_attach'",
",",
... | Register for an event notification.
@param p_event_manager: the event manager to which you want to attach to. Generally it is obtained by vlc_my_object_event_manager() where my_object is the object you want to listen to.
@param i_event_type: the desired event to which we want to listen.
@param f_callback: t... | [
"Register",
"for",
"an",
"event",
"notification",
"."
] | python | train |
wtsi-hgi/python-baton-wrapper | baton/_baton/_baton_runner.py | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L56-L78 | def _raise_any_errors_given_in_baton_out(baton_out_as_json: List[Dict]):
"""
Raises any errors that baton has expressed in its output.
:param baton_out_as_json: the output baton gave as parsed serialization
"""
if not isinstance(baton_out_as_json, list):
baton_out_as_... | [
"def",
"_raise_any_errors_given_in_baton_out",
"(",
"baton_out_as_json",
":",
"List",
"[",
"Dict",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"baton_out_as_json",
",",
"list",
")",
":",
"baton_out_as_json",
"=",
"[",
"baton_out_as_json",
"]",
"for",
"baton_ite... | Raises any errors that baton has expressed in its output.
:param baton_out_as_json: the output baton gave as parsed serialization | [
"Raises",
"any",
"errors",
"that",
"baton",
"has",
"expressed",
"in",
"its",
"output",
".",
":",
"param",
"baton_out_as_json",
":",
"the",
"output",
"baton",
"gave",
"as",
"parsed",
"serialization"
] | python | train |
SheffieldML/GPy | GPy/models/gradient_checker.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/models/gradient_checker.py#L196-L289 | def checkgrad_block(self, analytic_hess, numeric_hess, verbose=False, step=1e-6, tolerance=1e-3, block_indices=None, plot=False):
"""
Checkgrad a block matrix
"""
if analytic_hess.dtype is np.dtype('object'):
#Make numeric hessian also into a block matrix
real_siz... | [
"def",
"checkgrad_block",
"(",
"self",
",",
"analytic_hess",
",",
"numeric_hess",
",",
"verbose",
"=",
"False",
",",
"step",
"=",
"1e-6",
",",
"tolerance",
"=",
"1e-3",
",",
"block_indices",
"=",
"None",
",",
"plot",
"=",
"False",
")",
":",
"if",
"analyt... | Checkgrad a block matrix | [
"Checkgrad",
"a",
"block",
"matrix"
] | python | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L259-L272 | def jsonise(dic):
"""Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None : il faut laisser None et non pas null"""
d = {}
for k, v in dic.items():
if type(v) in abstractRequetesSQL.TYPES_PERMIS:
d[k] = v
... | [
"def",
"jsonise",
"(",
"dic",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
":",
"if",
"type",
"(",
"v",
")",
"in",
"abstractRequetesSQL",
".",
"TYPES_PERMIS",
":",
"d",
"[",
"k",
"]",
"=",
"v",
"els... | Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None : il faut laisser None et non pas null | [
"Renvoie",
"un",
"dictionnaire",
"dont",
"les",
"champs",
"dont",
"compatibles",
"avec",
"SQL",
"Utilise",
"Json",
".",
"Attention",
"à",
"None",
":",
"il",
"faut",
"laisser",
"None",
"et",
"non",
"pas",
"null"
] | python | train |
tanghaibao/goatools | goatools/grouper/sorter_gos.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L33-L38 | def sortby(self, ntd):
"""Return function for sorting."""
if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']:
return [ntd.NS, -1*ntd.dcnt, ntd.reldepth]
else:
return [ntd.NS, -1*ntd.dcnt, ntd.depth] | [
"def",
"sortby",
"(",
"self",
",",
"ntd",
")",
":",
"if",
"'reldepth'",
"in",
"self",
".",
"grprobj",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'flds'",
"]",
":",
"return",
"[",
"ntd",
".",
"NS",
",",
"-",
"1",
"*",
"ntd",
".",
"dcnt",
",",
"ntd",
... | Return function for sorting. | [
"Return",
"function",
"for",
"sorting",
"."
] | python | train |
wangwenpei/cliez | cliez/component.py | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/component.py#L257-L280 | def load_description(name, root=''):
"""
.. warning::
Experiment feature.
BE CAREFUL! WE MAY REMOVE THIS FEATURE!
Load resource file as description,
if resource file not exist,will return empty string.
:param str path: name resource path
:para... | [
"def",
"load_description",
"(",
"name",
",",
"root",
"=",
"''",
")",
":",
"desc",
"=",
"''",
"try",
":",
"desc",
"=",
"Component",
".",
"load_resource",
"(",
"name",
",",
"root",
"=",
"root",
")",
"except",
"(",
"IOError",
",",
"ImportError",
")",
":... | .. warning::
Experiment feature.
BE CAREFUL! WE MAY REMOVE THIS FEATURE!
Load resource file as description,
if resource file not exist,will return empty string.
:param str path: name resource path
:param str root: same as `load_resource` root
:return:... | [
"..",
"warning",
"::"
] | python | valid |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_2015.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2015.py#L134-L148 | def _compute_magnitude_term(self, C, dc1, mag):
"""
Computes the magnitude scaling term given by equation (2)
"""
base = C['theta1'] + (self.CONSTS['theta4'] * dc1)
dmag = self.CONSTS["C1"] + dc1
if mag > dmag:
f_mag = (self.CONSTS['theta5'] * (mag - dmag)) +\... | [
"def",
"_compute_magnitude_term",
"(",
"self",
",",
"C",
",",
"dc1",
",",
"mag",
")",
":",
"base",
"=",
"C",
"[",
"'theta1'",
"]",
"+",
"(",
"self",
".",
"CONSTS",
"[",
"'theta4'",
"]",
"*",
"dc1",
")",
"dmag",
"=",
"self",
".",
"CONSTS",
"[",
"\... | Computes the magnitude scaling term given by equation (2) | [
"Computes",
"the",
"magnitude",
"scaling",
"term",
"given",
"by",
"equation",
"(",
"2",
")"
] | python | train |
PythonRails/rails | rails/views/__init__.py | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/views/__init__.py#L18-L29 | def _load_view(self, template_engine_name, template_dir):
"""
Load view by name and return an instance.
"""
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".fo... | [
"def",
"_load_view",
"(",
"self",
",",
"template_engine_name",
",",
"template_dir",
")",
":",
"file_name",
"=",
"template_engine_name",
".",
"lower",
"(",
")",
"class_name",
"=",
"\"{}View\"",
".",
"format",
"(",
"template_engine_name",
".",
"title",
"(",
")",
... | Load view by name and return an instance. | [
"Load",
"view",
"by",
"name",
"and",
"return",
"an",
"instance",
"."
] | python | train |
fhcrc/seqmagick | seqmagick/subcommands/quality_filter.py | https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L575-L583 | def filter_record(self, record):
"""
Filter record, dropping any that don't meet minimum length
"""
if len(record) >= self.min_length:
return record
else:
raise FailedFilter(len(record)) | [
"def",
"filter_record",
"(",
"self",
",",
"record",
")",
":",
"if",
"len",
"(",
"record",
")",
">=",
"self",
".",
"min_length",
":",
"return",
"record",
"else",
":",
"raise",
"FailedFilter",
"(",
"len",
"(",
"record",
")",
")"
] | Filter record, dropping any that don't meet minimum length | [
"Filter",
"record",
"dropping",
"any",
"that",
"don",
"t",
"meet",
"minimum",
"length"
] | python | train |
pyviz/holoviews | holoviews/core/spaces.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/spaces.py#L1435-L1461 | def relabel(self, label=None, group=None, depth=1):
"""Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
Args:
label (str, optional): New label to apply to returned object
group (str, optional): New group to apply to... | [
"def",
"relabel",
"(",
"self",
",",
"label",
"=",
"None",
",",
"group",
"=",
"None",
",",
"depth",
"=",
"1",
")",
":",
"relabelled",
"=",
"super",
"(",
"DynamicMap",
",",
"self",
")",
".",
"relabel",
"(",
"label",
",",
"group",
",",
"depth",
")",
... | Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
Args:
label (str, optional): New label to apply to returned object
group (str, optional): New group to apply to returned object
depth (int, optional): Depth to wh... | [
"Clone",
"object",
"and",
"apply",
"new",
"group",
"and",
"/",
"or",
"label",
"."
] | python | train |
jterrace/pyssim | ssim/ssimlib.py | https://github.com/jterrace/pyssim/blob/ff9bd90c3eb7525013ad46babf66b7cc78391e89/ssim/ssimlib.py#L193-L246 | def main():
"""Main function for pyssim."""
description = '\n'.join([
'Compares an image with a list of images using the SSIM metric.',
' Example:',
' pyssim test-images/test1-1.png "test-images/*"'
])
parser = argparse.ArgumentParser(
prog='pyssim', formatter_class... | [
"def",
"main",
"(",
")",
":",
"description",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"'Compares an image with a list of images using the SSIM metric.'",
",",
"' Example:'",
",",
"' pyssim test-images/test1-1.png \"test-images/*\"'",
"]",
")",
"parser",
"=",
"argparse",
"... | Main function for pyssim. | [
"Main",
"function",
"for",
"pyssim",
"."
] | python | test |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L286-L306 | def g_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_g_interp'):
if self._lookup:
x = self._x_lookup
g_x = self._g_lookup
else:
... | [
"def",
"g_",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"_interpol",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_g_interp'",
")",
":",
"if",
"self",
".",
"_lookup",
":",
"x",
"=",
"self",
".",
"_x_lookup",
"g_x",
"=",
"self",
".",
... | computes h()
:param X:
:return: | [
"computes",
"h",
"()"
] | python | train |
xi/ldif3 | ldif3.py | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L159-L181 | def _unparse_change_record(self, modlist):
"""
:type modlist: List[Tuple]
:param modlist: List of additions (2-tuple) or modifications (3-tuple)
"""
mod_len = len(modlist[0])
self._unparse_changetype(mod_len)
for mod in modlist:
if len(mod) != mod_len... | [
"def",
"_unparse_change_record",
"(",
"self",
",",
"modlist",
")",
":",
"mod_len",
"=",
"len",
"(",
"modlist",
"[",
"0",
"]",
")",
"self",
".",
"_unparse_changetype",
"(",
"mod_len",
")",
"for",
"mod",
"in",
"modlist",
":",
"if",
"len",
"(",
"mod",
")"... | :type modlist: List[Tuple]
:param modlist: List of additions (2-tuple) or modifications (3-tuple) | [
":",
"type",
"modlist",
":",
"List",
"[",
"Tuple",
"]",
":",
"param",
"modlist",
":",
"List",
"of",
"additions",
"(",
"2",
"-",
"tuple",
")",
"or",
"modifications",
"(",
"3",
"-",
"tuple",
")"
] | python | train |
elastic/apm-agent-python | elasticapm/metrics/base_metrics.py | https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/metrics/base_metrics.py#L128-L143 | def gauge(self, name):
"""
Returns an existing or creates and returns a new gauge
:param name: name of the gauge
:return: the gauge object
"""
with self._lock:
if name not in self._gauges:
if self._registry._ignore_patterns and any(
... | [
"def",
"gauge",
"(",
"self",
",",
"name",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_gauges",
":",
"if",
"self",
".",
"_registry",
".",
"_ignore_patterns",
"and",
"any",
"(",
"pattern",
".",
"match",
"(",
... | Returns an existing or creates and returns a new gauge
:param name: name of the gauge
:return: the gauge object | [
"Returns",
"an",
"existing",
"or",
"creates",
"and",
"returns",
"a",
"new",
"gauge",
":",
"param",
"name",
":",
"name",
"of",
"the",
"gauge",
":",
"return",
":",
"the",
"gauge",
"object"
] | python | train |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/c14n.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L413-L433 | def Canonicalize(node, output=None, **kw):
'''Canonicalize(node, output=None, **kw) -> UTF-8
Canonicalize a DOM document/element node and all descendents.
Return the text; if output is specified then output.write will
be called to output the text and None will be returned
Keyword parameters:
... | [
"def",
"Canonicalize",
"(",
"node",
",",
"output",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"output",
":",
"apply",
"(",
"_implementation",
",",
"(",
"node",
",",
"output",
".",
"write",
")",
",",
"kw",
")",
"else",
":",
"s",
"=",
"Strin... | Canonicalize(node, output=None, **kw) -> UTF-8
Canonicalize a DOM document/element node and all descendents.
Return the text; if output is specified then output.write will
be called to output the text and None will be returned
Keyword parameters:
nsdict: a dictionary of prefix:uri namespace ent... | [
"Canonicalize",
"(",
"node",
"output",
"=",
"None",
"**",
"kw",
")",
"-",
">",
"UTF",
"-",
"8"
] | python | train |
treethought/flask-assistant | flask_assistant/core.py | https://github.com/treethought/flask-assistant/blob/9331b9796644dfa987bcd97a13e78e9ab62923d3/flask_assistant/core.py#L275-L311 | def action(
self,
intent_name,
is_fallback=False,
mapping={},
convert={},
default={},
with_context=[],
events=[],
*args,
**kw
):
"""Decorates an intent_name's Action view function.
The wrapped function is called whe... | [
"def",
"action",
"(",
"self",
",",
"intent_name",
",",
"is_fallback",
"=",
"False",
",",
"mapping",
"=",
"{",
"}",
",",
"convert",
"=",
"{",
"}",
",",
"default",
"=",
"{",
"}",
",",
"with_context",
"=",
"[",
"]",
",",
"events",
"=",
"[",
"]",
","... | Decorates an intent_name's Action view function.
The wrapped function is called when a request with the
given intent_name is recieved along with all required parameters. | [
"Decorates",
"an",
"intent_name",
"s",
"Action",
"view",
"function",
"."
] | python | train |
pytroll/satpy | satpy/writers/__init__.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/writers/__init__.py#L641-L684 | def save_datasets(self, datasets, compute=True, **kwargs):
"""Save all datasets to one or more files.
Subclasses can use this method to save all datasets to one single
file or optimize the writing of individual datasets. By default
this simply calls `save_dataset` for each dataset provi... | [
"def",
"save_datasets",
"(",
"self",
",",
"datasets",
",",
"compute",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"[",
"]",
"for",
"ds",
"in",
"datasets",
":",
"results",
".",
"append",
"(",
"self",
".",
"save_dataset",
"(",
"ds",... | Save all datasets to one or more files.
Subclasses can use this method to save all datasets to one single
file or optimize the writing of individual datasets. By default
this simply calls `save_dataset` for each dataset provided.
Args:
datasets (iterable): Iterable of `xarr... | [
"Save",
"all",
"datasets",
"to",
"one",
"or",
"more",
"files",
"."
] | python | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/common.py | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/common.py#L105-L123 | def disconnect_node(node, src=True, dst=True):
"""Disconnect all connections from node
:param node: the node to disconnect
:type node: str
:returns: None
:rtype: None
:raises: None
"""
if dst:
destconns = cmds.listConnections(node, connections=True, plugs=True, source=False) or ... | [
"def",
"disconnect_node",
"(",
"node",
",",
"src",
"=",
"True",
",",
"dst",
"=",
"True",
")",
":",
"if",
"dst",
":",
"destconns",
"=",
"cmds",
".",
"listConnections",
"(",
"node",
",",
"connections",
"=",
"True",
",",
"plugs",
"=",
"True",
",",
"sour... | Disconnect all connections from node
:param node: the node to disconnect
:type node: str
:returns: None
:rtype: None
:raises: None | [
"Disconnect",
"all",
"connections",
"from",
"node"
] | python | train |
lambdamusic/Ontospy | ontospy/core/entities.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L243-L253 | def annotations(self, qname=True):
"""
wrapper that returns all triples for an onto.
By default resources URIs are transformed into qnames
"""
if qname:
return sorted([(uri2niceString(x, self.namespaces)
), (uri2niceString(y, self.namespace... | [
"def",
"annotations",
"(",
"self",
",",
"qname",
"=",
"True",
")",
":",
"if",
"qname",
":",
"return",
"sorted",
"(",
"[",
"(",
"uri2niceString",
"(",
"x",
",",
"self",
".",
"namespaces",
")",
")",
",",
"(",
"uri2niceString",
"(",
"y",
",",
"self",
... | wrapper that returns all triples for an onto.
By default resources URIs are transformed into qnames | [
"wrapper",
"that",
"returns",
"all",
"triples",
"for",
"an",
"onto",
".",
"By",
"default",
"resources",
"URIs",
"are",
"transformed",
"into",
"qnames"
] | python | train |
shapiromatron/bmds | bmds/reporter.py | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/reporter.py#L312-L319 | def _get_session_for_table(self, base_session):
"""
Only present session for modeling when doses were dropped if it's succesful;
otherwise show the original modeling session.
"""
if base_session.recommended_model is None and base_session.doses_dropped > 0:
return base... | [
"def",
"_get_session_for_table",
"(",
"self",
",",
"base_session",
")",
":",
"if",
"base_session",
".",
"recommended_model",
"is",
"None",
"and",
"base_session",
".",
"doses_dropped",
">",
"0",
":",
"return",
"base_session",
".",
"doses_dropped_sessions",
"[",
"0"... | Only present session for modeling when doses were dropped if it's succesful;
otherwise show the original modeling session. | [
"Only",
"present",
"session",
"for",
"modeling",
"when",
"doses",
"were",
"dropped",
"if",
"it",
"s",
"succesful",
";",
"otherwise",
"show",
"the",
"original",
"modeling",
"session",
"."
] | python | train |
ethereum/py-evm | eth/chains/base.py | https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/chains/base.py#L579-L599 | def build_block_with_transactions(
self,
transactions: Tuple[BaseTransaction, ...],
parent_header: BlockHeader=None
) -> Tuple[BaseBlock, Tuple[Receipt, ...], Tuple[BaseComputation, ...]]:
"""
Generate a block with the provided transactions. This does *not* import... | [
"def",
"build_block_with_transactions",
"(",
"self",
",",
"transactions",
":",
"Tuple",
"[",
"BaseTransaction",
",",
"...",
"]",
",",
"parent_header",
":",
"BlockHeader",
"=",
"None",
")",
"->",
"Tuple",
"[",
"BaseBlock",
",",
"Tuple",
"[",
"Receipt",
",",
"... | Generate a block with the provided transactions. This does *not* import
that block into your chain. If you want this new block in your chain,
run :meth:`~import_block` with the result block from this method.
:param transactions: an iterable of transactions to insert to the block
:param ... | [
"Generate",
"a",
"block",
"with",
"the",
"provided",
"transactions",
".",
"This",
"does",
"*",
"not",
"*",
"import",
"that",
"block",
"into",
"your",
"chain",
".",
"If",
"you",
"want",
"this",
"new",
"block",
"in",
"your",
"chain",
"run",
":",
"meth",
... | python | train |
foremast/foremast | src/foremast/s3/s3apps.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L177-L190 | def _put_bucket_encryption(self):
"""Adds bucket encryption configuration."""
if self.s3props['encryption']['enabled']:
encryption_config = {'Rules': [{}]}
encryption_config = {
'Rules': self.s3props['encryption']['encryption_rules']
}
LOG.... | [
"def",
"_put_bucket_encryption",
"(",
"self",
")",
":",
"if",
"self",
".",
"s3props",
"[",
"'encryption'",
"]",
"[",
"'enabled'",
"]",
":",
"encryption_config",
"=",
"{",
"'Rules'",
":",
"[",
"{",
"}",
"]",
"}",
"encryption_config",
"=",
"{",
"'Rules'",
... | Adds bucket encryption configuration. | [
"Adds",
"bucket",
"encryption",
"configuration",
"."
] | python | train |
streamlink/streamlink | src/streamlink/utils/url.py | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/utils/url.py#L66-L97 | def update_qsd(url, qsd=None, remove=None):
"""
Update or remove keys from a query string in a URL
:param url: URL to update
:param qsd: dict of keys to update, a None value leaves it unchanged
:param remove: list of keys to remove, or "*" to remove all
note: updated keys are nev... | [
"def",
"update_qsd",
"(",
"url",
",",
"qsd",
"=",
"None",
",",
"remove",
"=",
"None",
")",
":",
"qsd",
"=",
"qsd",
"or",
"{",
"}",
"remove",
"=",
"remove",
"or",
"[",
"]",
"# parse current query string",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"c... | Update or remove keys from a query string in a URL
:param url: URL to update
:param qsd: dict of keys to update, a None value leaves it unchanged
:param remove: list of keys to remove, or "*" to remove all
note: updated keys are never removed, even if unchanged
:return: updated URL | [
"Update",
"or",
"remove",
"keys",
"from",
"a",
"query",
"string",
"in",
"a",
"URL"
] | python | test |
hubo1016/vlcp | vlcp/utils/walkerlib.py | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/walkerlib.py#L9-L19 | def ensure_keys(walk, *keys):
"""
Use walk to try to retrieve all keys
"""
all_retrieved = True
for k in keys:
try:
walk(k)
except WalkKeyNotRetrieved:
all_retrieved = False
return all_retrieved | [
"def",
"ensure_keys",
"(",
"walk",
",",
"*",
"keys",
")",
":",
"all_retrieved",
"=",
"True",
"for",
"k",
"in",
"keys",
":",
"try",
":",
"walk",
"(",
"k",
")",
"except",
"WalkKeyNotRetrieved",
":",
"all_retrieved",
"=",
"False",
"return",
"all_retrieved"
] | Use walk to try to retrieve all keys | [
"Use",
"walk",
"to",
"try",
"to",
"retrieve",
"all",
"keys"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.