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 |
|---|---|---|---|---|---|---|---|---|
facelessuser/soupsieve | soupsieve/css_match.py | https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L611-L629 | def match_attributes(self, el, attributes):
"""Match attributes."""
match = True
if attributes:
for a in attributes:
value = self.match_attribute_name(el, a.attribute, a.prefix)
pattern = a.xml_type_pattern if self.is_xml and a.xml_type_pattern else a... | [
"def",
"match_attributes",
"(",
"self",
",",
"el",
",",
"attributes",
")",
":",
"match",
"=",
"True",
"if",
"attributes",
":",
"for",
"a",
"in",
"attributes",
":",
"value",
"=",
"self",
".",
"match_attribute_name",
"(",
"el",
",",
"a",
".",
"attribute",
... | Match attributes. | [
"Match",
"attributes",
"."
] | python | train |
pkgw/pwkit | pwkit/phoenix.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/phoenix.py#L44-L103 | def load_spectrum(path, smoothing=181, DF=-8.):
"""Load a Phoenix model atmosphere spectrum.
path : string
The file path to load.
smoothing : integer
Smoothing to apply. If None, do not smooth. If an integer, smooth with a
Hamming window. Otherwise, the variable is assumed to be a differe... | [
"def",
"load_spectrum",
"(",
"path",
",",
"smoothing",
"=",
"181",
",",
"DF",
"=",
"-",
"8.",
")",
":",
"try",
":",
"ang",
",",
"lflam",
"=",
"np",
".",
"loadtxt",
"(",
"path",
",",
"usecols",
"=",
"(",
"0",
",",
"1",
")",
")",
".",
"T",
"exc... | Load a Phoenix model atmosphere spectrum.
path : string
The file path to load.
smoothing : integer
Smoothing to apply. If None, do not smooth. If an integer, smooth with a
Hamming window. Otherwise, the variable is assumed to be a different
smoothing window, and the data will be convolv... | [
"Load",
"a",
"Phoenix",
"model",
"atmosphere",
"spectrum",
"."
] | python | train |
StanfordVL/robosuite | robosuite/models/tasks/table_top_task.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/models/tasks/table_top_task.py#L65-L70 | def place_objects(self):
"""Places objects randomly until no collisions or max iterations hit."""
pos_arr, quat_arr = self.initializer.sample()
for i in range(len(self.objects)):
self.objects[i].set("pos", array_to_string(pos_arr[i]))
self.objects[i].set("quat", array_to_... | [
"def",
"place_objects",
"(",
"self",
")",
":",
"pos_arr",
",",
"quat_arr",
"=",
"self",
".",
"initializer",
".",
"sample",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"objects",
")",
")",
":",
"self",
".",
"objects",
"[",
"i"... | Places objects randomly until no collisions or max iterations hit. | [
"Places",
"objects",
"randomly",
"until",
"no",
"collisions",
"or",
"max",
"iterations",
"hit",
"."
] | python | train |
abseil/abseil-py | absl/flags/_validators.py | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L387-L421 | def mark_flags_as_mutual_exclusive(flag_names, required=False,
flag_values=_flagvalues.FLAGS):
"""Ensures that only one flag among flag_names is not None.
Important note: This validator checks if flag values are None, and it does not
distinguish between default and explicit val... | [
"def",
"mark_flags_as_mutual_exclusive",
"(",
"flag_names",
",",
"required",
"=",
"False",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"for",
"flag_name",
"in",
"flag_names",
":",
"if",
"flag_values",
"[",
"flag_name",
"]",
".",
"default",
... | Ensures that only one flag among flag_names is not None.
Important note: This validator checks if flag values are None, and it does not
distinguish between default and explicit values. Therefore, this validator
does not make sense when applied to flags with default values other than None,
including other false... | [
"Ensures",
"that",
"only",
"one",
"flag",
"among",
"flag_names",
"is",
"not",
"None",
"."
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/exmaralda.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/exmaralda.py#L437-L449 | def gen_token_range(self, start_id, stop_id):
"""
returns a list of all token IDs in the given, left-closed,
right-open interval (i.e. includes start_id, but excludes stop_id)
>>> gen_token_range('T0', 'T1')
['T0']
>>> gen_token_range('T1', 'T5')
['T1', 'T2', 'T... | [
"def",
"gen_token_range",
"(",
"self",
",",
"start_id",
",",
"stop_id",
")",
":",
"index_range",
"=",
"range",
"(",
"self",
".",
"tokenid2index",
"(",
"start_id",
")",
",",
"self",
".",
"tokenid2index",
"(",
"stop_id",
")",
")",
"return",
"[",
"\"T{}\"",
... | returns a list of all token IDs in the given, left-closed,
right-open interval (i.e. includes start_id, but excludes stop_id)
>>> gen_token_range('T0', 'T1')
['T0']
>>> gen_token_range('T1', 'T5')
['T1', 'T2', 'T3', 'T4'] | [
"returns",
"a",
"list",
"of",
"all",
"token",
"IDs",
"in",
"the",
"given",
"left",
"-",
"closed",
"right",
"-",
"open",
"interval",
"(",
"i",
".",
"e",
".",
"includes",
"start_id",
"but",
"excludes",
"stop_id",
")"
] | python | train |
ewels/MultiQC | multiqc/utils/mqc_colour.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/utils/mqc_colour.py#L41-L64 | def get_colour(self, val, colformat='hex'):
""" Given a value, return a colour within the colour scale """
try:
# Sanity checks
val = re.sub("[^0-9\.]", "", str(val))
if val == '':
val = self.minval
val = float(val)
val = max(val, self.minval)
val = min(val, self.maxval)
domain_nums = list... | [
"def",
"get_colour",
"(",
"self",
",",
"val",
",",
"colformat",
"=",
"'hex'",
")",
":",
"try",
":",
"# Sanity checks",
"val",
"=",
"re",
".",
"sub",
"(",
"\"[^0-9\\.]\"",
",",
"\"\"",
",",
"str",
"(",
"val",
")",
")",
"if",
"val",
"==",
"''",
":",
... | Given a value, return a colour within the colour scale | [
"Given",
"a",
"value",
"return",
"a",
"colour",
"within",
"the",
"colour",
"scale"
] | python | train |
SheffieldML/GPy | GPy/likelihoods/likelihood.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/likelihoods/likelihood.py#L597-L622 | def d2logpdf_df2(self, f, y, Y_metadata=None):
"""
Evaluates the link function link(f) then computes the second derivative of log likelihood using it
Uses the Faa di Bruno's formula for the chain rule
.. math::
\\frac{d^{2}\\log p(y|\\lambda(f))}{df^{2}} = \\frac{d^{2}\\log ... | [
"def",
"d2logpdf_df2",
"(",
"self",
",",
"f",
",",
"y",
",",
"Y_metadata",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"gp_link",
",",
"link_functions",
".",
"Identity",
")",
":",
"d2logpdf_df2",
"=",
"self",
".",
"d2logpdf_dlink2",
"(",... | Evaluates the link function link(f) then computes the second derivative of log likelihood using it
Uses the Faa di Bruno's formula for the chain rule
.. math::
\\frac{d^{2}\\log p(y|\\lambda(f))}{df^{2}} = \\frac{d^{2}\\log p(y|\\lambda(f))}{d^{2}\\lambda(f)}\\left(\\frac{d\\lambda(f)}{df}\... | [
"Evaluates",
"the",
"link",
"function",
"link",
"(",
"f",
")",
"then",
"computes",
"the",
"second",
"derivative",
"of",
"log",
"likelihood",
"using",
"it",
"Uses",
"the",
"Faa",
"di",
"Bruno",
"s",
"formula",
"for",
"the",
"chain",
"rule"
] | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/nearest_neighbors/_nearest_neighbors.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/nearest_neighbors/_nearest_neighbors.py#L937-L1060 | def similarity_graph(self, k=5, radius=None, include_self_edges=False,
output_type='SGraph', verbose=True):
"""
Construct the similarity graph on the reference dataset, which is
already stored in the model. This is conceptually very similar to
running `query` wit... | [
"def",
"similarity_graph",
"(",
"self",
",",
"k",
"=",
"5",
",",
"radius",
"=",
"None",
",",
"include_self_edges",
"=",
"False",
",",
"output_type",
"=",
"'SGraph'",
",",
"verbose",
"=",
"True",
")",
":",
"## Validate inputs.",
"if",
"k",
"is",
"not",
"N... | Construct the similarity graph on the reference dataset, which is
already stored in the model. This is conceptually very similar to
running `query` with the reference set, but this method is optimized
for the purpose, syntactically simpler, and automatically removes
self-edges.
... | [
"Construct",
"the",
"similarity",
"graph",
"on",
"the",
"reference",
"dataset",
"which",
"is",
"already",
"stored",
"in",
"the",
"model",
".",
"This",
"is",
"conceptually",
"very",
"similar",
"to",
"running",
"query",
"with",
"the",
"reference",
"set",
"but",
... | python | train |
tsroten/dragonmapper | dragonmapper/transcriptions.py | https://github.com/tsroten/dragonmapper/blob/68eaf43c32725f4b4923c01284cfc0112079e8ab/dragonmapper/transcriptions.py#L438-L448 | def to_zhuyin(s):
"""Convert *s* to Zhuyin."""
identity = identify(s)
if identity == ZHUYIN:
return s
elif identity == PINYIN:
return pinyin_to_zhuyin(s)
elif identity == IPA:
return ipa_to_zhuyin(s)
else:
raise ValueError("String is not a valid Chinese transcript... | [
"def",
"to_zhuyin",
"(",
"s",
")",
":",
"identity",
"=",
"identify",
"(",
"s",
")",
"if",
"identity",
"==",
"ZHUYIN",
":",
"return",
"s",
"elif",
"identity",
"==",
"PINYIN",
":",
"return",
"pinyin_to_zhuyin",
"(",
"s",
")",
"elif",
"identity",
"==",
"I... | Convert *s* to Zhuyin. | [
"Convert",
"*",
"s",
"*",
"to",
"Zhuyin",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/chipseq/__init__.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/__init__.py#L40-L57 | def _keep_assembled_chrom(bam_file, genome, config):
"""Remove contigs from the BAM file"""
fai = "%s.fai" % genome
chrom = []
with open(fai) as inh:
for line in inh:
c = line.split("\t")[0]
if c.find("_") < 0:
chrom.append(c)
chroms = " ".join(chrom)
... | [
"def",
"_keep_assembled_chrom",
"(",
"bam_file",
",",
"genome",
",",
"config",
")",
":",
"fai",
"=",
"\"%s.fai\"",
"%",
"genome",
"chrom",
"=",
"[",
"]",
"with",
"open",
"(",
"fai",
")",
"as",
"inh",
":",
"for",
"line",
"in",
"inh",
":",
"c",
"=",
... | Remove contigs from the BAM file | [
"Remove",
"contigs",
"from",
"the",
"BAM",
"file"
] | python | train |
lmjohns3/theanets | theanets/layers/base.py | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/layers/base.py#L396-L430 | def add_weights(self, name, nin, nout, mean=0, std=0, sparsity=0, diagonal=0):
'''Helper method to create a new weight matrix.
Parameters
----------
name : str
Name of the parameter to add.
nin : int
Size of "input" for this weight matrix.
nout : ... | [
"def",
"add_weights",
"(",
"self",
",",
"name",
",",
"nin",
",",
"nout",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"0",
",",
"sparsity",
"=",
"0",
",",
"diagonal",
"=",
"0",
")",
":",
"glorot",
"=",
"1",
"/",
"np",
".",
"sqrt",
"(",
"nin",
"+",... | Helper method to create a new weight matrix.
Parameters
----------
name : str
Name of the parameter to add.
nin : int
Size of "input" for this weight matrix.
nout : int
Size of "output" for this weight matrix.
mean : float, optional
... | [
"Helper",
"method",
"to",
"create",
"a",
"new",
"weight",
"matrix",
"."
] | python | test |
wandb/client | wandb/vendor/prompt_toolkit/buffer_mapping.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/buffer_mapping.py#L85-L92 | def pop_focus(self, cli):
"""
Pop buffer from the focus stack.
"""
if len(self.focus_stack) > 1:
self.focus_stack.pop()
else:
raise IndexError('Cannot pop last item from the focus stack.') | [
"def",
"pop_focus",
"(",
"self",
",",
"cli",
")",
":",
"if",
"len",
"(",
"self",
".",
"focus_stack",
")",
">",
"1",
":",
"self",
".",
"focus_stack",
".",
"pop",
"(",
")",
"else",
":",
"raise",
"IndexError",
"(",
"'Cannot pop last item from the focus stack.... | Pop buffer from the focus stack. | [
"Pop",
"buffer",
"from",
"the",
"focus",
"stack",
"."
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/guerilla/guerillamgmt.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L1218-L1230 | def prj_create_atype(self, *args, **kwargs):
"""Create a new project
:returns: None
:rtype: None
:raises: None
"""
if not self.cur_prj:
return
atype = self.create_atype(projects=[self.cur_prj])
if atype:
atypedata = djitemdata.Atyp... | [
"def",
"prj_create_atype",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"cur_prj",
":",
"return",
"atype",
"=",
"self",
".",
"create_atype",
"(",
"projects",
"=",
"[",
"self",
".",
"cur_prj",
"]",
")",
... | Create a new project
:returns: None
:rtype: None
:raises: None | [
"Create",
"a",
"new",
"project"
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/states/container_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/container_state.py#L904-L934 | def related_linkage_states_and_scoped_variables(self, state_ids, scoped_variables):
""" TODO: document
"""
# find all related transitions
related_transitions = {'enclosed': [], 'ingoing': [], 'outgoing': []}
for t in self.transitions.values():
# check if internal of ... | [
"def",
"related_linkage_states_and_scoped_variables",
"(",
"self",
",",
"state_ids",
",",
"scoped_variables",
")",
":",
"# find all related transitions",
"related_transitions",
"=",
"{",
"'enclosed'",
":",
"[",
"]",
",",
"'ingoing'",
":",
"[",
"]",
",",
"'outgoing'",
... | TODO: document | [
"TODO",
":",
"document"
] | python | train |
abilian/abilian-core | abilian/core/sqlalchemy.py | https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/core/sqlalchemy.py#L187-L196 | def coerce(cls, key, value):
"""Convert list to MutationList."""
if not isinstance(value, MutationList):
if isinstance(value, list):
return MutationList(value)
# this call will raise ValueError
return Mutable.coerce(key, value)
else:
... | [
"def",
"coerce",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"MutationList",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"return",
"MutationList",
"(",
"value",
")",
"# this call ... | Convert list to MutationList. | [
"Convert",
"list",
"to",
"MutationList",
"."
] | python | train |
JamesRamm/longclaw | longclaw/basket/forms.py | https://github.com/JamesRamm/longclaw/blob/8bbf2e6d703271b815ec111813c7c5d1d4e4e810/longclaw/basket/forms.py#L13-L19 | def clean(self):
""" Check user has cookies enabled
"""
if self.request:
if not self.request.session.test_cookie_worked():
raise forms.ValidationError("Cookies must be enabled.")
return self.cleaned_data | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
":",
"if",
"not",
"self",
".",
"request",
".",
"session",
".",
"test_cookie_worked",
"(",
")",
":",
"raise",
"forms",
".",
"ValidationError",
"(",
"\"Cookies must be enabled.\"",
")",
"re... | Check user has cookies enabled | [
"Check",
"user",
"has",
"cookies",
"enabled"
] | python | train |
WalletGuild/desw | desw/server.py | https://github.com/WalletGuild/desw/blob/f966c612e675961d9dbd8268749e349ba10a47c2/desw/server.py#L51-L58 | def get_user_by_key(app, key):
"""
An SQLAlchemy User getting function. Get a user by public key.
:param str key: the public key the user belongs to
"""
user = ses.query(um.User).join(um.UserKey).filter(um.UserKey.key==key).first()
return user | [
"def",
"get_user_by_key",
"(",
"app",
",",
"key",
")",
":",
"user",
"=",
"ses",
".",
"query",
"(",
"um",
".",
"User",
")",
".",
"join",
"(",
"um",
".",
"UserKey",
")",
".",
"filter",
"(",
"um",
".",
"UserKey",
".",
"key",
"==",
"key",
")",
".",... | An SQLAlchemy User getting function. Get a user by public key.
:param str key: the public key the user belongs to | [
"An",
"SQLAlchemy",
"User",
"getting",
"function",
".",
"Get",
"a",
"user",
"by",
"public",
"key",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/server/main.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/server/main.py#L8-L15 | def start(args):
"""Run server with provided command line arguments.
"""
application = tornado.web.Application([(r"/run", run.get_handler(args)),
(r"/status", run.StatusHandler)])
application.runmonitor = RunMonitor()
application.listen(args.port)
torna... | [
"def",
"start",
"(",
"args",
")",
":",
"application",
"=",
"tornado",
".",
"web",
".",
"Application",
"(",
"[",
"(",
"r\"/run\"",
",",
"run",
".",
"get_handler",
"(",
"args",
")",
")",
",",
"(",
"r\"/status\"",
",",
"run",
".",
"StatusHandler",
")",
... | Run server with provided command line arguments. | [
"Run",
"server",
"with",
"provided",
"command",
"line",
"arguments",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/CLI/cdn/origin_list.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/cdn/origin_list.py#L14-L28 | def cli(env, account_id):
"""List origin pull mappings."""
manager = SoftLayer.CDNManager(env.client)
origins = manager.get_origins(account_id)
table = formatting.Table(['id', 'media_type', 'cname', 'origin_url'])
for origin in origins:
table.add_row([origin['id'],
... | [
"def",
"cli",
"(",
"env",
",",
"account_id",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"CDNManager",
"(",
"env",
".",
"client",
")",
"origins",
"=",
"manager",
".",
"get_origins",
"(",
"account_id",
")",
"table",
"=",
"formatting",
".",
"Table",
"(",
... | List origin pull mappings. | [
"List",
"origin",
"pull",
"mappings",
"."
] | python | train |
kislyuk/aegea | aegea/audit.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L79-L87 | def audit_1_4(self):
"""1.4 Ensure access keys are rotated every 90 days or less (Scored)"""
for row in self.credential_report:
for access_key in "1", "2":
if json.loads(row["access_key_{}_active".format(access_key)]):
last_rotated = row["access_key_{}_las... | [
"def",
"audit_1_4",
"(",
"self",
")",
":",
"for",
"row",
"in",
"self",
".",
"credential_report",
":",
"for",
"access_key",
"in",
"\"1\"",
",",
"\"2\"",
":",
"if",
"json",
".",
"loads",
"(",
"row",
"[",
"\"access_key_{}_active\"",
".",
"format",
"(",
"acc... | 1.4 Ensure access keys are rotated every 90 days or less (Scored) | [
"1",
".",
"4",
"Ensure",
"access",
"keys",
"are",
"rotated",
"every",
"90",
"days",
"or",
"less",
"(",
"Scored",
")"
] | python | train |
esheldon/fitsio | fitsio/hdu/table.py | https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L562-L606 | def read(self, **keys):
"""
read data from this HDU
By default, all data are read.
send columns= and rows= to select subsets of the data.
Table data are read into a recarray; use read_column() to get a single
column as an ordinary array. You can alternatively use slice... | [
"def",
"read",
"(",
"self",
",",
"*",
"*",
"keys",
")",
":",
"columns",
"=",
"keys",
".",
"get",
"(",
"'columns'",
",",
"None",
")",
"rows",
"=",
"keys",
".",
"get",
"(",
"'rows'",
",",
"None",
")",
"if",
"columns",
"is",
"not",
"None",
":",
"i... | read data from this HDU
By default, all data are read.
send columns= and rows= to select subsets of the data.
Table data are read into a recarray; use read_column() to get a single
column as an ordinary array. You can alternatively use slice notation
fits=fitsio.FITS(filen... | [
"read",
"data",
"from",
"this",
"HDU"
] | python | train |
PMEAL/OpenPNM | openpnm/models/phases/viscosity.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/models/phases/viscosity.py#L4-L67 | def water(target, temperature='pore.temperature', salinity='pore.salinity'):
r"""
Calculates viscosity of pure water or seawater at atmospheric pressure
using Eq. (22) given by Sharqawy et. al [1]. Values at temperature higher
than the normal boiling temperature are calculated at the saturation
pres... | [
"def",
"water",
"(",
"target",
",",
"temperature",
"=",
"'pore.temperature'",
",",
"salinity",
"=",
"'pore.salinity'",
")",
":",
"T",
"=",
"target",
"[",
"temperature",
"]",
"if",
"salinity",
"in",
"target",
".",
"keys",
"(",
")",
":",
"S",
"=",
"target"... | r"""
Calculates viscosity of pure water or seawater at atmospheric pressure
using Eq. (22) given by Sharqawy et. al [1]. Values at temperature higher
than the normal boiling temperature are calculated at the saturation
pressure.
Parameters
----------
target : OpenPNM Object
The obje... | [
"r",
"Calculates",
"viscosity",
"of",
"pure",
"water",
"or",
"seawater",
"at",
"atmospheric",
"pressure",
"using",
"Eq",
".",
"(",
"22",
")",
"given",
"by",
"Sharqawy",
"et",
".",
"al",
"[",
"1",
"]",
".",
"Values",
"at",
"temperature",
"higher",
"than",... | python | train |
ambv/flake8-pyi | pyi.py | https://github.com/ambv/flake8-pyi/blob/19e8028b44b6305dff1bfb9a51a23a029c546993/pyi.py#L29-L43 | def ASSIGN(self, node):
"""This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type alias... | [
"def",
"ASSIGN",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"scope",
",",
"ModuleScope",
")",
":",
"return",
"super",
"(",
")",
".",
"ASSIGN",
"(",
"node",
")",
"for",
"target",
"in",
"node",
".",
"targets",
":... | This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type aliases might have forward references). | [
"This",
"is",
"a",
"custom",
"implementation",
"of",
"ASSIGN",
"derived",
"from",
"handleChildren",
"()",
"in",
"pyflakes",
"1",
".",
"3",
".",
"0",
"."
] | python | train |
biolink/ontobio | ontobio/golr/golr_associations.py | https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/golr/golr_associations.py#L126-L152 | def bulk_fetch(subject_category, object_category, taxon, rows=MAX_ROWS, **kwargs):
"""
Fetch associations for a species and pair of categories in bulk.
Arguments:
- subject_category: String (not None)
- object_category: String (not None)
- taxon: String
- rows: int
Additionally, a... | [
"def",
"bulk_fetch",
"(",
"subject_category",
",",
"object_category",
",",
"taxon",
",",
"rows",
"=",
"MAX_ROWS",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"subject_category",
"is",
"not",
"None",
"assert",
"object_category",
"is",
"not",
"None",
"time",
... | Fetch associations for a species and pair of categories in bulk.
Arguments:
- subject_category: String (not None)
- object_category: String (not None)
- taxon: String
- rows: int
Additionally, any argument for search_associations can be passed | [
"Fetch",
"associations",
"for",
"a",
"species",
"and",
"pair",
"of",
"categories",
"in",
"bulk",
"."
] | python | train |
knipknap/exscript | Exscript/util/ipv4.py | https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/ipv4.py#L221-L235 | def remote_ip(local_ip):
"""
Given an IP address, this function calculates the remaining available
IP address under the assumption that it is a /30 network.
In other words, given one link net address, this function returns the
other link net address.
:type local_ip: string
:param local_ip:... | [
"def",
"remote_ip",
"(",
"local_ip",
")",
":",
"local_ip",
"=",
"ip2int",
"(",
"local_ip",
")",
"network",
"=",
"local_ip",
"&",
"pfxlen2mask_int",
"(",
"30",
")",
"return",
"int2ip",
"(",
"network",
"+",
"3",
"-",
"(",
"local_ip",
"-",
"network",
")",
... | Given an IP address, this function calculates the remaining available
IP address under the assumption that it is a /30 network.
In other words, given one link net address, this function returns the
other link net address.
:type local_ip: string
:param local_ip: An IP address.
:rtype: string
... | [
"Given",
"an",
"IP",
"address",
"this",
"function",
"calculates",
"the",
"remaining",
"available",
"IP",
"address",
"under",
"the",
"assumption",
"that",
"it",
"is",
"a",
"/",
"30",
"network",
".",
"In",
"other",
"words",
"given",
"one",
"link",
"net",
"ad... | python | train |
Azure/blobxfer | blobxfer/util.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/util.py#L267-L277 | def page_align_content_length(length):
# type: (int) -> int
"""Compute page boundary alignment
:param int length: content length
:rtype: int
:return: aligned byte boundary
"""
mod = length % _PAGEBLOB_BOUNDARY
if mod != 0:
return length + (_PAGEBLOB_BOUNDARY - mod)
return len... | [
"def",
"page_align_content_length",
"(",
"length",
")",
":",
"# type: (int) -> int",
"mod",
"=",
"length",
"%",
"_PAGEBLOB_BOUNDARY",
"if",
"mod",
"!=",
"0",
":",
"return",
"length",
"+",
"(",
"_PAGEBLOB_BOUNDARY",
"-",
"mod",
")",
"return",
"length"
] | Compute page boundary alignment
:param int length: content length
:rtype: int
:return: aligned byte boundary | [
"Compute",
"page",
"boundary",
"alignment",
":",
"param",
"int",
"length",
":",
"content",
"length",
":",
"rtype",
":",
"int",
":",
"return",
":",
"aligned",
"byte",
"boundary"
] | python | train |
HazyResearch/metal | metal/tuners/tuner.py | https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/tuner.py#L258-L351 | def config_generator(search_space, max_search, rng, shuffle=True):
"""Generates config dicts from the given search space
Args:
search_space: (dict) A dictionary of parameters to search over.
See note below for more details.
max_search: (int) The maximum number of... | [
"def",
"config_generator",
"(",
"search_space",
",",
"max_search",
",",
"rng",
",",
"shuffle",
"=",
"True",
")",
":",
"def",
"dict_product",
"(",
"d",
")",
":",
"keys",
"=",
"d",
".",
"keys",
"(",
")",
"for",
"element",
"in",
"product",
"(",
"*",
"d"... | Generates config dicts from the given search space
Args:
search_space: (dict) A dictionary of parameters to search over.
See note below for more details.
max_search: (int) The maximum number of configurations to search.
If max_search is None, do a full gr... | [
"Generates",
"config",
"dicts",
"from",
"the",
"given",
"search",
"space"
] | python | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L205-L234 | def _get_connection(self, conn_or_int_id):
"""Get the data for a connection by either conn_id or internal_id
Args:
conn_or_int_id (int, string): The external integer connection id or
and internal string connection id
Returns:
dict: The context data assoc... | [
"def",
"_get_connection",
"(",
"self",
",",
"conn_or_int_id",
")",
":",
"key",
"=",
"conn_or_int_id",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"table",
"=",
"self",
".",
"_int_connections",
"elif",
"isinstance",
"(",
"key",
",",
"int",
")",
... | Get the data for a connection by either conn_id or internal_id
Args:
conn_or_int_id (int, string): The external integer connection id or
and internal string connection id
Returns:
dict: The context data associated with that connection or None if it cannot
... | [
"Get",
"the",
"data",
"for",
"a",
"connection",
"by",
"either",
"conn_id",
"or",
"internal_id"
] | python | train |
Kortemme-Lab/klab | klab/bio/bonsai.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L506-L544 | def find_sidechain_atoms_within_radius_of_residue_objects(self, source_residues, search_radius, find_ATOM_atoms = True, find_HETATM_atoms = False, restrict_to_CA = False):
'''for residue in source_residues:
for all heavy atoms in residue
find all heavy atoms within radius which are w... | [
"def",
"find_sidechain_atoms_within_radius_of_residue_objects",
"(",
"self",
",",
"source_residues",
",",
"search_radius",
",",
"find_ATOM_atoms",
"=",
"True",
",",
"find_HETATM_atoms",
"=",
"False",
",",
"restrict_to_CA",
"=",
"False",
")",
":",
"atom_hit_cache",
"=",
... | for residue in source_residues:
for all heavy atoms in residue
find all heavy atoms within radius which are within residues (ATOM records)
for all heavy atoms found
determing the associated residue
for all found residues not in source_residues
... | [
"for",
"residue",
"in",
"source_residues",
":",
"for",
"all",
"heavy",
"atoms",
"in",
"residue",
"find",
"all",
"heavy",
"atoms",
"within",
"radius",
"which",
"are",
"within",
"residues",
"(",
"ATOM",
"records",
")",
"for",
"all",
"heavy",
"atoms",
"found",
... | python | train |
csparpa/pyowm | pyowm/stationsapi30/stations_manager.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/stationsapi30/stations_manager.py#L138-L153 | def send_measurement(self, measurement):
"""
Posts the provided Measurement object's data to the Station API.
:param measurement: the *pyowm.stationsapi30.measurement.Measurement*
object to be posted
:type measurement: *pyowm.stationsapi30.measurement.Measurement* instance
... | [
"def",
"send_measurement",
"(",
"self",
",",
"measurement",
")",
":",
"assert",
"measurement",
"is",
"not",
"None",
"assert",
"measurement",
".",
"station_id",
"is",
"not",
"None",
"status",
",",
"_",
"=",
"self",
".",
"http_client",
".",
"post",
"(",
"MEA... | Posts the provided Measurement object's data to the Station API.
:param measurement: the *pyowm.stationsapi30.measurement.Measurement*
object to be posted
:type measurement: *pyowm.stationsapi30.measurement.Measurement* instance
:returns: `None` if creation is successful, an exception... | [
"Posts",
"the",
"provided",
"Measurement",
"object",
"s",
"data",
"to",
"the",
"Station",
"API",
"."
] | python | train |
rosenbrockc/fortpy | fortpy/parsers/executable.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/executable.py#L348-L362 | def _remove_dependency(self, dependlist, i, isSubroutine, anexec):
"""Removes the specified dependency from the executable if it exists
and matches the call signature."""
if dependlist[i] in anexec.dependencies:
all_depends = anexec.dependencies[dependlist[i]]
if len(all_... | [
"def",
"_remove_dependency",
"(",
"self",
",",
"dependlist",
",",
"i",
",",
"isSubroutine",
",",
"anexec",
")",
":",
"if",
"dependlist",
"[",
"i",
"]",
"in",
"anexec",
".",
"dependencies",
":",
"all_depends",
"=",
"anexec",
".",
"dependencies",
"[",
"depen... | Removes the specified dependency from the executable if it exists
and matches the call signature. | [
"Removes",
"the",
"specified",
"dependency",
"from",
"the",
"executable",
"if",
"it",
"exists",
"and",
"matches",
"the",
"call",
"signature",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L627-L657 | def _bgzip_from_fastq(data):
"""Prepare a bgzipped file from a fastq input, potentially gzipped (or bgzipped already).
"""
in_file = data["in_file"]
if isinstance(in_file, (list, tuple)):
in_file = in_file[0]
needs_convert = dd.get_quality_format(data).lower() == "illumina"
# special cas... | [
"def",
"_bgzip_from_fastq",
"(",
"data",
")",
":",
"in_file",
"=",
"data",
"[",
"\"in_file\"",
"]",
"if",
"isinstance",
"(",
"in_file",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"in_file",
"=",
"in_file",
"[",
"0",
"]",
"needs_convert",
"=",
"dd",... | Prepare a bgzipped file from a fastq input, potentially gzipped (or bgzipped already). | [
"Prepare",
"a",
"bgzipped",
"file",
"from",
"a",
"fastq",
"input",
"potentially",
"gzipped",
"(",
"or",
"bgzipped",
"already",
")",
"."
] | python | train |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L3056-L3066 | def GetPixelColorsHorizontally(self, x: int, y: int, count: int) -> ctypes.Array:
"""
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y horizontally.
"""
arrayType = ctypes.c_uint32 * count
values = a... | [
"def",
"GetPixelColorsHorizontally",
"(",
"self",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
",",
"count",
":",
"int",
")",
"->",
"ctypes",
".",
"Array",
":",
"arrayType",
"=",
"ctypes",
".",
"c_uint32",
"*",
"count",
"values",
"=",
"arrayType",
"(",
... | x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y horizontally. | [
"x",
":",
"int",
".",
"y",
":",
"int",
".",
"count",
":",
"int",
".",
"Return",
"ctypes",
".",
"Array",
"an",
"iterable",
"array",
"of",
"int",
"values",
"in",
"argb",
"form",
"point",
"x",
"y",
"horizontally",
"."
] | python | valid |
mikedh/trimesh | trimesh/intersections.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/intersections.py#L340-L386 | def planes_lines(plane_origins,
plane_normals,
line_origins,
line_directions):
"""
Given one line per plane, find the intersection points.
Parameters
-----------
plane_origins : (n,3) float
Point on each plane
plane_normals : (n,3) floa... | [
"def",
"planes_lines",
"(",
"plane_origins",
",",
"plane_normals",
",",
"line_origins",
",",
"line_directions",
")",
":",
"# check input types",
"plane_origins",
"=",
"np",
".",
"asanyarray",
"(",
"plane_origins",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"p... | Given one line per plane, find the intersection points.
Parameters
-----------
plane_origins : (n,3) float
Point on each plane
plane_normals : (n,3) float
Normal vector of each plane
line_origins : (n,3) float
Point at origin of each line
line_directions : (n,3) float
... | [
"Given",
"one",
"line",
"per",
"plane",
"find",
"the",
"intersection",
"points",
"."
] | python | train |
fermiPy/fermipy | fermipy/castro.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L404-L441 | def create_from_table(cls, tab_e):
"""
Parameters
----------
tab_e : `~astropy.table.Table`
EBOUNDS table.
"""
convert_sed_cols(tab_e)
try:
emin = np.array(tab_e['e_min'].to(u.MeV))
emax = np.array(tab_e['e_max'].to(u.M... | [
"def",
"create_from_table",
"(",
"cls",
",",
"tab_e",
")",
":",
"convert_sed_cols",
"(",
"tab_e",
")",
"try",
":",
"emin",
"=",
"np",
".",
"array",
"(",
"tab_e",
"[",
"'e_min'",
"]",
".",
"to",
"(",
"u",
".",
"MeV",
")",
")",
"emax",
"=",
"np",
"... | Parameters
----------
tab_e : `~astropy.table.Table`
EBOUNDS table. | [
"Parameters",
"----------",
"tab_e",
":",
"~astropy",
".",
"table",
".",
"Table",
"EBOUNDS",
"table",
"."
] | python | train |
algorithmiaio/algorithmia-python | Algorithmia/datadirectory.py | https://github.com/algorithmiaio/algorithmia-python/blob/fe33e6524272ff7ca11c43d1d6985890e6c48a79/Algorithmia/datadirectory.py#L40-L48 | def create(self, acl=None):
'''Creates a directory, optionally include Acl argument to set permissions'''
parent, name = getParentAndBase(self.path)
json = { 'name': name }
if acl is not None:
json['acl'] = acl.to_api_param()
response = self.client.postJsonHelper(Data... | [
"def",
"create",
"(",
"self",
",",
"acl",
"=",
"None",
")",
":",
"parent",
",",
"name",
"=",
"getParentAndBase",
"(",
"self",
".",
"path",
")",
"json",
"=",
"{",
"'name'",
":",
"name",
"}",
"if",
"acl",
"is",
"not",
"None",
":",
"json",
"[",
"'ac... | Creates a directory, optionally include Acl argument to set permissions | [
"Creates",
"a",
"directory",
"optionally",
"include",
"Acl",
"argument",
"to",
"set",
"permissions"
] | python | train |
Bachmann1234/diff-cover | diff_cover/diff_quality_tool.py | https://github.com/Bachmann1234/diff-cover/blob/901cb3fc986982961785e841658085ead453c6c9/diff_cover/diff_quality_tool.py#L149-L178 | def generate_quality_report(tool, compare_branch,
html_report=None, css_file=None,
ignore_staged=False, ignore_unstaged=False,
exclude=None):
"""
Generate the quality report, using kwargs from `parse_args()`.
"""
diff = ... | [
"def",
"generate_quality_report",
"(",
"tool",
",",
"compare_branch",
",",
"html_report",
"=",
"None",
",",
"css_file",
"=",
"None",
",",
"ignore_staged",
"=",
"False",
",",
"ignore_unstaged",
"=",
"False",
",",
"exclude",
"=",
"None",
")",
":",
"diff",
"=",... | Generate the quality report, using kwargs from `parse_args()`. | [
"Generate",
"the",
"quality",
"report",
"using",
"kwargs",
"from",
"parse_args",
"()",
"."
] | python | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L501-L529 | def load(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or ... | [
"def",
"load",
"(",
"self",
",",
"source",
",",
"mode",
"=",
"'create'",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
")",
":",
"job",
"=",
"self",
".",... | Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
mode: one of 'create', 'append', or 'overwrite'. 'append' or 'overwrite' will fail if the
table does not already exist, w... | [
"Load",
"the",
"table",
"from",
"GCS",
"."
] | python | train |
JoeVirtual/KonFoo | konfoo/options.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/options.py#L49-L64 | def nested_option(default=False):
""" Attaches the option ``nested`` with its *default* value to the
keyword arguments when the option does not exist. All positional
arguments and keyword arguments are forwarded unchanged.
"""
def decorator(method):
@wraps(method)
def wrapper(*args,... | [
"def",
"nested_option",
"(",
"default",
"=",
"False",
")",
":",
"def",
"decorator",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"option",
"=",
"Option",
".",
"nes... | Attaches the option ``nested`` with its *default* value to the
keyword arguments when the option does not exist. All positional
arguments and keyword arguments are forwarded unchanged. | [
"Attaches",
"the",
"option",
"nested",
"with",
"its",
"*",
"default",
"*",
"value",
"to",
"the",
"keyword",
"arguments",
"when",
"the",
"option",
"does",
"not",
"exist",
".",
"All",
"positional",
"arguments",
"and",
"keyword",
"arguments",
"are",
"forwarded",
... | python | train |
NYUCCL/psiTurk | psiturk/amt_services_wrapper.py | https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/amt_services_wrapper.py#L533-L543 | def db_aws_list_regions(self):
''' List AWS DB regions '''
regions = self.db_services.list_regions()
if regions != []:
print "Avaliable AWS regions:"
for reg in regions:
print '\t' + reg,
if reg == self.db_services.get_region():
print "... | [
"def",
"db_aws_list_regions",
"(",
"self",
")",
":",
"regions",
"=",
"self",
".",
"db_services",
".",
"list_regions",
"(",
")",
"if",
"regions",
"!=",
"[",
"]",
":",
"print",
"\"Avaliable AWS regions:\"",
"for",
"reg",
"in",
"regions",
":",
"print",
"'\\t'",... | List AWS DB regions | [
"List",
"AWS",
"DB",
"regions"
] | python | train |
SethMMorton/natsort | natsort/utils.py | https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L729-L791 | def path_splitter(s, _d_match=re.compile(r"\.\d").match):
"""
Split a string into its path components.
Assumes a string is a path or is path-like.
Parameters
----------
s : str | pathlib.Path
Returns
-------
split : tuple
The path split by directory components and extensio... | [
"def",
"path_splitter",
"(",
"s",
",",
"_d_match",
"=",
"re",
".",
"compile",
"(",
"r\"\\.\\d\"",
")",
".",
"match",
")",
":",
"if",
"has_pathlib",
"and",
"isinstance",
"(",
"s",
",",
"PurePath",
")",
":",
"s",
"=",
"py23_str",
"(",
"s",
")",
"path_p... | Split a string into its path components.
Assumes a string is a path or is path-like.
Parameters
----------
s : str | pathlib.Path
Returns
-------
split : tuple
The path split by directory components and extensions.
Examples
--------
>>> tuple(path_splitter("this/... | [
"Split",
"a",
"string",
"into",
"its",
"path",
"components",
"."
] | python | train |
user-cont/conu | conu/backend/docker/utils.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L65-L132 | def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance):
"""
process data from `docker container inspect` and update provided container metadata object
:param c_metadata_object: instance of ContainerMetadata
:param inspect_data: dict, metadata from `docker inspect` or `docker... | [
"def",
"inspect_to_container_metadata",
"(",
"c_metadata_object",
",",
"inspect_data",
",",
"image_instance",
")",
":",
"inspect_to_metadata",
"(",
"c_metadata_object",
",",
"inspect_data",
")",
"status",
"=",
"ContainerStatus",
".",
"get_from_docker",
"(",
"graceful_get"... | process data from `docker container inspect` and update provided container metadata object
:param c_metadata_object: instance of ContainerMetadata
:param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
:param image_instance: instance of DockerImage
:return: instance of C... | [
"process",
"data",
"from",
"docker",
"container",
"inspect",
"and",
"update",
"provided",
"container",
"metadata",
"object"
] | python | train |
theiviaxx/Frog | frog/common.py | https://github.com/theiviaxx/Frog/blob/a9475463a8eed1323fe3ef5d51f9751fb1dc9edd/frog/common.py#L57-L65 | def append(self, val):
"""Appends the object to the end of the values list. Will also set the value to the first
item in the values list
:param val: Object to append
:type val: primitive
"""
self.values.append(val)
self.value = self.values[0] | [
"def",
"append",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"values",
".",
"append",
"(",
"val",
")",
"self",
".",
"value",
"=",
"self",
".",
"values",
"[",
"0",
"]"
] | Appends the object to the end of the values list. Will also set the value to the first
item in the values list
:param val: Object to append
:type val: primitive | [
"Appends",
"the",
"object",
"to",
"the",
"end",
"of",
"the",
"values",
"list",
".",
"Will",
"also",
"set",
"the",
"value",
"to",
"the",
"first",
"item",
"in",
"the",
"values",
"list"
] | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/input_readers.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/input_readers.py#L2151-L2178 | def split_input(cls, mapper_spec):
"""Returns a list of input readers for the given input specification.
Args:
mapper_spec: The MapperSpec for this InputReader.
Returns:
A list of InputReaders.
"""
params = _get_params(mapper_spec)
shard_count = mapper_spec.shard_count
# Pick ... | [
"def",
"split_input",
"(",
"cls",
",",
"mapper_spec",
")",
":",
"params",
"=",
"_get_params",
"(",
"mapper_spec",
")",
"shard_count",
"=",
"mapper_spec",
".",
"shard_count",
"# Pick out the overall start and end times and time step per shard.",
"start_time",
"=",
"params"... | Returns a list of input readers for the given input specification.
Args:
mapper_spec: The MapperSpec for this InputReader.
Returns:
A list of InputReaders. | [
"Returns",
"a",
"list",
"of",
"input",
"readers",
"for",
"the",
"given",
"input",
"specification",
"."
] | python | train |
twilio/twilio-python | twilio/rest/preview/wireless/command.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/wireless/command.py#L71-L99 | def list(self, device=values.unset, sim=values.unset, status=values.unset,
direction=values.unset, limit=None, page_size=None):
"""
Lists CommandInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before... | [
"def",
"list",
"(",
"self",
",",
"device",
"=",
"values",
".",
"unset",
",",
"sim",
"=",
"values",
".",
"unset",
",",
"status",
"=",
"values",
".",
"unset",
",",
"direction",
"=",
"values",
".",
"unset",
",",
"limit",
"=",
"None",
",",
"page_size",
... | Lists CommandInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param unicode device: The device
:param unicode sim: The sim
:param unicode status: The status
:param unicode direc... | [
"Lists",
"CommandInstance",
"records",
"from",
"the",
"API",
"as",
"a",
"list",
".",
"Unlike",
"stream",
"()",
"this",
"operation",
"is",
"eager",
"and",
"will",
"load",
"limit",
"records",
"into",
"memory",
"before",
"returning",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/editor/lsp/decorators.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/decorators.py#L12-L24 | def send_request(req=None, method=None, requires_response=True):
"""Call function req and then send its results via ZMQ."""
if req is None:
return functools.partial(send_request, method=method,
requires_response=requires_response)
@functools.wraps(req)
def wrapp... | [
"def",
"send_request",
"(",
"req",
"=",
"None",
",",
"method",
"=",
"None",
",",
"requires_response",
"=",
"True",
")",
":",
"if",
"req",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"send_request",
",",
"method",
"=",
"method",
",",
... | Call function req and then send its results via ZMQ. | [
"Call",
"function",
"req",
"and",
"then",
"send",
"its",
"results",
"via",
"ZMQ",
"."
] | python | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L113-L152 | def watch(connection, volume_id, interval='daily', retention=0):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:type interval: str
:param in... | [
"def",
"watch",
"(",
"connection",
",",
"volume_id",
",",
"interval",
"=",
"'daily'",
",",
"retention",
"=",
"0",
")",
":",
"try",
":",
"volume",
"=",
"connection",
".",
"get_all_volumes",
"(",
"volume_ids",
"=",
"[",
"volume_id",
"]",
")",
"[",
"0",
"... | Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:type interval: str
:param interval: Backup interval [hourly|daily|weekly|monthly|yearly]
:type re... | [
"Start",
"watching",
"a",
"new",
"volume"
] | python | train |
ojake/django-tracked-model | tracked_model/serializer.py | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L86-L94 | def restore_model(cls, data):
"""Returns instance of ``cls`` with attributed loaded
from ``data`` dict.
"""
obj = cls()
for field in data:
setattr(obj, field, data[field][Field.VALUE])
return obj | [
"def",
"restore_model",
"(",
"cls",
",",
"data",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"for",
"field",
"in",
"data",
":",
"setattr",
"(",
"obj",
",",
"field",
",",
"data",
"[",
"field",
"]",
"[",
"Field",
".",
"VALUE",
"]",
")",
"return",
"obj"
... | Returns instance of ``cls`` with attributed loaded
from ``data`` dict. | [
"Returns",
"instance",
"of",
"cls",
"with",
"attributed",
"loaded",
"from",
"data",
"dict",
"."
] | python | train |
CalebBell/thermo | thermo/activity.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/activity.py#L39-L168 | def K_value(P=None, Psat=None, phi_l=None, phi_g=None, gamma=None, Poynting=1):
r'''Calculates the equilibrium K-value assuming Raoult's law,
or an equation of state model, or an activity coefficient model,
or a combined equation of state-activity model.
The calculation procedure will use the most adva... | [
"def",
"K_value",
"(",
"P",
"=",
"None",
",",
"Psat",
"=",
"None",
",",
"phi_l",
"=",
"None",
",",
"phi_g",
"=",
"None",
",",
"gamma",
"=",
"None",
",",
"Poynting",
"=",
"1",
")",
":",
"try",
":",
"if",
"gamma",
":",
"if",
"phi_l",
":",
"return... | r'''Calculates the equilibrium K-value assuming Raoult's law,
or an equation of state model, or an activity coefficient model,
or a combined equation of state-activity model.
The calculation procedure will use the most advanced approach with the
provided inputs:
* If `P`, `Psat`, `phi_l`, `phi... | [
"r",
"Calculates",
"the",
"equilibrium",
"K",
"-",
"value",
"assuming",
"Raoult",
"s",
"law",
"or",
"an",
"equation",
"of",
"state",
"model",
"or",
"an",
"activity",
"coefficient",
"model",
"or",
"a",
"combined",
"equation",
"of",
"state",
"-",
"activity",
... | python | valid |
PyCQA/pylint | pylint/message/message_handler_mix_in.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L403-L459 | def _print_checker_doc(checker_name, info, stream=None):
"""Helper method for print_full_documentation.
Also used by doc/exts/pylint_extensions.py.
"""
if not stream:
stream = sys.stdout
doc = info.get("doc")
module = info.get("module")
msgs = info.g... | [
"def",
"_print_checker_doc",
"(",
"checker_name",
",",
"info",
",",
"stream",
"=",
"None",
")",
":",
"if",
"not",
"stream",
":",
"stream",
"=",
"sys",
".",
"stdout",
"doc",
"=",
"info",
".",
"get",
"(",
"\"doc\"",
")",
"module",
"=",
"info",
".",
"ge... | Helper method for print_full_documentation.
Also used by doc/exts/pylint_extensions.py. | [
"Helper",
"method",
"for",
"print_full_documentation",
"."
] | python | test |
pantsbuild/pants | src/python/pants/base/exiter.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/exiter.py#L83-L90 | def exit_and_fail(self, msg=None, out=None):
"""Exits the runtime with a nonzero exit code, indicating failure.
:param msg: A string message to print to stderr or another custom file desciptor before exiting.
(Optional)
:param out: The file descriptor to emit `msg` to. (Optional)
"""
... | [
"def",
"exit_and_fail",
"(",
"self",
",",
"msg",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"self",
".",
"exit",
"(",
"result",
"=",
"PANTS_FAILED_EXIT_CODE",
",",
"msg",
"=",
"msg",
",",
"out",
"=",
"out",
")"
] | Exits the runtime with a nonzero exit code, indicating failure.
:param msg: A string message to print to stderr or another custom file desciptor before exiting.
(Optional)
:param out: The file descriptor to emit `msg` to. (Optional) | [
"Exits",
"the",
"runtime",
"with",
"a",
"nonzero",
"exit",
"code",
"indicating",
"failure",
"."
] | python | train |
saltstack/salt | salt/utils/openstack/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L558-L573 | def _volume_get(self, volume_id):
'''
Organize information about a volume from the volume_id
'''
if self.volume_conn is None:
raise SaltCloudSystemExit('No cinder endpoint available')
nt_ks = self.volume_conn
volume = nt_ks.volumes.get(volume_id)
respo... | [
"def",
"_volume_get",
"(",
"self",
",",
"volume_id",
")",
":",
"if",
"self",
".",
"volume_conn",
"is",
"None",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'No cinder endpoint available'",
")",
"nt_ks",
"=",
"self",
".",
"volume_conn",
"volume",
"=",
"nt_ks",
".... | Organize information about a volume from the volume_id | [
"Organize",
"information",
"about",
"a",
"volume",
"from",
"the",
"volume_id"
] | python | train |
bitprophet/releases | releases/line_manager.py | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/line_manager.py#L23-L37 | def add_family(self, major_number):
"""
Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping.
"""
# Normally, we have separate buckets for bugfixes vs features
... | [
"def",
"add_family",
"(",
"self",
",",
"major_number",
")",
":",
"# Normally, we have separate buckets for bugfixes vs features",
"keys",
"=",
"[",
"'unreleased_bugfix'",
",",
"'unreleased_feature'",
"]",
"# But unstable prehistorical releases roll all up into just",
"# 'unreleased... | Expand to a new release line with given ``major_number``.
This will flesh out mandatory buckets like ``unreleased_bugfix`` and do
other necessary bookkeeping. | [
"Expand",
"to",
"a",
"new",
"release",
"line",
"with",
"given",
"major_number",
"."
] | python | train |
pyamg/pyamg | pyamg/util/linalg.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/util/linalg.py#L58-L103 | def infinity_norm(A):
"""Infinity norm of a matrix (maximum absolute row sum).
Parameters
----------
A : csr_matrix, csc_matrix, sparse, or numpy matrix
Sparse or dense matrix
Returns
-------
n : float
Infinity norm of the matrix
Notes
-----
- This serves as an... | [
"def",
"infinity_norm",
"(",
"A",
")",
":",
"if",
"sparse",
".",
"isspmatrix_csr",
"(",
"A",
")",
"or",
"sparse",
".",
"isspmatrix_csc",
"(",
"A",
")",
":",
"# avoid copying index and ptr arrays",
"abs_A",
"=",
"A",
".",
"__class__",
"(",
"(",
"np",
".",
... | Infinity norm of a matrix (maximum absolute row sum).
Parameters
----------
A : csr_matrix, csc_matrix, sparse, or numpy matrix
Sparse or dense matrix
Returns
-------
n : float
Infinity norm of the matrix
Notes
-----
- This serves as an upper bound on spectral radi... | [
"Infinity",
"norm",
"of",
"a",
"matrix",
"(",
"maximum",
"absolute",
"row",
"sum",
")",
"."
] | python | train |
angr/angr | angr/analyses/cfg/cfg_emulated.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfg_emulated.py#L1479-L1520 | def _post_handle_job_debug(self, job, successors):
"""
Post job handling: print debugging information regarding the current job.
:param CFGJob job: The current CFGJob instance.
:param list successors: All successors of the analysis job.
:return: None
"""
si... | [
"def",
"_post_handle_job_debug",
"(",
"self",
",",
"job",
",",
"successors",
")",
":",
"sim_successors",
"=",
"job",
".",
"sim_successors",
"call_stack_suffix",
"=",
"job",
".",
"call_stack_suffix",
"extra_info",
"=",
"job",
".",
"extra_info",
"successor_status",
... | Post job handling: print debugging information regarding the current job.
:param CFGJob job: The current CFGJob instance.
:param list successors: All successors of the analysis job.
:return: None | [
"Post",
"job",
"handling",
":",
"print",
"debugging",
"information",
"regarding",
"the",
"current",
"job",
"."
] | python | train |
noahbenson/neuropythy | neuropythy/commands/atlas.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/atlas.py#L158-L243 | def calc_atlas_projections(subject_cortices, atlas_cortices, atlas_map, worklog, atlases=Ellipsis):
'''
calc_atlas_projections calculates the lazy map of atlas projections.
Afferent parameters:
@ atlases
The atlases that should be applied to the subject. This can be specified as a list/tuple... | [
"def",
"calc_atlas_projections",
"(",
"subject_cortices",
",",
"atlas_cortices",
",",
"atlas_map",
",",
"worklog",
",",
"atlases",
"=",
"Ellipsis",
")",
":",
"# Parse the atlases argument first:",
"if",
"atlases",
"is",
"Ellipsis",
":",
"atlases",
"=",
"(",
"'benson... | calc_atlas_projections calculates the lazy map of atlas projections.
Afferent parameters:
@ atlases
The atlases that should be applied to the subject. This can be specified as a list/tuple of
atlas names or as a string where the atlas names are separated by whitespace, commas, or
sem... | [
"calc_atlas_projections",
"calculates",
"the",
"lazy",
"map",
"of",
"atlas",
"projections",
"."
] | python | train |
aholkner/bacon | native/Vendor/FreeType/src/tools/docmaker/tohtml.py | https://github.com/aholkner/bacon/blob/edf3810dcb211942d392a8637945871399b0650d/native/Vendor/FreeType/src/tools/docmaker/tohtml.py#L245-L253 | def make_html_words( self, words ):
""" convert a series of simple words into some HTML text """
line = ""
if words:
line = html_quote( words[0] )
for w in words[1:]:
line = line + " " + html_quote( w )
return line | [
"def",
"make_html_words",
"(",
"self",
",",
"words",
")",
":",
"line",
"=",
"\"\"",
"if",
"words",
":",
"line",
"=",
"html_quote",
"(",
"words",
"[",
"0",
"]",
")",
"for",
"w",
"in",
"words",
"[",
"1",
":",
"]",
":",
"line",
"=",
"line",
"+",
"... | convert a series of simple words into some HTML text | [
"convert",
"a",
"series",
"of",
"simple",
"words",
"into",
"some",
"HTML",
"text"
] | python | test |
rambo/python-holviapi | holviapi/utils.py | https://github.com/rambo/python-holviapi/blob/f57f44e7b0a1030786aafd6f387114abb546bb32/holviapi/utils.py#L167-L173 | def iso_reference_valid_char(c, raise_error=True):
"""Helper to make sure the given character is valid for a reference number"""
if c in ISO_REFERENCE_VALID:
return True
if raise_error:
raise ValueError("'%s' is not in '%s'" % (c, ISO_REFERENCE_VALID))
return False | [
"def",
"iso_reference_valid_char",
"(",
"c",
",",
"raise_error",
"=",
"True",
")",
":",
"if",
"c",
"in",
"ISO_REFERENCE_VALID",
":",
"return",
"True",
"if",
"raise_error",
":",
"raise",
"ValueError",
"(",
"\"'%s' is not in '%s'\"",
"%",
"(",
"c",
",",
"ISO_REF... | Helper to make sure the given character is valid for a reference number | [
"Helper",
"to",
"make",
"sure",
"the",
"given",
"character",
"is",
"valid",
"for",
"a",
"reference",
"number"
] | python | valid |
aliyun/aliyun-odps-python-sdk | odps/df/expr/collections.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/df/expr/collections.py#L270-L363 | def sample(expr, parts=None, columns=None, i=None, n=None, frac=None, replace=False,
weights=None, strata=None, random_state=None):
"""
Sample collection.
:param expr: collection
:param parts: how many parts to hash
:param columns: the columns to sample
:param i: the part to sample o... | [
"def",
"sample",
"(",
"expr",
",",
"parts",
"=",
"None",
",",
"columns",
"=",
"None",
",",
"i",
"=",
"None",
",",
"n",
"=",
"None",
",",
"frac",
"=",
"None",
",",
"replace",
"=",
"False",
",",
"weights",
"=",
"None",
",",
"strata",
"=",
"None",
... | Sample collection.
:param expr: collection
:param parts: how many parts to hash
:param columns: the columns to sample
:param i: the part to sample out, can be a list of parts, must be from 0 to parts-1
:param n: how many rows to sample. If `strata` is specified, `n` should be a dict with values in ... | [
"Sample",
"collection",
"."
] | python | train |
openid/JWTConnect-Python-OidcService | src/oidcservice/state_interface.py | https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L103-L118 | def get_item(self, item_cls, item_type, key):
"""
Get a piece of information (a request or a response) from the state
database.
:param item_cls: The :py:class:`oidcmsg.message.Message` subclass
that described the item.
:param item_type: Which request/response that is... | [
"def",
"get_item",
"(",
"self",
",",
"item_cls",
",",
"item_type",
",",
"key",
")",
":",
"_state",
"=",
"self",
".",
"get_state",
"(",
"key",
")",
"try",
":",
"return",
"item_cls",
"(",
"*",
"*",
"_state",
"[",
"item_type",
"]",
")",
"except",
"TypeE... | Get a piece of information (a request or a response) from the state
database.
:param item_cls: The :py:class:`oidcmsg.message.Message` subclass
that described the item.
:param item_type: Which request/response that is wanted
:param key: The key to the information in the stat... | [
"Get",
"a",
"piece",
"of",
"information",
"(",
"a",
"request",
"or",
"a",
"response",
")",
"from",
"the",
"state",
"database",
"."
] | python | train |
wilson-eft/wilson | wilson/run/smeft/classes.py | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L197-L214 | def run(self, scale, accuracy='integrate', **kwargs):
"""Return the Wilson coefficients (as wcxf.WC instance) evolved to the
scale `scale`.
Parameters:
- `scale`: scale in GeV
- accuracy: whether to use the numerical solution to the RGE
('integrate', the default, slow ... | [
"def",
"run",
"(",
"self",
",",
"scale",
",",
"accuracy",
"=",
"'integrate'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"accuracy",
"==",
"'integrate'",
":",
"C_out",
"=",
"self",
".",
"_rgevolve",
"(",
"scale",
",",
"*",
"*",
"kwargs",
")",
"elif",
... | Return the Wilson coefficients (as wcxf.WC instance) evolved to the
scale `scale`.
Parameters:
- `scale`: scale in GeV
- accuracy: whether to use the numerical solution to the RGE
('integrate', the default, slow but precise) or the leading logarithmic
approximation ('l... | [
"Return",
"the",
"Wilson",
"coefficients",
"(",
"as",
"wcxf",
".",
"WC",
"instance",
")",
"evolved",
"to",
"the",
"scale",
"scale",
"."
] | python | train |
spacetelescope/pysynphot | pysynphot/binning.py | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/binning.py#L7-L42 | def calculate_bin_edges(centers):
"""
Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array_like
Se... | [
"def",
"calculate_bin_edges",
"(",
"centers",
")",
":",
"centers",
"=",
"np",
".",
"asanyarray",
"(",
"centers",
")",
"if",
"centers",
".",
"ndim",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'centers input array must be 1D.'",
")",
"if",
"centers",
".",
"s... | Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array_like
Sequence of bin centers. Must be 1D and have at ... | [
"Calculate",
"the",
"edges",
"of",
"wavelength",
"bins",
"given",
"the",
"centers",
"."
] | python | train |
KnightConan/sspdatatables | src/sspdatatables/utils/enum.py | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/enum.py#L135-L157 | def describe(cls) -> None:
"""
Prints in the console a table showing all the attributes for all the
definitions inside the class
:return: None
"""
max_lengths = []
for attr_name in cls.attr_names():
attr_func = "%ss" % attr_name
attr_list ... | [
"def",
"describe",
"(",
"cls",
")",
"->",
"None",
":",
"max_lengths",
"=",
"[",
"]",
"for",
"attr_name",
"in",
"cls",
".",
"attr_names",
"(",
")",
":",
"attr_func",
"=",
"\"%ss\"",
"%",
"attr_name",
"attr_list",
"=",
"list",
"(",
"map",
"(",
"str",
"... | Prints in the console a table showing all the attributes for all the
definitions inside the class
:return: None | [
"Prints",
"in",
"the",
"console",
"a",
"table",
"showing",
"all",
"the",
"attributes",
"for",
"all",
"the",
"definitions",
"inside",
"the",
"class"
] | python | train |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L144-L155 | def transpose(self) -> 'TextDiagramDrawer':
"""Returns the same diagram, but mirrored across its diagonal."""
out = TextDiagramDrawer()
out.entries = {(y, x): _DiagramText(v.transposed_text, v.text)
for (x, y), v in self.entries.items()}
out.vertical_lines = [_Vert... | [
"def",
"transpose",
"(",
"self",
")",
"->",
"'TextDiagramDrawer'",
":",
"out",
"=",
"TextDiagramDrawer",
"(",
")",
"out",
".",
"entries",
"=",
"{",
"(",
"y",
",",
"x",
")",
":",
"_DiagramText",
"(",
"v",
".",
"transposed_text",
",",
"v",
".",
"text",
... | Returns the same diagram, but mirrored across its diagonal. | [
"Returns",
"the",
"same",
"diagram",
"but",
"mirrored",
"across",
"its",
"diagonal",
"."
] | python | train |
helium/helium-python | helium/timeseries.py | https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/timeseries.py#L228-L269 | def create(self, port, value, timestamp=None):
"""Post a new reading to a timeseries.
A reading is comprised of a `port`, a `value` and a timestamp.
A port is like a tag for the given reading and gives an
indication of the meaning of the value.
The value of the reading can be ... | [
"def",
"create",
"(",
"self",
",",
"port",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"session",
"=",
"self",
".",
"_session",
"datapoint_class",
"=",
"self",
".",
"_datapoint_class",
"attributes",
"=",
"{",
"'port'",
":",
"port",
",",
"'valu... | Post a new reading to a timeseries.
A reading is comprised of a `port`, a `value` and a timestamp.
A port is like a tag for the given reading and gives an
indication of the meaning of the value.
The value of the reading can be any valid json value.
The timestamp is considered... | [
"Post",
"a",
"new",
"reading",
"to",
"a",
"timeseries",
"."
] | python | train |
Diviyan-Kalainathan/CausalDiscoveryToolbox | cdt/independence/graph/model.py | https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/model.py#L83-L100 | def run_feature_selection(self, df_data, target, idx=0, **kwargs):
"""Run feature selection for one node: wrapper around
``self.predict_features``.
Args:
df_data (pandas.DataFrame): All the observational data
target (str): Name of the target variable
idx (int... | [
"def",
"run_feature_selection",
"(",
"self",
",",
"df_data",
",",
"target",
",",
"idx",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"list_features",
"=",
"list",
"(",
"df_data",
".",
"columns",
".",
"values",
")",
"list_features",
".",
"remove",
"(",
... | Run feature selection for one node: wrapper around
``self.predict_features``.
Args:
df_data (pandas.DataFrame): All the observational data
target (str): Name of the target variable
idx (int): (optional) For printing purposes
Returns:
list: scores... | [
"Run",
"feature",
"selection",
"for",
"one",
"node",
":",
"wrapper",
"around",
"self",
".",
"predict_features",
"."
] | python | valid |
python-tap/tappy | tap/main.py | https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/main.py#L21-L28 | def build_suite(args):
"""Build a test suite by loading TAP files or a TAP stream."""
loader = Loader()
if len(args.files) == 0 or args.files[0] == "-":
suite = loader.load_suite_from_stdin()
else:
suite = loader.load(args.files)
return suite | [
"def",
"build_suite",
"(",
"args",
")",
":",
"loader",
"=",
"Loader",
"(",
")",
"if",
"len",
"(",
"args",
".",
"files",
")",
"==",
"0",
"or",
"args",
".",
"files",
"[",
"0",
"]",
"==",
"\"-\"",
":",
"suite",
"=",
"loader",
".",
"load_suite_from_std... | Build a test suite by loading TAP files or a TAP stream. | [
"Build",
"a",
"test",
"suite",
"by",
"loading",
"TAP",
"files",
"or",
"a",
"TAP",
"stream",
"."
] | python | train |
user-cont/conu | conu/utils/filesystem.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L177-L190 | def _set_ownership(self):
"""
set ownership of the directory: user and group
:return: None
"""
if self.owner or self.group:
args = (
self.path,
self.owner if self.owner else -1,
self.group if self.group else -1,
... | [
"def",
"_set_ownership",
"(",
"self",
")",
":",
"if",
"self",
".",
"owner",
"or",
"self",
".",
"group",
":",
"args",
"=",
"(",
"self",
".",
"path",
",",
"self",
".",
"owner",
"if",
"self",
".",
"owner",
"else",
"-",
"1",
",",
"self",
".",
"group"... | set ownership of the directory: user and group
:return: None | [
"set",
"ownership",
"of",
"the",
"directory",
":",
"user",
"and",
"group"
] | python | train |
polyaxon/polyaxon-schemas | polyaxon_schemas/specs/group.py | https://github.com/polyaxon/polyaxon-schemas/blob/a5360240316f4bbccfcdcb97a489cab14458277a/polyaxon_schemas/specs/group.py#L75-L80 | def get_experiment_spec(self, matrix_declaration):
"""Returns an experiment spec for this group spec and the given matrix declaration."""
parsed_data = Parser.parse(self, self._data, matrix_declaration)
del parsed_data[self.HP_TUNING]
validator.validate(spec=self, data=parsed_data)
... | [
"def",
"get_experiment_spec",
"(",
"self",
",",
"matrix_declaration",
")",
":",
"parsed_data",
"=",
"Parser",
".",
"parse",
"(",
"self",
",",
"self",
".",
"_data",
",",
"matrix_declaration",
")",
"del",
"parsed_data",
"[",
"self",
".",
"HP_TUNING",
"]",
"val... | Returns an experiment spec for this group spec and the given matrix declaration. | [
"Returns",
"an",
"experiment",
"spec",
"for",
"this",
"group",
"spec",
"and",
"the",
"given",
"matrix",
"declaration",
"."
] | python | train |
pipermerriam/flex | flex/core.py | https://github.com/pipermerriam/flex/blob/233f8149fb851a6255753bcec948cb6fefb2723b/flex/core.py#L121-L138 | def validate_api_response(schema, raw_response, request_method='get', raw_request=None):
"""
Validate the response of an api call against a swagger schema.
"""
request = None
if raw_request is not None:
request = normalize_request(raw_request)
response = None
if raw_response is not ... | [
"def",
"validate_api_response",
"(",
"schema",
",",
"raw_response",
",",
"request_method",
"=",
"'get'",
",",
"raw_request",
"=",
"None",
")",
":",
"request",
"=",
"None",
"if",
"raw_request",
"is",
"not",
"None",
":",
"request",
"=",
"normalize_request",
"(",... | Validate the response of an api call against a swagger schema. | [
"Validate",
"the",
"response",
"of",
"an",
"api",
"call",
"against",
"a",
"swagger",
"schema",
"."
] | python | train |
materialsproject/pymatgen-db | matgendb/dbgroup.py | https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/dbgroup.py#L110-L126 | def _expand(self, name):
"""Perform real work of `expand()` function."""
cfg = self._d[name]
if cfg.collection is None:
base_coll = ''
else:
base_coll = cfg.collection + self.SEP
qe = self._get_qe(name, cfg)
coll, db = qe.collection, qe.db
... | [
"def",
"_expand",
"(",
"self",
",",
"name",
")",
":",
"cfg",
"=",
"self",
".",
"_d",
"[",
"name",
"]",
"if",
"cfg",
".",
"collection",
"is",
"None",
":",
"base_coll",
"=",
"''",
"else",
":",
"base_coll",
"=",
"cfg",
".",
"collection",
"+",
"self",
... | Perform real work of `expand()` function. | [
"Perform",
"real",
"work",
"of",
"expand",
"()",
"function",
"."
] | python | train |
maas/python-libmaas | maas/client/viscera/nodes.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/viscera/nodes.py#L93-L101 | def as_machine(self):
"""Convert to a `Machine` object.
`node_type` must be `NodeType.MACHINE`.
"""
if self.node_type != NodeType.MACHINE:
raise ValueError(
'Cannot convert to `Machine`, node_type is not a machine.')
return self._origin.Machine(self._... | [
"def",
"as_machine",
"(",
"self",
")",
":",
"if",
"self",
".",
"node_type",
"!=",
"NodeType",
".",
"MACHINE",
":",
"raise",
"ValueError",
"(",
"'Cannot convert to `Machine`, node_type is not a machine.'",
")",
"return",
"self",
".",
"_origin",
".",
"Machine",
"(",... | Convert to a `Machine` object.
`node_type` must be `NodeType.MACHINE`. | [
"Convert",
"to",
"a",
"Machine",
"object",
"."
] | python | train |
chainer/chainerui | chainerui/views/project.py | https://github.com/chainer/chainerui/blob/87ad25e875bc332bfdad20197fd3d0cb81a078e8/chainerui/views/project.py#L73-L95 | def put(self, id):
"""put."""
project = db.session.query(Project).filter_by(id=id).first()
if project is None:
return jsonify({
'project': None,
'message': 'No interface defined for URL.'
}), 404
request_project = request.get_jso... | [
"def",
"put",
"(",
"self",
",",
"id",
")",
":",
"project",
"=",
"db",
".",
"session",
".",
"query",
"(",
"Project",
")",
".",
"filter_by",
"(",
"id",
"=",
"id",
")",
".",
"first",
"(",
")",
"if",
"project",
"is",
"None",
":",
"return",
"jsonify",... | put. | [
"put",
"."
] | python | train |
Kortemme-Lab/pull_into_place | pull_into_place/pipeline.py | https://github.com/Kortemme-Lab/pull_into_place/blob/247f303100a612cc90cf31c86e4fe5052eb28c8d/pull_into_place/pipeline.py#L811-L842 | def root_from_dir(directory, recurse=True):
"""
Similar to workspace_from_dir, but this returns the root directory
of a workspace rather than a workspace object.
"""
directory = os.path.abspath(directory)
pickle_path = os.path.join(directory, 'workspace.pkl')
# Make sure the given directo... | [
"def",
"root_from_dir",
"(",
"directory",
",",
"recurse",
"=",
"True",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
")",
"pickle_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'workspace.pkl'",
")"... | Similar to workspace_from_dir, but this returns the root directory
of a workspace rather than a workspace object. | [
"Similar",
"to",
"workspace_from_dir",
"but",
"this",
"returns",
"the",
"root",
"directory",
"of",
"a",
"workspace",
"rather",
"than",
"a",
"workspace",
"object",
"."
] | python | train |
NoneGG/aredis | aredis/lock.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/lock.py#L309-L350 | async def acquire(self, blocking=None, blocking_timeout=None):
"""
Use Redis to hold a shared, distributed lock named ``name``.
Returns True once the lock is acquired.
If ``blocking`` is False, always return immediately. If the lock
was acquired, return True, otherwise return Fa... | [
"async",
"def",
"acquire",
"(",
"self",
",",
"blocking",
"=",
"None",
",",
"blocking_timeout",
"=",
"None",
")",
":",
"sleep",
"=",
"self",
".",
"sleep",
"token",
"=",
"b",
"(",
"uuid",
".",
"uuid1",
"(",
")",
".",
"hex",
")",
"if",
"blocking",
"is... | Use Redis to hold a shared, distributed lock named ``name``.
Returns True once the lock is acquired.
If ``blocking`` is False, always return immediately. If the lock
was acquired, return True, otherwise return False.
``blocking_timeout`` specifies the maximum number of seconds to
... | [
"Use",
"Redis",
"to",
"hold",
"a",
"shared",
"distributed",
"lock",
"named",
"name",
".",
"Returns",
"True",
"once",
"the",
"lock",
"is",
"acquired",
"."
] | python | train |
eight04/pyAPNG | apng/__init__.py | https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L208-L224 | def open_any(cls, file):
"""Open an image file. If the image is not PNG format, it would convert
the image into PNG with Pillow module. If the module is not
installed, :class:`ImportError` would be raised.
:arg file: Input file.
:type file: path-like or file-like
:rtype: :class:`PNG`
"""
with open_fi... | [
"def",
"open_any",
"(",
"cls",
",",
"file",
")",
":",
"with",
"open_file",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"header",
"=",
"f",
".",
"read",
"(",
"8",
")",
"f",
".",
"seek",
"(",
"0",
")",
"if",
"header",
"!=",
"PNG_SIGN",
":",
... | Open an image file. If the image is not PNG format, it would convert
the image into PNG with Pillow module. If the module is not
installed, :class:`ImportError` would be raised.
:arg file: Input file.
:type file: path-like or file-like
:rtype: :class:`PNG` | [
"Open",
"an",
"image",
"file",
".",
"If",
"the",
"image",
"is",
"not",
"PNG",
"format",
"it",
"would",
"convert",
"the",
"image",
"into",
"PNG",
"with",
"Pillow",
"module",
".",
"If",
"the",
"module",
"is",
"not",
"installed",
":",
"class",
":",
"Impor... | python | train |
willkg/everett | everett/ext/yamlfile.py | https://github.com/willkg/everett/blob/5653134af59f439d2b33f3939fab2b8544428f11/everett/ext/yamlfile.py#L159-L166 | def get(self, key, namespace=None):
"""Retrieve value for key."""
if not self.path:
return NO_VALUE
logger.debug('Searching %r for key: %s, namepsace: %s', self, key, namespace)
full_key = generate_uppercase_key(key, namespace)
return get_key_from_envs(self.cfg, full... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"path",
":",
"return",
"NO_VALUE",
"logger",
".",
"debug",
"(",
"'Searching %r for key: %s, namepsace: %s'",
",",
"self",
",",
"key",
",",
"namespace"... | Retrieve value for key. | [
"Retrieve",
"value",
"for",
"key",
"."
] | python | train |
MisterWil/skybellpy | skybellpy/__init__.py | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/__init__.py#L229-L241 | def _load_cache(self):
"""Load existing cache and merge for updating if required."""
if not self._disable_cache:
if os.path.exists(self._cache_path):
_LOGGER.debug("Cache found at: %s", self._cache_path)
if os.path.getsize(self._cache_path) > 0:
... | [
"def",
"_load_cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_disable_cache",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_cache_path",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cache found at: %s\"",
",",
"self",
".",
"... | Load existing cache and merge for updating if required. | [
"Load",
"existing",
"cache",
"and",
"merge",
"for",
"updating",
"if",
"required",
"."
] | python | train |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2015_04_05/table/tableservice.py | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/table/tableservice.py#L385-L419 | def _list_tables(self, max_results=None, marker=None, timeout=None):
'''
Returns a list of tables under the specified account. Makes a single list
request to the service. Used internally by the list_tables method.
:param int max_results:
The maximum number of tables to retu... | [
"def",
"_list_tables",
"(",
"self",
",",
"max_results",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"method",
"=",
"'GET'",
"request",
".",
"host",
"=",
"self"... | Returns a list of tables under the specified account. Makes a single list
request to the service. Used internally by the list_tables method.
:param int max_results:
The maximum number of tables to return. A single list request may
return up to 1000 tables and potentially a con... | [
"Returns",
"a",
"list",
"of",
"tables",
"under",
"the",
"specified",
"account",
".",
"Makes",
"a",
"single",
"list",
"request",
"to",
"the",
"service",
".",
"Used",
"internally",
"by",
"the",
"list_tables",
"method",
"."
] | python | train |
ChrisTimperley/Kaskara | python/kaskara/insertions.py | https://github.com/ChrisTimperley/Kaskara/blob/3d182d95b2938508e5990eddd30321be15e2f2ef/python/kaskara/insertions.py#L98-L110 | def at_line(self, line: FileLine) -> Iterator[InsertionPoint]:
"""
Returns an iterator over all of the insertion points located at a
given line.
"""
logger.debug("finding insertion points at line: %s", str(line))
filename = line.filename # type: str
line_num = li... | [
"def",
"at_line",
"(",
"self",
",",
"line",
":",
"FileLine",
")",
"->",
"Iterator",
"[",
"InsertionPoint",
"]",
":",
"logger",
".",
"debug",
"(",
"\"finding insertion points at line: %s\"",
",",
"str",
"(",
"line",
")",
")",
"filename",
"=",
"line",
".",
"... | Returns an iterator over all of the insertion points located at a
given line. | [
"Returns",
"an",
"iterator",
"over",
"all",
"of",
"the",
"insertion",
"points",
"located",
"at",
"a",
"given",
"line",
"."
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3924-L3928 | def user_identities(self, user_id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/user_identities#list-identities"
api_path = "/api/v2/users/{user_id}/identities.json"
api_path = api_path.format(user_id=user_id)
return self.call(api_path, **kwargs) | [
"def",
"user_identities",
"(",
"self",
",",
"user_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/users/{user_id}/identities.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"user_id",
"=",
"user_id",
")",
"return",
"self",
".",
"c... | https://developer.zendesk.com/rest_api/docs/core/user_identities#list-identities | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"user_identities#list",
"-",
"identities"
] | python | train |
zaturox/glin | glin/zmq/messages.py | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L79-L85 | def uint8_3(self, val1, val2, val3):
"""append a frame containing 3 uint8"""
try:
self.msg += [pack("BBB", val1, val2, val3)]
except struct.error:
raise ValueError("Expected uint8")
return self | [
"def",
"uint8_3",
"(",
"self",
",",
"val1",
",",
"val2",
",",
"val3",
")",
":",
"try",
":",
"self",
".",
"msg",
"+=",
"[",
"pack",
"(",
"\"BBB\"",
",",
"val1",
",",
"val2",
",",
"val3",
")",
"]",
"except",
"struct",
".",
"error",
":",
"raise",
... | append a frame containing 3 uint8 | [
"append",
"a",
"frame",
"containing",
"3",
"uint8"
] | python | train |
marrow/WebCore | web/server/tornado_.py | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/tornado_.py#L18-L34 | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"*",
"*",
"options",
")",
":",
"# Wrap our our WSGI application (potentially stack) in a Tornado adapter.",
"container",
"=",
"tornado",
".",
"wsgi",
".",
"WSGIContai... | Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server | [
"Tornado",
"s",
"HTTPServer",
".",
"This",
"is",
"a",
"high",
"quality",
"asynchronous",
"server",
"with",
"many",
"options",
".",
"For",
"details",
"please",
"visit",
":",
"http",
":",
"//",
"www",
".",
"tornadoweb",
".",
"org",
"/",
"en",
"/",
"stable"... | python | train |
iotile/coretools | iotilecore/iotile/core/utilities/rcfile.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/rcfile.py#L52-L61 | def save(self):
"""Update the configuration file on disk with the current contents of self.contents.
Previous contents are overwritten.
"""
try:
with open(self.path, "w") as f:
f.writelines(self.contents)
except IOError as e:
raise Interna... | [
"def",
"save",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"writelines",
"(",
"self",
".",
"contents",
")",
"except",
"IOError",
"as",
"e",
":",
"raise",
"InternalError",... | Update the configuration file on disk with the current contents of self.contents.
Previous contents are overwritten. | [
"Update",
"the",
"configuration",
"file",
"on",
"disk",
"with",
"the",
"current",
"contents",
"of",
"self",
".",
"contents",
".",
"Previous",
"contents",
"are",
"overwritten",
"."
] | python | train |
nesdis/djongo | djongo/base.py | https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/base.py#L122-L157 | def get_connection_params(self):
"""
Default method to acquire database connection parameters.
Sets connection parameters to match settings.py, and sets
default values to blank fields.
"""
valid_settings = {
'NAME': 'name',
'HOST': 'host',
... | [
"def",
"get_connection_params",
"(",
"self",
")",
":",
"valid_settings",
"=",
"{",
"'NAME'",
":",
"'name'",
",",
"'HOST'",
":",
"'host'",
",",
"'PORT'",
":",
"'port'",
",",
"'USER'",
":",
"'username'",
",",
"'PASSWORD'",
":",
"'password'",
",",
"'AUTH_SOURCE... | Default method to acquire database connection parameters.
Sets connection parameters to match settings.py, and sets
default values to blank fields. | [
"Default",
"method",
"to",
"acquire",
"database",
"connection",
"parameters",
"."
] | python | test |
prthkms/alex | alex/support.py | https://github.com/prthkms/alex/blob/79d3167c877e94cc07db0aab55a35857fac67ef7/alex/support.py#L53-L61 | def get_path(query):
"""get_path(query) -> pathname -- return the path found in a
given, found by matching a regular expression.
"""
match = re.search(r'/(.*/)+(\S*(\.[\d\w]{1,4})?)', query)
if(os.path.isfile(match.group()) or os.path.isdir(match.group())):
return match.group()
else:
return None | [
"def",
"get_path",
"(",
"query",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r'/(.*/)+(\\S*(\\.[\\d\\w]{1,4})?)'",
",",
"query",
")",
"if",
"(",
"os",
".",
"path",
".",
"isfile",
"(",
"match",
".",
"group",
"(",
")",
")",
"or",
"os",
".",
"pat... | get_path(query) -> pathname -- return the path found in a
given, found by matching a regular expression. | [
"get_path",
"(",
"query",
")",
"-",
">",
"pathname",
"--",
"return",
"the",
"path",
"found",
"in",
"a",
"given",
"found",
"by",
"matching",
"a",
"regular",
"expression",
"."
] | python | train |
ecell/ecell4 | ecell4/util/simulation.py | https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/simulation.py#L96-L318 | def run_simulation(
t, y0=None, volume=1.0, model=None, solver='ode',
is_netfree=False, species_list=None, without_reset=False,
return_type='matplotlib', opt_args=(), opt_kwargs=None,
structures=None, observers=(), progressbar=0, rndseed=None,
factory=None, ## deprecated
... | [
"def",
"run_simulation",
"(",
"t",
",",
"y0",
"=",
"None",
",",
"volume",
"=",
"1.0",
",",
"model",
"=",
"None",
",",
"solver",
"=",
"'ode'",
",",
"is_netfree",
"=",
"False",
",",
"species_list",
"=",
"None",
",",
"without_reset",
"=",
"False",
",",
... | Run a simulation with the given model and plot the result on IPython
notebook with matplotlib.
Parameters
----------
t : array or Real
A sequence of time points for which to solve for 'm'.
y0 : dict
Initial condition.
volume : Real or Real3, optional
A size of the simula... | [
"Run",
"a",
"simulation",
"with",
"the",
"given",
"model",
"and",
"plot",
"the",
"result",
"on",
"IPython",
"notebook",
"with",
"matplotlib",
"."
] | python | train |
cirruscluster/cirruscluster | cirruscluster/core.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L586-L597 | def __WaitForVolume(volume, desired_state):
""" Blocks until EBS volume is in desired state. """
print 'Waiting for volume %s to be %s...' % (volume.id, desired_state)
while True:
volume.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % volume.status
if volume.status =... | [
"def",
"__WaitForVolume",
"(",
"volume",
",",
"desired_state",
")",
":",
"print",
"'Waiting for volume %s to be %s...'",
"%",
"(",
"volume",
".",
"id",
",",
"desired_state",
")",
"while",
"True",
":",
"volume",
".",
"update",
"(",
")",
"sys",
".",
"stdout",
... | Blocks until EBS volume is in desired state. | [
"Blocks",
"until",
"EBS",
"volume",
"is",
"in",
"desired",
"state",
"."
] | python | train |
scour-project/scour | scour/scour.py | https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1897-L1923 | def removeDefaultAttributeValue(node, attribute):
"""
Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance!
"""
if not node.hasAttribute(attribute.n... | [
"def",
"removeDefaultAttributeValue",
"(",
"node",
",",
"attribute",
")",
":",
"if",
"not",
"node",
".",
"hasAttribute",
"(",
"attribute",
".",
"name",
")",
":",
"return",
"0",
"# differentiate between text and numeric values",
"if",
"isinstance",
"(",
"attribute",
... | Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled
Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance! | [
"Removes",
"the",
"DefaultAttribute",
"attribute",
"from",
"node",
"if",
"specified",
"conditions",
"are",
"fulfilled"
] | python | train |
data61/clkhash | clkhash/field_formats.py | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L157-L188 | def fhp_from_json_dict(
json_dict # type: Dict[str, Any]
):
# type: (...) -> FieldHashingProperties
"""
Make a :class:`FieldHashingProperties` object from a dictionary.
:param dict json_dict:
The dictionary must have have an 'ngram' key
and one of k or num_bits.... | [
"def",
"fhp_from_json_dict",
"(",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> FieldHashingProperties",
"h",
"=",
"json_dict",
".",
"get",
"(",
"'hash'",
",",
"{",
"'type'",
":",
"'blakeHash'",
"}",
")",
"num_bits",
"=",
"json_dict",
".",
"ge... | Make a :class:`FieldHashingProperties` object from a dictionary.
:param dict json_dict:
The dictionary must have have an 'ngram' key
and one of k or num_bits. It may have
'positional' key; if missing a default is used.
The encoding is
always set to th... | [
"Make",
"a",
":",
"class",
":",
"FieldHashingProperties",
"object",
"from",
"a",
"dictionary",
"."
] | python | train |
googledatalab/pydatalab | datalab/utils/_job.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L175-L199 | def wait(self, timeout=None):
""" Wait for the job to complete, or a timeout to happen.
Args:
timeout: how long to wait before giving up (in seconds); default None which means no timeout.
Returns:
The Job
"""
if self._future:
try:
# Future.exception() will return rather t... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_future",
":",
"try",
":",
"# Future.exception() will return rather than raise any exception so we use it.",
"self",
".",
"_future",
".",
"exception",
"(",
"timeout",
")",
"exce... | Wait for the job to complete, or a timeout to happen.
Args:
timeout: how long to wait before giving up (in seconds); default None which means no timeout.
Returns:
The Job | [
"Wait",
"for",
"the",
"job",
"to",
"complete",
"or",
"a",
"timeout",
"to",
"happen",
"."
] | python | train |
blockstack/virtualchain | virtualchain/lib/indexer.py | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/indexer.py#L1789-L1842 | def state_engine_replay(consensus_impl, existing_working_dir, new_state_engine, target_block_height, start_block=None, initial_snapshots={}, expected_snapshots={}):
"""
Given consensus rules, a target block height, and a path to an existing chainstate db, replay the chain state's virtual transactions
throug... | [
"def",
"state_engine_replay",
"(",
"consensus_impl",
",",
"existing_working_dir",
",",
"new_state_engine",
",",
"target_block_height",
",",
"start_block",
"=",
"None",
",",
"initial_snapshots",
"=",
"{",
"}",
",",
"expected_snapshots",
"=",
"{",
"}",
")",
":",
"as... | Given consensus rules, a target block height, and a path to an existing chainstate db, replay the chain state's virtual transactions
through the consensus rules into a given directory (working_dir).
Optionally check that the snapshots in @expected_snapshots match up as we verify.
@expected_snapshots maps s... | [
"Given",
"consensus",
"rules",
"a",
"target",
"block",
"height",
"and",
"a",
"path",
"to",
"an",
"existing",
"chainstate",
"db",
"replay",
"the",
"chain",
"state",
"s",
"virtual",
"transactions",
"through",
"the",
"consensus",
"rules",
"into",
"a",
"given",
... | python | train |
tijme/not-your-average-web-crawler | nyawc/http/Handler.py | https://github.com/tijme/not-your-average-web-crawler/blob/d77c14e1616c541bb3980f649a7e6f8ed02761fb/nyawc/http/Handler.py#L154-L176 | def __content_type_matches(self, content_type, available_content_types):
"""Check if the given content type matches one of the available content types.
Args:
content_type (str): The given content type.
available_content_types list(str): All the available content types.
... | [
"def",
"__content_type_matches",
"(",
"self",
",",
"content_type",
",",
"available_content_types",
")",
":",
"if",
"content_type",
"is",
"None",
":",
"return",
"False",
"if",
"content_type",
"in",
"available_content_types",
":",
"return",
"True",
"for",
"available_c... | Check if the given content type matches one of the available content types.
Args:
content_type (str): The given content type.
available_content_types list(str): All the available content types.
Returns:
bool: True if a match was found, False otherwise. | [
"Check",
"if",
"the",
"given",
"content",
"type",
"matches",
"one",
"of",
"the",
"available",
"content",
"types",
"."
] | python | train |
MacHu-GWU/angora-project | angora/bot/macro.py | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L175-L179 | def Up(self, n = 1, dl = 0):
"""上方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.up_key, n) | [
"def",
"Up",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"up_key",
",",
"n",
")"
] | 上方向键n次 | [
"上方向键n次"
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L425-L444 | def bans_list(self, limit=None, max_id=None, since_id=None, **kwargs):
"https://developer.zendesk.com/rest_api/docs/chat/bans#get-all-bans"
api_path = "/api/v2/bans"
api_query = {}
if "query" in kwargs.keys():
api_query.update(kwargs["query"])
del kwargs["query"]
... | [
"def",
"bans_list",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"max_id",
"=",
"None",
",",
"since_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/bans\"",
"api_query",
"=",
"{",
"}",
"if",
"\"query\"",
"in",
"kwargs",... | https://developer.zendesk.com/rest_api/docs/chat/bans#get-all-bans | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"chat",
"/",
"bans#get",
"-",
"all",
"-",
"bans"
] | python | train |
pysal/esda | esda/smoothing.py | https://github.com/pysal/esda/blob/2fafc6ec505e153152a86601d3e0fba080610c20/esda/smoothing.py#L216-L298 | def direct_age_standardization(e, b, s, n, alpha=0.05):
"""A utility function to compute rate through direct age standardization
Parameters
----------
e : array
(n*h, 1), event variable measured for each age group across n spatial units
b : array
... | [
"def",
"direct_age_standardization",
"(",
"e",
",",
"b",
",",
"s",
",",
"n",
",",
"alpha",
"=",
"0.05",
")",
":",
"age_weight",
"=",
"(",
"1.0",
"/",
"b",
")",
"*",
"(",
"s",
"*",
"1.0",
"/",
"sum_by_n",
"(",
"s",
",",
"1.0",
",",
"n",
")",
"... | A utility function to compute rate through direct age standardization
Parameters
----------
e : array
(n*h, 1), event variable measured for each age group across n spatial units
b : array
(n*h, 1), population at risk variable measured for each age gro... | [
"A",
"utility",
"function",
"to",
"compute",
"rate",
"through",
"direct",
"age",
"standardization"
] | python | train |
btel/svg_utils | src/svgutils/transform.py | https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L315-L334 | def fromstring(text):
"""Create a SVG figure from a string.
Parameters
----------
text : str
string representing the SVG content. Must be valid SVG.
Returns
-------
SVGFigure
newly created :py:class:`SVGFigure` initialised with the string
content.
"""
fig = ... | [
"def",
"fromstring",
"(",
"text",
")",
":",
"fig",
"=",
"SVGFigure",
"(",
")",
"svg",
"=",
"etree",
".",
"fromstring",
"(",
"text",
".",
"encode",
"(",
")",
")",
"fig",
".",
"root",
"=",
"svg",
"return",
"fig"
] | Create a SVG figure from a string.
Parameters
----------
text : str
string representing the SVG content. Must be valid SVG.
Returns
-------
SVGFigure
newly created :py:class:`SVGFigure` initialised with the string
content. | [
"Create",
"a",
"SVG",
"figure",
"from",
"a",
"string",
"."
] | python | train |
naphatkrit/easyci | easyci/results.py | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/results.py#L64-L76 | def remove_results(vcs, signature):
"""Removed saved results for this signature
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError
"""
results_directory = _get_results_directory(vcs, signature)
if not os.path.exists(results_directory):
r... | [
"def",
"remove_results",
"(",
"vcs",
",",
"signature",
")",
":",
"results_directory",
"=",
"_get_results_directory",
"(",
"vcs",
",",
"signature",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"results_directory",
")",
":",
"raise",
"ResultsNotFound... | Removed saved results for this signature
Args:
vcs (easyci.vcs.base.Vcs)
signature (str)
Raises:
ResultsNotFoundError | [
"Removed",
"saved",
"results",
"for",
"this",
"signature"
] | python | train |
materialsproject/pymatgen | pymatgen/core/xcfunc.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/xcfunc.py#L219-L227 | def type(self):
"""The type of the functional."""
if self.xc in self.defined_aliases: return self.defined_aliases[self.xc].type
xc = (self.x, self.c)
if xc in self.defined_aliases: return self.defined_aliases[xc].type
# If self is not in defined_aliases, use LibxcFunc family
... | [
"def",
"type",
"(",
"self",
")",
":",
"if",
"self",
".",
"xc",
"in",
"self",
".",
"defined_aliases",
":",
"return",
"self",
".",
"defined_aliases",
"[",
"self",
".",
"xc",
"]",
".",
"type",
"xc",
"=",
"(",
"self",
".",
"x",
",",
"self",
".",
"c",... | The type of the functional. | [
"The",
"type",
"of",
"the",
"functional",
"."
] | python | train |
intuition-io/intuition | intuition/finance.py | https://github.com/intuition-io/intuition/blob/cd517e6b3b315a743eb4d0d0dc294e264ab913ce/intuition/finance.py#L151-L184 | def returns(ts, **kwargs):
'''
Compute returns on the given period
@param ts : time serie to process
@param kwargs.type: gross or simple returns
@param delta : period betweend two computed returns
@param start : with end, will return the return betweend this elapsed time
@param period : del... | [
"def",
"returns",
"(",
"ts",
",",
"*",
"*",
"kwargs",
")",
":",
"returns_type",
"=",
"kwargs",
".",
"get",
"(",
"'type'",
",",
"'net'",
")",
"cumulative",
"=",
"kwargs",
".",
"get",
"(",
"'cumulative'",
",",
"False",
")",
"if",
"returns_type",
"==",
... | Compute returns on the given period
@param ts : time serie to process
@param kwargs.type: gross or simple returns
@param delta : period betweend two computed returns
@param start : with end, will return the return betweend this elapsed time
@param period : delta is the number of lines/periods provi... | [
"Compute",
"returns",
"on",
"the",
"given",
"period"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.