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 |
|---|---|---|---|---|---|---|---|---|
rmohr/static3 | static.py | https://github.com/rmohr/static3/blob/e5f88c5e91789bd4db7fde0cf59e4a15c3326f11/static.py#L323-L330 | def _conditions(self, full_path, environ):
"""Return Etag and Last-Modified values defaults to now for both."""
magic = self._match_magic(full_path)
if magic is not None:
return magic.conditions(full_path, environ)
else:
mtime = stat(full_path).st_mtime
... | [
"def",
"_conditions",
"(",
"self",
",",
"full_path",
",",
"environ",
")",
":",
"magic",
"=",
"self",
".",
"_match_magic",
"(",
"full_path",
")",
"if",
"magic",
"is",
"not",
"None",
":",
"return",
"magic",
".",
"conditions",
"(",
"full_path",
",",
"enviro... | Return Etag and Last-Modified values defaults to now for both. | [
"Return",
"Etag",
"and",
"Last",
"-",
"Modified",
"values",
"defaults",
"to",
"now",
"for",
"both",
"."
] | python | train |
sassoftware/saspy | saspy/sasproccommons.py | https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasproccommons.py#L516-L551 | def _input_stmt(self, stmt: object) -> tuple:
"""
takes the input key from kwargs and processes it to aid in the generation of a model statement
:param stmt: str, list, or dict that contains the model information.
:return: tuple of strings one for the class statement one for the model st... | [
"def",
"_input_stmt",
"(",
"self",
",",
"stmt",
":",
"object",
")",
"->",
"tuple",
":",
"code",
"=",
"''",
"cls",
"=",
"''",
"if",
"isinstance",
"(",
"stmt",
",",
"str",
")",
":",
"code",
"+=",
"\"%s \"",
"%",
"(",
"stmt",
")",
"elif",
"isinstance"... | takes the input key from kwargs and processes it to aid in the generation of a model statement
:param stmt: str, list, or dict that contains the model information.
:return: tuple of strings one for the class statement one for the model statements | [
"takes",
"the",
"input",
"key",
"from",
"kwargs",
"and",
"processes",
"it",
"to",
"aid",
"in",
"the",
"generation",
"of",
"a",
"model",
"statement",
":",
"param",
"stmt",
":",
"str",
"list",
"or",
"dict",
"that",
"contains",
"the",
"model",
"information",
... | python | train |
asphalt-framework/asphalt | asphalt/core/context.py | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L444-L462 | def require_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
"""
Look up a resource in the chain of contexts and raise an exception if it is not found.
This is like :meth:`get_resource` except that instead of returning ``None`` when a resource
is not found, i... | [
"def",
"require_resource",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T_Resource",
"]",
",",
"name",
":",
"str",
"=",
"'default'",
")",
"->",
"T_Resource",
":",
"resource",
"=",
"self",
".",
"get_resource",
"(",
"type",
",",
"name",
")",
"if",
"resou... | Look up a resource in the chain of contexts and raise an exception if it is not found.
This is like :meth:`get_resource` except that instead of returning ``None`` when a resource
is not found, it will raise :exc:`~asphalt.core.context.ResourceNotFound`.
:param type: type of the requested resou... | [
"Look",
"up",
"a",
"resource",
"in",
"the",
"chain",
"of",
"contexts",
"and",
"raise",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] | python | train |
CityOfZion/neo-python | neo/SmartContract/ContractParameter.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/SmartContract/ContractParameter.py#L81-L130 | def ToJson(self, auto_hex=True):
"""
Converts a ContractParameter instance to a json representation
Returns:
dict: a dictionary representation of the contract parameter
"""
jsn = {}
jsn['type'] = str(ContractParameterType(self.Type))
if self.Type == ... | [
"def",
"ToJson",
"(",
"self",
",",
"auto_hex",
"=",
"True",
")",
":",
"jsn",
"=",
"{",
"}",
"jsn",
"[",
"'type'",
"]",
"=",
"str",
"(",
"ContractParameterType",
"(",
"self",
".",
"Type",
")",
")",
"if",
"self",
".",
"Type",
"==",
"ContractParameterTy... | Converts a ContractParameter instance to a json representation
Returns:
dict: a dictionary representation of the contract parameter | [
"Converts",
"a",
"ContractParameter",
"instance",
"to",
"a",
"json",
"representation"
] | python | train |
nschloe/pygmsh | pygmsh/opencascade/geometry.py | https://github.com/nschloe/pygmsh/blob/1a1a07481aebe6c161b60dd31e0fbe1ddf330d61/pygmsh/opencascade/geometry.py#L84-L161 | def _boolean_operation(
self,
operation,
input_entities,
tool_entities,
delete_first=True,
delete_other=True,
):
"""Boolean operations, see
https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity
and tool_entity are called objec... | [
"def",
"_boolean_operation",
"(",
"self",
",",
"operation",
",",
"input_entities",
",",
"tool_entities",
",",
"delete_first",
"=",
"True",
",",
"delete_other",
"=",
"True",
",",
")",
":",
"self",
".",
"_BOOLEAN_ID",
"+=",
"1",
"# assert that all entities are of th... | Boolean operations, see
https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity
and tool_entity are called object and tool in gmsh documentation. | [
"Boolean",
"operations",
"see",
"https",
":",
"//",
"gmsh",
".",
"info",
"/",
"doc",
"/",
"texinfo",
"/",
"gmsh",
".",
"html#Boolean",
"-",
"operations",
"input_entity",
"and",
"tool_entity",
"are",
"called",
"object",
"and",
"tool",
"in",
"gmsh",
"documenta... | python | train |
KennethWilke/PingdomLib | pingdomlib/pingdom.py | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L52-L97 | def request(self, method, url, parameters=dict()):
"""Requests wrapper function"""
# The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase
parameters = self._serializeBooleans(parameters)
headers = {'App-Key': self.apikey}
if self... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"parameters",
"=",
"dict",
"(",
")",
")",
":",
"# The requests library uses urllib, which serializes to \"True\"/\"False\" while Pingdom requires lowercase",
"parameters",
"=",
"self",
".",
"_serializeBooleans",... | Requests wrapper function | [
"Requests",
"wrapper",
"function"
] | python | train |
davenquinn/Attitude | attitude/error/bootstrap.py | https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/error/bootstrap.py#L6-L16 | def bootstrap(array):
"""
Provides a bootstrap resampling of an array. Provides another
statistical method to estimate the variance of a dataset.
For a `PCA` object in this library, it should be applied to
`Orientation.array` method.
"""
reg_func = lambda a: N.linalg.svd(a,full_matrices=Fal... | [
"def",
"bootstrap",
"(",
"array",
")",
":",
"reg_func",
"=",
"lambda",
"a",
":",
"N",
".",
"linalg",
".",
"svd",
"(",
"a",
",",
"full_matrices",
"=",
"False",
")",
"[",
"2",
"]",
"[",
"2",
"]",
"beta_boots",
"=",
"bootstrap",
"(",
"array",
",",
"... | Provides a bootstrap resampling of an array. Provides another
statistical method to estimate the variance of a dataset.
For a `PCA` object in this library, it should be applied to
`Orientation.array` method. | [
"Provides",
"a",
"bootstrap",
"resampling",
"of",
"an",
"array",
".",
"Provides",
"another",
"statistical",
"method",
"to",
"estimate",
"the",
"variance",
"of",
"a",
"dataset",
"."
] | python | train |
pystorm/pystorm | pystorm/component.py | https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L504-L542 | def run(self):
"""Main run loop for all components.
Performs initial handshake with Storm and reads Tuples handing them off
to subclasses. Any exceptions are caught and logged back to Storm
prior to the Python process exiting.
.. warning::
Subclasses should **not*... | [
"def",
"run",
"(",
"self",
")",
":",
"storm_conf",
",",
"context",
"=",
"self",
".",
"read_handshake",
"(",
")",
"self",
".",
"_setup_component",
"(",
"storm_conf",
",",
"context",
")",
"self",
".",
"initialize",
"(",
"storm_conf",
",",
"context",
")",
"... | Main run loop for all components.
Performs initial handshake with Storm and reads Tuples handing them off
to subclasses. Any exceptions are caught and logged back to Storm
prior to the Python process exiting.
.. warning::
Subclasses should **not** override this method. | [
"Main",
"run",
"loop",
"for",
"all",
"components",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datarepo.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L1313-L1328 | def insertRnaQuantificationSet(self, rnaQuantificationSet):
"""
Inserts a the specified rnaQuantificationSet into this repository.
"""
try:
models.Rnaquantificationset.create(
id=rnaQuantificationSet.getId(),
datasetid=rnaQuantificationSet.getP... | [
"def",
"insertRnaQuantificationSet",
"(",
"self",
",",
"rnaQuantificationSet",
")",
":",
"try",
":",
"models",
".",
"Rnaquantificationset",
".",
"create",
"(",
"id",
"=",
"rnaQuantificationSet",
".",
"getId",
"(",
")",
",",
"datasetid",
"=",
"rnaQuantificationSet"... | Inserts a the specified rnaQuantificationSet into this repository. | [
"Inserts",
"a",
"the",
"specified",
"rnaQuantificationSet",
"into",
"this",
"repository",
"."
] | python | train |
androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/androconf.py#L280-L293 | def make_color_tuple(color):
"""
turn something like "#000000" into 0,0,0
or "#FFFFFF into "255,255,255"
"""
R = color[1:3]
G = color[3:5]
B = color[5:7]
R = int(R, 16)
G = int(G, 16)
B = int(B, 16)
return R, G, B | [
"def",
"make_color_tuple",
"(",
"color",
")",
":",
"R",
"=",
"color",
"[",
"1",
":",
"3",
"]",
"G",
"=",
"color",
"[",
"3",
":",
"5",
"]",
"B",
"=",
"color",
"[",
"5",
":",
"7",
"]",
"R",
"=",
"int",
"(",
"R",
",",
"16",
")",
"G",
"=",
... | turn something like "#000000" into 0,0,0
or "#FFFFFF into "255,255,255" | [
"turn",
"something",
"like",
"#000000",
"into",
"0",
"0",
"0",
"or",
"#FFFFFF",
"into",
"255",
"255",
"255"
] | python | train |
postlund/pyatv | pyatv/airplay/auth.py | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/auth.py#L36-L58 | async def finish_authentication(self, username, password):
"""Finish authentication process.
A username (generated by new_credentials) and the PIN code shown on
screen must be provided.
"""
# Step 1
self.srp.step1(username, password)
data = await self._send_plist... | [
"async",
"def",
"finish_authentication",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"# Step 1",
"self",
".",
"srp",
".",
"step1",
"(",
"username",
",",
"password",
")",
"data",
"=",
"await",
"self",
".",
"_send_plist",
"(",
"'step1'",
",",
... | Finish authentication process.
A username (generated by new_credentials) and the PIN code shown on
screen must be provided. | [
"Finish",
"authentication",
"process",
"."
] | python | train |
bmcfee/resampy | resampy/core.py | https://github.com/bmcfee/resampy/blob/e5238a7120dcf0d76813bcd3e277998ead8fc308/resampy/core.py#L14-L115 | def resample(x, sr_orig, sr_new, axis=-1, filter='kaiser_best', **kwargs):
'''Resample a signal x from sr_orig to sr_new along a given axis.
Parameters
----------
x : np.ndarray, dtype=np.float*
The input signal(s) to resample.
sr_orig : int > 0
The sampling rate of x
sr_new :... | [
"def",
"resample",
"(",
"x",
",",
"sr_orig",
",",
"sr_new",
",",
"axis",
"=",
"-",
"1",
",",
"filter",
"=",
"'kaiser_best'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sr_orig",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid sample rate: sr_orig={}... | Resample a signal x from sr_orig to sr_new along a given axis.
Parameters
----------
x : np.ndarray, dtype=np.float*
The input signal(s) to resample.
sr_orig : int > 0
The sampling rate of x
sr_new : int > 0
The target sampling rate of the output signal(s)
axis : int
... | [
"Resample",
"a",
"signal",
"x",
"from",
"sr_orig",
"to",
"sr_new",
"along",
"a",
"given",
"axis",
"."
] | python | train |
awslabs/serverless-application-model | samtranslator/model/function_policies.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/function_policies.py#L96-L105 | def _contains_policies(self, resource_properties):
"""
Is there policies data in this resource?
:param dict resource_properties: Properties of the resource
:return: True if we can process this resource. False, otherwise
"""
return resource_properties is not None \
... | [
"def",
"_contains_policies",
"(",
"self",
",",
"resource_properties",
")",
":",
"return",
"resource_properties",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"resource_properties",
",",
"dict",
")",
"and",
"self",
".",
"POLICIES_PROPERTY_NAME",
"in",
"resource_pro... | Is there policies data in this resource?
:param dict resource_properties: Properties of the resource
:return: True if we can process this resource. False, otherwise | [
"Is",
"there",
"policies",
"data",
"in",
"this",
"resource?"
] | python | train |
workforce-data-initiative/skills-utils | skills_utils/s3.py | https://github.com/workforce-data-initiative/skills-utils/blob/4cf9b7c2938984f34bbcc33d45482d23c52c7539/skills_utils/s3.py#L44-L63 | def upload_dict(s3_conn, s3_prefix, data_to_sync):
"""Syncs a dictionary to an S3 bucket, serializing each value in the
dictionary as a JSON file with the key as its name.
Args:
s3_conn: (boto.s3.connection) an s3 connection
s3_prefix: (str) the destination prefix
data_to_sync: (dic... | [
"def",
"upload_dict",
"(",
"s3_conn",
",",
"s3_prefix",
",",
"data_to_sync",
")",
":",
"bucket_name",
",",
"prefix",
"=",
"split_s3_path",
"(",
"s3_prefix",
")",
"bucket",
"=",
"s3_conn",
".",
"get_bucket",
"(",
"bucket_name",
")",
"for",
"key",
",",
"value"... | Syncs a dictionary to an S3 bucket, serializing each value in the
dictionary as a JSON file with the key as its name.
Args:
s3_conn: (boto.s3.connection) an s3 connection
s3_prefix: (str) the destination prefix
data_to_sync: (dict) | [
"Syncs",
"a",
"dictionary",
"to",
"an",
"S3",
"bucket",
"serializing",
"each",
"value",
"in",
"the",
"dictionary",
"as",
"a",
"JSON",
"file",
"with",
"the",
"key",
"as",
"its",
"name",
"."
] | python | train |
pandas-dev/pandas | pandas/core/generic.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L9046-L9101 | def tshift(self, periods=1, freq=None, axis=0):
"""
Shift the time index, using the index's frequency if available.
Parameters
----------
periods : int
Number of periods to move, can be positive or negative
freq : DateOffset, timedelta, or time rule string, d... | [
"def",
"tshift",
"(",
"self",
",",
"periods",
"=",
"1",
",",
"freq",
"=",
"None",
",",
"axis",
"=",
"0",
")",
":",
"index",
"=",
"self",
".",
"_get_axis",
"(",
"axis",
")",
"if",
"freq",
"is",
"None",
":",
"freq",
"=",
"getattr",
"(",
"index",
... | Shift the time index, using the index's frequency if available.
Parameters
----------
periods : int
Number of periods to move, can be positive or negative
freq : DateOffset, timedelta, or time rule string, default None
Increment to use from the tseries module or ... | [
"Shift",
"the",
"time",
"index",
"using",
"the",
"index",
"s",
"frequency",
"if",
"available",
"."
] | python | train |
Phyks/libbmc | libbmc/citations/pdf.py | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/pdf.py#L219-L240 | def pdfextract_dois(pdf_file):
"""
Extract DOIs of references using \
`pdfextract <https://github.com/CrossRef/pdfextract>`_.
.. note::
See ``libbmc.citations.pdf.pdfextract`` function as this one is just \
a wrapper around it.
See ``libbmc.citations.plaintext.g... | [
"def",
"pdfextract_dois",
"(",
"pdf_file",
")",
":",
"# Call pdf-extract on the PDF file",
"references",
"=",
"pdfextract",
"(",
"pdf_file",
")",
"# Parse the resulting XML",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"references",
")",
"plaintext_references",
"=",
"[... | Extract DOIs of references using \
`pdfextract <https://github.com/CrossRef/pdfextract>`_.
.. note::
See ``libbmc.citations.pdf.pdfextract`` function as this one is just \
a wrapper around it.
See ``libbmc.citations.plaintext.get_cited_dois`` as well for the \
... | [
"Extract",
"DOIs",
"of",
"references",
"using",
"\\",
"pdfextract",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"CrossRef",
"/",
"pdfextract",
">",
"_",
"."
] | python | train |
calmjs/calmjs.parse | src/calmjs/parse/parsers/es5.py | https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L1272-L1277 | def p_continue_statement_2(self, p):
"""continue_statement : CONTINUE identifier SEMI
| CONTINUE identifier AUTOSEMI
"""
p[0] = self.asttypes.Continue(p[2])
p[0].setpos(p) | [
"def",
"p_continue_statement_2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"asttypes",
".",
"Continue",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
".",
"setpos",
"(",
"p",
")"
] | continue_statement : CONTINUE identifier SEMI
| CONTINUE identifier AUTOSEMI | [
"continue_statement",
":",
"CONTINUE",
"identifier",
"SEMI",
"|",
"CONTINUE",
"identifier",
"AUTOSEMI"
] | python | train |
rigetti/quantumflow | quantumflow/utils.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/utils.py#L108-L116 | def spanning_tree_count(graph: nx.Graph) -> int:
"""Return the number of unique spanning trees of a graph, using
Kirchhoff's matrix tree theorem.
"""
laplacian = nx.laplacian_matrix(graph).toarray()
comatrix = laplacian[:-1, :-1]
det = np.linalg.det(comatrix)
count = int(round(det))
retu... | [
"def",
"spanning_tree_count",
"(",
"graph",
":",
"nx",
".",
"Graph",
")",
"->",
"int",
":",
"laplacian",
"=",
"nx",
".",
"laplacian_matrix",
"(",
"graph",
")",
".",
"toarray",
"(",
")",
"comatrix",
"=",
"laplacian",
"[",
":",
"-",
"1",
",",
":",
"-",... | Return the number of unique spanning trees of a graph, using
Kirchhoff's matrix tree theorem. | [
"Return",
"the",
"number",
"of",
"unique",
"spanning",
"trees",
"of",
"a",
"graph",
"using",
"Kirchhoff",
"s",
"matrix",
"tree",
"theorem",
"."
] | python | train |
NLeSC/noodles | noodles/prov/sqlite.py | https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/prov/sqlite.py#L178-L186 | def register(self, job):
"""Takes a job (unencoded) and adorns it with a unique key; this makes
an entry in the database without any further specification."""
with self.lock:
self.cur.execute(
'insert into "jobs" ("name", "session", "status") '
'values... | [
"def",
"register",
"(",
"self",
",",
"job",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"cur",
".",
"execute",
"(",
"'insert into \"jobs\" (\"name\", \"session\", \"status\") '",
"'values (?, ?, ?)'",
",",
"(",
"job",
".",
"name",
",",
"self",
"."... | Takes a job (unencoded) and adorns it with a unique key; this makes
an entry in the database without any further specification. | [
"Takes",
"a",
"job",
"(",
"unencoded",
")",
"and",
"adorns",
"it",
"with",
"a",
"unique",
"key",
";",
"this",
"makes",
"an",
"entry",
"in",
"the",
"database",
"without",
"any",
"further",
"specification",
"."
] | python | train |
ssato/python-anyconfig | src/anyconfig/api.py | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/api.py#L480-L523 | def loads(content, ac_parser=None, ac_dict=None, ac_template=False,
ac_context=None, **options):
"""
:param content: Configuration file's content (a string)
:param ac_parser: Forced parser type or ID or parser object
:param ac_dict:
callable (function or class) to make mapping object w... | [
"def",
"loads",
"(",
"content",
",",
"ac_parser",
"=",
"None",
",",
"ac_dict",
"=",
"None",
",",
"ac_template",
"=",
"False",
",",
"ac_context",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"ac_parser",
"is",
"None",
":",
"LOGGER",
".",
"wa... | :param content: Configuration file's content (a string)
:param ac_parser: Forced parser type or ID or parser object
:param ac_dict:
callable (function or class) to make mapping object will be returned as
a result or None. If not given or ac_dict is None, default mapping
object used to st... | [
":",
"param",
"content",
":",
"Configuration",
"file",
"s",
"content",
"(",
"a",
"string",
")",
":",
"param",
"ac_parser",
":",
"Forced",
"parser",
"type",
"or",
"ID",
"or",
"parser",
"object",
":",
"param",
"ac_dict",
":",
"callable",
"(",
"function",
"... | python | train |
StanfordVL/robosuite | robosuite/wrappers/ik_wrapper.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/wrappers/ik_wrapper.py#L73-L114 | def step(self, action):
"""
Move the end effector(s) according to the input control.
Args:
action (numpy array): The array should have the corresponding elements.
0-2: The desired change in end effector position in x, y, and z.
3-6: The desired change... | [
"def",
"step",
"(",
"self",
",",
"action",
")",
":",
"input_1",
"=",
"self",
".",
"_make_input",
"(",
"action",
"[",
":",
"7",
"]",
",",
"self",
".",
"env",
".",
"_right_hand_quat",
")",
"if",
"self",
".",
"env",
".",
"mujoco_robot",
".",
"name",
"... | Move the end effector(s) according to the input control.
Args:
action (numpy array): The array should have the corresponding elements.
0-2: The desired change in end effector position in x, y, and z.
3-6: The desired change in orientation, expressed as a (x, y, z, w)... | [
"Move",
"the",
"end",
"effector",
"(",
"s",
")",
"according",
"to",
"the",
"input",
"control",
"."
] | python | train |
galaxyproject/pulsar | pulsar/managers/stateful.py | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/stateful.py#L177-L188 | def __status(self, job_directory, proxy_status):
""" Use proxied manager's status to compute the real
(stateful) status of job.
"""
if proxy_status == status.COMPLETE:
if not job_directory.has_metadata(JOB_FILE_POSTPROCESSED):
job_status = status.POSTPROCESSIN... | [
"def",
"__status",
"(",
"self",
",",
"job_directory",
",",
"proxy_status",
")",
":",
"if",
"proxy_status",
"==",
"status",
".",
"COMPLETE",
":",
"if",
"not",
"job_directory",
".",
"has_metadata",
"(",
"JOB_FILE_POSTPROCESSED",
")",
":",
"job_status",
"=",
"sta... | Use proxied manager's status to compute the real
(stateful) status of job. | [
"Use",
"proxied",
"manager",
"s",
"status",
"to",
"compute",
"the",
"real",
"(",
"stateful",
")",
"status",
"of",
"job",
"."
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/download.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/download.py#L35-L48 | def download_all(data_home=None, replace=False):
"""
Downloads all the example datasets to the data directory specified by
``get_data_home``. This function ensures that all datasets are available
for use with the examples.
"""
for _, meta in DATASETS.items():
download_data(
m... | [
"def",
"download_all",
"(",
"data_home",
"=",
"None",
",",
"replace",
"=",
"False",
")",
":",
"for",
"_",
",",
"meta",
"in",
"DATASETS",
".",
"items",
"(",
")",
":",
"download_data",
"(",
"meta",
"[",
"'url'",
"]",
",",
"meta",
"[",
"'signature'",
"]... | Downloads all the example datasets to the data directory specified by
``get_data_home``. This function ensures that all datasets are available
for use with the examples. | [
"Downloads",
"all",
"the",
"example",
"datasets",
"to",
"the",
"data",
"directory",
"specified",
"by",
"get_data_home",
".",
"This",
"function",
"ensures",
"that",
"all",
"datasets",
"are",
"available",
"for",
"use",
"with",
"the",
"examples",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/sts/forecast.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/forecast.py#L35-L169 | def one_step_predictive(model, observed_time_series, parameter_samples):
"""Compute one-step-ahead predictive distributions for all timesteps.
Given samples from the posterior over parameters, return the predictive
distribution over observations at each time `T`, given observations up
through time `T-1`.
Ar... | [
"def",
"one_step_predictive",
"(",
"model",
",",
"observed_time_series",
",",
"parameter_samples",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"'one_step_predictive'",
",",
"values",
"=",
"[",
"observed_time_series",
",",
"parameter_s... | Compute one-step-ahead predictive distributions for all timesteps.
Given samples from the posterior over parameters, return the predictive
distribution over observations at each time `T`, given observations up
through time `T-1`.
Args:
model: An instance of `StructuralTimeSeries` representing a
time... | [
"Compute",
"one",
"-",
"step",
"-",
"ahead",
"predictive",
"distributions",
"for",
"all",
"timesteps",
"."
] | python | test |
opereto/pyopereto | pyopereto/client.py | https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L1231-L1250 | def get_process_properties(self, pid=None, name=None):
'''
get_process_properties(self, pid=None, name=None)
Get process properties (both input and output properties)
:Parameters:
* *pid* (`string`) -- Identifier of an existing process
* *name* (`string`) -- optional - ... | [
"def",
"get_process_properties",
"(",
"self",
",",
"pid",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"pid",
"=",
"self",
".",
"_get_pid",
"(",
"pid",
")",
"res",
"=",
"self",
".",
"_call_rest_api",
"(",
"'get'",
",",
"'/processes/'",
"+",
"pid",
... | get_process_properties(self, pid=None, name=None)
Get process properties (both input and output properties)
:Parameters:
* *pid* (`string`) -- Identifier of an existing process
* *name* (`string`) -- optional - Property name | [
"get_process_properties",
"(",
"self",
"pid",
"=",
"None",
"name",
"=",
"None",
")"
] | python | train |
hsolbrig/PyShEx | pyshex/prefixlib.py | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/prefixlib.py#L100-L115 | def nsname(self, uri: Union[str, URIRef]) -> str:
"""
Return the 'ns:name' format of URI
:param uri: URI to transform
:return: nsname format of URI or straight URI if no mapping
"""
uri = str(uri)
nsuri = ""
prefix = None
for pfx, ns in self:
... | [
"def",
"nsname",
"(",
"self",
",",
"uri",
":",
"Union",
"[",
"str",
",",
"URIRef",
"]",
")",
"->",
"str",
":",
"uri",
"=",
"str",
"(",
"uri",
")",
"nsuri",
"=",
"\"\"",
"prefix",
"=",
"None",
"for",
"pfx",
",",
"ns",
"in",
"self",
":",
"nss",
... | Return the 'ns:name' format of URI
:param uri: URI to transform
:return: nsname format of URI or straight URI if no mapping | [
"Return",
"the",
"ns",
":",
"name",
"format",
"of",
"URI"
] | python | train |
obulpathi/cdn-fastly-python | fastly/__init__.py | https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L614-L618 | def update_request_setting(self, service_id, version_number, name_key, **kwargs):
"""Updates the specified Request Settings object."""
body = self._formdata(kwargs, FastlyHealthCheck.FIELDS)
content = self._fetch("/service/%s/version/%d/request_settings/%s" % (service_id, version_number, name_key), method="PUT", ... | [
"def",
"update_request_setting",
"(",
"self",
",",
"service_id",
",",
"version_number",
",",
"name_key",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"self",
".",
"_formdata",
"(",
"kwargs",
",",
"FastlyHealthCheck",
".",
"FIELDS",
")",
"content",
"=",
... | Updates the specified Request Settings object. | [
"Updates",
"the",
"specified",
"Request",
"Settings",
"object",
"."
] | python | train |
twosigma/marbles | marbles/mixins/marbles/mixins/mixins.py | https://github.com/twosigma/marbles/blob/f0c668be8344c70d4d63bc57e82c6f2da43c6925/marbles/mixins/marbles/mixins/mixins.py#L788-L813 | def assertFileEncodingEqual(self, filename, encoding, msg=None):
'''Fail if ``filename`` is not encoded with the given
``encoding`` as determined by the '==' operator.
Parameters
----------
filename : str, bytes, file-like
encoding : str, bytes
msg : str
... | [
"def",
"assertFileEncodingEqual",
"(",
"self",
",",
"filename",
",",
"encoding",
",",
"msg",
"=",
"None",
")",
":",
"fencoding",
"=",
"self",
".",
"_get_file_encoding",
"(",
"filename",
")",
"fname",
"=",
"self",
".",
"_get_file_name",
"(",
"filename",
")",
... | Fail if ``filename`` is not encoded with the given
``encoding`` as determined by the '==' operator.
Parameters
----------
filename : str, bytes, file-like
encoding : str, bytes
msg : str
If not provided, the :mod:`marbles.mixins` or
:mod:`unittest... | [
"Fail",
"if",
"filename",
"is",
"not",
"encoded",
"with",
"the",
"given",
"encoding",
"as",
"determined",
"by",
"the",
"==",
"operator",
"."
] | python | train |
bhmm/bhmm | bhmm/estimators/_tmatrix_disconnected.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/_tmatrix_disconnected.py#L46-L56 | def closed_sets(C, mincount_connectivity=0):
""" Computes the strongly connected closed sets of C """
n = np.shape(C)[0]
S = connected_sets(C, mincount_connectivity=mincount_connectivity, strong=True)
closed = []
for s in S:
mask = np.zeros(n, dtype=bool)
mask[s] = True
if C[... | [
"def",
"closed_sets",
"(",
"C",
",",
"mincount_connectivity",
"=",
"0",
")",
":",
"n",
"=",
"np",
".",
"shape",
"(",
"C",
")",
"[",
"0",
"]",
"S",
"=",
"connected_sets",
"(",
"C",
",",
"mincount_connectivity",
"=",
"mincount_connectivity",
",",
"strong",... | Computes the strongly connected closed sets of C | [
"Computes",
"the",
"strongly",
"connected",
"closed",
"sets",
"of",
"C"
] | python | train |
saltstack/salt | salt/modules/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/state.py#L2032-L2099 | def single(fun, name, test=None, queue=False, **kwargs):
'''
Execute a single state function with the named kwargs, returns False if
insufficient data is sent to the command
By default, the values of the kwargs will be parsed as YAML. So, you can
specify lists values, or lists of single entry key-v... | [
"def",
"single",
"(",
"fun",
",",
"name",
",",
"test",
"=",
"None",
",",
"queue",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"conflict",
"=",
"_check_queue",
"(",
"queue",
",",
"kwargs",
")",
"if",
"conflict",
"is",
"not",
"None",
":",
"retur... | Execute a single state function with the named kwargs, returns False if
insufficient data is sent to the command
By default, the values of the kwargs will be parsed as YAML. So, you can
specify lists values, or lists of single entry key-value maps, as you
would in a YAML salt file. Alternatively, JSON ... | [
"Execute",
"a",
"single",
"state",
"function",
"with",
"the",
"named",
"kwargs",
"returns",
"False",
"if",
"insufficient",
"data",
"is",
"sent",
"to",
"the",
"command"
] | python | train |
twisted/mantissa | xmantissa/people.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/people.py#L1636-L1643 | def getAddPerson(self):
"""
Return an L{AddPersonFragment} which is a child of this fragment and
which will add a person to C{self.organizer}.
"""
fragment = AddPersonFragment(self.organizer)
fragment.setFragmentParent(self)
return fragment | [
"def",
"getAddPerson",
"(",
"self",
")",
":",
"fragment",
"=",
"AddPersonFragment",
"(",
"self",
".",
"organizer",
")",
"fragment",
".",
"setFragmentParent",
"(",
"self",
")",
"return",
"fragment"
] | Return an L{AddPersonFragment} which is a child of this fragment and
which will add a person to C{self.organizer}. | [
"Return",
"an",
"L",
"{",
"AddPersonFragment",
"}",
"which",
"is",
"a",
"child",
"of",
"this",
"fragment",
"and",
"which",
"will",
"add",
"a",
"person",
"to",
"C",
"{",
"self",
".",
"organizer",
"}",
"."
] | python | train |
bovee/Aston | aston/trace/new_integrator.py | https://github.com/bovee/Aston/blob/007630fdf074690373d03398fe818260d3d3cf5a/aston/trace/new_integrator.py#L6-L20 | def _get_windows(peak_list):
"""
Given a list of peaks, bin them into windows.
"""
win_list = []
for t0, t1, hints in peak_list:
p_w = (t0, t1)
for w in win_list:
if p_w[0] <= w[0][1] and p_w[1] >= w[0][0]:
w[0] = (min(p_w[0], w[0][0]), max(p_w[1], w[0][1]... | [
"def",
"_get_windows",
"(",
"peak_list",
")",
":",
"win_list",
"=",
"[",
"]",
"for",
"t0",
",",
"t1",
",",
"hints",
"in",
"peak_list",
":",
"p_w",
"=",
"(",
"t0",
",",
"t1",
")",
"for",
"w",
"in",
"win_list",
":",
"if",
"p_w",
"[",
"0",
"]",
"<... | Given a list of peaks, bin them into windows. | [
"Given",
"a",
"list",
"of",
"peaks",
"bin",
"them",
"into",
"windows",
"."
] | python | train |
bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/poolmanager.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/poolmanager.py#L120-L123 | def urlopen(self, method, url, **kw):
"Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
kw['assert_same_host'] = False
return self.proxy_pool.urlopen(method, url, **kw) | [
"def",
"urlopen",
"(",
"self",
",",
"method",
",",
"url",
",",
"*",
"*",
"kw",
")",
":",
"kw",
"[",
"'assert_same_host'",
"]",
"=",
"False",
"return",
"self",
".",
"proxy_pool",
".",
"urlopen",
"(",
"method",
",",
"url",
",",
"*",
"*",
"kw",
")"
] | Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute. | [
"Same",
"as",
"HTTP",
"(",
"S",
")",
"ConnectionPool",
".",
"urlopen",
"url",
"must",
"be",
"absolute",
"."
] | python | train |
Microsoft/nni | examples/trials/weight_sharing/ga_squad/train_model.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/train_model.py#L234-L263 | def build_char_states(self, char_embed, is_training, reuse, char_ids, char_lengths):
"""Build char embedding network for the QA model."""
max_char_length = self.cfg.max_char_length
inputs = dropout(tf.nn.embedding_lookup(char_embed, char_ids),
self.cfg.dropout, is_train... | [
"def",
"build_char_states",
"(",
"self",
",",
"char_embed",
",",
"is_training",
",",
"reuse",
",",
"char_ids",
",",
"char_lengths",
")",
":",
"max_char_length",
"=",
"self",
".",
"cfg",
".",
"max_char_length",
"inputs",
"=",
"dropout",
"(",
"tf",
".",
"nn",
... | Build char embedding network for the QA model. | [
"Build",
"char",
"embedding",
"network",
"for",
"the",
"QA",
"model",
"."
] | python | train |
angr/claripy | claripy/ast/base.py | https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/ast/base.py#L395-L402 | def remove_annotation(self, a):
"""
Removes an annotation from this AST.
:param a: the annotation to remove
:returns: a new AST, with the annotation removed
"""
return self._apply_to_annotations(lambda alist: tuple(oa for oa in alist if oa != a)) | [
"def",
"remove_annotation",
"(",
"self",
",",
"a",
")",
":",
"return",
"self",
".",
"_apply_to_annotations",
"(",
"lambda",
"alist",
":",
"tuple",
"(",
"oa",
"for",
"oa",
"in",
"alist",
"if",
"oa",
"!=",
"a",
")",
")"
] | Removes an annotation from this AST.
:param a: the annotation to remove
:returns: a new AST, with the annotation removed | [
"Removes",
"an",
"annotation",
"from",
"this",
"AST",
"."
] | python | train |
tensorflow/cleverhans | cleverhans/confidence_report.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/confidence_report.py#L238-L270 | def print_stats(correctness, confidence, name):
"""
Prints out accuracy, coverage, etc. statistics
:param correctness: ndarray
One bool per example specifying whether it was correctly classified
:param confidence: ndarray
The probability associated with each prediction
:param name: str
The name of... | [
"def",
"print_stats",
"(",
"correctness",
",",
"confidence",
",",
"name",
")",
":",
"accuracy",
"=",
"correctness",
".",
"mean",
"(",
")",
"wrongness",
"=",
"1",
"-",
"correctness",
"denom1",
"=",
"np",
".",
"maximum",
"(",
"1",
",",
"wrongness",
".",
... | Prints out accuracy, coverage, etc. statistics
:param correctness: ndarray
One bool per example specifying whether it was correctly classified
:param confidence: ndarray
The probability associated with each prediction
:param name: str
The name of this type of data (e.g. "clean", "MaxConfidence") | [
"Prints",
"out",
"accuracy",
"coverage",
"etc",
".",
"statistics",
":",
"param",
"correctness",
":",
"ndarray",
"One",
"bool",
"per",
"example",
"specifying",
"whether",
"it",
"was",
"correctly",
"classified",
":",
"param",
"confidence",
":",
"ndarray",
"The",
... | python | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L112-L131 | def funcConvPar(aryDm,
vecHrf,
varNumVol):
"""
Function for convolution of pixel-wise 'design matrix' with HRF model.
"""
# In order to avoid an artefact at the end of the time series, we have to
# concatenate an empty array to both the design matrix and the HRF mode... | [
"def",
"funcConvPar",
"(",
"aryDm",
",",
"vecHrf",
",",
"varNumVol",
")",
":",
"# In order to avoid an artefact at the end of the time series, we have to",
"# concatenate an empty array to both the design matrix and the HRF model",
"# before convolution.",
"aryDm",
"=",
"np",
".",
... | Function for convolution of pixel-wise 'design matrix' with HRF model. | [
"Function",
"for",
"convolution",
"of",
"pixel",
"-",
"wise",
"design",
"matrix",
"with",
"HRF",
"model",
"."
] | python | train |
bukun/TorCMS | torcms/handlers/post_handler.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L190-L198 | def _gen_uid(self):
'''
Generate the ID for post.
:return: the new ID.
'''
cur_uid = self.kind + tools.get_uu4d()
while MPost.get_by_uid(cur_uid):
cur_uid = self.kind + tools.get_uu4d()
return cur_uid | [
"def",
"_gen_uid",
"(",
"self",
")",
":",
"cur_uid",
"=",
"self",
".",
"kind",
"+",
"tools",
".",
"get_uu4d",
"(",
")",
"while",
"MPost",
".",
"get_by_uid",
"(",
"cur_uid",
")",
":",
"cur_uid",
"=",
"self",
".",
"kind",
"+",
"tools",
".",
"get_uu4d",... | Generate the ID for post.
:return: the new ID. | [
"Generate",
"the",
"ID",
"for",
"post",
".",
":",
"return",
":",
"the",
"new",
"ID",
"."
] | python | train |
praekeltfoundation/seed-auth-api | authapi/views.py | https://github.com/praekeltfoundation/seed-auth-api/blob/ac03538ec4f9470931473f0700ad4fa69075d44b/authapi/views.py#L41-L54 | def get_queryset(self):
'''We want to still be able to modify archived organizations, but they
shouldn't show up on list views.
We have an archived query param, where 'true' shows archived, 'false'
omits them, and 'both' shows both.'''
if self.action == 'list':
archi... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"if",
"self",
".",
"action",
"==",
"'list'",
":",
"archived",
"=",
"get_true_false_both",
"(",
"self",
".",
"request",
".",
"query_params",
",",
"'archived'",
",",
"'false'",
")",
"if",
"archived",
"==",
"'true... | We want to still be able to modify archived organizations, but they
shouldn't show up on list views.
We have an archived query param, where 'true' shows archived, 'false'
omits them, and 'both' shows both. | [
"We",
"want",
"to",
"still",
"be",
"able",
"to",
"modify",
"archived",
"organizations",
"but",
"they",
"shouldn",
"t",
"show",
"up",
"on",
"list",
"views",
"."
] | python | train |
Telefonica/toolium | toolium/utils.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/utils.py#L393-L403 | def wait_until_element_not_contain_text(self, element, text, timeout=None):
"""Search element and wait until it does not contain the expected text
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param text: text expected to be contained into ... | [
"def",
"wait_until_element_not_contain_text",
"(",
"self",
",",
"element",
",",
"text",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_wait_until",
"(",
"self",
".",
"_expected_condition_find_element_not_containing_text",
",",
"(",
"element",
",",
... | Search element and wait until it does not contain the expected text
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param text: text expected to be contained into the element
:param timeout: max time to wait
:returns: the web element ... | [
"Search",
"element",
"and",
"wait",
"until",
"it",
"does",
"not",
"contain",
"the",
"expected",
"text"
] | python | train |
CGATOxford/UMI-tools | umi_tools/dedup.py | https://github.com/CGATOxford/UMI-tools/blob/c4b5d84aac391d59916d294f8f4f8f5378abcfbe/umi_tools/dedup.py#L127-L416 | def main(argv=None):
"""script main.
parses command line options in sys.argv, unless *argv* is given.
"""
if argv is None:
argv = sys.argv
# setup command line parser
parser = U.OptionParser(version="%prog version: $Id$",
usage=usage,
... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"# setup command line parser",
"parser",
"=",
"U",
".",
"OptionParser",
"(",
"version",
"=",
"\"%prog version: $Id$\"",
",",
"usage",
"=",
... | script main.
parses command line options in sys.argv, unless *argv* is given. | [
"script",
"main",
"."
] | python | train |
PyCQA/pylint | pylint/message/message_definition.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_definition.py#L51-L77 | def format_help(self, checkerref=False):
"""return the help string for the given message id"""
desc = self.descr
if checkerref:
desc += " This message belongs to the %s checker." % self.checker.name
title = self.msg
if self.symbol:
msgid = "%s (%s)" % (sel... | [
"def",
"format_help",
"(",
"self",
",",
"checkerref",
"=",
"False",
")",
":",
"desc",
"=",
"self",
".",
"descr",
"if",
"checkerref",
":",
"desc",
"+=",
"\" This message belongs to the %s checker.\"",
"%",
"self",
".",
"checker",
".",
"name",
"title",
"=",
"s... | return the help string for the given message id | [
"return",
"the",
"help",
"string",
"for",
"the",
"given",
"message",
"id"
] | python | test |
hydpy-dev/hydpy | hydpy/models/dam/dam_model.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/dam/dam_model.py#L382-L436 | def calc_naturalremotedischarge_v1(self):
"""Try to estimate the natural discharge of a cross section far downstream
based on the last few simulation steps.
Required control parameter:
|NmbLogEntries|
Required log sequences:
|LoggedTotalRemoteDischarge|
|LoggedOutflow|
Calculate... | [
"def",
"calc_naturalremotedischarge_v1",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"parameters",
".",
"control",
".",
"fastaccess",
"flu",
"=",
"self",
".",
"sequences",
".",
"fluxes",
".",
"fastaccess",
"log",
"=",
"self",
".",
"sequences",
".",
"lo... | Try to estimate the natural discharge of a cross section far downstream
based on the last few simulation steps.
Required control parameter:
|NmbLogEntries|
Required log sequences:
|LoggedTotalRemoteDischarge|
|LoggedOutflow|
Calculated flux sequence:
|NaturalRemoteDischarge|
... | [
"Try",
"to",
"estimate",
"the",
"natural",
"discharge",
"of",
"a",
"cross",
"section",
"far",
"downstream",
"based",
"on",
"the",
"last",
"few",
"simulation",
"steps",
"."
] | python | train |
google/grumpy | third_party/pypy/_md5.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_md5.py#L350-L367 | def copy(self):
"""Return a clone object.
Return a copy ('clone') of the md5 object. This can be used
to efficiently compute the digests of strings that share
a common initial substring.
"""
if 0: # set this to 1 to make the flow space crash
return copy.deepcopy(self)
clone = self.__... | [
"def",
"copy",
"(",
"self",
")",
":",
"if",
"0",
":",
"# set this to 1 to make the flow space crash",
"return",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
"=",
"self",
".",
"__class__",
"(",
")",
"clone",
".",
"length",
"=",
"self",
".",
"length",... | Return a clone object.
Return a copy ('clone') of the md5 object. This can be used
to efficiently compute the digests of strings that share
a common initial substring. | [
"Return",
"a",
"clone",
"object",
"."
] | python | valid |
tensorflow/tensor2tensor | tensor2tensor/trax/rlax/ppo.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/rlax/ppo.py#L159-L275 | def collect_trajectories(env,
policy_fun,
num_trajectories=1,
policy="greedy",
max_timestep=None,
epsilon=0.1):
"""Collect trajectories with the given policy net and behaviour.
Args:
env... | [
"def",
"collect_trajectories",
"(",
"env",
",",
"policy_fun",
",",
"num_trajectories",
"=",
"1",
",",
"policy",
"=",
"\"greedy\"",
",",
"max_timestep",
"=",
"None",
",",
"epsilon",
"=",
"0.1",
")",
":",
"trajectories",
"=",
"[",
"]",
"for",
"t",
"in",
"r... | Collect trajectories with the given policy net and behaviour.
Args:
env: A gym env interface, for now this is not-batched.
policy_fun: observations(B,T+1) -> log-probabs(B,T+1, A) callable.
num_trajectories: int, number of trajectories.
policy: string, "greedy", "epsilon-greedy", or "categorical-samp... | [
"Collect",
"trajectories",
"with",
"the",
"given",
"policy",
"net",
"and",
"behaviour",
"."
] | python | train |
tanghaibao/jcvi | jcvi/formats/gff.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/gff.py#L491-L509 | def is_valid_codon(codon, type='start'):
"""
Given a codon sequence, check if it is a valid start/stop codon
"""
if len(codon) != 3:
return False
if type == 'start':
if codon != 'ATG':
return False
elif type == 'stop':
if not any(_codon == codon for _codon in... | [
"def",
"is_valid_codon",
"(",
"codon",
",",
"type",
"=",
"'start'",
")",
":",
"if",
"len",
"(",
"codon",
")",
"!=",
"3",
":",
"return",
"False",
"if",
"type",
"==",
"'start'",
":",
"if",
"codon",
"!=",
"'ATG'",
":",
"return",
"False",
"elif",
"type",... | Given a codon sequence, check if it is a valid start/stop codon | [
"Given",
"a",
"codon",
"sequence",
"check",
"if",
"it",
"is",
"a",
"valid",
"start",
"/",
"stop",
"codon"
] | python | train |
Yelp/detect-secrets | detect_secrets/core/secrets_collection.py | https://github.com/Yelp/detect-secrets/blob/473923ea71f1ac2b5ea1eacc49b98f97967e3d05/detect_secrets/core/secrets_collection.py#L249-L272 | def format_for_baseline_output(self):
"""
:rtype: dict
"""
results = self.json()
for key in results:
results[key] = sorted(results[key], key=lambda x: x['line_number'])
plugins_used = list(map(
lambda x: x.__dict__,
self.plugins,
... | [
"def",
"format_for_baseline_output",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"json",
"(",
")",
"for",
"key",
"in",
"results",
":",
"results",
"[",
"key",
"]",
"=",
"sorted",
"(",
"results",
"[",
"key",
"]",
",",
"key",
"=",
"lambda",
"x",... | :rtype: dict | [
":",
"rtype",
":",
"dict"
] | python | train |
annoviko/pyclustering | pyclustering/cluster/bang.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/bang.py#L156-L169 | def __draw_blocks(ax, blocks, pair):
"""!
@brief Display BANG-blocks on specified figure.
@param[in] ax (Axis): Axis where bang-blocks should be displayed.
@param[in] blocks (list): List of blocks that should be displyed.
@param[in] pair (tuple): Pair of coordinate index t... | [
"def",
"__draw_blocks",
"(",
"ax",
",",
"blocks",
",",
"pair",
")",
":",
"ax",
".",
"grid",
"(",
"False",
")",
"density_scale",
"=",
"blocks",
"[",
"-",
"1",
"]",
".",
"get_density",
"(",
")",
"for",
"block",
"in",
"blocks",
":",
"bang_visualizer",
"... | !
@brief Display BANG-blocks on specified figure.
@param[in] ax (Axis): Axis where bang-blocks should be displayed.
@param[in] blocks (list): List of blocks that should be displyed.
@param[in] pair (tuple): Pair of coordinate index that should be displayed. | [
"!"
] | python | valid |
tensorflow/lucid | lucid/misc/io/loading.py | https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/loading.py#L92-L104 | def _load_graphdef_protobuf(handle, **kwargs):
"""Load GraphDef from a binary proto file."""
# as_graph_def
graph_def = tf.GraphDef.FromString(handle.read())
# check if this is a lucid-saved model
# metadata = modelzoo.util.extract_metadata(graph_def)
# if metadata is not None:
# url = ha... | [
"def",
"_load_graphdef_protobuf",
"(",
"handle",
",",
"*",
"*",
"kwargs",
")",
":",
"# as_graph_def",
"graph_def",
"=",
"tf",
".",
"GraphDef",
".",
"FromString",
"(",
"handle",
".",
"read",
"(",
")",
")",
"# check if this is a lucid-saved model",
"# metadata = mod... | Load GraphDef from a binary proto file. | [
"Load",
"GraphDef",
"from",
"a",
"binary",
"proto",
"file",
"."
] | python | train |
davenquinn/Attitude | attitude/geom/__init__.py | https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/geom/__init__.py#L7-L15 | def aligned_covariance(fit, type='noise'):
"""
Covariance rescaled so that eigenvectors sum to 1
and rotated into data coordinates from PCA space
"""
cov = fit._covariance_matrix(type)
# Rescale eigenvectors to sum to 1
cov /= N.linalg.norm(cov)
return dot(fit.axes,cov) | [
"def",
"aligned_covariance",
"(",
"fit",
",",
"type",
"=",
"'noise'",
")",
":",
"cov",
"=",
"fit",
".",
"_covariance_matrix",
"(",
"type",
")",
"# Rescale eigenvectors to sum to 1",
"cov",
"/=",
"N",
".",
"linalg",
".",
"norm",
"(",
"cov",
")",
"return",
"... | Covariance rescaled so that eigenvectors sum to 1
and rotated into data coordinates from PCA space | [
"Covariance",
"rescaled",
"so",
"that",
"eigenvectors",
"sum",
"to",
"1",
"and",
"rotated",
"into",
"data",
"coordinates",
"from",
"PCA",
"space"
] | python | train |
marcotcr/lime | lime/lime_image.py | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L216-L261 | def data_labels(self,
image,
fudged_image,
segments,
classifier_fn,
num_samples,
batch_size=10):
"""Generates images and predictions in the neighborhood of this image.
Args:
... | [
"def",
"data_labels",
"(",
"self",
",",
"image",
",",
"fudged_image",
",",
"segments",
",",
"classifier_fn",
",",
"num_samples",
",",
"batch_size",
"=",
"10",
")",
":",
"n_features",
"=",
"np",
".",
"unique",
"(",
"segments",
")",
".",
"shape",
"[",
"0",... | Generates images and predictions in the neighborhood of this image.
Args:
image: 3d numpy array, the image
fudged_image: 3d numpy array, image to replace original image when
superpixel is turned off
segments: segmentation of the image
classifier_f... | [
"Generates",
"images",
"and",
"predictions",
"in",
"the",
"neighborhood",
"of",
"this",
"image",
"."
] | python | train |
habnabit/panglery | panglery/pangler.py | https://github.com/habnabit/panglery/blob/4d62e408c4bfaae126c93a6151ded1e8dc75bcc8/panglery/pangler.py#L128-L139 | def bind(self, instance):
"""Bind an instance to this Pangler.
Returns a clone of this Pangler, with the only difference being that
the new Pangler is bound to the provided instance. Both will have the
same `id`, but new hooks will not be shared.
"""
p = self.clone()
... | [
"def",
"bind",
"(",
"self",
",",
"instance",
")",
":",
"p",
"=",
"self",
".",
"clone",
"(",
")",
"p",
".",
"instance",
"=",
"weakref",
".",
"ref",
"(",
"instance",
")",
"return",
"p"
] | Bind an instance to this Pangler.
Returns a clone of this Pangler, with the only difference being that
the new Pangler is bound to the provided instance. Both will have the
same `id`, but new hooks will not be shared. | [
"Bind",
"an",
"instance",
"to",
"this",
"Pangler",
"."
] | python | train |
JasonKessler/scattertext | scattertext/__init__.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/__init__.py#L1239-L1323 | def produce_pca_explorer(corpus,
category,
word2vec_model=None,
projection_model=None,
embeddings=None,
projection=None,
term_acceptance_re=re.compile('[a-z]{3,}'),
... | [
"def",
"produce_pca_explorer",
"(",
"corpus",
",",
"category",
",",
"word2vec_model",
"=",
"None",
",",
"projection_model",
"=",
"None",
",",
"embeddings",
"=",
"None",
",",
"projection",
"=",
"None",
",",
"term_acceptance_re",
"=",
"re",
".",
"compile",
"(",
... | Parameters
----------
corpus : ParsedCorpus
It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
category : str
word2vec_model : Word2Vec
A gensim word2vec model. A default model will be used instead. See Word2VecFromParsedCorpus for th... | [
"Parameters",
"----------",
"corpus",
":",
"ParsedCorpus",
"It",
"is",
"highly",
"recommended",
"to",
"use",
"a",
"stoplisted",
"unigram",
"corpus",
"--",
"corpus",
".",
"get_stoplisted_unigram_corpus",
"()",
"category",
":",
"str",
"word2vec_model",
":",
"Word2Vec"... | python | train |
geertj/gruvi | lib/gruvi/poll.py | https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L151-L160 | def close(self):
"""Close the poll instance."""
if self._poll is None:
return
self._poll.close()
self._poll = None
self._readers = 0
self._writers = 0
self._events = 0
clear_callbacks(self) | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_poll",
"is",
"None",
":",
"return",
"self",
".",
"_poll",
".",
"close",
"(",
")",
"self",
".",
"_poll",
"=",
"None",
"self",
".",
"_readers",
"=",
"0",
"self",
".",
"_writers",
"=",
"0",... | Close the poll instance. | [
"Close",
"the",
"poll",
"instance",
"."
] | python | train |
MonashBI/arcana | arcana/data/collection.py | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/collection.py#L167-L205 | def bind(self, study, **kwargs): # @UnusedVariable
"""
Used for duck typing Collection objects with Spec and Match
in source and sink initiation. Checks IDs match sessions in study.
"""
if self.frequency == 'per_subject':
tree_subject_ids = list(study.tree.subject_id... | [
"def",
"bind",
"(",
"self",
",",
"study",
",",
"*",
"*",
"kwargs",
")",
":",
"# @UnusedVariable",
"if",
"self",
".",
"frequency",
"==",
"'per_subject'",
":",
"tree_subject_ids",
"=",
"list",
"(",
"study",
".",
"tree",
".",
"subject_ids",
")",
"subject_ids"... | Used for duck typing Collection objects with Spec and Match
in source and sink initiation. Checks IDs match sessions in study. | [
"Used",
"for",
"duck",
"typing",
"Collection",
"objects",
"with",
"Spec",
"and",
"Match",
"in",
"source",
"and",
"sink",
"initiation",
".",
"Checks",
"IDs",
"match",
"sessions",
"in",
"study",
"."
] | python | train |
LuminosoInsight/wordfreq | wordfreq/__init__.py | https://github.com/LuminosoInsight/wordfreq/blob/170e3c6536854b06dc63da8d873e8cc4f9ef6180/wordfreq/__init__.py#L35-L84 | def read_cBpack(filename):
"""
Read a file from an idiosyncratic format that we use for storing
approximate word frequencies, called "cBpack".
The cBpack format is as follows:
- The file on disk is a gzipped file in msgpack format, which decodes to a
list whose first element is a header, and... | [
"def",
"read_cBpack",
"(",
"filename",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"infile",
":",
"data",
"=",
"msgpack",
".",
"load",
"(",
"infile",
",",
"raw",
"=",
"False",
")",
"header",
"=",
"data",
"[",
"0"... | Read a file from an idiosyncratic format that we use for storing
approximate word frequencies, called "cBpack".
The cBpack format is as follows:
- The file on disk is a gzipped file in msgpack format, which decodes to a
list whose first element is a header, and whose remaining elements are
lis... | [
"Read",
"a",
"file",
"from",
"an",
"idiosyncratic",
"format",
"that",
"we",
"use",
"for",
"storing",
"approximate",
"word",
"frequencies",
"called",
"cBpack",
"."
] | python | train |
minhhoit/yacms | yacms/accounts/__init__.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/__init__.py#L43-L61 | def get_profile_for_user(user):
"""
Returns site-specific profile for this user. Raises
``ProfileNotConfigured`` if ``settings.ACCOUNTS_PROFILE_MODEL`` is not
set, and ``ImproperlyConfigured`` if the corresponding model can't
be found.
"""
if not hasattr(user, '_yacms_profile'):
# Ra... | [
"def",
"get_profile_for_user",
"(",
"user",
")",
":",
"if",
"not",
"hasattr",
"(",
"user",
",",
"'_yacms_profile'",
")",
":",
"# Raises ProfileNotConfigured if not bool(ACCOUNTS_PROFILE_MODEL)",
"profile_model",
"=",
"get_profile_model",
"(",
")",
"profile_manager",
"=",
... | Returns site-specific profile for this user. Raises
``ProfileNotConfigured`` if ``settings.ACCOUNTS_PROFILE_MODEL`` is not
set, and ``ImproperlyConfigured`` if the corresponding model can't
be found. | [
"Returns",
"site",
"-",
"specific",
"profile",
"for",
"this",
"user",
".",
"Raises",
"ProfileNotConfigured",
"if",
"settings",
".",
"ACCOUNTS_PROFILE_MODEL",
"is",
"not",
"set",
"and",
"ImproperlyConfigured",
"if",
"the",
"corresponding",
"model",
"can",
"t",
"be"... | python | train |
twidi/py-dataql | dataql/parsers/base.py | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/base.py#L343-L369 | def visit_oper(self, node, _):
"""Return an operator as a string. Currently only "=" and ":" (both synonyms)
Arguments
---------
node : parsimonious.nodes.Node.
_ (children) : list, unused
Result
------
str
The operator as a string.
... | [
"def",
"visit_oper",
"(",
"self",
",",
"node",
",",
"_",
")",
":",
"oper",
"=",
"node",
".",
"text",
"if",
"oper",
"==",
"':'",
":",
"oper",
"=",
"'='",
"return",
"oper"
] | Return an operator as a string. Currently only "=" and ":" (both synonyms)
Arguments
---------
node : parsimonious.nodes.Node.
_ (children) : list, unused
Result
------
str
The operator as a string.
Example
-------
>>> BaseP... | [
"Return",
"an",
"operator",
"as",
"a",
"string",
".",
"Currently",
"only",
"=",
"and",
":",
"(",
"both",
"synonyms",
")"
] | python | train |
saltstack/salt | salt/ext/ipaddress.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1377-L1398 | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8')... | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"(",
"self",
"in",
"IPv4Network",
"(",
"'0.0.0.0/8'",
")",
"or",
"self",
"in",
"IPv4Network",
"(",
"'10.0.0.0/8'",
")",
"or",
"self",
"in",
"IPv4Network",
"(",
"'127.0.0.0/8'",
")",
"or",
"self",
"in",
... | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry. | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"private",
"networks",
"."
] | python | train |
cdeboever3/cdpybio | cdpybio/analysis.py | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/analysis.py#L211-L299 | def ld_prune(df, ld_beds, snvs=None):
"""
Prune set of GWAS based on LD and significance. A graph of all SNVs is
constructed with edges for LD >= 0.8 and the most significant SNV per
connected component is kept.
Parameters
----------
df : pandas.DataFrame
Pandas dataframe with ... | [
"def",
"ld_prune",
"(",
"df",
",",
"ld_beds",
",",
"snvs",
"=",
"None",
")",
":",
"import",
"networkx",
"as",
"nx",
"import",
"tabix",
"if",
"snvs",
":",
"df",
"=",
"df",
".",
"ix",
"[",
"set",
"(",
"df",
".",
"index",
")",
"&",
"set",
"(",
"sn... | Prune set of GWAS based on LD and significance. A graph of all SNVs is
constructed with edges for LD >= 0.8 and the most significant SNV per
connected component is kept.
Parameters
----------
df : pandas.DataFrame
Pandas dataframe with unique SNVs. The index is of the form chrom:pos
... | [
"Prune",
"set",
"of",
"GWAS",
"based",
"on",
"LD",
"and",
"significance",
".",
"A",
"graph",
"of",
"all",
"SNVs",
"is",
"constructed",
"with",
"edges",
"for",
"LD",
">",
"=",
"0",
".",
"8",
"and",
"the",
"most",
"significant",
"SNV",
"per",
"connected"... | python | train |
nickpandolfi/Cyther | cyther/pathway.py | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/pathway.py#L233-L247 | def has_suffix(path_name, suffix):
"""
Determines if path_name has a suffix of at least 'suffix'
"""
if isinstance(suffix, str):
suffix = disintegrate(suffix)
components = disintegrate(path_name)
for i in range(-1, -(len(suffix) + 1), -1):
if components[i] != suffix[i]:
... | [
"def",
"has_suffix",
"(",
"path_name",
",",
"suffix",
")",
":",
"if",
"isinstance",
"(",
"suffix",
",",
"str",
")",
":",
"suffix",
"=",
"disintegrate",
"(",
"suffix",
")",
"components",
"=",
"disintegrate",
"(",
"path_name",
")",
"for",
"i",
"in",
"range... | Determines if path_name has a suffix of at least 'suffix' | [
"Determines",
"if",
"path_name",
"has",
"a",
"suffix",
"of",
"at",
"least",
"suffix"
] | python | train |
chrisrink10/basilisp | src/basilisp/lang/compiler/generator.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1265-L1314 | def _if_to_py_ast(ctx: GeneratorContext, node: If) -> GeneratedPyAST:
"""Generate an intermediate if statement which assigns to a temporary
variable, which is returned as the expression value at the end of
evaluation.
Every expression in Basilisp is true if it is not the literal values nil
or false... | [
"def",
"_if_to_py_ast",
"(",
"ctx",
":",
"GeneratorContext",
",",
"node",
":",
"If",
")",
"->",
"GeneratedPyAST",
":",
"assert",
"node",
".",
"op",
"==",
"NodeOp",
".",
"IF",
"test_ast",
"=",
"gen_py_ast",
"(",
"ctx",
",",
"node",
".",
"test",
")",
"re... | Generate an intermediate if statement which assigns to a temporary
variable, which is returned as the expression value at the end of
evaluation.
Every expression in Basilisp is true if it is not the literal values nil
or false. This function compiles direct checks for the test value against
the Pyt... | [
"Generate",
"an",
"intermediate",
"if",
"statement",
"which",
"assigns",
"to",
"a",
"temporary",
"variable",
"which",
"is",
"returned",
"as",
"the",
"expression",
"value",
"at",
"the",
"end",
"of",
"evaluation",
"."
] | python | test |
spotify/luigi | luigi/contrib/redshift.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L293-L357 | def create_table(self, connection):
"""
Override to provide code for creating the target table.
By default it will be created using types (optionally)
specified in columns.
If overridden, use the provided connection object for
setting up the table in order to create the... | [
"def",
"create_table",
"(",
"self",
",",
"connection",
")",
":",
"if",
"len",
"(",
"self",
".",
"columns",
"[",
"0",
"]",
")",
"==",
"1",
":",
"# only names of columns specified, no types",
"raise",
"NotImplementedError",
"(",
"\"create_table() not implemented \"",
... | Override to provide code for creating the target table.
By default it will be created using types (optionally)
specified in columns.
If overridden, use the provided connection object for
setting up the table in order to create the table and
insert data using the same transactio... | [
"Override",
"to",
"provide",
"code",
"for",
"creating",
"the",
"target",
"table",
"."
] | python | train |
msfrank/cifparser | cifparser/parser.py | https://github.com/msfrank/cifparser/blob/ecd899ba2e7b990e2cec62b115742d830e7e4384/cifparser/parser.py#L414-L421 | def print_ast(f):
"""
:param f:
:type f: file
:return:
"""
for linenum,indent,value in iter_lines(f):
print("{0}{1}|{2}".format(str(linenum).rjust(3), ' ' * indent, value)) | [
"def",
"print_ast",
"(",
"f",
")",
":",
"for",
"linenum",
",",
"indent",
",",
"value",
"in",
"iter_lines",
"(",
"f",
")",
":",
"print",
"(",
"\"{0}{1}|{2}\"",
".",
"format",
"(",
"str",
"(",
"linenum",
")",
".",
"rjust",
"(",
"3",
")",
",",
"' '",
... | :param f:
:type f: file
:return: | [
":",
"param",
"f",
":",
":",
"type",
"f",
":",
"file",
":",
"return",
":"
] | python | train |
OCHA-DAP/hdx-python-utilities | src/hdx/utilities/dictandlist.py | https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/dictandlist.py#L268-L280 | def integer_key_convert(dictin, dropfailedkeys=False):
# type: (DictUpperBound, bool) -> Dict
"""Convert keys of dictionary to integers
Args:
dictin (DictUpperBound): Input dictionary
dropfailedkeys (bool): Whether to drop dictionary entries where key conversion fails. Defaults to False.
... | [
"def",
"integer_key_convert",
"(",
"dictin",
",",
"dropfailedkeys",
"=",
"False",
")",
":",
"# type: (DictUpperBound, bool) -> Dict",
"return",
"key_value_convert",
"(",
"dictin",
",",
"keyfn",
"=",
"int",
",",
"dropfailedkeys",
"=",
"dropfailedkeys",
")"
] | Convert keys of dictionary to integers
Args:
dictin (DictUpperBound): Input dictionary
dropfailedkeys (bool): Whether to drop dictionary entries where key conversion fails. Defaults to False.
Returns:
Dict: Dictionary with keys converted to integers | [
"Convert",
"keys",
"of",
"dictionary",
"to",
"integers"
] | python | train |
sporsh/carnifex | carnifex/sshprocess.py | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/sshprocess.py#L64-L88 | def execute(self, processProtocol, command, env={},
path=None, uid=None, gid=None, usePTY=0, childFDs=None):
"""Execute a process on the remote machine using SSH
@param processProtocol: the ProcessProtocol instance to connect
@param executable: the executable program to run
... | [
"def",
"execute",
"(",
"self",
",",
"processProtocol",
",",
"command",
",",
"env",
"=",
"{",
"}",
",",
"path",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"usePTY",
"=",
"0",
",",
"childFDs",
"=",
"None",
")",
":",
"sshCom... | Execute a process on the remote machine using SSH
@param processProtocol: the ProcessProtocol instance to connect
@param executable: the executable program to run
@param args: the arguments to pass to the process
@param env: environment variables to request the remote ssh server to set
... | [
"Execute",
"a",
"process",
"on",
"the",
"remote",
"machine",
"using",
"SSH"
] | python | train |
VasilyStepanov/pywidl | pywidl/grammar.py | https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L988-L992 | def p_ExtendedAttributeIdent(p):
"""ExtendedAttributeIdent : IDENTIFIER "=" IDENTIFIER"""
p[0] = model.ExtendedAttribute(
name=p[1],
value=model.ExtendedAttributeValue(name=p[3])) | [
"def",
"p_ExtendedAttributeIdent",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"model",
".",
"ExtendedAttribute",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"value",
"=",
"model",
".",
"ExtendedAttributeValue",
"(",
"name",
"=",
"p",
"[",
"3",
"]",
... | ExtendedAttributeIdent : IDENTIFIER "=" IDENTIFIER | [
"ExtendedAttributeIdent",
":",
"IDENTIFIER",
"=",
"IDENTIFIER"
] | python | train |
jeffknupp/sandman | sandman/sandman.py | https://github.com/jeffknupp/sandman/blob/253ea4d15cbccd9f0016d66fedd7478614cc0b2f/sandman/sandman.py#L203-L219 | def get_resource_data(incoming_request):
"""Return the data from the incoming *request* based on the
Content-type."""
content_type = incoming_request.headers['Content-type'].split(';')[0]
if ('Content-type' not in incoming_request.headers or
content_type in JSON_CONTENT_TYPES):
retur... | [
"def",
"get_resource_data",
"(",
"incoming_request",
")",
":",
"content_type",
"=",
"incoming_request",
".",
"headers",
"[",
"'Content-type'",
"]",
".",
"split",
"(",
"';'",
")",
"[",
"0",
"]",
"if",
"(",
"'Content-type'",
"not",
"in",
"incoming_request",
".",... | Return the data from the incoming *request* based on the
Content-type. | [
"Return",
"the",
"data",
"from",
"the",
"incoming",
"*",
"request",
"*",
"based",
"on",
"the",
"Content",
"-",
"type",
"."
] | python | train |
saltstack/salt | salt/modules/firewalld.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/firewalld.py#L855-L872 | def get_interfaces(zone, permanent=True):
'''
List interfaces bound to a zone
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' firewalld.get_interfaces zone
'''
cmd = '--zone={0} --list-interfaces'.format(zone)
if permanent:
cmd += ' --permanent'... | [
"def",
"get_interfaces",
"(",
"zone",
",",
"permanent",
"=",
"True",
")",
":",
"cmd",
"=",
"'--zone={0} --list-interfaces'",
".",
"format",
"(",
"zone",
")",
"if",
"permanent",
":",
"cmd",
"+=",
"' --permanent'",
"return",
"__firewall_cmd",
"(",
"cmd",
")",
... | List interfaces bound to a zone
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' firewalld.get_interfaces zone | [
"List",
"interfaces",
"bound",
"to",
"a",
"zone"
] | python | train |
epfl-lts2/pygsp | pygsp/filters/approximations.py | https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/filters/approximations.py#L58-L114 | def cheby_op(G, c, signal, **kwargs):
r"""
Chebyshev polynomial of graph Laplacian applied to vector.
Parameters
----------
G : Graph
c : ndarray or list of ndarrays
Chebyshev coefficients for a Filter or a Filterbank
signal : ndarray
Signal to filter
Returns
------... | [
"def",
"cheby_op",
"(",
"G",
",",
"c",
",",
"signal",
",",
"*",
"*",
"kwargs",
")",
":",
"# Handle if we do not have a list of filters but only a simple filter in cheby_coeff.",
"if",
"not",
"isinstance",
"(",
"c",
",",
"np",
".",
"ndarray",
")",
":",
"c",
"=",
... | r"""
Chebyshev polynomial of graph Laplacian applied to vector.
Parameters
----------
G : Graph
c : ndarray or list of ndarrays
Chebyshev coefficients for a Filter or a Filterbank
signal : ndarray
Signal to filter
Returns
-------
r : ndarray
Result of the fi... | [
"r",
"Chebyshev",
"polynomial",
"of",
"graph",
"Laplacian",
"applied",
"to",
"vector",
"."
] | python | train |
brbsix/pip-utils | pip_utils/outdated.py | https://github.com/brbsix/pip-utils/blob/bdd2a0a17cf36a1c88aa9e68002e9ed04a27bad8/pip_utils/outdated.py#L218-L245 | def run_outdated(cls, options):
"""Print outdated user packages."""
latest_versions = sorted(
cls.find_packages_latest_versions(cls.options),
key=lambda p: p[0].project_name.lower())
for dist, latest_version, typ in latest_versions:
if latest_version > dist.p... | [
"def",
"run_outdated",
"(",
"cls",
",",
"options",
")",
":",
"latest_versions",
"=",
"sorted",
"(",
"cls",
".",
"find_packages_latest_versions",
"(",
"cls",
".",
"options",
")",
",",
"key",
"=",
"lambda",
"p",
":",
"p",
"[",
"0",
"]",
".",
"project_name"... | Print outdated user packages. | [
"Print",
"outdated",
"user",
"packages",
"."
] | python | train |
fronzbot/blinkpy | blinkpy/blinkpy.py | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L197-L214 | def get_cameras(self):
"""Retrieve a camera list for each onboarded network."""
response = api.request_homescreen(self)
try:
all_cameras = {}
for camera in response['cameras']:
camera_network = str(camera['network_id'])
camera_name = camera... | [
"def",
"get_cameras",
"(",
"self",
")",
":",
"response",
"=",
"api",
".",
"request_homescreen",
"(",
"self",
")",
"try",
":",
"all_cameras",
"=",
"{",
"}",
"for",
"camera",
"in",
"response",
"[",
"'cameras'",
"]",
":",
"camera_network",
"=",
"str",
"(",
... | Retrieve a camera list for each onboarded network. | [
"Retrieve",
"a",
"camera",
"list",
"for",
"each",
"onboarded",
"network",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/dependencies.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/dependencies.py#L57-L77 | def find_all_matches(finder, ireq, pre=False):
# type: (PackageFinder, InstallRequirement, bool) -> List[InstallationCandidate]
"""Find all matching dependencies using the supplied finder and the
given ireq.
:param finder: A package finder for discovering matching candidates.
:type finder: :class:`... | [
"def",
"find_all_matches",
"(",
"finder",
",",
"ireq",
",",
"pre",
"=",
"False",
")",
":",
"# type: (PackageFinder, InstallRequirement, bool) -> List[InstallationCandidate]",
"candidates",
"=",
"clean_requires_python",
"(",
"finder",
".",
"find_all_candidates",
"(",
"ireq",... | Find all matching dependencies using the supplied finder and the
given ireq.
:param finder: A package finder for discovering matching candidates.
:type finder: :class:`~pip._internal.index.PackageFinder`
:param ireq: An install requirement.
:type ireq: :class:`~pip._internal.req.req_install.Install... | [
"Find",
"all",
"matching",
"dependencies",
"using",
"the",
"supplied",
"finder",
"and",
"the",
"given",
"ireq",
"."
] | python | train |
ojarva/python-sshpubkeys | sshpubkeys/keys.py | https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L324-L353 | def _process_ssh_dss(self, data):
"""Parses ssh-dsa public keys."""
data_fields = {}
current_position = 0
for item in ("p", "q", "g", "y"):
current_position, value = self._unpack_by_int(data, current_position)
data_fields[item] = self._parse_long(value)
q... | [
"def",
"_process_ssh_dss",
"(",
"self",
",",
"data",
")",
":",
"data_fields",
"=",
"{",
"}",
"current_position",
"=",
"0",
"for",
"item",
"in",
"(",
"\"p\"",
",",
"\"q\"",
",",
"\"g\"",
",",
"\"y\"",
")",
":",
"current_position",
",",
"value",
"=",
"se... | Parses ssh-dsa public keys. | [
"Parses",
"ssh",
"-",
"dsa",
"public",
"keys",
"."
] | python | test |
raiden-network/raiden | raiden/transfer/mediated_transfer/mediator.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1565-L1678 | def state_transition(
mediator_state: Optional[MediatorTransferState],
state_change: StateChange,
channelidentifiers_to_channels: ChannelMap,
nodeaddresses_to_networkstates: NodeNetworkStateMap,
pseudo_random_generator: random.Random,
block_number: BlockNumber,
bl... | [
"def",
"state_transition",
"(",
"mediator_state",
":",
"Optional",
"[",
"MediatorTransferState",
"]",
",",
"state_change",
":",
"StateChange",
",",
"channelidentifiers_to_channels",
":",
"ChannelMap",
",",
"nodeaddresses_to_networkstates",
":",
"NodeNetworkStateMap",
",",
... | State machine for a node mediating a transfer. | [
"State",
"machine",
"for",
"a",
"node",
"mediating",
"a",
"transfer",
"."
] | python | train |
IdentityPython/pysaml2 | src/saml2/sigver.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/sigver.py#L990-L1068 | def security_context(conf):
""" Creates a security context based on the configuration
:param conf: The configuration, this is a Config instance
:return: A SecurityContext instance
"""
if not conf:
return None
try:
metadata = conf.metadata
except AttributeError:
meta... | [
"def",
"security_context",
"(",
"conf",
")",
":",
"if",
"not",
"conf",
":",
"return",
"None",
"try",
":",
"metadata",
"=",
"conf",
".",
"metadata",
"except",
"AttributeError",
":",
"metadata",
"=",
"None",
"try",
":",
"id_attr",
"=",
"conf",
".",
"id_att... | Creates a security context based on the configuration
:param conf: The configuration, this is a Config instance
:return: A SecurityContext instance | [
"Creates",
"a",
"security",
"context",
"based",
"on",
"the",
"configuration"
] | python | train |
pywbem/pywbem | pywbem_mock/_wbemconnection_mock.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem_mock/_wbemconnection_mock.py#L3025-L3032 | def _make_pull_imethod_resp(objs, eos, context_id):
"""
Create the correct imethod response for the open and pull methods
"""
eos_tup = (u'EndOfSequence', None, eos)
enum_ctxt_tup = (u'EnumerationContext', None, context_id)
return [("IRETURNVALUE", {}, objs), enum_ctxt_t... | [
"def",
"_make_pull_imethod_resp",
"(",
"objs",
",",
"eos",
",",
"context_id",
")",
":",
"eos_tup",
"=",
"(",
"u'EndOfSequence'",
",",
"None",
",",
"eos",
")",
"enum_ctxt_tup",
"=",
"(",
"u'EnumerationContext'",
",",
"None",
",",
"context_id",
")",
"return",
... | Create the correct imethod response for the open and pull methods | [
"Create",
"the",
"correct",
"imethod",
"response",
"for",
"the",
"open",
"and",
"pull",
"methods"
] | python | train |
datadesk/python-documentcloud | documentcloud/__init__.py | https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L219-L265 | def search(self, query, page=None, per_page=1000, mentions=3, data=False):
"""
Retrieve all objects that make a search query.
Will loop through all pages that match unless you provide
the number of pages you'd like to restrict the search to.
Example usage:
>> docum... | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"page",
"=",
"None",
",",
"per_page",
"=",
"1000",
",",
"mentions",
"=",
"3",
",",
"data",
"=",
"False",
")",
":",
"# If the user provides a page, search it and stop there",
"if",
"page",
":",
"document_list",
... | Retrieve all objects that make a search query.
Will loop through all pages that match unless you provide
the number of pages you'd like to restrict the search to.
Example usage:
>> documentcloud.documents.search('salazar') | [
"Retrieve",
"all",
"objects",
"that",
"make",
"a",
"search",
"query",
"."
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/bindings/dxworkflow.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxworkflow.py#L257-L275 | def remove_stage(self, stage, edit_version=None, **kwargs):
'''
:param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param edit_version: if provided, the edit version of the workflow that ... | [
"def",
"remove_stage",
"(",
"self",
",",
"stage",
",",
"edit_version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"stage_id",
"=",
"self",
".",
"_get_stage_id",
"(",
"stage",
")",
"remove_stage_input",
"=",
"{",
"\"stage\"",
":",
"stage_id",
"}",
"s... | :param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID
:type stage: int or string
:param edit_version: if provided, the edit version of the workflow that should be modified; if not provided, the current edit version will be used (opti... | [
":",
"param",
"stage",
":",
"A",
"number",
"for",
"the",
"stage",
"index",
"(",
"for",
"the",
"nth",
"stage",
"starting",
"from",
"0",
")",
"or",
"a",
"string",
"of",
"the",
"stage",
"index",
"name",
"or",
"ID",
":",
"type",
"stage",
":",
"int",
"o... | python | train |
iskandr/fancyimpute | fancyimpute/dictionary_helpers.py | https://github.com/iskandr/fancyimpute/blob/9f0837d387c7303d5c8c925a9989ca77a1a96e3e/fancyimpute/dictionary_helpers.py#L50-L57 | def flattened_nested_key_indices(nested_dict):
"""
Combine the outer and inner keys of nested dictionaries into a single
ordering.
"""
outer_keys, inner_keys = collect_nested_keys(nested_dict)
combined_keys = list(sorted(set(outer_keys + inner_keys)))
return {k: i for (i, k) in enumerate(com... | [
"def",
"flattened_nested_key_indices",
"(",
"nested_dict",
")",
":",
"outer_keys",
",",
"inner_keys",
"=",
"collect_nested_keys",
"(",
"nested_dict",
")",
"combined_keys",
"=",
"list",
"(",
"sorted",
"(",
"set",
"(",
"outer_keys",
"+",
"inner_keys",
")",
")",
")... | Combine the outer and inner keys of nested dictionaries into a single
ordering. | [
"Combine",
"the",
"outer",
"and",
"inner",
"keys",
"of",
"nested",
"dictionaries",
"into",
"a",
"single",
"ordering",
"."
] | python | train |
bitesofcode/projexui | projexui/xsettings.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xsettings.py#L260-L314 | def storeValue(self, xelem, value):
"""
Stores the value for the inptued instance to the given xml element.
:param xelem | <xml.etree.Element>
value | <variant>
"""
typ = type(value)
if typ == QtGui.QColor:
... | [
"def",
"storeValue",
"(",
"self",
",",
"xelem",
",",
"value",
")",
":",
"typ",
"=",
"type",
"(",
"value",
")",
"if",
"typ",
"==",
"QtGui",
".",
"QColor",
":",
"xelem",
".",
"set",
"(",
"'type'",
",",
"'color'",
")",
"xelem",
".",
"text",
"=",
"na... | Stores the value for the inptued instance to the given xml element.
:param xelem | <xml.etree.Element>
value | <variant> | [
"Stores",
"the",
"value",
"for",
"the",
"inptued",
"instance",
"to",
"the",
"given",
"xml",
"element",
".",
":",
"param",
"xelem",
"|",
"<xml",
".",
"etree",
".",
"Element",
">",
"value",
"|",
"<variant",
">"
] | python | train |
reiinakano/xcessiv | xcessiv/models.py | https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L317-L327 | def meta_features_path(self, path):
"""Returns path for meta-features
Args:
path (str): Absolute/local path of xcessiv folder
"""
return os.path.join(
path,
app.config['XCESSIV_META_FEATURES_FOLDER'],
str(self.id)
)... | [
"def",
"meta_features_path",
"(",
"self",
",",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"app",
".",
"config",
"[",
"'XCESSIV_META_FEATURES_FOLDER'",
"]",
",",
"str",
"(",
"self",
".",
"id",
")",
")",
"+",
"'.npy'"
] | Returns path for meta-features
Args:
path (str): Absolute/local path of xcessiv folder | [
"Returns",
"path",
"for",
"meta",
"-",
"features"
] | python | train |
ronhanson/python-tbx | tbx/bytes.py | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/bytes.py#L81-L94 | def batch(byte_array, funcs):
"""
Converts a batch to a list of values.
:param byte_array: a byte array of length n*item_length + 8
:return: a list of uuid objects
"""
result = []
length = bytes_to_int(byte_array[0:4])
item_size = bytes_to_int(byte_array[4:8])
for i in range(0, lengt... | [
"def",
"batch",
"(",
"byte_array",
",",
"funcs",
")",
":",
"result",
"=",
"[",
"]",
"length",
"=",
"bytes_to_int",
"(",
"byte_array",
"[",
"0",
":",
"4",
"]",
")",
"item_size",
"=",
"bytes_to_int",
"(",
"byte_array",
"[",
"4",
":",
"8",
"]",
")",
"... | Converts a batch to a list of values.
:param byte_array: a byte array of length n*item_length + 8
:return: a list of uuid objects | [
"Converts",
"a",
"batch",
"to",
"a",
"list",
"of",
"values",
".",
":",
"param",
"byte_array",
":",
"a",
"byte",
"array",
"of",
"length",
"n",
"*",
"item_length",
"+",
"8",
":",
"return",
":",
"a",
"list",
"of",
"uuid",
"objects"
] | python | train |
push-things/wallabag_api | wallabag_api/wallabag.py | https://github.com/push-things/wallabag_api/blob/8d1e10a6ebc03d1ac9af2b38b57eb69f29b4216e/wallabag_api/wallabag.py#L534-L556 | async def get_token(cls, host, **params):
"""
POST /oauth/v2/token
Get a new token
:param host: host of the service
:param params: will contain :
params = {"grant_type": "password",
"client_id": "a string",
"client_secret": "a string... | [
"async",
"def",
"get_token",
"(",
"cls",
",",
"host",
",",
"*",
"*",
"params",
")",
":",
"params",
"[",
"'grant_type'",
"]",
"=",
"\"password\"",
"path",
"=",
"\"/oauth/v2/token\"",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"sess",
... | POST /oauth/v2/token
Get a new token
:param host: host of the service
:param params: will contain :
params = {"grant_type": "password",
"client_id": "a string",
"client_secret": "a string",
"username": "a login",
... | [
"POST",
"/",
"oauth",
"/",
"v2",
"/",
"token"
] | python | train |
ralphbean/bugwarrior | bugwarrior/db.py | https://github.com/ralphbean/bugwarrior/blob/b2a5108f7b40cb0c437509b64eaa28f941f7ac8b/bugwarrior/db.py#L129-L212 | def find_local_uuid(tw, keys, issue, legacy_matching=False):
""" For a given issue issue, find its local UUID.
Assembles a list of task IDs existing in taskwarrior
matching the supplied issue (`issue`) on the combination of any
set of supplied unique identifiers (`keys`) or, optionally,
the task's ... | [
"def",
"find_local_uuid",
"(",
"tw",
",",
"keys",
",",
"issue",
",",
"legacy_matching",
"=",
"False",
")",
":",
"if",
"not",
"issue",
"[",
"'description'",
"]",
":",
"raise",
"ValueError",
"(",
"'Issue %s has no description.'",
"%",
"issue",
")",
"possibilitie... | For a given issue issue, find its local UUID.
Assembles a list of task IDs existing in taskwarrior
matching the supplied issue (`issue`) on the combination of any
set of supplied unique identifiers (`keys`) or, optionally,
the task's description field (should `legacy_matching` be `True`).
:params:... | [
"For",
"a",
"given",
"issue",
"issue",
"find",
"its",
"local",
"UUID",
"."
] | python | test |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L17-L45 | def make_mashes(fastas, mash_file, threads, kmer = 21, force = False):
"""
Create mash files for multiple fasta files
Input:
fastas <list[str]> -- paths to fasta files
mash_file <str> -- path to output mash file
threads <int> -- # threads for parallelization
kmer <... | [
"def",
"make_mashes",
"(",
"fastas",
",",
"mash_file",
",",
"threads",
",",
"kmer",
"=",
"21",
",",
"force",
"=",
"False",
")",
":",
"mash_processes",
"=",
"set",
"(",
")",
"sketches",
"=",
"[",
"fasta",
"+",
"'.msh'",
"for",
"fasta",
"in",
"fastas",
... | Create mash files for multiple fasta files
Input:
fastas <list[str]> -- paths to fasta files
mash_file <str> -- path to output mash file
threads <int> -- # threads for parallelization
kmer <int> -- kmer size for mash sketching
force <boolean> -- force ... | [
"Create",
"mash",
"files",
"for",
"multiple",
"fasta",
"files",
"Input",
":",
"fastas",
"<list",
"[",
"str",
"]",
">",
"--",
"paths",
"to",
"fasta",
"files",
"mash_file",
"<str",
">",
"--",
"path",
"to",
"output",
"mash",
"file",
"threads",
"<int",
">",
... | python | train |
cloud-custodian/cloud-custodian | tools/c7n_gcp/c7n_gcp/mu.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L171-L194 | def _upload(self, archive, region):
"""Upload function source and return source url
"""
# Generate source upload url
url = self.client.execute_command(
'generateUploadUrl',
{'parent': 'projects/{}/locations/{}'.format(
self.session.get_default_proj... | [
"def",
"_upload",
"(",
"self",
",",
"archive",
",",
"region",
")",
":",
"# Generate source upload url",
"url",
"=",
"self",
".",
"client",
".",
"execute_command",
"(",
"'generateUploadUrl'",
",",
"{",
"'parent'",
":",
"'projects/{}/locations/{}'",
".",
"format",
... | Upload function source and return source url | [
"Upload",
"function",
"source",
"and",
"return",
"source",
"url"
] | python | train |
salesking/salesking_python_sdk | salesking/utils/schema.py | https://github.com/salesking/salesking_python_sdk/blob/0d5a95c5ee4e16a85562ceaf67bb11b55e47ee4c/salesking/utils/schema.py#L43-L52 | def _value_is_type_text(val):
"""
val is a dictionary
:param val:
:return: True/False
"""
if ((u'type' in val.keys()) and
(val['type'].lower() == u"text")):
return True
return False | [
"def",
"_value_is_type_text",
"(",
"val",
")",
":",
"if",
"(",
"(",
"u'type'",
"in",
"val",
".",
"keys",
"(",
")",
")",
"and",
"(",
"val",
"[",
"'type'",
"]",
".",
"lower",
"(",
")",
"==",
"u\"text\"",
")",
")",
":",
"return",
"True",
"return",
"... | val is a dictionary
:param val:
:return: True/False | [
"val",
"is",
"a",
"dictionary",
":",
"param",
"val",
":",
":",
"return",
":",
"True",
"/",
"False"
] | python | train |
hvac/hvac | hvac/v1/__init__.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/v1/__init__.py#L1631-L1642 | def transit_read_key(self, name, mount_point='transit'):
"""GET /<mount_point>/keys/<name>
:param name:
:type name:
:param mount_point:
:type mount_point:
:return:
:rtype:
"""
url = '/v1/{0}/keys/{1}'.format(mount_point, name)
return self.... | [
"def",
"transit_read_key",
"(",
"self",
",",
"name",
",",
"mount_point",
"=",
"'transit'",
")",
":",
"url",
"=",
"'/v1/{0}/keys/{1}'",
".",
"format",
"(",
"mount_point",
",",
"name",
")",
"return",
"self",
".",
"_adapter",
".",
"get",
"(",
"url",
")",
".... | GET /<mount_point>/keys/<name>
:param name:
:type name:
:param mount_point:
:type mount_point:
:return:
:rtype: | [
"GET",
"/",
"<mount_point",
">",
"/",
"keys",
"/",
"<name",
">"
] | python | train |
globus/globus-cli | globus_cli/commands/endpoint/permission/update.py | https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/commands/endpoint/permission/update.py#L21-L29 | def update_command(permissions, rule_id, endpoint_id):
"""
Executor for `globus endpoint permission update`
"""
client = get_client()
rule_data = assemble_generic_doc("access", permissions=permissions)
res = client.update_endpoint_acl_rule(endpoint_id, rule_id, rule_data)
formatted_print(re... | [
"def",
"update_command",
"(",
"permissions",
",",
"rule_id",
",",
"endpoint_id",
")",
":",
"client",
"=",
"get_client",
"(",
")",
"rule_data",
"=",
"assemble_generic_doc",
"(",
"\"access\"",
",",
"permissions",
"=",
"permissions",
")",
"res",
"=",
"client",
".... | Executor for `globus endpoint permission update` | [
"Executor",
"for",
"globus",
"endpoint",
"permission",
"update"
] | python | train |
SmokinCaterpillar/pypet | pypet/storageservice.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L2632-L2645 | def _tree_create_leaf(self, name, trajectory, hdf5_group):
""" Creates a new pypet leaf instance.
Returns the leaf and if it is an explored parameter the length of the range.
"""
class_name = self._all_get_from_attrs(hdf5_group, HDF5StorageService.CLASS_NAME)
# Create the inst... | [
"def",
"_tree_create_leaf",
"(",
"self",
",",
"name",
",",
"trajectory",
",",
"hdf5_group",
")",
":",
"class_name",
"=",
"self",
".",
"_all_get_from_attrs",
"(",
"hdf5_group",
",",
"HDF5StorageService",
".",
"CLASS_NAME",
")",
"# Create the instance with the appropria... | Creates a new pypet leaf instance.
Returns the leaf and if it is an explored parameter the length of the range. | [
"Creates",
"a",
"new",
"pypet",
"leaf",
"instance",
"."
] | python | test |
StackStorm/pybind | pybind/slxos/v17s_1_02/isis_state/router_isis_config/is_address_family_v6/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/isis_state/router_isis_config/is_address_family_v6/__init__.py#L558-L579 | def _set_redist_connected(self, v, load=False):
"""
Setter method for redist_connected, mapped from YANG variable /isis_state/router_isis_config/is_address_family_v6/redist_connected (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_redist_connected is consider... | [
"def",
"_set_redist_connected",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for redist_connected, mapped from YANG variable /isis_state/router_isis_config/is_address_family_v6/redist_connected (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_redist_connected is considered as a private
method. Backends looking to populate thi... | [
"Setter",
"method",
"for",
"redist_connected",
"mapped",
"from",
"YANG",
"variable",
"/",
"isis_state",
"/",
"router_isis_config",
"/",
"is_address_family_v6",
"/",
"redist_connected",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"("... | python | train |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L26-L37 | def help_cli_basic(self):
""" Help for Workbench CLI Basics """
help = '%sWorkbench: Getting started...' % (color.Yellow)
help += '\n%sLoad in a sample:' % (color.Green)
help += '\n\t%s> load_sample /path/to/file' % (color.LightBlue)
help += '\n\n%sNotice the prompt now shows t... | [
"def",
"help_cli_basic",
"(",
"self",
")",
":",
"help",
"=",
"'%sWorkbench: Getting started...'",
"%",
"(",
"color",
".",
"Yellow",
")",
"help",
"+=",
"'\\n%sLoad in a sample:'",
"%",
"(",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\t%s> load_sample /path/to/... | Help for Workbench CLI Basics | [
"Help",
"for",
"Workbench",
"CLI",
"Basics"
] | python | train |
SergeySatskiy/cdm-pythonparser | legacy/src/cdmbriefparser.py | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/legacy/src/cdmbriefparser.py#L397-L423 | def niceStringify( self ):
" Returns a string representation with new lines and shifts "
out = ""
if self.docstring is not None:
out += str( self.docstring )
if not self.encoding is None:
if out != "":
out += '\n'
out += str( self.enco... | [
"def",
"niceStringify",
"(",
"self",
")",
":",
"out",
"=",
"\"\"",
"if",
"self",
".",
"docstring",
"is",
"not",
"None",
":",
"out",
"+=",
"str",
"(",
"self",
".",
"docstring",
")",
"if",
"not",
"self",
".",
"encoding",
"is",
"None",
":",
"if",
"out... | Returns a string representation with new lines and shifts | [
"Returns",
"a",
"string",
"representation",
"with",
"new",
"lines",
"and",
"shifts"
] | python | train |
btr1975/persistentdatatools | persistentdatatools/persistentdatatools.py | https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L115-L131 | def verify_directory(directory_name, directory_location, directory_create=False):
"""
Function to verify if a directory exists
Args:
directory_name: The name of directory to check
directory_location: The location of the directory, derive from the os module
directory_create: If you wa... | [
"def",
"verify_directory",
"(",
"directory_name",
",",
"directory_location",
",",
"directory_create",
"=",
"False",
")",
":",
"if",
"not",
"directory_create",
":",
"return",
"__os",
".",
"path",
".",
"exists",
"(",
"__os",
".",
"path",
".",
"join",
"(",
"dir... | Function to verify if a directory exists
Args:
directory_name: The name of directory to check
directory_location: The location of the directory, derive from the os module
directory_create: If you want to create the directory
Returns: returns boolean True or False, but if you set directo... | [
"Function",
"to",
"verify",
"if",
"a",
"directory",
"exists",
"Args",
":",
"directory_name",
":",
"The",
"name",
"of",
"directory",
"to",
"check",
"directory_location",
":",
"The",
"location",
"of",
"the",
"directory",
"derive",
"from",
"the",
"os",
"module",
... | python | train |
saltstack/salt | salt/runners/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/state.py#L43-L52 | def soft_kill(jid, state_id=None):
'''
Set up a state run to die before executing the given state id,
this instructs a running state to safely exit at a given
state id. This needs to pass in the jid of the running state.
If a state_id is not passed then the jid referenced will be safely exited
a... | [
"def",
"soft_kill",
"(",
"jid",
",",
"state_id",
"=",
"None",
")",
":",
"minion",
"=",
"salt",
".",
"minion",
".",
"MasterMinion",
"(",
"__opts__",
")",
"minion",
".",
"functions",
"[",
"'state.soft_kill'",
"]",
"(",
"jid",
",",
"state_id",
")"
] | Set up a state run to die before executing the given state id,
this instructs a running state to safely exit at a given
state id. This needs to pass in the jid of the running state.
If a state_id is not passed then the jid referenced will be safely exited
at the beginning of the next state run. | [
"Set",
"up",
"a",
"state",
"run",
"to",
"die",
"before",
"executing",
"the",
"given",
"state",
"id",
"this",
"instructs",
"a",
"running",
"state",
"to",
"safely",
"exit",
"at",
"a",
"given",
"state",
"id",
".",
"This",
"needs",
"to",
"pass",
"in",
"the... | python | train |
spyder-ide/spyder-notebook | spyder_notebook/notebookplugin.py | https://github.com/spyder-ide/spyder-notebook/blob/54e626b9d2a3fccd3e4625b0f97fe06e5bb1a6db/spyder_notebook/notebookplugin.py#L439-L455 | def open_console(self, client=None):
"""Open an IPython console for the given client or the current one."""
if not client:
client = self.get_current_client()
if self.ipyconsole is not None:
kernel_id = client.get_kernel_id()
if not kernel_id:
... | [
"def",
"open_console",
"(",
"self",
",",
"client",
"=",
"None",
")",
":",
"if",
"not",
"client",
":",
"client",
"=",
"self",
".",
"get_current_client",
"(",
")",
"if",
"self",
".",
"ipyconsole",
"is",
"not",
"None",
":",
"kernel_id",
"=",
"client",
"."... | Open an IPython console for the given client or the current one. | [
"Open",
"an",
"IPython",
"console",
"for",
"the",
"given",
"client",
"or",
"the",
"current",
"one",
"."
] | python | train |
annoviko/pyclustering | pyclustering/cluster/silhouette.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/silhouette.py#L287-L301 | def get_type(self):
"""!
@brief Returns algorithm type that corresponds to specified enumeration value.
@return (type) Algorithm type for cluster analysis.
"""
if self == silhouette_ksearch_type.KMEANS:
return kmeans
elif self == silhouette_ksearch_... | [
"def",
"get_type",
"(",
"self",
")",
":",
"if",
"self",
"==",
"silhouette_ksearch_type",
".",
"KMEANS",
":",
"return",
"kmeans",
"elif",
"self",
"==",
"silhouette_ksearch_type",
".",
"KMEDIANS",
":",
"return",
"kmedians",
"elif",
"self",
"==",
"silhouette_ksearc... | !
@brief Returns algorithm type that corresponds to specified enumeration value.
@return (type) Algorithm type for cluster analysis. | [
"!"
] | python | valid |
iotile/coretools | iotilecore/iotile/core/hw/transport/server/standard.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/server/standard.py#L369-L387 | async def send_script(self, client_id, conn_string, script):
"""Send a script to a device on behalf of a client.
See :meth:`AbstractDeviceAdapter.send_script`.
Args:
client_id (str): The client we are working for.
conn_string (str): A connection string that will be
... | [
"async",
"def",
"send_script",
"(",
"self",
",",
"client_id",
",",
"conn_string",
",",
"script",
")",
":",
"conn_id",
"=",
"self",
".",
"_client_connection",
"(",
"client_id",
",",
"conn_string",
")",
"await",
"self",
".",
"adapter",
".",
"send_script",
"(",... | Send a script to a device on behalf of a client.
See :meth:`AbstractDeviceAdapter.send_script`.
Args:
client_id (str): The client we are working for.
conn_string (str): A connection string that will be
passed to the underlying device adapter.
script ... | [
"Send",
"a",
"script",
"to",
"a",
"device",
"on",
"behalf",
"of",
"a",
"client",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xtoolbutton.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbutton.py#L94-L110 | def blink(self, state=True):
"""
Starts or stops the blinking state for this button. This only
works for when the toolbutton is in Shadowed or Colored mode.
:param state | <bool>
:return <bool> | success
"""
if self._blinking =... | [
"def",
"blink",
"(",
"self",
",",
"state",
"=",
"True",
")",
":",
"if",
"self",
".",
"_blinking",
"==",
"state",
":",
"return",
"True",
"elif",
"not",
"self",
".",
"graphicsEffect",
"(",
")",
":",
"return",
"False",
"else",
":",
"self",
".",
"_blinki... | Starts or stops the blinking state for this button. This only
works for when the toolbutton is in Shadowed or Colored mode.
:param state | <bool>
:return <bool> | success | [
"Starts",
"or",
"stops",
"the",
"blinking",
"state",
"for",
"this",
"button",
".",
"This",
"only",
"works",
"for",
"when",
"the",
"toolbutton",
"is",
"in",
"Shadowed",
"or",
"Colored",
"mode",
".",
":",
"param",
"state",
"|",
"<bool",
">",
":",
"return",... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.