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 |
|---|---|---|---|---|---|---|---|---|
swimlane/swimlane-python | swimlane/core/fields/base/multiselect.py | https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/fields/base/multiselect.py#L80-L91 | def set_swimlane(self, value):
"""Cast all multi-select elements to correct internal type like single-select mode"""
if self.multiselect:
value = value or []
children = []
for child in value:
children.append(self.cast_to_python(child))
re... | [
"def",
"set_swimlane",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"multiselect",
":",
"value",
"=",
"value",
"or",
"[",
"]",
"children",
"=",
"[",
"]",
"for",
"child",
"in",
"value",
":",
"children",
".",
"append",
"(",
"self",
".",
"c... | Cast all multi-select elements to correct internal type like single-select mode | [
"Cast",
"all",
"multi",
"-",
"select",
"elements",
"to",
"correct",
"internal",
"type",
"like",
"single",
"-",
"select",
"mode"
] | python | train |
tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L135-L146 | def _write_summary_cnts(self, cnts):
"""Write summary of level and depth counts for active GO Terms."""
# Count level(shortest path to root) and depth(longest path to root)
# values for all unique GO Terms.
max_val = max(max(dep for dep in cnts['depth']),
max(lev fo... | [
"def",
"_write_summary_cnts",
"(",
"self",
",",
"cnts",
")",
":",
"# Count level(shortest path to root) and depth(longest path to root)",
"# values for all unique GO Terms.",
"max_val",
"=",
"max",
"(",
"max",
"(",
"dep",
"for",
"dep",
"in",
"cnts",
"[",
"'depth'",
"]",... | Write summary of level and depth counts for active GO Terms. | [
"Write",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"active",
"GO",
"Terms",
"."
] | python | train |
howie6879/ruia | ruia/spider.py | https://github.com/howie6879/ruia/blob/2dc5262fc9c3e902a8faa7d5fa2f046f9d9ee1fa/ruia/spider.py#L446-L454 | async def stop(self, _signal):
"""
Finish all running tasks, cancel remaining tasks, then stop loop.
:param _signal:
:return:
"""
self.logger.info(f'Stopping spider: {self.name}')
await self._cancel_tasks()
self.loop.stop() | [
"async",
"def",
"stop",
"(",
"self",
",",
"_signal",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"f'Stopping spider: {self.name}'",
")",
"await",
"self",
".",
"_cancel_tasks",
"(",
")",
"self",
".",
"loop",
".",
"stop",
"(",
")"
] | Finish all running tasks, cancel remaining tasks, then stop loop.
:param _signal:
:return: | [
"Finish",
"all",
"running",
"tasks",
"cancel",
"remaining",
"tasks",
"then",
"stop",
"loop",
".",
":",
"param",
"_signal",
":",
":",
"return",
":"
] | python | test |
hyperledger/indy-plenum | ledger/merkle_verifier.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/merkle_verifier.py#L241-L266 | def verify_leaf_inclusion(self, leaf: bytes, leaf_index: int,
proof: List[bytes], sth: STH):
"""Verify a Merkle Audit Path.
See section 2.1.1 of RFC6962 for the exact path description.
Args:
leaf: The leaf for which the proof was provided.
... | [
"def",
"verify_leaf_inclusion",
"(",
"self",
",",
"leaf",
":",
"bytes",
",",
"leaf_index",
":",
"int",
",",
"proof",
":",
"List",
"[",
"bytes",
"]",
",",
"sth",
":",
"STH",
")",
":",
"leaf_hash",
"=",
"self",
".",
"hasher",
".",
"hash_leaf",
"(",
"le... | Verify a Merkle Audit Path.
See section 2.1.1 of RFC6962 for the exact path description.
Args:
leaf: The leaf for which the proof was provided.
leaf_index: Index of the leaf in the tree.
proof: A list of SHA-256 hashes representing the Merkle audit
path... | [
"Verify",
"a",
"Merkle",
"Audit",
"Path",
"."
] | python | train |
knipknap/exscript | Exscript/util/start.py | https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/start.py#L104-L121 | def quickstart(hosts, func, only_authenticate=False, **kwargs):
"""
Like quickrun(), but automatically logs into the host before passing
the connection to the callback function.
:type hosts: Host|list[Host]
:param hosts: A list of Host objects.
:type func: function
:param func: The callba... | [
"def",
"quickstart",
"(",
"hosts",
",",
"func",
",",
"only_authenticate",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"only_authenticate",
":",
"quickrun",
"(",
"hosts",
",",
"autoauthenticate",
"(",
")",
"(",
"func",
")",
",",
"*",
"*",
"kw... | Like quickrun(), but automatically logs into the host before passing
the connection to the callback function.
:type hosts: Host|list[Host]
:param hosts: A list of Host objects.
:type func: function
:param func: The callback function.
:type only_authenticate: bool
:param only_authenticate... | [
"Like",
"quickrun",
"()",
"but",
"automatically",
"logs",
"into",
"the",
"host",
"before",
"passing",
"the",
"connection",
"to",
"the",
"callback",
"function",
"."
] | python | train |
oseledets/ttpy | tt/core/tools.py | https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/core/tools.py#L138-L146 | def dot(a, b):
"""Dot product of two TT-matrices or two TT-vectors"""
if hasattr(a, '__dot__'):
return a.__dot__(b)
if a is None:
return b
else:
raise ValueError(
'Dot is waiting for two TT-vectors or two TT- matrices') | [
"def",
"dot",
"(",
"a",
",",
"b",
")",
":",
"if",
"hasattr",
"(",
"a",
",",
"'__dot__'",
")",
":",
"return",
"a",
".",
"__dot__",
"(",
"b",
")",
"if",
"a",
"is",
"None",
":",
"return",
"b",
"else",
":",
"raise",
"ValueError",
"(",
"'Dot is waitin... | Dot product of two TT-matrices or two TT-vectors | [
"Dot",
"product",
"of",
"two",
"TT",
"-",
"matrices",
"or",
"two",
"TT",
"-",
"vectors"
] | python | train |
MoseleyBioinformaticsLab/filehandles | filehandles/filehandles.py | https://github.com/MoseleyBioinformaticsLab/filehandles/blob/dd09354a2f12c315fb5c6fa5d6919e1d7ae3e076/filehandles/filehandles.py#L80-L106 | def filehandles(path, openers_list=openers, pattern='', verbose=False):
"""Main function that iterates over list of openers and decides which opener to use.
:param str path: Path.
:param list openers_list: List of openers.
:param str pattern: Regular expression pattern.
:param verbose: Print additi... | [
"def",
"filehandles",
"(",
"path",
",",
"openers_list",
"=",
"openers",
",",
"pattern",
"=",
"''",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"not",
"verbose",
":",
"logging",
".",
"disable",
"(",
"logging",
".",
"VERBOSE",
")",
"for",
"opener",
"in... | Main function that iterates over list of openers and decides which opener to use.
:param str path: Path.
:param list openers_list: List of openers.
:param str pattern: Regular expression pattern.
:param verbose: Print additional information.
:type verbose: :py:obj:`True` or :py:obj:`False`
:ret... | [
"Main",
"function",
"that",
"iterates",
"over",
"list",
"of",
"openers",
"and",
"decides",
"which",
"opener",
"to",
"use",
"."
] | python | train |
ellethee/argparseinator | argparseinator/utils.py | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/utils.py#L68-L85 | def check_class():
"""
Return the class name for the current frame.
If the result is ** None ** means that the call is made from a module.
"""
# get frames
frames = inspect.stack()
cls = None
# should be the third frame
# 0: this function
# 1: function/decorator
# 2: class th... | [
"def",
"check_class",
"(",
")",
":",
"# get frames",
"frames",
"=",
"inspect",
".",
"stack",
"(",
")",
"cls",
"=",
"None",
"# should be the third frame",
"# 0: this function",
"# 1: function/decorator",
"# 2: class that contains the function",
"if",
"len",
"(",
"frames"... | Return the class name for the current frame.
If the result is ** None ** means that the call is made from a module. | [
"Return",
"the",
"class",
"name",
"for",
"the",
"current",
"frame",
".",
"If",
"the",
"result",
"is",
"**",
"None",
"**",
"means",
"that",
"the",
"call",
"is",
"made",
"from",
"a",
"module",
"."
] | python | train |
Duke-GCB/DukeDSClient | ddsc/core/ignorefile.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/ignorefile.py#L105-L111 | def include(self, path, is_file):
"""
Returns False if any pattern matches the path
:param path: str: filename path to test
:return: boolean: True if we should include this path
"""
return self.pattern_list.include(path) and self.file_filter.include(os.path.basename(path)... | [
"def",
"include",
"(",
"self",
",",
"path",
",",
"is_file",
")",
":",
"return",
"self",
".",
"pattern_list",
".",
"include",
"(",
"path",
")",
"and",
"self",
".",
"file_filter",
".",
"include",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")... | Returns False if any pattern matches the path
:param path: str: filename path to test
:return: boolean: True if we should include this path | [
"Returns",
"False",
"if",
"any",
"pattern",
"matches",
"the",
"path",
":",
"param",
"path",
":",
"str",
":",
"filename",
"path",
"to",
"test",
":",
"return",
":",
"boolean",
":",
"True",
"if",
"we",
"should",
"include",
"this",
"path"
] | python | train |
PolyJIT/benchbuild | benchbuild/utils/wrapping.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/wrapping.py#L247-L274 | def persist(id_obj, filename=None, suffix=None):
"""Persist an object in the filesystem.
This will generate a pickled version of the given obj in the filename path.
Objects shall provide an id() method to be able to use this persistence API.
If not, we will use the id() builtin of python to generate an... | [
"def",
"persist",
"(",
"id_obj",
",",
"filename",
"=",
"None",
",",
"suffix",
"=",
"None",
")",
":",
"if",
"suffix",
"is",
"None",
":",
"suffix",
"=",
"\".pickle\"",
"if",
"hasattr",
"(",
"id_obj",
",",
"'id'",
")",
":",
"ident",
"=",
"id_obj",
".",
... | Persist an object in the filesystem.
This will generate a pickled version of the given obj in the filename path.
Objects shall provide an id() method to be able to use this persistence API.
If not, we will use the id() builtin of python to generate an identifier
for you.
The file will be created, ... | [
"Persist",
"an",
"object",
"in",
"the",
"filesystem",
"."
] | python | train |
malramsay64/experi | src/experi/commands.py | https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/commands.py#L140-L150 | def as_bash_array(self) -> str:
"""Return a representation as a bash array.
This creates a string formatted as a bash array containing all the commands in the job.
"""
return_string = "( \\\n"
for command in self:
return_string += '"' + str(command) + '" \\\n'
... | [
"def",
"as_bash_array",
"(",
"self",
")",
"->",
"str",
":",
"return_string",
"=",
"\"( \\\\\\n\"",
"for",
"command",
"in",
"self",
":",
"return_string",
"+=",
"'\"'",
"+",
"str",
"(",
"command",
")",
"+",
"'\" \\\\\\n'",
"return_string",
"+=",
"\")\"",
"retu... | Return a representation as a bash array.
This creates a string formatted as a bash array containing all the commands in the job. | [
"Return",
"a",
"representation",
"as",
"a",
"bash",
"array",
"."
] | python | train |
has2k1/plotnine | plotnine/stats/density.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L96-L120 | def kde_sklearn(data, grid, **kwargs):
"""
Kernel Density Estimation with Scikit-learn
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
D... | [
"def",
"kde_sklearn",
"(",
"data",
",",
"grid",
",",
"*",
"*",
"kwargs",
")",
":",
"kde_skl",
"=",
"KernelDensity",
"(",
"*",
"*",
"kwargs",
")",
"kde_skl",
".",
"fit",
"(",
"data",
")",
"# score_samples() returns the log-likelihood of the samples",
"log_pdf",
... | Kernel Density Estimation with Scikit-learn
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data points at which the desity will be estimated. I... | [
"Kernel",
"Density",
"Estimation",
"with",
"Scikit",
"-",
"learn"
] | python | train |
spyder-ide/spyder | spyder/plugins/workingdirectory/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/workingdirectory/plugin.py#L160-L169 | def load_wdhistory(self, workdir=None):
"""Load history from a text file in user home directory"""
if osp.isfile(self.LOG_PATH):
wdhistory, _ = encoding.readlines(self.LOG_PATH)
wdhistory = [name for name in wdhistory if os.path.isdir(name)]
else:
if wor... | [
"def",
"load_wdhistory",
"(",
"self",
",",
"workdir",
"=",
"None",
")",
":",
"if",
"osp",
".",
"isfile",
"(",
"self",
".",
"LOG_PATH",
")",
":",
"wdhistory",
",",
"_",
"=",
"encoding",
".",
"readlines",
"(",
"self",
".",
"LOG_PATH",
")",
"wdhistory",
... | Load history from a text file in user home directory | [
"Load",
"history",
"from",
"a",
"text",
"file",
"in",
"user",
"home",
"directory"
] | python | train |
ml4ai/delphi | delphi/GrFN/networks.py | https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/GrFN/networks.py#L806-L862 | def S2_surface(self, sizes, bounds, presets, covers, use_torch=False,
num_samples = 10):
"""Calculates the sensitivity surface of a GrFN for the two variables with
the highest S2 index.
Args:
num_samples: Number of samples for sensitivity analysis.
sizes: Tup... | [
"def",
"S2_surface",
"(",
"self",
",",
"sizes",
",",
"bounds",
",",
"presets",
",",
"covers",
",",
"use_torch",
"=",
"False",
",",
"num_samples",
"=",
"10",
")",
":",
"args",
"=",
"self",
".",
"inputs",
"Si",
"=",
"self",
".",
"sobol_analysis",
"(",
... | Calculates the sensitivity surface of a GrFN for the two variables with
the highest S2 index.
Args:
num_samples: Number of samples for sensitivity analysis.
sizes: Tuple of (number of x inputs, number of y inputs).
bounds: Set of bounds for GrFN inputs.
p... | [
"Calculates",
"the",
"sensitivity",
"surface",
"of",
"a",
"GrFN",
"for",
"the",
"two",
"variables",
"with",
"the",
"highest",
"S2",
"index",
"."
] | python | train |
IBMStreams/pypi.streamsx | streamsx/rest.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L345-L372 | def _get_credentials(vcap_services, service_name=None):
"""Retrieves the credentials of the VCAP Service of the specified `service_name`. If
`service_name` is not specified, it takes the information from STREAMING_ANALYTICS_SERVICE_NAME environment
variable.
Args:
vcap_services (dict): A dict ... | [
"def",
"_get_credentials",
"(",
"vcap_services",
",",
"service_name",
"=",
"None",
")",
":",
"service_name",
"=",
"service_name",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'STREAMING_ANALYTICS_SERVICE_NAME'",
",",
"None",
")",
"# Get the service corresponding to t... | Retrieves the credentials of the VCAP Service of the specified `service_name`. If
`service_name` is not specified, it takes the information from STREAMING_ANALYTICS_SERVICE_NAME environment
variable.
Args:
vcap_services (dict): A dict representation of the VCAP Services information.
servic... | [
"Retrieves",
"the",
"credentials",
"of",
"the",
"VCAP",
"Service",
"of",
"the",
"specified",
"service_name",
".",
"If",
"service_name",
"is",
"not",
"specified",
"it",
"takes",
"the",
"information",
"from",
"STREAMING_ANALYTICS_SERVICE_NAME",
"environment",
"variable"... | python | train |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L69-L78 | def resolve_pid(fetched_pid):
"""Retrieve the real PID given a fetched PID.
:param pid: fetched PID to resolve.
"""
return PersistentIdentifier.get(
pid_type=fetched_pid.pid_type,
pid_value=fetched_pid.pid_value,
pid_provider=fetched_pid.provider.pid_provider
) | [
"def",
"resolve_pid",
"(",
"fetched_pid",
")",
":",
"return",
"PersistentIdentifier",
".",
"get",
"(",
"pid_type",
"=",
"fetched_pid",
".",
"pid_type",
",",
"pid_value",
"=",
"fetched_pid",
".",
"pid_value",
",",
"pid_provider",
"=",
"fetched_pid",
".",
"provide... | Retrieve the real PID given a fetched PID.
:param pid: fetched PID to resolve. | [
"Retrieve",
"the",
"real",
"PID",
"given",
"a",
"fetched",
"PID",
"."
] | python | train |
apache/incubator-heron | heron/tools/cli/src/python/cli_helper.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/cli/src/python/cli_helper.py#L34-L56 | def create_parser(subparsers, action, help_arg):
'''
:param subparsers:
:param action:
:param help_arg:
:return:
'''
parser = subparsers.add_parser(
action,
help=help_arg,
usage="%(prog)s [options] cluster/[role]/[env] <topology-name>",
add_help=True)
args.add_titles(parser)
a... | [
"def",
"create_parser",
"(",
"subparsers",
",",
"action",
",",
"help_arg",
")",
":",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"action",
",",
"help",
"=",
"help_arg",
",",
"usage",
"=",
"\"%(prog)s [options] cluster/[role]/[env] <topology-name>\"",
",",
... | :param subparsers:
:param action:
:param help_arg:
:return: | [
":",
"param",
"subparsers",
":",
":",
"param",
"action",
":",
":",
"param",
"help_arg",
":",
":",
"return",
":"
] | python | valid |
orsinium/textdistance | textdistance/algorithms/base.py | https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L153-L159 | def _count_counters(self, counter):
"""Return all elements count from Counter
"""
if getattr(self, 'as_set', False):
return len(set(counter))
else:
return sum(counter.values()) | [
"def",
"_count_counters",
"(",
"self",
",",
"counter",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'as_set'",
",",
"False",
")",
":",
"return",
"len",
"(",
"set",
"(",
"counter",
")",
")",
"else",
":",
"return",
"sum",
"(",
"counter",
".",
"values"... | Return all elements count from Counter | [
"Return",
"all",
"elements",
"count",
"from",
"Counter"
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient_mock/_urihandler.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L1712-L1744 | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion):
"""Operation: Decrease Crypto Configuration (requires DPM mode)."""
assert wait_for_completion is True # async not supported yet
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/'... | [
"def",
"post",
"(",
"method",
",",
"hmc",
",",
"uri",
",",
"uri_parms",
",",
"body",
",",
"logon_required",
",",
"wait_for_completion",
")",
":",
"assert",
"wait_for_completion",
"is",
"True",
"# async not supported yet",
"partition_oid",
"=",
"uri_parms",
"[",
... | Operation: Decrease Crypto Configuration (requires DPM mode). | [
"Operation",
":",
"Decrease",
"Crypto",
"Configuration",
"(",
"requires",
"DPM",
"mode",
")",
"."
] | python | train |
CodyKochmann/generators | generators/average.py | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/average.py#L14-L21 | def average():
""" generator that holds a rolling average """
count = 0
total = total()
i=0
while 1:
i = yield ((total.send(i)*1.0)/count if count else 0)
count += 1 | [
"def",
"average",
"(",
")",
":",
"count",
"=",
"0",
"total",
"=",
"total",
"(",
")",
"i",
"=",
"0",
"while",
"1",
":",
"i",
"=",
"yield",
"(",
"(",
"total",
".",
"send",
"(",
"i",
")",
"*",
"1.0",
")",
"/",
"count",
"if",
"count",
"else",
"... | generator that holds a rolling average | [
"generator",
"that",
"holds",
"a",
"rolling",
"average"
] | python | train |
clusterpoint/python-client-api | pycps/query.py | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/query.py#L93-L103 | def or_terms(*args):
""" Connect given term strings or list(s) of term strings with a OR operator for querying.
Args:
An arbitrary number of either strings or lists of strings representing query terms.
Returns
A query string consisting of argument terms or'ed together.
... | [
"def",
"or_terms",
"(",
"*",
"args",
")",
":",
"args",
"=",
"[",
"arg",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"list",
")",
"else",
"' '",
".",
"join",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
"]",
"return",
"'{{{0}}}'",
".",
"format",
"... | Connect given term strings or list(s) of term strings with a OR operator for querying.
Args:
An arbitrary number of either strings or lists of strings representing query terms.
Returns
A query string consisting of argument terms or'ed together. | [
"Connect",
"given",
"term",
"strings",
"or",
"list",
"(",
"s",
")",
"of",
"term",
"strings",
"with",
"a",
"OR",
"operator",
"for",
"querying",
"."
] | python | train |
SethDusek/define | define/define.py | https://github.com/SethDusek/define/blob/ba538d367be989f425a75d889aae14bca7d07f34/define/define.py#L81-L92 | def getThesaurus(self, word):
"""response = requests.get("http://words.bighugelabs.com/api/2/%s/%s/json"
% (self.tkey, word)).json()
return response"""
response = requests.get(
"http://api.wordnik.com:80/v4/word.json/%s/relatedWords?"
"useCanon... | [
"def",
"getThesaurus",
"(",
"self",
",",
"word",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"\"http://api.wordnik.com:80/v4/word.json/%s/relatedWords?\"",
"\"useCanonical=false&relationshipTypes=synonym&limitPer\"",
"\"RelationshipType=15&api_key=%s\"",
"%",
"(",
"... | response = requests.get("http://words.bighugelabs.com/api/2/%s/%s/json"
% (self.tkey, word)).json()
return response | [
"response",
"=",
"requests",
".",
"get",
"(",
"http",
":",
"//",
"words",
".",
"bighugelabs",
".",
"com",
"/",
"api",
"/",
"2",
"/",
"%s",
"/",
"%s",
"/",
"json",
"%",
"(",
"self",
".",
"tkey",
"word",
"))",
".",
"json",
"()",
"return",
"response... | python | train |
scott-maddox/openbandparams | src/openbandparams/iii_v_zinc_blende_alloy.py | https://github.com/scott-maddox/openbandparams/blob/bc24e59187326bcb8948117434536082c9055777/src/openbandparams/iii_v_zinc_blende_alloy.py#L184-L196 | def meff_e_Gamma(self, **kwargs):
'''
Returns the electron effective mass in the Gamma-valley
calculated from Eg_Gamma(T), Delta_SO, Ep and F.
Interpolation of Eg_Gamma(T), Delta_SO, Ep and F, and
then calculation of meff_e_Gamma is recommended for alloys.
'''
... | [
"def",
"meff_e_Gamma",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"Eg",
"=",
"self",
".",
"Eg_Gamma",
"(",
"*",
"*",
"kwargs",
")",
"Delta_SO",
"=",
"self",
".",
"Delta_SO",
"(",
"*",
"*",
"kwargs",
")",
"Ep",
"=",
"self",
".",
"Ep",
"(",
... | Returns the electron effective mass in the Gamma-valley
calculated from Eg_Gamma(T), Delta_SO, Ep and F.
Interpolation of Eg_Gamma(T), Delta_SO, Ep and F, and
then calculation of meff_e_Gamma is recommended for alloys. | [
"Returns",
"the",
"electron",
"effective",
"mass",
"in",
"the",
"Gamma",
"-",
"valley",
"calculated",
"from",
"Eg_Gamma",
"(",
"T",
")",
"Delta_SO",
"Ep",
"and",
"F",
".",
"Interpolation",
"of",
"Eg_Gamma",
"(",
"T",
")",
"Delta_SO",
"Ep",
"and",
"F",
"a... | python | train |
shaypal5/utilitime | utilitime/dateint/dateint.py | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/dateint/dateint.py#L114-L133 | def dateint_to_datetime(dateint):
"""Converts the given dateint to a datetime object, in local timezone.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
datetime.datetime
A timezone-unaware datetime obj... | [
"def",
"dateint_to_datetime",
"(",
"dateint",
")",
":",
"if",
"len",
"(",
"str",
"(",
"dateint",
")",
")",
"!=",
"8",
":",
"raise",
"ValueError",
"(",
"'Dateints must have exactly 8 digits; the first four representing '",
"'the year, the next two the months, and the last tw... | Converts the given dateint to a datetime object, in local timezone.
Arguments
---------
dateint : int
An integer object decipting a specific calendaric day; e.g. 20161225.
Returns
-------
datetime.datetime
A timezone-unaware datetime object representing the start of the given
... | [
"Converts",
"the",
"given",
"dateint",
"to",
"a",
"datetime",
"object",
"in",
"local",
"timezone",
"."
] | python | train |
NetEaseGame/ATX | atx/adbkit/device.py | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L237-L242 | def click(self, x, y):
'''
same as adb -s ${SERIALNO} shell input tap x y
FIXME(ssx): not tested on horizontal screen
'''
self.shell('input', 'tap', str(x), str(y)) | [
"def",
"click",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"shell",
"(",
"'input'",
",",
"'tap'",
",",
"str",
"(",
"x",
")",
",",
"str",
"(",
"y",
")",
")"
] | same as adb -s ${SERIALNO} shell input tap x y
FIXME(ssx): not tested on horizontal screen | [
"same",
"as",
"adb",
"-",
"s",
"$",
"{",
"SERIALNO",
"}",
"shell",
"input",
"tap",
"x",
"y",
"FIXME",
"(",
"ssx",
")",
":",
"not",
"tested",
"on",
"horizontal",
"screen"
] | python | train |
evonove/django-stored-messages | stored_messages/backends/redis/backend.py | https://github.com/evonove/django-stored-messages/blob/23b71f952d5d3fd03285f5e700879d05796ef7ba/stored_messages/backends/redis/backend.py#L60-L78 | def create_message(self, level, msg_text, extra_tags='', date=None, url=None):
"""
Message instances are namedtuples of type `Message`.
The date field is already serialized in datetime.isoformat ECMA-262 format
"""
if not date:
now = timezone.now()
else:
... | [
"def",
"create_message",
"(",
"self",
",",
"level",
",",
"msg_text",
",",
"extra_tags",
"=",
"''",
",",
"date",
"=",
"None",
",",
"url",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"else",
":",
"... | Message instances are namedtuples of type `Message`.
The date field is already serialized in datetime.isoformat ECMA-262 format | [
"Message",
"instances",
"are",
"namedtuples",
"of",
"type",
"Message",
".",
"The",
"date",
"field",
"is",
"already",
"serialized",
"in",
"datetime",
".",
"isoformat",
"ECMA",
"-",
"262",
"format"
] | python | valid |
log2timeline/plaso | plaso/cli/storage_media_tool.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/storage_media_tool.py#L1049-L1066 | def AddCredentialOptions(self, argument_group):
"""Adds the credential options to the argument group.
The credential options are use to unlock encrypted volumes.
Args:
argument_group (argparse._ArgumentGroup): argparse argument group.
"""
argument_group.add_argument(
'--credential', ... | [
"def",
"AddCredentialOptions",
"(",
"self",
",",
"argument_group",
")",
":",
"argument_group",
".",
"add_argument",
"(",
"'--credential'",
",",
"action",
"=",
"'append'",
",",
"default",
"=",
"[",
"]",
",",
"type",
"=",
"str",
",",
"dest",
"=",
"'credentials... | Adds the credential options to the argument group.
The credential options are use to unlock encrypted volumes.
Args:
argument_group (argparse._ArgumentGroup): argparse argument group. | [
"Adds",
"the",
"credential",
"options",
"to",
"the",
"argument",
"group",
"."
] | python | train |
CyberReboot/vent | vent/menus/add.py | https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/add.py#L75-L141 | def on_ok(self):
""" Add the repository """
def popup(thr, add_type, title):
"""
Start the thread and display a popup of the plugin being cloned
until the thread is finished
"""
thr.start()
tool_str = 'Cloning repository...'
... | [
"def",
"on_ok",
"(",
"self",
")",
":",
"def",
"popup",
"(",
"thr",
",",
"add_type",
",",
"title",
")",
":",
"\"\"\"\n Start the thread and display a popup of the plugin being cloned\n until the thread is finished\n \"\"\"",
"thr",
".",
"start",
... | Add the repository | [
"Add",
"the",
"repository"
] | python | train |
ssalentin/plip | plip/modules/preparation.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L420-L447 | def identify_kmers(self, residues):
"""Using the covalent linkage information, find out which fragments/subunits form a ligand."""
# Remove all those not considered by ligands and pairings including alternate conformations
ligdoubles = [[(link.id1, link.chain1, link.pos1),
... | [
"def",
"identify_kmers",
"(",
"self",
",",
"residues",
")",
":",
"# Remove all those not considered by ligands and pairings including alternate conformations",
"ligdoubles",
"=",
"[",
"[",
"(",
"link",
".",
"id1",
",",
"link",
".",
"chain1",
",",
"link",
".",
"pos1",
... | Using the covalent linkage information, find out which fragments/subunits form a ligand. | [
"Using",
"the",
"covalent",
"linkage",
"information",
"find",
"out",
"which",
"fragments",
"/",
"subunits",
"form",
"a",
"ligand",
"."
] | python | train |
seung-lab/cloud-volume | cloudvolume/storage.py | https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/storage.py#L818-L832 | def _radix_sort(L, i=0):
"""
Most significant char radix sort
"""
if len(L) <= 1:
return L
done_bucket = []
buckets = [ [] for x in range(255) ]
for s in L:
if i >= len(s):
done_bucket.append(s)
else:
buckets[ ord(s[i]) ].append(s)
buckets = [ _radix_sort(b, i + 1) for b in buck... | [
"def",
"_radix_sort",
"(",
"L",
",",
"i",
"=",
"0",
")",
":",
"if",
"len",
"(",
"L",
")",
"<=",
"1",
":",
"return",
"L",
"done_bucket",
"=",
"[",
"]",
"buckets",
"=",
"[",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"255",
")",
"]",
"for",
"s... | Most significant char radix sort | [
"Most",
"significant",
"char",
"radix",
"sort"
] | python | train |
bhmm/bhmm | bhmm/estimators/_tmatrix_disconnected.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/_tmatrix_disconnected.py#L28-L43 | def connected_sets(C, mincount_connectivity=0, strong=True):
""" Computes the connected sets of C.
C : count matrix
mincount_connectivity : float
Minimum count which counts as a connection.
strong : boolean
True: Seek strongly connected sets. False: Seek weakly connected sets.
"""
... | [
"def",
"connected_sets",
"(",
"C",
",",
"mincount_connectivity",
"=",
"0",
",",
"strong",
"=",
"True",
")",
":",
"import",
"msmtools",
".",
"estimation",
"as",
"msmest",
"Cconn",
"=",
"C",
".",
"copy",
"(",
")",
"Cconn",
"[",
"np",
".",
"where",
"(",
... | Computes the connected sets of C.
C : count matrix
mincount_connectivity : float
Minimum count which counts as a connection.
strong : boolean
True: Seek strongly connected sets. False: Seek weakly connected sets. | [
"Computes",
"the",
"connected",
"sets",
"of",
"C",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/fcoe/fcoe_map/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/fcoe/fcoe_map/__init__.py#L143-L167 | def _set_fcoe_map_fabric_map(self, v, load=False):
"""
Setter method for fcoe_map_fabric_map, mapped from YANG variable /fcoe/fcoe_map/fcoe_map_fabric_map (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_fcoe_map_fabric_map is considered as a private
metho... | [
"def",
"_set_fcoe_map_fabric_map",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",... | Setter method for fcoe_map_fabric_map, mapped from YANG variable /fcoe/fcoe_map/fcoe_map_fabric_map (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_fcoe_map_fabric_map is considered as a private
method. Backends looking to populate this variable should
do so ... | [
"Setter",
"method",
"for",
"fcoe_map_fabric_map",
"mapped",
"from",
"YANG",
"variable",
"/",
"fcoe",
"/",
"fcoe_map",
"/",
"fcoe_map_fabric_map",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"i... | python | train |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L952-L955 | def p_expression_uor(self, p):
'expression : OR expression %prec UOR'
p[0] = Uor(p[2], lineno=p.lineno(1))
p.set_lineno(0, p.lineno(1)) | [
"def",
"p_expression_uor",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Uor",
"(",
"p",
"[",
"2",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")",
"p",
".",
"set_lineno",
"(",
"0",
",",
"p",
".",
"lineno",
"(",... | expression : OR expression %prec UOR | [
"expression",
":",
"OR",
"expression",
"%prec",
"UOR"
] | python | train |
pettarin/ipapy | ipapy/ipachar.py | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L311-L329 | def variant_to_list(obj):
"""
Return a list containing the descriptors in the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
... | [
"def",
"variant_to_list",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"obj",
"elif",
"is_unicode_string",
"(",
"obj",
")",
":",
"return",
"[",
"s",
"for",
"s",
"in",
"obj",
".",
"split",
"(",
")",
"if",
"l... | Return a list containing the descriptors in the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
:rtype: list
:raise TypeError:... | [
"Return",
"a",
"list",
"containing",
"the",
"descriptors",
"in",
"the",
"given",
"object",
"."
] | python | train |
google/grr | grr/server/grr_response_server/check_lib/filters.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L397-L438 | def _Initialize(self):
"""Initialize the filter configuration from a validated configuration.
The configuration is read. Active filters are added to the matcher list,
which is used to process the Stat values.
"""
if self.cfg.mask:
self.mask = int(self.cfg.mask[0], 8)
else:
self.mas... | [
"def",
"_Initialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"cfg",
".",
"mask",
":",
"self",
".",
"mask",
"=",
"int",
"(",
"self",
".",
"cfg",
".",
"mask",
"[",
"0",
"]",
",",
"8",
")",
"else",
":",
"self",
".",
"mask",
"=",
"0o7777",
"if... | Initialize the filter configuration from a validated configuration.
The configuration is read. Active filters are added to the matcher list,
which is used to process the Stat values. | [
"Initialize",
"the",
"filter",
"configuration",
"from",
"a",
"validated",
"configuration",
"."
] | python | train |
pymoca/pymoca | src/pymoca/tree.py | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L720-L746 | def modify_symbol(sym: ast.Symbol, scope: ast.InstanceClass) -> None:
"""
Apply a modification to a symbol if the scope matches (or is None)
:param sym: symbol to apply modifications for
:param scope: scope of modification
"""
# We assume that we do not screw up the order of applying modificati... | [
"def",
"modify_symbol",
"(",
"sym",
":",
"ast",
".",
"Symbol",
",",
"scope",
":",
"ast",
".",
"InstanceClass",
")",
"->",
"None",
":",
"# We assume that we do not screw up the order of applying modifications",
"# when \"moving up\" with the scope.",
"apply_args",
"=",
"["... | Apply a modification to a symbol if the scope matches (or is None)
:param sym: symbol to apply modifications for
:param scope: scope of modification | [
"Apply",
"a",
"modification",
"to",
"a",
"symbol",
"if",
"the",
"scope",
"matches",
"(",
"or",
"is",
"None",
")",
":",
"param",
"sym",
":",
"symbol",
"to",
"apply",
"modifications",
"for",
":",
"param",
"scope",
":",
"scope",
"of",
"modification"
] | python | train |
Alignak-monitoring/alignak | alignak/objects/config.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/config.py#L2857-L3040 | def cut_into_parts(self):
# pylint: disable=too-many-branches, too-many-locals, too-many-statements
"""Cut conf into part for scheduler dispatch.
Basically it provides a set of host/services for each scheduler that
have no dependencies between them
:return: None
"""
... | [
"def",
"cut_into_parts",
"(",
"self",
")",
":",
"# pylint: disable=too-many-branches, too-many-locals, too-many-statements",
"# User must have set a spare if he needed one",
"logger",
".",
"info",
"(",
"\"Splitting the configuration into parts:\"",
")",
"nb_parts",
"=",
"0",
"for",... | Cut conf into part for scheduler dispatch.
Basically it provides a set of host/services for each scheduler that
have no dependencies between them
:return: None | [
"Cut",
"conf",
"into",
"part",
"for",
"scheduler",
"dispatch",
"."
] | python | train |
cloudendpoints/endpoints-management-python | endpoints_management/control/check_request.py | https://github.com/cloudendpoints/endpoints-management-python/blob/ec3c4a330ae9d65738861ce6df4dd6c3cb9f7731/endpoints_management/control/check_request.py#L369-L374 | def clear(self):
"""Clears this instance's cache."""
if self._cache is not None:
with self._cache as c:
c.clear()
c.out_deque.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cache",
"is",
"not",
"None",
":",
"with",
"self",
".",
"_cache",
"as",
"c",
":",
"c",
".",
"clear",
"(",
")",
"c",
".",
"out_deque",
".",
"clear",
"(",
")"
] | Clears this instance's cache. | [
"Clears",
"this",
"instance",
"s",
"cache",
"."
] | python | train |
rix0rrr/gcl | gcl/runtime.py | https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/runtime.py#L312-L326 | def resolve(self, current_file, rel_path):
"""Search the filesystem."""
search_path = [path.dirname(current_file)] + self.search_path
target_path = None
for search in search_path:
if self.exists(path.join(search, rel_path)):
target_path = path.normpath(path.join(search, rel_path))
... | [
"def",
"resolve",
"(",
"self",
",",
"current_file",
",",
"rel_path",
")",
":",
"search_path",
"=",
"[",
"path",
".",
"dirname",
"(",
"current_file",
")",
"]",
"+",
"self",
".",
"search_path",
"target_path",
"=",
"None",
"for",
"search",
"in",
"search_path"... | Search the filesystem. | [
"Search",
"the",
"filesystem",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datarepo.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L1364-L1370 | def removePeer(self, url):
"""
Remove peers by URL.
"""
q = models.Peer.delete().where(
models.Peer.url == url)
q.execute() | [
"def",
"removePeer",
"(",
"self",
",",
"url",
")",
":",
"q",
"=",
"models",
".",
"Peer",
".",
"delete",
"(",
")",
".",
"where",
"(",
"models",
".",
"Peer",
".",
"url",
"==",
"url",
")",
"q",
".",
"execute",
"(",
")"
] | Remove peers by URL. | [
"Remove",
"peers",
"by",
"URL",
"."
] | python | train |
taskcluster/taskcluster-client.py | taskcluster/client.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/client.py#L444-L553 | def _makeHttpRequest(self, method, route, payload):
""" Make an HTTP Request for the API endpoint. This method wraps
the logic about doing failure retry and passes off the actual work
of doing an HTTP request to another method."""
url = self._constructUrl(route)
log.debug('Full... | [
"def",
"_makeHttpRequest",
"(",
"self",
",",
"method",
",",
"route",
",",
"payload",
")",
":",
"url",
"=",
"self",
".",
"_constructUrl",
"(",
"route",
")",
"log",
".",
"debug",
"(",
"'Full URL used is: %s'",
",",
"url",
")",
"hawkExt",
"=",
"self",
".",
... | Make an HTTP Request for the API endpoint. This method wraps
the logic about doing failure retry and passes off the actual work
of doing an HTTP request to another method. | [
"Make",
"an",
"HTTP",
"Request",
"for",
"the",
"API",
"endpoint",
".",
"This",
"method",
"wraps",
"the",
"logic",
"about",
"doing",
"failure",
"retry",
"and",
"passes",
"off",
"the",
"actual",
"work",
"of",
"doing",
"an",
"HTTP",
"request",
"to",
"another"... | python | train |
lepture/flask-oauthlib | flask_oauthlib/client.py | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L700-L714 | def authorized_response(self, args=None):
"""Handles authorization response smartly."""
if args is None:
args = request.args
if 'oauth_verifier' in args:
data = self.handle_oauth1_response(args)
elif 'code' in args:
data = self.handle_oauth2_response(a... | [
"def",
"authorized_response",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"request",
".",
"args",
"if",
"'oauth_verifier'",
"in",
"args",
":",
"data",
"=",
"self",
".",
"handle_oauth1_response",
"(",
"ar... | Handles authorization response smartly. | [
"Handles",
"authorization",
"response",
"smartly",
"."
] | python | test |
UCL-INGI/INGInious | inginious/frontend/pages/register.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/register.py#L63-L117 | def register_user(self, data):
""" Parses input and register user """
error = False
msg = ""
email_re = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\0... | [
"def",
"register_user",
"(",
"self",
",",
"data",
")",
":",
"error",
"=",
"False",
"msg",
"=",
"\"\"",
"email_re",
"=",
"re",
".",
"compile",
"(",
"r\"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\"",
"# dot-atom",
"r'|^\"([\\001-\\010\\013\\014\\016-\\... | Parses input and register user | [
"Parses",
"input",
"and",
"register",
"user"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/GettextCommon.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/GettextCommon.py#L261-L266 | def _translate(env, target=None, source=SCons.Environment._null, *args, **kw):
""" Function for `Translate()` pseudo-builder """
if target is None: target = []
pot = env.POTUpdate(None, source, *args, **kw)
po = env.POUpdate(target, pot, *args, **kw)
return po | [
"def",
"_translate",
"(",
"env",
",",
"target",
"=",
"None",
",",
"source",
"=",
"SCons",
".",
"Environment",
".",
"_null",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"target",
"is",
"None",
":",
"target",
"=",
"[",
"]",
"pot",
"=",
... | Function for `Translate()` pseudo-builder | [
"Function",
"for",
"Translate",
"()",
"pseudo",
"-",
"builder"
] | python | train |
gplepage/lsqfit | src/lsqfit/__init__.py | https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1282-L1360 | def simulated_fit_iter(
self, n=None, pexact=None, add_priornoise=False, bootstrap=None, **kargs
):
""" Iterator that returns simulation copies of a fit.
Fit reliability is tested using simulated data which
replaces the mean values in ``self.y`` with random numbers
drawn... | [
"def",
"simulated_fit_iter",
"(",
"self",
",",
"n",
"=",
"None",
",",
"pexact",
"=",
"None",
",",
"add_priornoise",
"=",
"False",
",",
"bootstrap",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"pexact",
"=",
"self",
".",
"pmean",
"if",
"pexact",
"i... | Iterator that returns simulation copies of a fit.
Fit reliability is tested using simulated data which
replaces the mean values in ``self.y`` with random numbers
drawn from a distribution whose mean equals ``self.fcn(pexact)``
and whose covariance matrix is the same as ``self.y``'s. Sim... | [
"Iterator",
"that",
"returns",
"simulation",
"copies",
"of",
"a",
"fit",
"."
] | python | train |
aichaos/rivescript-python | eg/twilio/app.py | https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/eg/twilio/app.py#L28-L42 | def hello_rivescript():
"""Receive an inbound SMS and send a reply from RiveScript."""
from_number = request.values.get("From", "unknown")
message = request.values.get("Body")
reply = "(Internal error)"
# Get a reply from RiveScript.
if message:
reply = bot.reply(from_number,... | [
"def",
"hello_rivescript",
"(",
")",
":",
"from_number",
"=",
"request",
".",
"values",
".",
"get",
"(",
"\"From\"",
",",
"\"unknown\"",
")",
"message",
"=",
"request",
".",
"values",
".",
"get",
"(",
"\"Body\"",
")",
"reply",
"=",
"\"(Internal error)\"",
... | Receive an inbound SMS and send a reply from RiveScript. | [
"Receive",
"an",
"inbound",
"SMS",
"and",
"send",
"a",
"reply",
"from",
"RiveScript",
"."
] | python | train |
materialsproject/pymatgen-db | matgendb/vv/validate.py | https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/vv/validate.py#L380-L400 | def validate(self, coll, constraint_spec, subject='collection'):
"""Validation of a collection.
This is a generator that yields ConstraintViolationGroups.
:param coll: Mongo collection
:type coll: pymongo.Collection
:param constraint_spec: Constraint specification
:type... | [
"def",
"validate",
"(",
"self",
",",
"coll",
",",
"constraint_spec",
",",
"subject",
"=",
"'collection'",
")",
":",
"self",
".",
"_spec",
"=",
"constraint_spec",
"self",
".",
"_progress",
".",
"set_subject",
"(",
"subject",
")",
"self",
".",
"_build",
"(",... | Validation of a collection.
This is a generator that yields ConstraintViolationGroups.
:param coll: Mongo collection
:type coll: pymongo.Collection
:param constraint_spec: Constraint specification
:type constraint_spec: ConstraintSpec
:param subject: Name of the thing b... | [
"Validation",
"of",
"a",
"collection",
".",
"This",
"is",
"a",
"generator",
"that",
"yields",
"ConstraintViolationGroups",
"."
] | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/lib/input_reader/_gcs.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/lib/input_reader/_gcs.py#L289-L325 | def next(self):
"""Returns a handler to the next file.
Non existent files will be logged and skipped. The file might have been
removed after input splitting.
Returns:
The next input from this input reader in the form of a cloudstorage
ReadBuffer that supports a File-like interface (read, r... | [
"def",
"next",
"(",
"self",
")",
":",
"options",
"=",
"{",
"}",
"if",
"self",
".",
"_buffer_size",
":",
"options",
"[",
"\"read_buffer_size\"",
"]",
"=",
"self",
".",
"_buffer_size",
"if",
"self",
".",
"_account_id",
":",
"options",
"[",
"\"_account_id\"",... | Returns a handler to the next file.
Non existent files will be logged and skipped. The file might have been
removed after input splitting.
Returns:
The next input from this input reader in the form of a cloudstorage
ReadBuffer that supports a File-like interface (read, readline, seek,
te... | [
"Returns",
"a",
"handler",
"to",
"the",
"next",
"file",
"."
] | python | train |
riga/scinum | scinum.py | https://github.com/riga/scinum/blob/55eb6d8aa77beacee5a07443392954b8a0aad8cb/scinum.py#L1188-L1196 | def atan(x):
""" tan(x)
Trigonometric arc tan function.
"""
_math = infer_math(x)
if _math is math:
return _math.atan(x)
else:
return _math.arctan(x) | [
"def",
"atan",
"(",
"x",
")",
":",
"_math",
"=",
"infer_math",
"(",
"x",
")",
"if",
"_math",
"is",
"math",
":",
"return",
"_math",
".",
"atan",
"(",
"x",
")",
"else",
":",
"return",
"_math",
".",
"arctan",
"(",
"x",
")"
] | tan(x)
Trigonometric arc tan function. | [
"tan",
"(",
"x",
")",
"Trigonometric",
"arc",
"tan",
"function",
"."
] | python | train |
blue-yonder/turbodbc | python/turbodbc/cursor.py | https://github.com/blue-yonder/turbodbc/blob/5556625e69244d941a708c69eb2c1e7b37c190b1/python/turbodbc/cursor.py#L280-L292 | def fetchnumpybatches(self):
"""
Returns an iterator over all rows in the active result set generated with ``execute()`` or
``executemany()``.
:return: An iterator you can use to iterate over batches of rows of the result set. Each
batch consists of an ``OrderedDict`` o... | [
"def",
"fetchnumpybatches",
"(",
"self",
")",
":",
"batchgen",
"=",
"self",
".",
"_numpy_batch_generator",
"(",
")",
"column_names",
"=",
"[",
"description",
"[",
"0",
"]",
"for",
"description",
"in",
"self",
".",
"description",
"]",
"for",
"next_batch",
"in... | Returns an iterator over all rows in the active result set generated with ``execute()`` or
``executemany()``.
:return: An iterator you can use to iterate over batches of rows of the result set. Each
batch consists of an ``OrderedDict`` of NumPy ``MaskedArray`` instances. See
... | [
"Returns",
"an",
"iterator",
"over",
"all",
"rows",
"in",
"the",
"active",
"result",
"set",
"generated",
"with",
"execute",
"()",
"or",
"executemany",
"()",
"."
] | python | train |
saltstack/salt | salt/modules/systemd_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/systemd_service.py#L323-L346 | def _systemctl_cmd(action, name=None, systemd_scope=False, no_block=False,
root=None):
'''
Build a systemctl command line. Treat unit names without one
of the valid suffixes as a service.
'''
ret = []
if systemd_scope \
and salt.utils.systemd.has_scope(__context__)... | [
"def",
"_systemctl_cmd",
"(",
"action",
",",
"name",
"=",
"None",
",",
"systemd_scope",
"=",
"False",
",",
"no_block",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"systemd_scope",
"and",
"salt",
".",
"utils",
".",
"s... | Build a systemctl command line. Treat unit names without one
of the valid suffixes as a service. | [
"Build",
"a",
"systemctl",
"command",
"line",
".",
"Treat",
"unit",
"names",
"without",
"one",
"of",
"the",
"valid",
"suffixes",
"as",
"a",
"service",
"."
] | python | train |
devassistant/devassistant | devassistant/argument.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/argument.py#L111-L133 | def construct_arg(cls, name, params):
"""Construct an argument from name, and params (dict loaded from assistant/snippet).
"""
use_snippet = params.pop('use', None)
if use_snippet:
# if snippet is used, take this parameter from snippet and update
# it with current... | [
"def",
"construct_arg",
"(",
"cls",
",",
"name",
",",
"params",
")",
":",
"use_snippet",
"=",
"params",
".",
"pop",
"(",
"'use'",
",",
"None",
")",
"if",
"use_snippet",
":",
"# if snippet is used, take this parameter from snippet and update",
"# it with current params... | Construct an argument from name, and params (dict loaded from assistant/snippet). | [
"Construct",
"an",
"argument",
"from",
"name",
"and",
"params",
"(",
"dict",
"loaded",
"from",
"assistant",
"/",
"snippet",
")",
"."
] | python | train |
datastax/python-driver | cassandra/encoder.py | https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/encoder.py#L227-L235 | def cql_encode_all_types(self, val, as_text_type=False):
"""
Converts any type into a CQL string, defaulting to ``cql_encode_object``
if :attr:`~Encoder.mapping` does not contain an entry for the type.
"""
encoded = self.mapping.get(type(val), self.cql_encode_object)(val)
... | [
"def",
"cql_encode_all_types",
"(",
"self",
",",
"val",
",",
"as_text_type",
"=",
"False",
")",
":",
"encoded",
"=",
"self",
".",
"mapping",
".",
"get",
"(",
"type",
"(",
"val",
")",
",",
"self",
".",
"cql_encode_object",
")",
"(",
"val",
")",
"if",
... | Converts any type into a CQL string, defaulting to ``cql_encode_object``
if :attr:`~Encoder.mapping` does not contain an entry for the type. | [
"Converts",
"any",
"type",
"into",
"a",
"CQL",
"string",
"defaulting",
"to",
"cql_encode_object",
"if",
":",
"attr",
":",
"~Encoder",
".",
"mapping",
"does",
"not",
"contain",
"an",
"entry",
"for",
"the",
"type",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/utils.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L837-L848 | def local_path_export(at_start=True, env_cmd=None):
"""Retrieve paths to local install, also including environment paths if env_cmd included.
"""
paths = [get_bcbio_bin()]
if env_cmd:
env_path = os.path.dirname(get_program_python(env_cmd))
if env_path not in paths:
paths.inse... | [
"def",
"local_path_export",
"(",
"at_start",
"=",
"True",
",",
"env_cmd",
"=",
"None",
")",
":",
"paths",
"=",
"[",
"get_bcbio_bin",
"(",
")",
"]",
"if",
"env_cmd",
":",
"env_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"get_program_python",
"(",
... | Retrieve paths to local install, also including environment paths if env_cmd included. | [
"Retrieve",
"paths",
"to",
"local",
"install",
"also",
"including",
"environment",
"paths",
"if",
"env_cmd",
"included",
"."
] | python | train |
Miserlou/Zappa | zappa/core.py | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2142-L2237 | def update_stack(self, name, working_bucket, wait=False, update_only=False, disable_progress=False):
"""
Update or create the CF stack managed by Zappa.
"""
capabilities = []
template = name + '-template-' + str(int(time.time())) + '.json'
with open(template, 'wb') as ou... | [
"def",
"update_stack",
"(",
"self",
",",
"name",
",",
"working_bucket",
",",
"wait",
"=",
"False",
",",
"update_only",
"=",
"False",
",",
"disable_progress",
"=",
"False",
")",
":",
"capabilities",
"=",
"[",
"]",
"template",
"=",
"name",
"+",
"'-template-'... | Update or create the CF stack managed by Zappa. | [
"Update",
"or",
"create",
"the",
"CF",
"stack",
"managed",
"by",
"Zappa",
"."
] | python | train |
MatMaul/pynetgear | pynetgear/__init__.py | https://github.com/MatMaul/pynetgear/blob/247d6b9524fcee4b2da0e65ca12c52ebdd3676b2/pynetgear/__init__.py#L127-L200 | def get_attached_devices(self):
"""
Return list of connected devices to the router.
Returns None if error occurred.
"""
_LOGGER.info("Get attached devices")
success, response = self._make_request(SERVICE_DEVICE_INFO,
"GetAt... | [
"def",
"get_attached_devices",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Get attached devices\"",
")",
"success",
",",
"response",
"=",
"self",
".",
"_make_request",
"(",
"SERVICE_DEVICE_INFO",
",",
"\"GetAttachDevice\"",
")",
"if",
"not",
"success",
... | Return list of connected devices to the router.
Returns None if error occurred. | [
"Return",
"list",
"of",
"connected",
"devices",
"to",
"the",
"router",
"."
] | python | valid |
AnthonyBloomer/daftlistings | daftlistings/listing.py | https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L330-L346 | def agent_url(self):
"""
This method returns the agent's url.
:return:
"""
try:
if self._data_from_search:
agent = self._data_from_search.find('ul', {'class': 'links'})
links = agent.find_all('a')
return links[1]['href']... | [
"def",
"agent_url",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_data_from_search",
":",
"agent",
"=",
"self",
".",
"_data_from_search",
".",
"find",
"(",
"'ul'",
",",
"{",
"'class'",
":",
"'links'",
"}",
")",
"links",
"=",
"agent",
".",
"... | This method returns the agent's url.
:return: | [
"This",
"method",
"returns",
"the",
"agent",
"s",
"url",
".",
":",
"return",
":"
] | python | train |
bcbio/bcbio-nextgen | bcbio/structural/wham.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L64-L87 | def filter_by_background(in_vcf, full_vcf, background, data):
"""Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets.
"""
Filter = collections.namedtuple('Filter', ['id', 'desc'])
... | [
"def",
"filter_by_background",
"(",
"in_vcf",
",",
"full_vcf",
",",
"background",
",",
"data",
")",
":",
"Filter",
"=",
"collections",
".",
"namedtuple",
"(",
"'Filter'",
",",
"[",
"'id'",
",",
"'desc'",
"]",
")",
"back_filter",
"=",
"Filter",
"(",
"id",
... | Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets. | [
"Filter",
"SV",
"calls",
"also",
"present",
"in",
"background",
"samples",
"."
] | python | train |
lambdalisue/maidenhair | src/maidenhair/utils/plugins.py | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/utils/plugins.py#L73-L116 | def register(self, name, obj, namespace=None):
"""
Register :attr:`obj` as :attr:`name` in :attr:`namespace`
Parameters
----------
name : string
A name of the object entry
obj : instance
A python object which will be registered
namespace :... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"obj",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"\".\"",
"in",
"name",
":",
"namespace",
",",
"name",
"=",
"name",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"caret",
"=",
"self",
".",
"raw... | Register :attr:`obj` as :attr:`name` in :attr:`namespace`
Parameters
----------
name : string
A name of the object entry
obj : instance
A python object which will be registered
namespace : string, optional
A period separated namespace. E.g. `f... | [
"Register",
":",
"attr",
":",
"obj",
"as",
":",
"attr",
":",
"name",
"in",
":",
"attr",
":",
"namespace"
] | python | train |
jopohl/urh | src/urh/ui/SimulatorScene.py | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/SimulatorScene.py#L376-L412 | def dropEvent(self, event: QDropEvent):
items = [item for item in self.items(event.scenePos()) if isinstance(item, GraphicsItem) and item.acceptDrops()]
item = None if len(items) == 0 else items[0]
if len(event.mimeData().urls()) > 0:
self.files_dropped.emit(event.mimeData().urls())
... | [
"def",
"dropEvent",
"(",
"self",
",",
"event",
":",
"QDropEvent",
")",
":",
"items",
"=",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"items",
"(",
"event",
".",
"scenePos",
"(",
")",
")",
"if",
"isinstance",
"(",
"item",
",",
"GraphicsItem",
")",... | :type: list of ProtocolTreeItem | [
":",
"type",
":",
"list",
"of",
"ProtocolTreeItem"
] | python | train |
ibis-project/ibis | ibis/clickhouse/client.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/clickhouse/client.py#L338-L359 | def get_schema(self, table_name, database=None):
"""
Return a Schema object for the indicated table and database
Parameters
----------
table_name : string
May be fully qualified
database : string, default None
Returns
-------
schema : i... | [
"def",
"get_schema",
"(",
"self",
",",
"table_name",
",",
"database",
"=",
"None",
")",
":",
"qualified_name",
"=",
"self",
".",
"_fully_qualified_name",
"(",
"table_name",
",",
"database",
")",
"query",
"=",
"'DESC {0}'",
".",
"format",
"(",
"qualified_name",... | Return a Schema object for the indicated table and database
Parameters
----------
table_name : string
May be fully qualified
database : string, default None
Returns
-------
schema : ibis Schema | [
"Return",
"a",
"Schema",
"object",
"for",
"the",
"indicated",
"table",
"and",
"database"
] | python | train |
Alignak-monitoring/alignak | alignak/scheduler.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/scheduler.py#L1822-L1840 | def get_new_broks(self):
"""Iter over all hosts and services to add new broks in internal lists
:return: None
"""
# ask for service and hosts their broks waiting
# be eaten
for elt in self.all_my_hosts_and_services():
for brok in elt.broks:
se... | [
"def",
"get_new_broks",
"(",
"self",
")",
":",
"# ask for service and hosts their broks waiting",
"# be eaten",
"for",
"elt",
"in",
"self",
".",
"all_my_hosts_and_services",
"(",
")",
":",
"for",
"brok",
"in",
"elt",
".",
"broks",
":",
"self",
".",
"add",
"(",
... | Iter over all hosts and services to add new broks in internal lists
:return: None | [
"Iter",
"over",
"all",
"hosts",
"and",
"services",
"to",
"add",
"new",
"broks",
"in",
"internal",
"lists"
] | python | train |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L121-L125 | def create_file(self, path, content, mode='w', user='root'):
"""Create a file on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.create_file(user, path, content, mode) | [
"def",
"create_file",
"(",
"self",
",",
"path",
",",
"content",
",",
"mode",
"=",
"'w'",
",",
"user",
"=",
"'root'",
")",
":",
"self",
".",
"enable_user",
"(",
"user",
")",
"return",
"self",
".",
"ssh_pool",
".",
"create_file",
"(",
"user",
",",
"pat... | Create a file on the remote host. | [
"Create",
"a",
"file",
"on",
"the",
"remote",
"host",
"."
] | python | train |
aliyun/aliyun-odps-python-sdk | odps/errors.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/errors.py#L62-L84 | def throw_if_parsable(resp):
"""Try to parse the content of the response and raise an exception
if neccessary.
"""
e = None
try:
e = parse_response(resp)
except:
# Error occurred during parsing the response. We ignore it and delegate
# the situation to caller to handle.
... | [
"def",
"throw_if_parsable",
"(",
"resp",
")",
":",
"e",
"=",
"None",
"try",
":",
"e",
"=",
"parse_response",
"(",
"resp",
")",
"except",
":",
"# Error occurred during parsing the response. We ignore it and delegate",
"# the situation to caller to handle.",
"LOG",
".",
"... | Try to parse the content of the response and raise an exception
if neccessary. | [
"Try",
"to",
"parse",
"the",
"content",
"of",
"the",
"response",
"and",
"raise",
"an",
"exception",
"if",
"neccessary",
"."
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/ssh_tunnel_app_support.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/ssh_tunnel_app_support.py#L89-L131 | def run_notebook(args, ssh_config_check):
"""
Launch the notebook server.
"""
# Check that ssh is setup. Currently notebooks require ssh for tunelling.
ssh_config_check()
if args.only_check_config:
return
# If the user requested a specific version of the notebook server,
# get ... | [
"def",
"run_notebook",
"(",
"args",
",",
"ssh_config_check",
")",
":",
"# Check that ssh is setup. Currently notebooks require ssh for tunelling.",
"ssh_config_check",
"(",
")",
"if",
"args",
".",
"only_check_config",
":",
"return",
"# If the user requested a specific version of... | Launch the notebook server. | [
"Launch",
"the",
"notebook",
"server",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xfindwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xfindwidget.py#L198-L209 | def setTextEdit( self, textEdit ):
"""
Sets the text edit that this find widget will use to search.
:param textEdit | <QTextEdit>
"""
if ( self._textEdit ):
self._textEdit.removeAction(self._findAction)
self._textEdit = text... | [
"def",
"setTextEdit",
"(",
"self",
",",
"textEdit",
")",
":",
"if",
"(",
"self",
".",
"_textEdit",
")",
":",
"self",
".",
"_textEdit",
".",
"removeAction",
"(",
"self",
".",
"_findAction",
")",
"self",
".",
"_textEdit",
"=",
"textEdit",
"if",
"(",
"tex... | Sets the text edit that this find widget will use to search.
:param textEdit | <QTextEdit> | [
"Sets",
"the",
"text",
"edit",
"that",
"this",
"find",
"widget",
"will",
"use",
"to",
"search",
".",
":",
"param",
"textEdit",
"|",
"<QTextEdit",
">"
] | python | train |
LLNL/certipy | certipy/certipy.py | https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L545-L569 | def create_bundle(self, bundle_name, names=None, ca_only=True):
"""Create a bundle of public certs for trust distribution
This will create a bundle of both CAs and/or regular certificates.
Arguments: names - The names of certs to include in the bundle
bundle_name - The ... | [
"def",
"create_bundle",
"(",
"self",
",",
"bundle_name",
",",
"names",
"=",
"None",
",",
"ca_only",
"=",
"True",
")",
":",
"if",
"not",
"names",
":",
"if",
"ca_only",
":",
"names",
"=",
"[",
"]",
"for",
"name",
",",
"record",
"in",
"self",
".",
"st... | Create a bundle of public certs for trust distribution
This will create a bundle of both CAs and/or regular certificates.
Arguments: names - The names of certs to include in the bundle
bundle_name - The name of the bundle file to output
Returns: Path to the bundle fil... | [
"Create",
"a",
"bundle",
"of",
"public",
"certs",
"for",
"trust",
"distribution"
] | python | train |
MasterOdin/pylint_runner | pylint_runner/main.py | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L187-L190 | def main(output=None, error=None, verbose=False):
""" The main (cli) interface for the pylint runner. """
runner = Runner(args=["--verbose"] if verbose is not False else None)
runner.run(output, error) | [
"def",
"main",
"(",
"output",
"=",
"None",
",",
"error",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"runner",
"=",
"Runner",
"(",
"args",
"=",
"[",
"\"--verbose\"",
"]",
"if",
"verbose",
"is",
"not",
"False",
"else",
"None",
")",
"runner",
... | The main (cli) interface for the pylint runner. | [
"The",
"main",
"(",
"cli",
")",
"interface",
"for",
"the",
"pylint",
"runner",
"."
] | python | train |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/drivers.py | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/drivers.py#L127-L251 | def _send_command(self, command, immediate=False, timeout=1.0,
check_echo=None):
""" Send a single command to the drive after sanitizing it.
Takes a single given `command`, sanitizes it (strips out
comments, extra whitespace, and newlines), sends the command to
the... | [
"def",
"_send_command",
"(",
"self",
",",
"command",
",",
"immediate",
"=",
"False",
",",
"timeout",
"=",
"1.0",
",",
"check_echo",
"=",
"None",
")",
":",
"# Use the default echo checking if None was given.",
"if",
"check_echo",
"is",
"None",
":",
"check_echo",
... | Send a single command to the drive after sanitizing it.
Takes a single given `command`, sanitizes it (strips out
comments, extra whitespace, and newlines), sends the command to
the drive, and returns the sanitized command. The validity of
the command is **NOT** checked.
Paramet... | [
"Send",
"a",
"single",
"command",
"to",
"the",
"drive",
"after",
"sanitizing",
"it",
"."
] | python | train |
iskandr/fancyimpute | fancyimpute/iterative_imputer.py | https://github.com/iskandr/fancyimpute/blob/9f0837d387c7303d5c8c925a9989ca77a1a96e3e/fancyimpute/iterative_imputer.py#L99-L113 | def _get_mask(X, value_to_mask):
"""Compute the boolean mask X == missing_values."""
if is_scalar_nan(value_to_mask):
if X.dtype.kind == "f":
return np.isnan(X)
elif X.dtype.kind in ("i", "u"):
# can't have NaNs in integer array.
return np.zeros(X.shape, dtype... | [
"def",
"_get_mask",
"(",
"X",
",",
"value_to_mask",
")",
":",
"if",
"is_scalar_nan",
"(",
"value_to_mask",
")",
":",
"if",
"X",
".",
"dtype",
".",
"kind",
"==",
"\"f\"",
":",
"return",
"np",
".",
"isnan",
"(",
"X",
")",
"elif",
"X",
".",
"dtype",
"... | Compute the boolean mask X == missing_values. | [
"Compute",
"the",
"boolean",
"mask",
"X",
"==",
"missing_values",
"."
] | python | train |
hardbyte/python-can | can/bus.py | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L285-L308 | def set_filters(self, filters=None):
"""Apply filtering to all messages received by this Bus.
All messages that match at least one filter are returned.
If `filters` is `None` or a zero length sequence, all
messages are matched.
Calling without passing any filters will reset the... | [
"def",
"set_filters",
"(",
"self",
",",
"filters",
"=",
"None",
")",
":",
"self",
".",
"_filters",
"=",
"filters",
"or",
"None",
"self",
".",
"_apply_filters",
"(",
"self",
".",
"_filters",
")"
] | Apply filtering to all messages received by this Bus.
All messages that match at least one filter are returned.
If `filters` is `None` or a zero length sequence, all
messages are matched.
Calling without passing any filters will reset the applied
filters to `None`.
:pa... | [
"Apply",
"filtering",
"to",
"all",
"messages",
"received",
"by",
"this",
"Bus",
"."
] | python | train |
BD2KGenomics/protect | src/protect/common.py | https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/common.py#L67-L80 | def docker_path(filepath, work_dir=None):
"""
Given a path, return that files path inside the docker mount directory (/data).
:param str filepath: The path to a file
:param str work_dir: The part of the path to replace with /data
:return: The docker-friendly path for `filepath`
:rtype: str
... | [
"def",
"docker_path",
"(",
"filepath",
",",
"work_dir",
"=",
"None",
")",
":",
"if",
"work_dir",
":",
"return",
"re",
".",
"sub",
"(",
"work_dir",
",",
"'/data'",
",",
"filepath",
")",
"else",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"'/da... | Given a path, return that files path inside the docker mount directory (/data).
:param str filepath: The path to a file
:param str work_dir: The part of the path to replace with /data
:return: The docker-friendly path for `filepath`
:rtype: str | [
"Given",
"a",
"path",
"return",
"that",
"files",
"path",
"inside",
"the",
"docker",
"mount",
"directory",
"(",
"/",
"data",
")",
"."
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient/_storage_group.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_storage_group.py#L514-L562 | def add_candidate_adapter_ports(self, ports):
"""
Add a list of storage adapter ports to this storage group's candidate
adapter ports list.
This operation only applies to storage groups of type "fcp".
These adapter ports become candidates for use as backing adapters when
... | [
"def",
"add_candidate_adapter_ports",
"(",
"self",
",",
"ports",
")",
":",
"body",
"=",
"{",
"'adapter-port-uris'",
":",
"[",
"p",
".",
"uri",
"for",
"p",
"in",
"ports",
"]",
",",
"}",
"self",
".",
"manager",
".",
"session",
".",
"post",
"(",
"self",
... | Add a list of storage adapter ports to this storage group's candidate
adapter ports list.
This operation only applies to storage groups of type "fcp".
These adapter ports become candidates for use as backing adapters when
creating virtual storage resources when the storage group is att... | [
"Add",
"a",
"list",
"of",
"storage",
"adapter",
"ports",
"to",
"this",
"storage",
"group",
"s",
"candidate",
"adapter",
"ports",
"list",
"."
] | python | train |
dj-stripe/dj-stripe | djstripe/models/billing.py | https://github.com/dj-stripe/dj-stripe/blob/a5308a3808cd6e2baba49482f7a699f3a8992518/djstripe/models/billing.py#L479-L503 | def plan(self):
""" Gets the associated plan for this invoice.
In order to provide a consistent view of invoices, the plan object
should be taken from the first invoice item that has one, rather than
using the plan associated with the subscription.
Subscriptions (and their associated plan) are updated by th... | [
"def",
"plan",
"(",
"self",
")",
":",
"for",
"invoiceitem",
"in",
"self",
".",
"invoiceitems",
".",
"all",
"(",
")",
":",
"if",
"invoiceitem",
".",
"plan",
":",
"return",
"invoiceitem",
".",
"plan",
"if",
"self",
".",
"subscription",
":",
"return",
"se... | Gets the associated plan for this invoice.
In order to provide a consistent view of invoices, the plan object
should be taken from the first invoice item that has one, rather than
using the plan associated with the subscription.
Subscriptions (and their associated plan) are updated by the customer
and repre... | [
"Gets",
"the",
"associated",
"plan",
"for",
"this",
"invoice",
"."
] | python | train |
kivy/python-for-android | pythonforandroid/recipes/ifaddrs/__init__.py | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipes/ifaddrs/__init__.py#L19-L24 | def prebuild_arch(self, arch):
"""Make the build and target directories"""
path = self.get_build_dir(arch.arch)
if not exists(path):
info("creating {}".format(path))
shprint(sh.mkdir, '-p', path) | [
"def",
"prebuild_arch",
"(",
"self",
",",
"arch",
")",
":",
"path",
"=",
"self",
".",
"get_build_dir",
"(",
"arch",
".",
"arch",
")",
"if",
"not",
"exists",
"(",
"path",
")",
":",
"info",
"(",
"\"creating {}\"",
".",
"format",
"(",
"path",
")",
")",
... | Make the build and target directories | [
"Make",
"the",
"build",
"and",
"target",
"directories"
] | python | train |
erdewit/ib_insync | ib_insync/decoder.py | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/decoder.py#L181-L190 | def interpret(self, fields):
"""
Decode fields and invoke corresponding wrapper method.
"""
try:
msgId = int(fields[0])
handler = self.handlers[msgId]
handler(fields)
except Exception:
self.logger.exception(f'Error handling fields: ... | [
"def",
"interpret",
"(",
"self",
",",
"fields",
")",
":",
"try",
":",
"msgId",
"=",
"int",
"(",
"fields",
"[",
"0",
"]",
")",
"handler",
"=",
"self",
".",
"handlers",
"[",
"msgId",
"]",
"handler",
"(",
"fields",
")",
"except",
"Exception",
":",
"se... | Decode fields and invoke corresponding wrapper method. | [
"Decode",
"fields",
"and",
"invoke",
"corresponding",
"wrapper",
"method",
"."
] | python | train |
saltstack/salt | salt/spm/pkgdb/sqlite3.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/spm/pkgdb/sqlite3.py#L180-L204 | def register_file(name, member, path, digest='', conn=None):
'''
Register a file in the package database
'''
close = False
if conn is None:
close = True
conn = init()
conn.execute('INSERT INTO files VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (
name,
'{0}/{1}'.... | [
"def",
"register_file",
"(",
"name",
",",
"member",
",",
"path",
",",
"digest",
"=",
"''",
",",
"conn",
"=",
"None",
")",
":",
"close",
"=",
"False",
"if",
"conn",
"is",
"None",
":",
"close",
"=",
"True",
"conn",
"=",
"init",
"(",
")",
"conn",
".... | Register a file in the package database | [
"Register",
"a",
"file",
"in",
"the",
"package",
"database"
] | python | train |
jobovy/galpy | galpy/orbit/integratePlanarOrbit.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/integratePlanarOrbit.py#L42-L308 | def _parse_pot(pot):
"""Parse the potential so it can be fed to C"""
from .integrateFullOrbit import _parse_scf_pot
#Figure out what's in pot
if not isinstance(pot,list):
pot= [pot]
#Initialize everything
pot_type= []
pot_args= []
npot= len(pot)
for p in pot:
# Prepar... | [
"def",
"_parse_pot",
"(",
"pot",
")",
":",
"from",
".",
"integrateFullOrbit",
"import",
"_parse_scf_pot",
"#Figure out what's in pot",
"if",
"not",
"isinstance",
"(",
"pot",
",",
"list",
")",
":",
"pot",
"=",
"[",
"pot",
"]",
"#Initialize everything",
"pot_type"... | Parse the potential so it can be fed to C | [
"Parse",
"the",
"potential",
"so",
"it",
"can",
"be",
"fed",
"to",
"C"
] | python | train |
cggh/scikit-allel | allel/model/ndarray.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3586-L3630 | def locate_range(self, start=None, stop=None):
"""Locate slice of index containing all entries within `start` and
`stop` values **inclusive**.
Parameters
----------
start : int, optional
Start value.
stop : int, optional
Stop value.
Retur... | [
"def",
"locate_range",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"# locate start and stop indices",
"if",
"start",
"is",
"None",
":",
"start_index",
"=",
"0",
"else",
":",
"start_index",
"=",
"bisect",
".",
"bisect_left",
... | Locate slice of index containing all entries within `start` and
`stop` values **inclusive**.
Parameters
----------
start : int, optional
Start value.
stop : int, optional
Stop value.
Returns
-------
loc : slice
Slice o... | [
"Locate",
"slice",
"of",
"index",
"containing",
"all",
"entries",
"within",
"start",
"and",
"stop",
"values",
"**",
"inclusive",
"**",
"."
] | python | train |
CellProfiler/centrosome | centrosome/cpmorphology.py | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3771-L3849 | def label_skeleton(skeleton):
'''Label a skeleton so that each edge has a unique label
This operation produces a labels matrix where each edge between
two branchpoints has a different label. If the skeleton has been
properly eroded, there are three kinds of points:
1) point adjacent to 0 or 1 o... | [
"def",
"label_skeleton",
"(",
"skeleton",
")",
":",
"bpts",
"=",
"branchpoints",
"(",
"skeleton",
")",
"#",
"# Count the # of neighbors per point",
"#",
"neighbors",
"=",
"scind",
".",
"convolve",
"(",
"skeleton",
".",
"astype",
"(",
"int",
")",
",",
"np",
"... | Label a skeleton so that each edge has a unique label
This operation produces a labels matrix where each edge between
two branchpoints has a different label. If the skeleton has been
properly eroded, there are three kinds of points:
1) point adjacent to 0 or 1 other points = end of edge
2) poin... | [
"Label",
"a",
"skeleton",
"so",
"that",
"each",
"edge",
"has",
"a",
"unique",
"label",
"This",
"operation",
"produces",
"a",
"labels",
"matrix",
"where",
"each",
"edge",
"between",
"two",
"branchpoints",
"has",
"a",
"different",
"label",
".",
"If",
"the",
... | python | train |
astropy/astropy-healpix | astropy_healpix/core.py | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/core.py#L236-L295 | def pixel_resolution_to_nside(resolution, round='nearest'):
"""Find closest HEALPix nside for a given angular resolution.
This function is the inverse of `nside_to_pixel_resolution`,
for the default rounding scheme of ``round='nearest'``.
If you choose ``round='up'``, you'll get HEALPix pixels that
... | [
"def",
"pixel_resolution_to_nside",
"(",
"resolution",
",",
"round",
"=",
"'nearest'",
")",
":",
"resolution",
"=",
"resolution",
".",
"to",
"(",
"u",
".",
"rad",
")",
".",
"value",
"pixel_area",
"=",
"resolution",
"*",
"resolution",
"npix",
"=",
"4",
"*",... | Find closest HEALPix nside for a given angular resolution.
This function is the inverse of `nside_to_pixel_resolution`,
for the default rounding scheme of ``round='nearest'``.
If you choose ``round='up'``, you'll get HEALPix pixels that
have at least the requested resolution (usually a bit better
... | [
"Find",
"closest",
"HEALPix",
"nside",
"for",
"a",
"given",
"angular",
"resolution",
"."
] | python | train |
svartalf/python-2gis | dgis/utils.py | https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/utils.py#L6-L30 | def force_text(s, encoding='utf-8', errors='strict'):
"""
Returns a bytestring version of 's', encoded as specified in 'encoding'.
If strings_only is True, don't convert (some) non-string-like objects.
Based on the `django.utils.encoding.smart_str' (https://github.com/django/django/blob/master/django/... | [
"def",
"force_text",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
"return",
"str",
"(",
"s",
")",
"except",
"UnicodeEn... | Returns a bytestring version of 's', encoded as specified in 'encoding'.
If strings_only is True, don't convert (some) non-string-like objects.
Based on the `django.utils.encoding.smart_str' (https://github.com/django/django/blob/master/django/utils/encoding.py) | [
"Returns",
"a",
"bytestring",
"version",
"of",
"s",
"encoded",
"as",
"specified",
"in",
"encoding",
"."
] | python | train |
Kozea/pygal | pygal/graph/horizontal.py | https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/horizontal.py#L33-L44 | def _post_compute(self):
"""After computations transpose labels"""
self._x_labels, self._y_labels = self._y_labels, self._x_labels
self._x_labels_major, self._y_labels_major = (
self._y_labels_major, self._x_labels_major
)
self._x_2nd_labels, self._y_2nd_labels = (
... | [
"def",
"_post_compute",
"(",
"self",
")",
":",
"self",
".",
"_x_labels",
",",
"self",
".",
"_y_labels",
"=",
"self",
".",
"_y_labels",
",",
"self",
".",
"_x_labels",
"self",
".",
"_x_labels_major",
",",
"self",
".",
"_y_labels_major",
"=",
"(",
"self",
"... | After computations transpose labels | [
"After",
"computations",
"transpose",
"labels"
] | python | train |
Shinichi-Nakagawa/pitchpx | pitchpx/game/players.py | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/players.py#L325-L333 | def isdigit(cls, value):
"""
ditit check for stats
:param value: stats value
:return: True or False
"""
if str(value).replace('.','').replace('-','').isdigit():
return True
return False | [
"def",
"isdigit",
"(",
"cls",
",",
"value",
")",
":",
"if",
"str",
"(",
"value",
")",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
".",
"isdigit",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | ditit check for stats
:param value: stats value
:return: True or False | [
"ditit",
"check",
"for",
"stats",
":",
"param",
"value",
":",
"stats",
"value",
":",
"return",
":",
"True",
"or",
"False"
] | python | train |
julienc91/utools | utools/math.py | https://github.com/julienc91/utools/blob/6b2f18a5cb30a9349ba25a20c720c737f0683099/utools/math.py#L202-L226 | def binomial_coefficient(n, k):
""" Calculate the binomial coefficient indexed by n and k.
Args:
n (int): positive integer
k (int): positive integer
Returns:
The binomial coefficient indexed by n and k
Raises:
TypeError: If either n or k is not an integer
Valu... | [
"def",
"binomial_coefficient",
"(",
"n",
",",
"k",
")",
":",
"if",
"not",
"isinstance",
"(",
"k",
",",
"int",
")",
"or",
"not",
"isinstance",
"(",
"n",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"\"Expecting positive integers\"",
")",
"if",
"k",
... | Calculate the binomial coefficient indexed by n and k.
Args:
n (int): positive integer
k (int): positive integer
Returns:
The binomial coefficient indexed by n and k
Raises:
TypeError: If either n or k is not an integer
ValueError: If either n or k is negative, or ... | [
"Calculate",
"the",
"binomial",
"coefficient",
"indexed",
"by",
"n",
"and",
"k",
"."
] | python | train |
mishan/twemredis-py | twemredis.py | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L351-L369 | def mget(self, args):
"""
mget wrapper that batches keys per shard and execute as few
mgets as necessary to fetch the keys from all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
... | [
"def",
"mget",
"(",
"self",
",",
"args",
")",
":",
"key_map",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"results",
"=",
"{",
"}",
"for",
"key",
"in",
"args",
":",
"shard_num",
"=",
"self",
".",
"get_shard_num_by_key",
"(",
"key",
")",
... | mget wrapper that batches keys per shard and execute as few
mgets as necessary to fetch the keys from all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance. | [
"mget",
"wrapper",
"that",
"batches",
"keys",
"per",
"shard",
"and",
"execute",
"as",
"few",
"mgets",
"as",
"necessary",
"to",
"fetch",
"the",
"keys",
"from",
"all",
"the",
"shards",
"involved",
"."
] | python | train |
dfm/celerite | celerite/celerite.py | https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L420-L459 | def get_matrix(self, x1=None, x2=None, include_diagonal=None,
include_general=None):
"""
Get the covariance matrix at given independent coordinates
Args:
x1 (Optional[array[n1]]): The first set of independent coordinates.
If this is omitted, ``x1``... | [
"def",
"get_matrix",
"(",
"self",
",",
"x1",
"=",
"None",
",",
"x2",
"=",
"None",
",",
"include_diagonal",
"=",
"None",
",",
"include_general",
"=",
"None",
")",
":",
"if",
"x1",
"is",
"None",
"and",
"x2",
"is",
"None",
":",
"if",
"self",
".",
"_t"... | Get the covariance matrix at given independent coordinates
Args:
x1 (Optional[array[n1]]): The first set of independent coordinates.
If this is omitted, ``x1`` will be assumed to be equal to ``x``
from a previous call to :func:`GP.compute`.
x2 (Optional[a... | [
"Get",
"the",
"covariance",
"matrix",
"at",
"given",
"independent",
"coordinates"
] | python | train |
saltstack/salt | salt/transport/ipc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L308-L328 | def connect(self, callback=None, timeout=None):
'''
Connect to the IPC socket
'''
if hasattr(self, '_connecting_future') and not self._connecting_future.done(): # pylint: disable=E0203
future = self._connecting_future # pylint: disable=E0203
else:
if has... | [
"def",
"connect",
"(",
"self",
",",
"callback",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_connecting_future'",
")",
"and",
"not",
"self",
".",
"_connecting_future",
".",
"done",
"(",
")",
":",
"# pylint: di... | Connect to the IPC socket | [
"Connect",
"to",
"the",
"IPC",
"socket"
] | python | train |
infobloxopen/infoblox-client | infoblox_client/objects.py | https://github.com/infobloxopen/infoblox-client/blob/edeec62db1935784c728731b2ae7cf0fcc9bf84d/infoblox_client/objects.py#L141-L147 | def from_dict(cls, eas_from_nios):
"""Converts extensible attributes from the NIOS reply."""
if not eas_from_nios:
return
return cls({name: cls._process_value(ib_utils.try_value_to_bool,
eas_from_nios[name]['value'])
fo... | [
"def",
"from_dict",
"(",
"cls",
",",
"eas_from_nios",
")",
":",
"if",
"not",
"eas_from_nios",
":",
"return",
"return",
"cls",
"(",
"{",
"name",
":",
"cls",
".",
"_process_value",
"(",
"ib_utils",
".",
"try_value_to_bool",
",",
"eas_from_nios",
"[",
"name",
... | Converts extensible attributes from the NIOS reply. | [
"Converts",
"extensible",
"attributes",
"from",
"the",
"NIOS",
"reply",
"."
] | python | train |
tanghaibao/jcvi | jcvi/apps/base.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/base.py#L832-L839 | def glob(pathname, pattern=None):
"""
Wraps around glob.glob(), but return a sorted list.
"""
import glob as gl
if pattern:
pathname = op.join(pathname, pattern)
return natsorted(gl.glob(pathname)) | [
"def",
"glob",
"(",
"pathname",
",",
"pattern",
"=",
"None",
")",
":",
"import",
"glob",
"as",
"gl",
"if",
"pattern",
":",
"pathname",
"=",
"op",
".",
"join",
"(",
"pathname",
",",
"pattern",
")",
"return",
"natsorted",
"(",
"gl",
".",
"glob",
"(",
... | Wraps around glob.glob(), but return a sorted list. | [
"Wraps",
"around",
"glob",
".",
"glob",
"()",
"but",
"return",
"a",
"sorted",
"list",
"."
] | python | train |
saltstack/salt | salt/states/logrotate.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/logrotate.py#L51-L131 | def set_(name, key, value, setting=None, conf_file=_DEFAULT_CONF):
'''
Set a new value for a specific configuration line.
:param str key: The command or block to configure.
:param str value: The command value or command of the block specified by the key parameter.
:param str setting: The command va... | [
"def",
"set_",
"(",
"name",
",",
"key",
",",
"value",
",",
"setting",
"=",
"None",
",",
"conf_file",
"=",
"_DEFAULT_CONF",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"dict",
"(",
")",
",",
"'comment'",
":",
"six",
".",... | Set a new value for a specific configuration line.
:param str key: The command or block to configure.
:param str value: The command value or command of the block specified by the key parameter.
:param str setting: The command value for the command specified by the value parameter.
:param str conf_file:... | [
"Set",
"a",
"new",
"value",
"for",
"a",
"specific",
"configuration",
"line",
"."
] | python | train |
AdvancedClimateSystems/uModbus | umodbus/functions.py | https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/functions.py#L1074-L1088 | def create_from_response_pdu(resp_pdu):
""" Create instance from response PDU.
:param resp_pdu: Byte array with request PDU.
:return: Instance of :class:`WriteSingleCoil`.
"""
write_single_coil = WriteSingleCoil()
address, value = struct.unpack('>HH', resp_pdu[1:5])
... | [
"def",
"create_from_response_pdu",
"(",
"resp_pdu",
")",
":",
"write_single_coil",
"=",
"WriteSingleCoil",
"(",
")",
"address",
",",
"value",
"=",
"struct",
".",
"unpack",
"(",
"'>HH'",
",",
"resp_pdu",
"[",
"1",
":",
"5",
"]",
")",
"value",
"=",
"1",
"i... | Create instance from response PDU.
:param resp_pdu: Byte array with request PDU.
:return: Instance of :class:`WriteSingleCoil`. | [
"Create",
"instance",
"from",
"response",
"PDU",
"."
] | python | train |
vladsaveliev/TargQC | targqc/utilz/jsontemplate/_jsontemplate.py | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L400-L417 | def _GetPredicate(self, pred_str, test_attr=False):
"""
The user's predicates are consulted first, then the default predicates.
"""
predicate, args, func_type = self.predicates.LookupWithType(pred_str)
if predicate:
pred = predicate, args, func_type
else:
... | [
"def",
"_GetPredicate",
"(",
"self",
",",
"pred_str",
",",
"test_attr",
"=",
"False",
")",
":",
"predicate",
",",
"args",
",",
"func_type",
"=",
"self",
".",
"predicates",
".",
"LookupWithType",
"(",
"pred_str",
")",
"if",
"predicate",
":",
"pred",
"=",
... | The user's predicates are consulted first, then the default predicates. | [
"The",
"user",
"s",
"predicates",
"are",
"consulted",
"first",
"then",
"the",
"default",
"predicates",
"."
] | python | train |
angr/angr | angr/analyses/analysis.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/analysis.py#L190-L203 | def _finish_progress(self):
"""
Mark the progressbar as finished.
:return: None
"""
if self._show_progressbar:
if self._progressbar is None:
self._initialize_progressbar()
if self._progressbar is not None:
self._progressbar... | [
"def",
"_finish_progress",
"(",
"self",
")",
":",
"if",
"self",
".",
"_show_progressbar",
":",
"if",
"self",
".",
"_progressbar",
"is",
"None",
":",
"self",
".",
"_initialize_progressbar",
"(",
")",
"if",
"self",
".",
"_progressbar",
"is",
"not",
"None",
"... | Mark the progressbar as finished.
:return: None | [
"Mark",
"the",
"progressbar",
"as",
"finished",
".",
":",
"return",
":",
"None"
] | python | train |
gwastro/pycbc | pycbc/inference/io/__init__.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/io/__init__.py#L258-L293 | def get_common_parameters(input_files, collection=None):
"""Gets a list of variable params that are common across all input files.
If no common parameters are found, a ``ValueError`` is raised.
Parameters
----------
input_files : list of str
List of input files to load.
collection : st... | [
"def",
"get_common_parameters",
"(",
"input_files",
",",
"collection",
"=",
"None",
")",
":",
"if",
"collection",
"is",
"None",
":",
"collection",
"=",
"\"all\"",
"parameters",
"=",
"[",
"]",
"for",
"fn",
"in",
"input_files",
":",
"fp",
"=",
"loadfile",
"(... | Gets a list of variable params that are common across all input files.
If no common parameters are found, a ``ValueError`` is raised.
Parameters
----------
input_files : list of str
List of input files to load.
collection : str, optional
What group of parameters to load. Can be the... | [
"Gets",
"a",
"list",
"of",
"variable",
"params",
"that",
"are",
"common",
"across",
"all",
"input",
"files",
"."
] | python | train |
senaite/senaite.core | bika/lims/validators.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/validators.py#L99-L104 | def get_parent_objects(self, context):
"""Return all objects of the same type from the parent object
"""
parent_object = api.get_parent(context)
portal_type = api.get_portal_type(context)
return parent_object.objectValues(portal_type) | [
"def",
"get_parent_objects",
"(",
"self",
",",
"context",
")",
":",
"parent_object",
"=",
"api",
".",
"get_parent",
"(",
"context",
")",
"portal_type",
"=",
"api",
".",
"get_portal_type",
"(",
"context",
")",
"return",
"parent_object",
".",
"objectValues",
"("... | Return all objects of the same type from the parent object | [
"Return",
"all",
"objects",
"of",
"the",
"same",
"type",
"from",
"the",
"parent",
"object"
] | python | train |
bjoernricks/python-quilt | quilt/add.py | https://github.com/bjoernricks/python-quilt/blob/fae88237f601848cc34d073584d9dcb409f01777/quilt/add.py#L62-L70 | def _backup_file(self, file, patch):
""" Creates a backup of file """
dest_dir = self.quilt_pc + patch.get_name()
file_dir = file.get_directory()
if file_dir:
#TODO get relative path
dest_dir = dest_dir + file_dir
backup = Backup()
backup.backup_fi... | [
"def",
"_backup_file",
"(",
"self",
",",
"file",
",",
"patch",
")",
":",
"dest_dir",
"=",
"self",
".",
"quilt_pc",
"+",
"patch",
".",
"get_name",
"(",
")",
"file_dir",
"=",
"file",
".",
"get_directory",
"(",
")",
"if",
"file_dir",
":",
"#TODO get relativ... | Creates a backup of file | [
"Creates",
"a",
"backup",
"of",
"file"
] | python | test |
LudovicRousseau/PyKCS11 | PyKCS11/__init__.py | https://github.com/LudovicRousseau/PyKCS11/blob/76ccd8741af2ea193aaf1ca29dfedfa412c134fe/PyKCS11/__init__.py#L952-L963 | def createObject(self, template):
"""
C_CreateObject
:param template: object template
"""
attrs = self._template2ckattrlist(template)
handle = PyKCS11.LowLevel.CK_OBJECT_HANDLE()
rv = self.lib.C_CreateObject(self.session, attrs, handle)
if rv != PyKCS11.C... | [
"def",
"createObject",
"(",
"self",
",",
"template",
")",
":",
"attrs",
"=",
"self",
".",
"_template2ckattrlist",
"(",
"template",
")",
"handle",
"=",
"PyKCS11",
".",
"LowLevel",
".",
"CK_OBJECT_HANDLE",
"(",
")",
"rv",
"=",
"self",
".",
"lib",
".",
"C_C... | C_CreateObject
:param template: object template | [
"C_CreateObject"
] | python | test |
jbloomlab/phydms | phydmslib/treelikelihood.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/treelikelihood.py#L764-L769 | def _dstationarystate(self, k, param):
"""Returns the dstationarystate ."""
if self._distributionmodel:
return self.model.dstationarystate(k, param)
else:
return self.model.dstationarystate(param) | [
"def",
"_dstationarystate",
"(",
"self",
",",
"k",
",",
"param",
")",
":",
"if",
"self",
".",
"_distributionmodel",
":",
"return",
"self",
".",
"model",
".",
"dstationarystate",
"(",
"k",
",",
"param",
")",
"else",
":",
"return",
"self",
".",
"model",
... | Returns the dstationarystate . | [
"Returns",
"the",
"dstationarystate",
"."
] | python | train |
vingd/vingd-api-python | vingd/client.py | https://github.com/vingd/vingd-api-python/blob/7548a49973a472f7277c8ef847563faa7b6f3706/vingd/client.py#L543-L562 | def authorized_purchase_object(self, oid, price, huid):
"""Does delegated (pre-authorized) purchase of `oid` in the name of
`huid`, at price `price` (vingd transferred from `huid` to consumer's
acc).
:raises GeneralException:
:resource: ``objects/<oid>/purchases``
... | [
"def",
"authorized_purchase_object",
"(",
"self",
",",
"oid",
",",
"price",
",",
"huid",
")",
":",
"return",
"self",
".",
"request",
"(",
"'post'",
",",
"safeformat",
"(",
"'objects/{:int}/purchases'",
",",
"oid",
")",
",",
"json",
".",
"dumps",
"(",
"{",
... | Does delegated (pre-authorized) purchase of `oid` in the name of
`huid`, at price `price` (vingd transferred from `huid` to consumer's
acc).
:raises GeneralException:
:resource: ``objects/<oid>/purchases``
:access: authorized users with ACL flag ``purchase.objec... | [
"Does",
"delegated",
"(",
"pre",
"-",
"authorized",
")",
"purchase",
"of",
"oid",
"in",
"the",
"name",
"of",
"huid",
"at",
"price",
"price",
"(",
"vingd",
"transferred",
"from",
"huid",
"to",
"consumer",
"s",
"acc",
")",
".",
":",
"raises",
"GeneralExcep... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.