repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
pszafer/epson_projector | epson_projector/main.py | https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L75-L87 | def __checkLock(self):
"""
Lock checking.
Check if there is lock pending and check if enough time
passed so requests can be unlocked.
"""
if self._isLocked:
if (time.time() - self._timer) > TIMEOUT_TIMES[self._operation]:
self.__unLock()
... | [
"def",
"__checkLock",
"(",
"self",
")",
":",
"if",
"self",
".",
"_isLocked",
":",
"if",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_timer",
")",
">",
"TIMEOUT_TIMES",
"[",
"self",
".",
"_operation",
"]",
":",
"self",
".",
"__unLock",
"(... | Lock checking.
Check if there is lock pending and check if enough time
passed so requests can be unlocked. | [
"Lock",
"checking",
"."
] | python | train | 28.923077 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/ratelimits.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/ratelimits.py#L100-L117 | def rate_limit(client, headers, atexit=False):
"""Pause the process based on suggested rate interval."""
if not client or not headers:
return False
if not getattr(client.config, "rate_limit", False):
return False
rate_info = RateLimitsInfo.from_headers(headers)
if not rate_info or ... | [
"def",
"rate_limit",
"(",
"client",
",",
"headers",
",",
"atexit",
"=",
"False",
")",
":",
"if",
"not",
"client",
"or",
"not",
"headers",
":",
"return",
"False",
"if",
"not",
"getattr",
"(",
"client",
".",
"config",
",",
"\"rate_limit\"",
",",
"False",
... | Pause the process based on suggested rate interval. | [
"Pause",
"the",
"process",
"based",
"on",
"suggested",
"rate",
"interval",
"."
] | python | train | 31.555556 |
Josef-Friedrich/tmep | tmep/template.py | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L244-L254 | def evaluate(self, env):
"""Evaluate the entire expression in the environment, returning
a Unicode string.
"""
out = []
for part in self.parts:
if isinstance(part, str):
out.append(part)
else:
out.append(part.evaluate(env))
... | [
"def",
"evaluate",
"(",
"self",
",",
"env",
")",
":",
"out",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"if",
"isinstance",
"(",
"part",
",",
"str",
")",
":",
"out",
".",
"append",
"(",
"part",
")",
"else",
":",
"out",
".",
... | Evaluate the entire expression in the environment, returning
a Unicode string. | [
"Evaluate",
"the",
"entire",
"expression",
"in",
"the",
"environment",
"returning",
"a",
"Unicode",
"string",
"."
] | python | train | 31.636364 |
spdx/tools-python | spdx/parsers/rdf.py | https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/rdf.py#L911-L954 | def parse_doc_fields(self, doc_term):
"""Parses the version, data license, name, SPDX Identifier, namespace,
and comment."""
try:
self.builder.set_doc_spdx_id(self.doc, doc_term)
except SPDXValueError:
self.value_error('DOC_SPDX_ID_VALUE', doc_term)
try:
... | [
"def",
"parse_doc_fields",
"(",
"self",
",",
"doc_term",
")",
":",
"try",
":",
"self",
".",
"builder",
".",
"set_doc_spdx_id",
"(",
"self",
".",
"doc",
",",
"doc_term",
")",
"except",
"SPDXValueError",
":",
"self",
".",
"value_error",
"(",
"'DOC_SPDX_ID_VALU... | Parses the version, data license, name, SPDX Identifier, namespace,
and comment. | [
"Parses",
"the",
"version",
"data",
"license",
"name",
"SPDX",
"Identifier",
"namespace",
"and",
"comment",
"."
] | python | valid | 45.727273 |
scanny/python-pptx | pptx/chart/data.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/data.py#L419-L431 | def depth(self):
"""
The number of hierarchy levels in this category graph. Returns 0 if
it contains no categories.
"""
categories = self._categories
if not categories:
return 0
first_depth = categories[0].depth
for category in categories[1:]:
... | [
"def",
"depth",
"(",
"self",
")",
":",
"categories",
"=",
"self",
".",
"_categories",
"if",
"not",
"categories",
":",
"return",
"0",
"first_depth",
"=",
"categories",
"[",
"0",
"]",
".",
"depth",
"for",
"category",
"in",
"categories",
"[",
"1",
":",
"]... | The number of hierarchy levels in this category graph. Returns 0 if
it contains no categories. | [
"The",
"number",
"of",
"hierarchy",
"levels",
"in",
"this",
"category",
"graph",
".",
"Returns",
"0",
"if",
"it",
"contains",
"no",
"categories",
"."
] | python | train | 34.076923 |
twilio/twilio-python | twilio/rest/video/v1/composition_hook.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/video/v1/composition_hook.py#L416-L426 | def _proxy(self):
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CompositionHookContext for this CompositionHookInstance
:rtype: twilio.rest.video.v1.composition_... | [
"def",
"_proxy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_context",
"is",
"None",
":",
"self",
".",
"_context",
"=",
"CompositionHookContext",
"(",
"self",
".",
"_version",
",",
"sid",
"=",
"self",
".",
"_solution",
"[",
"'sid'",
"]",
",",
")",
"r... | Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CompositionHookContext for this CompositionHookInstance
:rtype: twilio.rest.video.v1.composition_hook.CompositionHookContext | [
"Generate",
"an",
"instance",
"context",
"for",
"the",
"instance",
"the",
"context",
"is",
"capable",
"of",
"performing",
"various",
"actions",
".",
"All",
"instance",
"actions",
"are",
"proxied",
"to",
"the",
"context"
] | python | train | 46.090909 |
ojarva/python-sshpubkeys | sshpubkeys/keys.py | https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L251-L295 | def parse_options(self, options):
"""Parses ssh options string."""
quote_open = False
parsed_options = {}
def parse_add_single_option(opt):
"""Parses and validates a single option, and adds it to parsed_options field."""
if "=" in opt:
opt_name, o... | [
"def",
"parse_options",
"(",
"self",
",",
"options",
")",
":",
"quote_open",
"=",
"False",
"parsed_options",
"=",
"{",
"}",
"def",
"parse_add_single_option",
"(",
"opt",
")",
":",
"\"\"\"Parses and validates a single option, and adds it to parsed_options field.\"\"\"",
"i... | Parses ssh options string. | [
"Parses",
"ssh",
"options",
"string",
"."
] | python | test | 45.666667 |
senaite/senaite.core | bika/lims/content/reflexrule.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/reflexrule.py#L252-L283 | def getActionReflexRules(self, analysis, wf_action):
"""
This function returns a list of dictionaries with the rules to be done
for the analysis service.
:analysis: the analysis full object which we want to obtain the
rules for.
:wf_action: it is the workflow action t... | [
"def",
"getActionReflexRules",
"(",
"self",
",",
"analysis",
",",
"wf_action",
")",
":",
"# Setting up the analyses catalog",
"self",
".",
"analyses_catalog",
"=",
"getToolByName",
"(",
"self",
",",
"CATALOG_ANALYSIS_LISTING",
")",
"# Getting the action sets, those that con... | This function returns a list of dictionaries with the rules to be done
for the analysis service.
:analysis: the analysis full object which we want to obtain the
rules for.
:wf_action: it is the workflow action that the analysis is doing, we
have to act in consideration of... | [
"This",
"function",
"returns",
"a",
"list",
"of",
"dictionaries",
"with",
"the",
"rules",
"to",
"be",
"done",
"for",
"the",
"analysis",
"service",
".",
":",
"analysis",
":",
"the",
"analysis",
"full",
"object",
"which",
"we",
"want",
"to",
"obtain",
"the",... | python | train | 50.40625 |
jason-weirather/py-seq-tools | seqtools/graph/__init__.py | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/graph/__init__.py#L53-L55 | def roots(self):
"""get the nodes with no children"""
return [x for x in self._nodes.values() if x.id not in self._c2p] | [
"def",
"roots",
"(",
"self",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"_nodes",
".",
"values",
"(",
")",
"if",
"x",
".",
"id",
"not",
"in",
"self",
".",
"_c2p",
"]"
] | get the nodes with no children | [
"get",
"the",
"nodes",
"with",
"no",
"children"
] | python | train | 43 |
Hackerfleet/hfos | modules/maps/hfos/map/TileTools.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L92-L105 | def tileXYZToQuadKey(self, x, y, z):
'''
Computes quadKey value based on tile x, y and z values.
'''
quadKey = ''
for i in range(z, 0, -1):
digit = 0
mask = 1 << (i - 1)
if (x & mask) != 0:
digit += 1
if (y & mask) !... | [
"def",
"tileXYZToQuadKey",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"quadKey",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"z",
",",
"0",
",",
"-",
"1",
")",
":",
"digit",
"=",
"0",
"mask",
"=",
"1",
"<<",
"(",
"i",
"-",
"1",
"... | Computes quadKey value based on tile x, y and z values. | [
"Computes",
"quadKey",
"value",
"based",
"on",
"tile",
"x",
"y",
"and",
"z",
"values",
"."
] | python | train | 28.214286 |
PyPSA/PyPSA | pypsa/graph.py | https://github.com/PyPSA/PyPSA/blob/46954b1b3c21460550f7104681517065279a53b7/pypsa/graph.py#L157-L208 | def incidence_matrix(network, branch_components=None, busorder=None):
"""
Construct a sparse incidence matrix (directed)
Parameters
----------
branch_components : iterable sublist of `branch_components`
Buses connected by any of the selected branches are adjacent
(default: branch_comp... | [
"def",
"incidence_matrix",
"(",
"network",
",",
"branch_components",
"=",
"None",
",",
"busorder",
"=",
"None",
")",
":",
"from",
".",
"import",
"components",
"if",
"isinstance",
"(",
"network",
",",
"components",
".",
"Network",
")",
":",
"if",
"branch_comp... | Construct a sparse incidence matrix (directed)
Parameters
----------
branch_components : iterable sublist of `branch_components`
Buses connected by any of the selected branches are adjacent
(default: branch_components (network) or passive_branch_components (sub_network))
busorder : pd.Ind... | [
"Construct",
"a",
"sparse",
"incidence",
"matrix",
"(",
"directed",
")"
] | python | train | 38.134615 |
darothen/xbpch | xbpch/grid.py | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L217-L324 | def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs):
"""
Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a... | [
"def",
"get_layers",
"(",
"self",
",",
"Psurf",
"=",
"1013.25",
",",
"Ptop",
"=",
"0.01",
",",
"*",
"*",
"kwargs",
")",
":",
"Psurf",
"=",
"np",
".",
"asarray",
"(",
"Psurf",
")",
"output_ndims",
"=",
"Psurf",
".",
"ndim",
"+",
"1",
"if",
"output_n... | Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a given model coordinate system.
Returns
-------
dicti... | [
"Compute",
"scalars",
"or",
"coordinates",
"associated",
"to",
"the",
"vertical",
"layers",
"."
] | python | train | 34.916667 |
iotile/coretools | iotilesensorgraph/iotile/sg/sensor_log.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L382-L419 | def inspect_last(self, stream, only_allocated=False):
"""Return the last value pushed into a stream.
This function works even if the stream is virtual and no
virtual walker has been created for it. It is primarily
useful to aid in debugging sensor graphs.
Args:
str... | [
"def",
"inspect_last",
"(",
"self",
",",
"stream",
",",
"only_allocated",
"=",
"False",
")",
":",
"if",
"only_allocated",
":",
"found",
"=",
"False",
"for",
"walker",
"in",
"self",
".",
"_virtual_walkers",
":",
"if",
"walker",
".",
"matches",
"(",
"stream"... | Return the last value pushed into a stream.
This function works even if the stream is virtual and no
virtual walker has been created for it. It is primarily
useful to aid in debugging sensor graphs.
Args:
stream (DataStream): The stream to inspect.
only_allocat... | [
"Return",
"the",
"last",
"value",
"pushed",
"into",
"a",
"stream",
"."
] | python | train | 40.052632 |
graphql-python/graphql-core-next | graphql/subscription/subscribe.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/subscription/subscribe.py#L91-L178 | async def create_source_event_stream(
schema: GraphQLSchema,
document: DocumentNode,
root_value: Any = None,
context_value: Any = None,
variable_values: Dict[str, Any] = None,
operation_name: str = None,
field_resolver: GraphQLFieldResolver = None,
) -> Union[AsyncIterable[Any], ExecutionRes... | [
"async",
"def",
"create_source_event_stream",
"(",
"schema",
":",
"GraphQLSchema",
",",
"document",
":",
"DocumentNode",
",",
"root_value",
":",
"Any",
"=",
"None",
",",
"context_value",
":",
"Any",
"=",
"None",
",",
"variable_values",
":",
"Dict",
"[",
"str",... | Create source even stream
Implements the "CreateSourceEventStream" algorithm described in the GraphQL
specification, resolving the subscription source event stream.
Returns a coroutine that yields an AsyncIterable.
If the client provided invalid arguments, the source stream could not be created,
... | [
"Create",
"source",
"even",
"stream"
] | python | train | 40.545455 |
inasafe/inasafe | safe/utilities/rounding.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/rounding.py#L17-L45 | def format_number(
x, use_rounding=True, is_population=False, coefficient=1):
"""Format a number according to the standards.
:param x: A number to be formatted in a locale friendly way.
:type x: int
:param use_rounding: Flag to enable a rounding.
:type use_rounding: bool
:param is_pop... | [
"def",
"format_number",
"(",
"x",
",",
"use_rounding",
"=",
"True",
",",
"is_population",
"=",
"False",
",",
"coefficient",
"=",
"1",
")",
":",
"if",
"use_rounding",
":",
"x",
"=",
"rounding",
"(",
"x",
",",
"is_population",
")",
"x",
"//=",
"coefficient... | Format a number according to the standards.
:param x: A number to be formatted in a locale friendly way.
:type x: int
:param use_rounding: Flag to enable a rounding.
:type use_rounding: bool
:param is_population: Flag if the number is population. It needs to be
used with enable_rounding.
... | [
"Format",
"a",
"number",
"according",
"to",
"the",
"standards",
"."
] | python | train | 28.931034 |
UCBerkeleySETI/blimpy | blimpy/filterbank.py | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/filterbank.py#L237-L326 | def read_filterbank(self, filename=None, f_start=None, f_stop=None,
t_start=None, t_stop=None, load_data=True):
""" Populate Filterbank instance with data from Filterbank file
Note:
This is to be deprecated in future, please use Waterfall() to open files.
"""... | [
"def",
"read_filterbank",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"f_start",
"=",
"None",
",",
"f_stop",
"=",
"None",
",",
"t_start",
"=",
"None",
",",
"t_stop",
"=",
"None",
",",
"load_data",
"=",
"True",
")",
":",
"if",
"filename",
"is",
"N... | Populate Filterbank instance with data from Filterbank file
Note:
This is to be deprecated in future, please use Waterfall() to open files. | [
"Populate",
"Filterbank",
"instance",
"with",
"data",
"from",
"Filterbank",
"file"
] | python | test | 37.622222 |
bwohlberg/sporco | sporco/admm/cbpdntv.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/cbpdntv.py#L455-L464 | def cnst_A0(self, X, Xf=None):
r"""Compute :math:`A_0 \mathbf{x}` component of ADMM problem
constraint. In this case :math:`A_0 \mathbf{x} = (\Gamma_0^T \;\;
\Gamma_1^T \;\; \ldots )^T \mathbf{x}`.
"""
if Xf is None:
Xf = sl.rfftn(X, axes=self.cri.axisN)
retu... | [
"def",
"cnst_A0",
"(",
"self",
",",
"X",
",",
"Xf",
"=",
"None",
")",
":",
"if",
"Xf",
"is",
"None",
":",
"Xf",
"=",
"sl",
".",
"rfftn",
"(",
"X",
",",
"axes",
"=",
"self",
".",
"cri",
".",
"axisN",
")",
"return",
"self",
".",
"Wtv",
"[",
"... | r"""Compute :math:`A_0 \mathbf{x}` component of ADMM problem
constraint. In this case :math:`A_0 \mathbf{x} = (\Gamma_0^T \;\;
\Gamma_1^T \;\; \ldots )^T \mathbf{x}`. | [
"r",
"Compute",
":",
"math",
":",
"A_0",
"\\",
"mathbf",
"{",
"x",
"}",
"component",
"of",
"ADMM",
"problem",
"constraint",
".",
"In",
"this",
"case",
":",
"math",
":",
"A_0",
"\\",
"mathbf",
"{",
"x",
"}",
"=",
"(",
"\\",
"Gamma_0^T",
"\\",
";",
... | python | train | 42.9 |
aio-libs/aioftp | aioftp/client.py | https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/aioftp/client.py#L982-L1021 | async def download(self, source, destination="", *, write_into=False,
block_size=DEFAULT_BLOCK_SIZE):
"""
:py:func:`asyncio.coroutine`
High level download method for downloading files and directories
recursively and save them to the file system.
:param so... | [
"async",
"def",
"download",
"(",
"self",
",",
"source",
",",
"destination",
"=",
"\"\"",
",",
"*",
",",
"write_into",
"=",
"False",
",",
"block_size",
"=",
"DEFAULT_BLOCK_SIZE",
")",
":",
"source",
"=",
"pathlib",
".",
"PurePosixPath",
"(",
"source",
")",
... | :py:func:`asyncio.coroutine`
High level download method for downloading files and directories
recursively and save them to the file system.
:param source: source path of file or directory on server side
:type source: :py:class:`str` or :py:class:`pathlib.PurePosixPath`
:param ... | [
":",
"py",
":",
"func",
":",
"asyncio",
".",
"coroutine"
] | python | valid | 47.1 |
UCSBarchlab/PyRTL | pyrtl/analysis/estimate.py | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L329-L389 | def yosys_area_delay(library, abc_cmd=None, block=None):
""" Synthesize with Yosys and return estimate of area and delay.
:param library: stdcell library file to target in liberty format
:param abc_cmd: string of commands for yosys to pass to abc for synthesis
:param block: pyrtl block to analyze
:... | [
"def",
"yosys_area_delay",
"(",
"library",
",",
"abc_cmd",
"=",
"None",
",",
"block",
"=",
"None",
")",
":",
"if",
"abc_cmd",
"is",
"None",
":",
"abc_cmd",
"=",
"'strash;scorr;ifraig;retime;dch,-f;map;print_stats;'",
"else",
":",
"# first, replace whitespace with comm... | Synthesize with Yosys and return estimate of area and delay.
:param library: stdcell library file to target in liberty format
:param abc_cmd: string of commands for yosys to pass to abc for synthesis
:param block: pyrtl block to analyze
:return: a tuple of numbers: area, delay
The area and delay a... | [
"Synthesize",
"with",
"Yosys",
"and",
"return",
"estimate",
"of",
"area",
"and",
"delay",
"."
] | python | train | 43.852459 |
djangobot/djangobot | djangobot/cli.py | https://github.com/djangobot/djangobot/blob/0ec951891812ea4114c27a08c790f63d0f0fd254/djangobot/cli.py#L38-L57 | def run(self, args):
"""
Pass in raw arguments, instantiate Slack API and begin client.
"""
args = self.parser.parse_args(args)
if not args.token:
raise ValueError('Supply the slack token through --token or setting DJANGOBOT_TOKEN')
# Import the channel layer... | [
"def",
"run",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
"args",
")",
"if",
"not",
"args",
".",
"token",
":",
"raise",
"ValueError",
"(",
"'Supply the slack token through --token or setting DJANGOBOT_TOKEN'",
... | Pass in raw arguments, instantiate Slack API and begin client. | [
"Pass",
"in",
"raw",
"arguments",
"instantiate",
"Slack",
"API",
"and",
"begin",
"client",
"."
] | python | test | 34.8 |
pywbem/pywbem | pywbem/cim_types.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_types.py#L508-L524 | def minutes_from_utc(self):
"""
The timezone offset of this point in time object as +/- minutes from
UTC.
A positive value of the timezone offset indicates minutes east of UTC,
and a negative value indicates minutes west of UTC.
0, if this object represents a time inter... | [
"def",
"minutes_from_utc",
"(",
"self",
")",
":",
"offset",
"=",
"0",
"if",
"self",
".",
"__datetime",
"is",
"not",
"None",
"and",
"self",
".",
"__datetime",
".",
"utcoffset",
"(",
")",
"is",
"not",
"None",
":",
"offset",
"=",
"self",
".",
"__datetime"... | The timezone offset of this point in time object as +/- minutes from
UTC.
A positive value of the timezone offset indicates minutes east of UTC,
and a negative value indicates minutes west of UTC.
0, if this object represents a time interval. | [
"The",
"timezone",
"offset",
"of",
"this",
"point",
"in",
"time",
"object",
"as",
"+",
"/",
"-",
"minutes",
"from",
"UTC",
"."
] | python | train | 37.176471 |
saghul/evergreen | evergreen/locks.py | https://github.com/saghul/evergreen/blob/22f22f45892f397c23c3e09e6ea1ad4c00b3add8/evergreen/locks.py#L324-L342 | def reset(self):
"""Reset the barrier to the initial state.
Any threads currently waiting will get the BrokenBarrier exception
raised.
"""
with self._cond:
if self._count > 0:
if self._state == 0:
#reset the barrier, waking up thr... | [
"def",
"reset",
"(",
"self",
")",
":",
"with",
"self",
".",
"_cond",
":",
"if",
"self",
".",
"_count",
">",
"0",
":",
"if",
"self",
".",
"_state",
"==",
"0",
":",
"#reset the barrier, waking up threads",
"self",
".",
"_state",
"=",
"-",
"1",
"elif",
... | Reset the barrier to the initial state.
Any threads currently waiting will get the BrokenBarrier exception
raised. | [
"Reset",
"the",
"barrier",
"to",
"the",
"initial",
"state",
"."
] | python | train | 32.736842 |
genialis/resolwe | resolwe/flow/managers/dispatcher.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/dispatcher.py#L388-L411 | def _get_per_data_dir(self, dir_base, subpath):
"""Extend the given base directory with a per-data component.
The method creates a private path for the
:class:`~resolwe.flow.models.Data` object, such as::
./test_data/1/
if ``base_dir`` is ``'./test_data'`` and ``subpath`` ... | [
"def",
"_get_per_data_dir",
"(",
"self",
",",
"dir_base",
",",
"subpath",
")",
":",
"# Use Django settings here, because the state must be preserved",
"# across events. This also implies the directory settings can't",
"# be patched outside the manager and then just sent along in the",
"# c... | Extend the given base directory with a per-data component.
The method creates a private path for the
:class:`~resolwe.flow.models.Data` object, such as::
./test_data/1/
if ``base_dir`` is ``'./test_data'`` and ``subpath`` is ``1``.
:param dir_base: The base path to be ext... | [
"Extend",
"the",
"given",
"base",
"directory",
"with",
"a",
"per",
"-",
"data",
"component",
"."
] | python | train | 43.166667 |
tanghaibao/jcvi | jcvi/apps/uclust.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/uclust.py#L816-L834 | def filter_samples(names, seqs, sep='.'):
"""
When there are uncollapsed contigs within the same sample, only retain the
first seq, or the seq that is most abundant (with cluster_size).
"""
seen = set()
filtered_names, filtered_seqs = [], []
for name, seq in zip(names, seqs):
samp = ... | [
"def",
"filter_samples",
"(",
"names",
",",
"seqs",
",",
"sep",
"=",
"'.'",
")",
":",
"seen",
"=",
"set",
"(",
")",
"filtered_names",
",",
"filtered_seqs",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"name",
",",
"seq",
"in",
"zip",
"(",
"names",
",",
"... | When there are uncollapsed contigs within the same sample, only retain the
first seq, or the seq that is most abundant (with cluster_size). | [
"When",
"there",
"are",
"uncollapsed",
"contigs",
"within",
"the",
"same",
"sample",
"only",
"retain",
"the",
"first",
"seq",
"or",
"the",
"seq",
"that",
"is",
"most",
"abundant",
"(",
"with",
"cluster_size",
")",
"."
] | python | train | 31.631579 |
odlgroup/odl | odl/operator/pspace_ops.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/pspace_ops.py#L685-L693 | def _call(self, x, out=None):
"""Extend ``x`` from the subspace."""
if out is None:
out = self.range.zero()
else:
out.set_zero()
out[self.index] = x
return out | [
"def",
"_call",
"(",
"self",
",",
"x",
",",
"out",
"=",
"None",
")",
":",
"if",
"out",
"is",
"None",
":",
"out",
"=",
"self",
".",
"range",
".",
"zero",
"(",
")",
"else",
":",
"out",
".",
"set_zero",
"(",
")",
"out",
"[",
"self",
".",
"index"... | Extend ``x`` from the subspace. | [
"Extend",
"x",
"from",
"the",
"subspace",
"."
] | python | train | 24 |
inasafe/inasafe | safe/gui/widgets/message.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L40-L80 | def missing_keyword_message(sender, missing_keyword_exception):
"""Display an error when there is missing keyword.
:param sender: The sender.
:type sender: object
:param missing_keyword_exception: A KeywordNotFoundError exception.
:type missing_keyword_exception: KeywordNotFoundError
"""
w... | [
"def",
"missing_keyword_message",
"(",
"sender",
",",
"missing_keyword_exception",
")",
":",
"warning_heading",
"=",
"m",
".",
"Heading",
"(",
"tr",
"(",
"'Missing Keyword'",
")",
",",
"*",
"*",
"WARNING_STYLE",
")",
"warning_message",
"=",
"tr",
"(",
"'There is... | Display an error when there is missing keyword.
:param sender: The sender.
:type sender: object
:param missing_keyword_exception: A KeywordNotFoundError exception.
:type missing_keyword_exception: KeywordNotFoundError | [
"Display",
"an",
"error",
"when",
"there",
"is",
"missing",
"keyword",
"."
] | python | train | 33.95122 |
TheHive-Project/Cortex-Analyzers | analyzers/CIRCLPassiveDNS/circl_passivedns.py | https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/CIRCLPassiveDNS/circl_passivedns.py#L13-L37 | def query(self, domain):
"""The actual query happens here. Time from queries is replaced with isoformat.
:param domain: The domain which should gets queried.
:type domain: str
:returns: List of dicts containing the search results.
:rtype: [list, dict]
"""
result ... | [
"def",
"query",
"(",
"self",
",",
"domain",
")",
":",
"result",
"=",
"{",
"}",
"try",
":",
"result",
"=",
"self",
".",
"pdns",
".",
"query",
"(",
"domain",
")",
"except",
":",
"self",
".",
"error",
"(",
"'Exception while querying passiveDNS. Check the doma... | The actual query happens here. Time from queries is replaced with isoformat.
:param domain: The domain which should gets queried.
:type domain: str
:returns: List of dicts containing the search results.
:rtype: [list, dict] | [
"The",
"actual",
"query",
"happens",
"here",
".",
"Time",
"from",
"queries",
"is",
"replaced",
"with",
"isoformat",
"."
] | python | train | 38.44 |
bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L130-L134 | def _get_samtools0_path(self):
"""Retrieve PATH to the samtools version specific for eriscript.
"""
samtools_path = os.path.realpath(os.path.join(self._get_ericscript_path(),"..", "..", "bin"))
return samtools_path | [
"def",
"_get_samtools0_path",
"(",
"self",
")",
":",
"samtools_path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_get_ericscript_path",
"(",
")",
",",
"\"..\"",
",",
"\"..\"",
",",
"\"bin\"",
")",
"... | Retrieve PATH to the samtools version specific for eriscript. | [
"Retrieve",
"PATH",
"to",
"the",
"samtools",
"version",
"specific",
"for",
"eriscript",
"."
] | python | train | 48.4 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_system.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_system.py#L71-L85 | def get_system_uptime_output_show_system_uptime_minutes(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_system_uptime = ET.Element("get_system_uptime")
config = get_system_uptime
output = ET.SubElement(get_system_uptime, "output")
sho... | [
"def",
"get_system_uptime_output_show_system_uptime_minutes",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_system_uptime",
"=",
"ET",
".",
"Element",
"(",
"\"get_system_uptime\"",
")",
"config",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 46.266667 |
tango-controls/pytango | tango/databaseds/database.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/databaseds/database.py#L1388-L1397 | def DbUnExportEvent(self, argin):
""" Mark one event channel as non exported in database
:param argin: name of event channel or factory to unexport
:type: tango.DevString
:return: none
:rtype: tango.DevVoid """
self._log.debug("In DbUnExportEvent()")
event_name =... | [
"def",
"DbUnExportEvent",
"(",
"self",
",",
"argin",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"In DbUnExportEvent()\"",
")",
"event_name",
"=",
"argin",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"self",
".",
"db",
".",
"unexport_event",
"(",
"e... | Mark one event channel as non exported in database
:param argin: name of event channel or factory to unexport
:type: tango.DevString
:return: none
:rtype: tango.DevVoid | [
"Mark",
"one",
"event",
"channel",
"as",
"non",
"exported",
"in",
"database"
] | python | train | 37.1 |
bigcommerce/bigcommerce-api-python | bigcommerce/connection.py | https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L133-L140 | def put(self, url, data):
"""
Make a PUT request to save data.
data should be a dictionary.
"""
response = self._run_method('PUT', url, data=data)
log.debug("OUTPUT: %s" % response.content)
return self._handle_response(url, response) | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"_run_method",
"(",
"'PUT'",
",",
"url",
",",
"data",
"=",
"data",
")",
"log",
".",
"debug",
"(",
"\"OUTPUT: %s\"",
"%",
"response",
".",
"content",
")",
"r... | Make a PUT request to save data.
data should be a dictionary. | [
"Make",
"a",
"PUT",
"request",
"to",
"save",
"data",
".",
"data",
"should",
"be",
"a",
"dictionary",
"."
] | python | train | 35.25 |
klen/flask-pw | flask_pw/models.py | https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L105-L109 | def select(cls, *args, **kwargs):
"""Support read slaves."""
query = super(Model, cls).select(*args, **kwargs)
query.database = cls._get_read_database()
return query | [
"def",
"select",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"query",
"=",
"super",
"(",
"Model",
",",
"cls",
")",
".",
"select",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"query",
".",
"database",
"=",
"cls",
".",
... | Support read slaves. | [
"Support",
"read",
"slaves",
"."
] | python | train | 38.6 |
gwastro/pycbc | pycbc/events/coinc.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/events/coinc.py#L642-L681 | def add(self, values, times, ifos):
"""Add values to the internal buffer
Parameters
----------
values: numpy.ndarray
Array of elements to add to the internal buffer.
times: dict of arrays
The current time to use for each element being added.
ifos:... | [
"def",
"add",
"(",
"self",
",",
"values",
",",
"times",
",",
"ifos",
")",
":",
"for",
"ifo",
"in",
"ifos",
":",
"self",
".",
"time",
"[",
"ifo",
"]",
"+=",
"1",
"# Resize the internal buffer if we need more space",
"if",
"self",
".",
"index",
"+",
"len",... | Add values to the internal buffer
Parameters
----------
values: numpy.ndarray
Array of elements to add to the internal buffer.
times: dict of arrays
The current time to use for each element being added.
ifos: list of strs
The set of timers to ... | [
"Add",
"values",
"to",
"the",
"internal",
"buffer"
] | python | train | 34.75 |
saltstack/salt | salt/states/pip_state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pip_state.py#L106-L181 | def _check_pkg_version_format(pkg):
'''
Takes a package name and version specification (if any) and checks it using
the pip library.
'''
ret = {'result': False, 'comment': None,
'prefix': None, 'version_spec': None}
if not HAS_PIP:
ret['comment'] = (
'An importab... | [
"def",
"_check_pkg_version_format",
"(",
"pkg",
")",
":",
"ret",
"=",
"{",
"'result'",
":",
"False",
",",
"'comment'",
":",
"None",
",",
"'prefix'",
":",
"None",
",",
"'version_spec'",
":",
"None",
"}",
"if",
"not",
"HAS_PIP",
":",
"ret",
"[",
"'comment'... | Takes a package name and version specification (if any) and checks it using
the pip library. | [
"Takes",
"a",
"package",
"name",
"and",
"version",
"specification",
"(",
"if",
"any",
")",
"and",
"checks",
"it",
"using",
"the",
"pip",
"library",
"."
] | python | train | 36.447368 |
spencerahill/aospy | aospy/utils/vertcoord.py | https://github.com/spencerahill/aospy/blob/2f6e775b9b9956c54af117fdcdce2c87196afb6c/aospy/utils/vertcoord.py#L167-L228 | def dp_from_p(p, ps, p_top=0., p_bot=1.1e5):
"""Get level thickness of pressure data, incorporating surface pressure.
Level edges are defined as halfway between the levels, as well as the user-
specified uppermost and lowermost values. The dp of levels whose bottom
pressure is less than the surface pr... | [
"def",
"dp_from_p",
"(",
"p",
",",
"ps",
",",
"p_top",
"=",
"0.",
",",
"p_bot",
"=",
"1.1e5",
")",
":",
"p_str",
"=",
"get_dim_name",
"(",
"p",
",",
"(",
"internal_names",
".",
"PLEVEL_STR",
",",
"'plev'",
")",
")",
"p_vals",
"=",
"to_pascal",
"(",
... | Get level thickness of pressure data, incorporating surface pressure.
Level edges are defined as halfway between the levels, as well as the user-
specified uppermost and lowermost values. The dp of levels whose bottom
pressure is less than the surface pressure is not changed by ps, since they
don't in... | [
"Get",
"level",
"thickness",
"of",
"pressure",
"data",
"incorporating",
"surface",
"pressure",
"."
] | python | train | 46.709677 |
ManiacalLabs/PixelWeb | pixelweb/bottle.py | https://github.com/ManiacalLabs/PixelWeb/blob/9eacbfd40a1d35011c2dcea15c303da9636c6b9e/pixelweb/bottle.py#L1900-L1909 | def decode(self, encoding=None):
''' Returns a copy with all keys and values de- or recoded to match
:attr:`input_encoding`. Some libraries (e.g. WTForms) want a
unicode dictionary. '''
copy = FormsDict()
enc = copy.input_encoding = encoding or self.input_encoding
... | [
"def",
"decode",
"(",
"self",
",",
"encoding",
"=",
"None",
")",
":",
"copy",
"=",
"FormsDict",
"(",
")",
"enc",
"=",
"copy",
".",
"input_encoding",
"=",
"encoding",
"or",
"self",
".",
"input_encoding",
"copy",
".",
"recode_unicode",
"=",
"False",
"for",... | Returns a copy with all keys and values de- or recoded to match
:attr:`input_encoding`. Some libraries (e.g. WTForms) want a
unicode dictionary. | [
"Returns",
"a",
"copy",
"with",
"all",
"keys",
"and",
"values",
"de",
"-",
"or",
"recoded",
"to",
"match",
":",
"attr",
":",
"input_encoding",
".",
"Some",
"libraries",
"(",
"e",
".",
"g",
".",
"WTForms",
")",
"want",
"a",
"unicode",
"dictionary",
"."
... | python | train | 47 |
PGower/PyCanvas | pycanvas/apis/outcome_results.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/outcome_results.py#L19-L59 | def get_outcome_results(self, course_id, include=None, outcome_ids=None, user_ids=None):
"""
Get outcome results.
Gets the outcome results for users and outcomes in the specified context.
"""
path = {}
data = {}
params = {}
# REQUIRED - PATH - ... | [
"def",
"get_outcome_results",
"(",
"self",
",",
"course_id",
",",
"include",
"=",
"None",
",",
"outcome_ids",
"=",
"None",
",",
"user_ids",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRED - PATH... | Get outcome results.
Gets the outcome results for users and outcomes in the specified context. | [
"Get",
"outcome",
"results",
".",
"Gets",
"the",
"outcome",
"results",
"for",
"users",
"and",
"outcomes",
"in",
"the",
"specified",
"context",
"."
] | python | train | 45.292683 |
tensorflow/tensorboard | tensorboard/plugins/interactive_inference/utils/platform_utils.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/interactive_inference/utils/platform_utils.py#L160-L205 | def call_servo(examples, serving_bundle):
"""Send an RPC request to the Servomatic prediction service.
Args:
examples: A list of examples that matches the model spec.
serving_bundle: A `ServingBundle` object that contains the information to
make the serving request.
Returns:
A ClassificationRe... | [
"def",
"call_servo",
"(",
"examples",
",",
"serving_bundle",
")",
":",
"parsed_url",
"=",
"urlparse",
"(",
"'http://'",
"+",
"serving_bundle",
".",
"inference_address",
")",
"channel",
"=",
"implementations",
".",
"insecure_channel",
"(",
"parsed_url",
".",
"hostn... | Send an RPC request to the Servomatic prediction service.
Args:
examples: A list of examples that matches the model spec.
serving_bundle: A `ServingBundle` object that contains the information to
make the serving request.
Returns:
A ClassificationResponse or RegressionResponse proto. | [
"Send",
"an",
"RPC",
"request",
"to",
"the",
"Servomatic",
"prediction",
"service",
"."
] | python | train | 41.130435 |
secdev/scapy | scapy/layers/sixlowpan.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L452-L515 | def post_dissect(self, data):
"""dissect the IPv6 package compressed into this IPHC packet.
The packet payload needs to be decompressed and depending on the
arguments, several conversions should be done.
"""
# uncompress payload
packet = IPv6()
packet.version = ... | [
"def",
"post_dissect",
"(",
"self",
",",
"data",
")",
":",
"# uncompress payload",
"packet",
"=",
"IPv6",
"(",
")",
"packet",
".",
"version",
"=",
"IPHC_DEFAULT_VERSION",
"packet",
".",
"tc",
",",
"packet",
".",
"fl",
"=",
"self",
".",
"_getTrafficClassAndFl... | dissect the IPv6 package compressed into this IPHC packet.
The packet payload needs to be decompressed and depending on the
arguments, several conversions should be done. | [
"dissect",
"the",
"IPv6",
"package",
"compressed",
"into",
"this",
"IPHC",
"packet",
"."
] | python | train | 34.921875 |
lambdamusic/Ontospy | ontospy/extras/shell_lib.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1076-L1098 | def do_next(self, line):
"""Jump to the next entities (ontology, class or property) depending on context"""
if not self.current:
print("Please select an ontology first. E.g. use the 'ls ontologies' or 'get ontology <name>' commands.")
elif self.currentEntity:
g = self.cur... | [
"def",
"do_next",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"self",
".",
"current",
":",
"print",
"(",
"\"Please select an ontology first. E.g. use the 'ls ontologies' or 'get ontology <name>' commands.\"",
")",
"elif",
"self",
".",
"currentEntity",
":",
"g",
"... | Jump to the next entities (ontology, class or property) depending on context | [
"Jump",
"to",
"the",
"next",
"entities",
"(",
"ontology",
"class",
"or",
"property",
")",
"depending",
"on",
"context"
] | python | train | 51.73913 |
joferkington/mplstereonet | mplstereonet/analysis.py | https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/mplstereonet/analysis.py#L219-L264 | def find_mean_vector(*args, **kwargs):
"""
Returns the mean vector for a set of measurments. By default, this expects
the input to be plunges and bearings, but the type of input can be
controlled through the ``measurement`` kwarg.
Parameters
----------
*args : 2 or 3 sequences of measureme... | [
"def",
"find_mean_vector",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lon",
",",
"lat",
"=",
"_convert_measurements",
"(",
"args",
",",
"kwargs",
".",
"get",
"(",
"'measurement'",
",",
"'lines'",
")",
")",
"vector",
",",
"r_value",
"=",
"ste... | Returns the mean vector for a set of measurments. By default, this expects
the input to be plunges and bearings, but the type of input can be
controlled through the ``measurement`` kwarg.
Parameters
----------
*args : 2 or 3 sequences of measurements
By default, this will be expected to be... | [
"Returns",
"the",
"mean",
"vector",
"for",
"a",
"set",
"of",
"measurments",
".",
"By",
"default",
"this",
"expects",
"the",
"input",
"to",
"be",
"plunges",
"and",
"bearings",
"but",
"the",
"type",
"of",
"input",
"can",
"be",
"controlled",
"through",
"the",... | python | train | 41.434783 |
rm-hull/luma.core | luma/core/mixin.py | https://github.com/rm-hull/luma.core/blob/034b628fb304a01e77732a299c0b42e94d6443db/luma/core/mixin.py#L13-L40 | def capabilities(self, width, height, rotate, mode="1"):
"""
Assigns attributes such as ``width``, ``height``, ``size`` and
``bounding_box`` correctly oriented from the supplied parameters.
:param width: The device width.
:type width: int
:param height: The device height... | [
"def",
"capabilities",
"(",
"self",
",",
"width",
",",
"height",
",",
"rotate",
",",
"mode",
"=",
"\"1\"",
")",
":",
"assert",
"mode",
"in",
"(",
"\"1\"",
",",
"\"RGB\"",
",",
"\"RGBA\"",
")",
"assert",
"rotate",
"in",
"(",
"0",
",",
"1",
",",
"2",... | Assigns attributes such as ``width``, ``height``, ``size`` and
``bounding_box`` correctly oriented from the supplied parameters.
:param width: The device width.
:type width: int
:param height: The device height.
:type height: int
:param rotate: An integer value of 0 (def... | [
"Assigns",
"attributes",
"such",
"as",
"width",
"height",
"size",
"and",
"bounding_box",
"correctly",
"oriented",
"from",
"the",
"supplied",
"parameters",
"."
] | python | train | 40.392857 |
PGower/PyCanvas | pycanvas/apis/external_tools.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/external_tools.py#L19-L50 | def list_external_tools_courses(self, course_id, include_parents=None, search_term=None, selectable=None):
"""
List external tools.
Returns the paginated list of external tools for the current context.
See the get request docs for a single tool for a list of properties on an extern... | [
"def",
"list_external_tools_courses",
"(",
"self",
",",
"course_id",
",",
"include_parents",
"=",
"None",
",",
"search_term",
"=",
"None",
",",
"selectable",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
... | List external tools.
Returns the paginated list of external tools for the current context.
See the get request docs for a single tool for a list of properties on an external tool. | [
"List",
"external",
"tools",
".",
"Returns",
"the",
"paginated",
"list",
"of",
"external",
"tools",
"for",
"the",
"current",
"context",
".",
"See",
"the",
"get",
"request",
"docs",
"for",
"a",
"single",
"tool",
"for",
"a",
"list",
"of",
"properties",
"on",... | python | train | 43.9375 |
playpauseandstop/bootstrapper | bootstrapper.py | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L691-L700 | def smart_str(value, encoding='utf-8', errors='strict'):
"""Convert Python object to string.
:param value: Python object to convert.
:param encoding: Encoding to use if in Python 2 given object is unicode.
:param errors: Errors mode to use if in Python 2 given object is unicode.
"""
if not IS_P... | [
"def",
"smart_str",
"(",
"value",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"IS_PY3",
"and",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"# noqa",
"return",
"value",
".",
"encode",
"(",
"encoding",
... | Convert Python object to string.
:param value: Python object to convert.
:param encoding: Encoding to use if in Python 2 given object is unicode.
:param errors: Errors mode to use if in Python 2 given object is unicode. | [
"Convert",
"Python",
"object",
"to",
"string",
"."
] | python | valid | 42.1 |
inveniosoftware/invenio-communities | invenio_communities/models.py | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L222-L227 | def create(cls, community_id, user_id, **data):
"""Get a community."""
with db.session.begin_nested():
obj = cls(id=community_id, id_user=user_id, **data)
db.session.add(obj)
return obj | [
"def",
"create",
"(",
"cls",
",",
"community_id",
",",
"user_id",
",",
"*",
"*",
"data",
")",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"obj",
"=",
"cls",
"(",
"id",
"=",
"community_id",
",",
"id_user",
"=",
"user_id",
... | Get a community. | [
"Get",
"a",
"community",
"."
] | python | train | 38 |
colab/colab-superarchives-plugin | src/colab_superarchives/management/commands/import_emails.py | https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/management/commands/import_emails.py#L265-L301 | def handle(self, *args, **options):
"""Main command method."""
# Already running, so quit
if os.path.exists(self.lock_file):
self.log(("This script is already running. "
"(If your are sure it's not please "
"delete the lock file in {}')").... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"# Already running, so quit",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"lock_file",
")",
":",
"self",
".",
"log",
"(",
"(",
"\"This script is already run... | Main command method. | [
"Main",
"command",
"method",
"."
] | python | train | 33.351351 |
peerplays-network/python-peerplays | peerplays/cli/info.py | https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/cli/info.py#L104-L126 | def fees(ctx):
""" List fees
"""
from peerplaysbase.operationids import getOperationNameForId
chain = Blockchain(peerplays_instance=ctx.peerplays)
feesObj = chain.chainParameters().get("current_fees")
fees = feesObj["parameters"]
t = PrettyTable(["Operation", "Type", "Fee"])
t.align = ... | [
"def",
"fees",
"(",
"ctx",
")",
":",
"from",
"peerplaysbase",
".",
"operationids",
"import",
"getOperationNameForId",
"chain",
"=",
"Blockchain",
"(",
"peerplays_instance",
"=",
"ctx",
".",
"peerplays",
")",
"feesObj",
"=",
"chain",
".",
"chainParameters",
"(",
... | List fees | [
"List",
"fees"
] | python | train | 27.043478 |
allenai/allennlp | allennlp/models/model.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/model.py#L288-L327 | def load(cls,
config: Params,
serialization_dir: str,
weights_file: str = None,
cuda_device: int = -1) -> 'Model':
"""
Instantiates an already-trained model, based on the experiment
configuration and some optional overrides.
Parameters... | [
"def",
"load",
"(",
"cls",
",",
"config",
":",
"Params",
",",
"serialization_dir",
":",
"str",
",",
"weights_file",
":",
"str",
"=",
"None",
",",
"cuda_device",
":",
"int",
"=",
"-",
"1",
")",
"->",
"'Model'",
":",
"# Peak at the class of the model.",
"mod... | Instantiates an already-trained model, based on the experiment
configuration and some optional overrides.
Parameters
----------
config: Params
The configuration that was used to train the model. It should definitely
have a `model` section, and should probably hav... | [
"Instantiates",
"an",
"already",
"-",
"trained",
"model",
"based",
"on",
"the",
"experiment",
"configuration",
"and",
"some",
"optional",
"overrides",
"."
] | python | train | 38.725 |
pgjones/quart | quart/templating.py | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/templating.py#L43-L55 | def get_source(
self, environment: Environment, template: str,
) -> Tuple[str, Optional[str], Callable]:
"""Returns the template source from the environment.
This considers the loaders on the :attr:`app` and blueprints.
"""
for loader in self._loaders():
try:... | [
"def",
"get_source",
"(",
"self",
",",
"environment",
":",
"Environment",
",",
"template",
":",
"str",
",",
")",
"->",
"Tuple",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
",",
"Callable",
"]",
":",
"for",
"loader",
"in",
"self",
".",
"_loaders",
"... | Returns the template source from the environment.
This considers the loaders on the :attr:`app` and blueprints. | [
"Returns",
"the",
"template",
"source",
"from",
"the",
"environment",
"."
] | python | train | 36.538462 |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/future_account.py#L184-L188 | def buy_margin(self):
"""
[float] 买方向保证金
"""
return sum(position.buy_margin for position in six.itervalues(self._positions)) | [
"def",
"buy_margin",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"position",
".",
"buy_margin",
"for",
"position",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_positions",
")",
")"
] | [float] 买方向保证金 | [
"[",
"float",
"]",
"买方向保证金"
] | python | train | 30.4 |
pyviz/holoviews | holoviews/operation/stats.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/operation/stats.py#L13-L20 | def _kde_support(bin_range, bw, gridsize, cut, clip):
"""Establish support for a kernel density estimate."""
kmin, kmax = bin_range[0] - bw * cut, bin_range[1] + bw * cut
if isfinite(clip[0]):
kmin = max(kmin, clip[0])
if isfinite(clip[1]):
kmax = min(kmax, clip[1])
return np.linspac... | [
"def",
"_kde_support",
"(",
"bin_range",
",",
"bw",
",",
"gridsize",
",",
"cut",
",",
"clip",
")",
":",
"kmin",
",",
"kmax",
"=",
"bin_range",
"[",
"0",
"]",
"-",
"bw",
"*",
"cut",
",",
"bin_range",
"[",
"1",
"]",
"+",
"bw",
"*",
"cut",
"if",
"... | Establish support for a kernel density estimate. | [
"Establish",
"support",
"for",
"a",
"kernel",
"density",
"estimate",
"."
] | python | train | 42 |
saltstack/salt | salt/utils/dictupdate.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dictupdate.py#L204-L228 | def set_dict_key_value(
in_dict,
keys,
value,
delimiter=DEFAULT_TARGET_DELIM,
ordered_dict=False):
'''
Ensures that in_dict contains the series of recursive keys defined in keys.
Also sets whatever is at the end of `in_dict` traversed with `keys` to `value`.
:par... | [
"def",
"set_dict_key_value",
"(",
"in_dict",
",",
"keys",
",",
"value",
",",
"delimiter",
"=",
"DEFAULT_TARGET_DELIM",
",",
"ordered_dict",
"=",
"False",
")",
":",
"dict_pointer",
",",
"last_key",
"=",
"_dict_rpartition",
"(",
"in_dict",
",",
"keys",
",",
"del... | Ensures that in_dict contains the series of recursive keys defined in keys.
Also sets whatever is at the end of `in_dict` traversed with `keys` to `value`.
:param dict in_dict: The dictionary to work with
:param str keys: The delimited string with one or more keys.
:param any value: The value to assign... | [
"Ensures",
"that",
"in_dict",
"contains",
"the",
"series",
"of",
"recursive",
"keys",
"defined",
"in",
"keys",
".",
"Also",
"sets",
"whatever",
"is",
"at",
"the",
"end",
"of",
"in_dict",
"traversed",
"with",
"keys",
"to",
"value",
"."
] | python | train | 41.68 |
hosford42/xcs | xcs/algorithms/xcs.py | https://github.com/hosford42/xcs/blob/183bdd0dd339e19ded3be202f86e1b38bdb9f1e5/xcs/algorithms/xcs.py#L746-L777 | def _update_fitness(self, action_set):
"""Update the fitness values of the rules belonging to this action
set."""
# Compute the accuracy of each rule. Accuracy is inversely
# proportional to error. Below a certain error threshold, accuracy
# becomes constant. Accuracy values rang... | [
"def",
"_update_fitness",
"(",
"self",
",",
"action_set",
")",
":",
"# Compute the accuracy of each rule. Accuracy is inversely",
"# proportional to error. Below a certain error threshold, accuracy",
"# becomes constant. Accuracy values range over (0, 1].",
"total_accuracy",
"=",
"0",
"a... | Update the fitness values of the rules belonging to this action
set. | [
"Update",
"the",
"fitness",
"values",
"of",
"the",
"rules",
"belonging",
"to",
"this",
"action",
"set",
"."
] | python | train | 38.65625 |
zrong/rookout | rookout/base.py | https://github.com/zrong/rookout/blob/f94871a564274625768f2da63507d120232ca717/rookout/base.py#L231-L259 | def merge_dicts(d1, d2):
"""合并两个无限深度的 dict
会自动合并 list 格式
:param dict d1: 被合并的 dict
:param dict d2: 待合并的 dict
:returns: 一个新的生成器对象
:rtype: generator
"""
for k in set(d1.keys()).union(d2.keys()):
if k in d1 and k in d2:
if isinstance(d1[k], dict) and isinstance(d2[k], ... | [
"def",
"merge_dicts",
"(",
"d1",
",",
"d2",
")",
":",
"for",
"k",
"in",
"set",
"(",
"d1",
".",
"keys",
"(",
")",
")",
".",
"union",
"(",
"d2",
".",
"keys",
"(",
")",
")",
":",
"if",
"k",
"in",
"d1",
"and",
"k",
"in",
"d2",
":",
"if",
"isi... | 合并两个无限深度的 dict
会自动合并 list 格式
:param dict d1: 被合并的 dict
:param dict d2: 待合并的 dict
:returns: 一个新的生成器对象
:rtype: generator | [
"合并两个无限深度的",
"dict",
"会自动合并",
"list",
"格式"
] | python | train | 33.931034 |
DinoTools/python-overpy | overpy/__init__.py | https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1521-L1535 | def _handle_start_area(self, attrs):
"""
Handle opening area element
:param attrs: Attributes of the element
:type attrs: Dict
"""
self._curr = {
'attributes': dict(attrs),
'tags': {},
'area_id': None
}
if attrs.get('id... | [
"def",
"_handle_start_area",
"(",
"self",
",",
"attrs",
")",
":",
"self",
".",
"_curr",
"=",
"{",
"'attributes'",
":",
"dict",
"(",
"attrs",
")",
",",
"'tags'",
":",
"{",
"}",
",",
"'area_id'",
":",
"None",
"}",
"if",
"attrs",
".",
"get",
"(",
"'id... | Handle opening area element
:param attrs: Attributes of the element
:type attrs: Dict | [
"Handle",
"opening",
"area",
"element"
] | python | train | 28.466667 |
libtcod/python-tcod | tcod/event.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/event.py#L655-L663 | def dispatch(self, event: Any) -> None:
"""Send an event to an `ev_*` method.
`*` will be the events type converted to lower-case.
If `event.type` is an empty string or None then it will be ignored.
"""
if event.type:
getattr(self, "ev_%s" % (event.type.lower(),))(e... | [
"def",
"dispatch",
"(",
"self",
",",
"event",
":",
"Any",
")",
"->",
"None",
":",
"if",
"event",
".",
"type",
":",
"getattr",
"(",
"self",
",",
"\"ev_%s\"",
"%",
"(",
"event",
".",
"type",
".",
"lower",
"(",
")",
",",
")",
")",
"(",
"event",
")... | Send an event to an `ev_*` method.
`*` will be the events type converted to lower-case.
If `event.type` is an empty string or None then it will be ignored. | [
"Send",
"an",
"event",
"to",
"an",
"ev_",
"*",
"method",
"."
] | python | train | 35.222222 |
deepmind/sonnet | sonnet/examples/learn_to_execute.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/learn_to_execute.py#L273-L277 | def fetch(self):
"""Samples up to current difficulty."""
length = np.random.randint(1, self._curr_length + 1)
nesting = np.random.randint(1, self._curr_nesting + 1)
return length, nesting | [
"def",
"fetch",
"(",
"self",
")",
":",
"length",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"1",
",",
"self",
".",
"_curr_length",
"+",
"1",
")",
"nesting",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"1",
",",
"self",
".",
"_curr_nesting",
... | Samples up to current difficulty. | [
"Samples",
"up",
"to",
"current",
"difficulty",
"."
] | python | train | 39.8 |
cackharot/suds-py3 | suds/sax/element.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/sax/element.py#L186-L200 | def set(self, name, value):
"""
Set an attribute's value.
@param name: The name of the attribute.
@type name: basestring
@param value: The attribute value.
@type value: basestring
@see: __setitem__()
"""
attr = self.getAttribute(name)
if at... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"attr",
"=",
"self",
".",
"getAttribute",
"(",
"name",
")",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"Attribute",
"(",
"name",
",",
"value",
")",
"self",
".",
"append",
"(",
"at... | Set an attribute's value.
@param name: The name of the attribute.
@type name: basestring
@param value: The attribute value.
@type value: basestring
@see: __setitem__() | [
"Set",
"an",
"attribute",
"s",
"value",
"."
] | python | train | 29.066667 |
Mindwerks/worldengine | worldengine/simulations/erosion.py | https://github.com/Mindwerks/worldengine/blob/64dff8eb7824ce46b5b6cb8006bcef21822ef144/worldengine/simulations/erosion.py#L178-L287 | def river_flow(self, source, world, river_list, lake_list):
"""simulate fluid dynamics by using starting point and flowing to the
lowest available point"""
current_location = source
path = [source]
# start the flow
while True:
x, y = current_location
... | [
"def",
"river_flow",
"(",
"self",
",",
"source",
",",
"world",
",",
"river_list",
",",
"lake_list",
")",
":",
"current_location",
"=",
"source",
"path",
"=",
"[",
"source",
"]",
"# start the flow",
"while",
"True",
":",
"x",
",",
"y",
"=",
"current_locatio... | simulate fluid dynamics by using starting point and flowing to the
lowest available point | [
"simulate",
"fluid",
"dynamics",
"by",
"using",
"starting",
"point",
"and",
"flowing",
"to",
"the",
"lowest",
"available",
"point"
] | python | train | 42.5 |
tomduck/pandoc-xnos | pandocxnos/core.py | https://github.com/tomduck/pandoc-xnos/blob/df8e162d257a548cea7eebf597efb2c21a1a4ba3/pandocxnos/core.py#L327-L342 | def dollarfy(x):
"""Replaces Math elements in element list 'x' with a $-enclosed string.
stringify() passes through TeX math. Use dollarfy(x) first to replace
Math elements with math strings set in dollars. 'x' should be a deep copy
so that the underlying document is left untouched.
Returns 'x'.... | [
"def",
"dollarfy",
"(",
"x",
")",
":",
"def",
"_dollarfy",
"(",
"key",
",",
"value",
",",
"fmt",
",",
"meta",
")",
":",
"# pylint: disable=unused-argument",
"\"\"\"Replaces Math elements\"\"\"",
"if",
"key",
"==",
"'Math'",
":",
"return",
"Str",
"(",
"'$'",
... | Replaces Math elements in element list 'x' with a $-enclosed string.
stringify() passes through TeX math. Use dollarfy(x) first to replace
Math elements with math strings set in dollars. 'x' should be a deep copy
so that the underlying document is left untouched.
Returns 'x'. | [
"Replaces",
"Math",
"elements",
"in",
"element",
"list",
"x",
"with",
"a",
"$",
"-",
"enclosed",
"string",
"."
] | python | train | 34.5625 |
materialsproject/pymatgen-db | matgendb/creator.py | https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/creator.py#L299-L395 | def post_process(self, dir_name, d):
"""
Simple post-processing for various files other than the vasprun.xml.
Called by generate_task_doc. Modify this if your runs have other
kinds of processing requirements.
Args:
dir_name:
The dir_name.
... | [
"def",
"post_process",
"(",
"self",
",",
"dir_name",
",",
"d",
")",
":",
"logger",
".",
"info",
"(",
"\"Post-processing dir:{}\"",
".",
"format",
"(",
"dir_name",
")",
")",
"fullpath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dir_name",
")",
"# VASP... | Simple post-processing for various files other than the vasprun.xml.
Called by generate_task_doc. Modify this if your runs have other
kinds of processing requirements.
Args:
dir_name:
The dir_name.
d:
Current doc generated. | [
"Simple",
"post",
"-",
"processing",
"for",
"various",
"files",
"other",
"than",
"the",
"vasprun",
".",
"xml",
".",
"Called",
"by",
"generate_task_doc",
".",
"Modify",
"this",
"if",
"your",
"runs",
"have",
"other",
"kinds",
"of",
"processing",
"requirements",
... | python | train | 40.948454 |
rackerlabs/rackspace-python-neutronclient | neutronclient/v2_0/client.py | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L760-L763 | def remove_interface_router(self, router, body=None):
"""Removes an internal network interface from the specified router."""
return self.put((self.router_path % router) +
"/remove_router_interface", body=body) | [
"def",
"remove_interface_router",
"(",
"self",
",",
"router",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"put",
"(",
"(",
"self",
".",
"router_path",
"%",
"router",
")",
"+",
"\"/remove_router_interface\"",
",",
"body",
"=",
"body",
")"
] | Removes an internal network interface from the specified router. | [
"Removes",
"an",
"internal",
"network",
"interface",
"from",
"the",
"specified",
"router",
"."
] | python | train | 61.5 |
inveniosoftware-attic/invenio-utils | invenio_utils/html.py | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L681-L693 | def unescape(s, quote=False):
"""
The opposite of the cgi.escape function.
Replace escaped characters '&', '<' and '>' with the corresponding
regular characters. If the optional flag quote is true, the escaped quotation
mark character ('"') is also translated.
"""
s = s.replac... | [
"def",
"unescape",
"(",
"s",
",",
"quote",
"=",
"False",
")",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"'<'",
",",
"'<'",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"'>'",
",",
"'>'",
")",
"if",
"quote",
":",
"s",
"=",
"s",
".",
"replace"... | The opposite of the cgi.escape function.
Replace escaped characters '&', '<' and '>' with the corresponding
regular characters. If the optional flag quote is true, the escaped quotation
mark character ('"') is also translated. | [
"The",
"opposite",
"of",
"the",
"cgi",
".",
"escape",
"function",
".",
"Replace",
"escaped",
"characters",
"&",
";",
"<",
";",
"and",
">",
";",
"with",
"the",
"corresponding",
"regular",
"characters",
".",
"If",
"the",
"optional",
"flag",
"quote",
"... | python | train | 34.538462 |
glenbot/campbx | campbx/campbx.py | https://github.com/glenbot/campbx/blob/b2e34c59ac1d645969e3a56551a1dcd755516094/campbx/campbx.py#L114-L118 | def _create_endpoints(self):
"""Create all api endpoints using self.endpoint and partial from functools"""
for k, v in self.endpoints.items():
_repr = '%s.%s' % (self.__class__.__name__, k)
self.__dict__[k] = EndPointPartial(self._make_request, v, _repr) | [
"def",
"_create_endpoints",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"endpoints",
".",
"items",
"(",
")",
":",
"_repr",
"=",
"'%s.%s'",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"k",
")",
"self",
".",
"__dict_... | Create all api endpoints using self.endpoint and partial from functools | [
"Create",
"all",
"api",
"endpoints",
"using",
"self",
".",
"endpoint",
"and",
"partial",
"from",
"functools"
] | python | train | 58 |
saltstack/salt | salt/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3935-L3946 | def _handle_exclude(self, state, sls, saltenv, errors):
'''
Take the exclude dec out of the state and apply it to the highstate
global dec
'''
if 'exclude' in state:
exc = state.pop('exclude')
if not isinstance(exc, list):
err = ('Exclude D... | [
"def",
"_handle_exclude",
"(",
"self",
",",
"state",
",",
"sls",
",",
"saltenv",
",",
"errors",
")",
":",
"if",
"'exclude'",
"in",
"state",
":",
"exc",
"=",
"state",
".",
"pop",
"(",
"'exclude'",
")",
"if",
"not",
"isinstance",
"(",
"exc",
",",
"list... | Take the exclude dec out of the state and apply it to the highstate
global dec | [
"Take",
"the",
"exclude",
"dec",
"out",
"of",
"the",
"state",
"and",
"apply",
"it",
"to",
"the",
"highstate",
"global",
"dec"
] | python | train | 40.75 |
scottgigante/tasklogger | tasklogger/api.py | https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/api.py#L24-L43 | def log_start(task, logger="TaskLogger"):
"""Begin logging of a task
Convenience function to log a task in the default
TaskLogger
Parameters
----------
task : str
Name of the task to be started
logger : str, optional (default: "TaskLogger")
Unique name of the logger to retr... | [
"def",
"log_start",
"(",
"task",
",",
"logger",
"=",
"\"TaskLogger\"",
")",
":",
"tasklogger",
"=",
"get_tasklogger",
"(",
"logger",
")",
"tasklogger",
".",
"start_task",
"(",
"task",
")",
"return",
"tasklogger"
] | Begin logging of a task
Convenience function to log a task in the default
TaskLogger
Parameters
----------
task : str
Name of the task to be started
logger : str, optional (default: "TaskLogger")
Unique name of the logger to retrieve
Returns
-------
logger : TaskLo... | [
"Begin",
"logging",
"of",
"a",
"task"
] | python | train | 22.8 |
gwastro/pycbc-glue | pycbc_glue/LDBDClient.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/LDBDClient.py#L329-L347 | def query(self,sql):
"""
Execute an SQL query on the server and fetch the resulting XML file
back.
@return: message received (may be empty) from LDBD Server as a string
"""
msg = "QUERY\0" + sql + "\0"
self.sfile.write(msg)
ret, output = self.__response__()
reply = str(output[0])
... | [
"def",
"query",
"(",
"self",
",",
"sql",
")",
":",
"msg",
"=",
"\"QUERY\\0\"",
"+",
"sql",
"+",
"\"\\0\"",
"self",
".",
"sfile",
".",
"write",
"(",
"msg",
")",
"ret",
",",
"output",
"=",
"self",
".",
"__response__",
"(",
")",
"reply",
"=",
"str",
... | Execute an SQL query on the server and fetch the resulting XML file
back.
@return: message received (may be empty) from LDBD Server as a string | [
"Execute",
"an",
"SQL",
"query",
"on",
"the",
"server",
"and",
"fetch",
"the",
"resulting",
"XML",
"file",
"back",
"."
] | python | train | 22.947368 |
mozilla/treeherder | treeherder/model/error_summary.py | https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/model/error_summary.py#L51-L95 | def bug_suggestions_line(err, term_cache=None):
"""
Get Bug suggestions for a given TextLogError (err).
Tries to extract a search term from a clean version of the given error's
line. We build a search term from the cleaned line and use that to search
for bugs. Returns a dictionary with the cleane... | [
"def",
"bug_suggestions_line",
"(",
"err",
",",
"term_cache",
"=",
"None",
")",
":",
"if",
"term_cache",
"is",
"None",
":",
"term_cache",
"=",
"{",
"}",
"# remove the mozharness prefix",
"clean_line",
"=",
"get_mozharness_substring",
"(",
"err",
".",
"line",
")"... | Get Bug suggestions for a given TextLogError (err).
Tries to extract a search term from a clean version of the given error's
line. We build a search term from the cleaned line and use that to search
for bugs. Returns a dictionary with the cleaned line, the generated search
term, and any bugs found wi... | [
"Get",
"Bug",
"suggestions",
"for",
"a",
"given",
"TextLogError",
"(",
"err",
")",
"."
] | python | train | 37.222222 |
pyviz/holoviews | holoviews/plotting/mpl/__init__.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/mpl/__init__.py#L41-L60 | def set_style(key):
"""
Select a style by name, e.g. set_style('default'). To revert to the
previous style use the key 'unset' or False.
"""
if key is None:
return
elif not key or key in ['unset', 'backup']:
if 'backup' in styles:
plt.rcParams.update(styles['backup'])... | [
"def",
"set_style",
"(",
"key",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"elif",
"not",
"key",
"or",
"key",
"in",
"[",
"'unset'",
",",
"'backup'",
"]",
":",
"if",
"'backup'",
"in",
"styles",
":",
"plt",
".",
"rcParams",
".",
"update",
"(... | Select a style by name, e.g. set_style('default'). To revert to the
previous style use the key 'unset' or False. | [
"Select",
"a",
"style",
"by",
"name",
"e",
".",
"g",
".",
"set_style",
"(",
"default",
")",
".",
"To",
"revert",
"to",
"the",
"previous",
"style",
"use",
"the",
"key",
"unset",
"or",
"False",
"."
] | python | train | 34.8 |
fabioz/PyDev.Debugger | third_party/pep8/pycodestyle.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/pycodestyle.py#L1900-L1907 | def error(self, line_number, offset, text, check):
"""Report an error, according to options."""
code = super(StandardReport, self).error(line_number, offset,
text, check)
if code and (self.counters[code] == 1 or self._repeat):
self._de... | [
"def",
"error",
"(",
"self",
",",
"line_number",
",",
"offset",
",",
"text",
",",
"check",
")",
":",
"code",
"=",
"super",
"(",
"StandardReport",
",",
"self",
")",
".",
"error",
"(",
"line_number",
",",
"offset",
",",
"text",
",",
"check",
")",
"if",... | Report an error, according to options. | [
"Report",
"an",
"error",
"according",
"to",
"options",
"."
] | python | train | 52.875 |
penguinmenac3/starttf | starttf/losses/loss_processors.py | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L115-L125 | def mask_and_mean_loss(input_tensor, binary_tensor, axis=None):
"""
Mask a loss by using a tensor filled with 0 or 1 and average correctly.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] ... | [
"def",
"mask_and_mean_loss",
"(",
"input_tensor",
",",
"binary_tensor",
",",
"axis",
"=",
"None",
")",
":",
"return",
"mean_on_masked",
"(",
"mask_loss",
"(",
"input_tensor",
",",
"binary_tensor",
")",
",",
"binary_tensor",
",",
"axis",
"=",
"axis",
")"
] | Mask a loss by using a tensor filled with 0 or 1 and average correctly.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] representing the mask.
:return: A float tensor of shape [batch_size, ...... | [
"Mask",
"a",
"loss",
"by",
"using",
"a",
"tensor",
"filled",
"with",
"0",
"or",
"1",
"and",
"average",
"correctly",
"."
] | python | train | 62.545455 |
mwgielen/jackal | jackal/scripts/named_pipes.py | https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/scripts/named_pipes.py#L99-L123 | def main():
"""
Loads the config and handles the workers.
"""
config = Config()
pipes_dir = config.get('pipes', 'directory')
pipes_config = config.get('pipes', 'config_file')
pipes_config_path = os.path.join(config.config_dir, pipes_config)
if not os.path.exists(pipes_config_path):
... | [
"def",
"main",
"(",
")",
":",
"config",
"=",
"Config",
"(",
")",
"pipes_dir",
"=",
"config",
".",
"get",
"(",
"'pipes'",
",",
"'directory'",
")",
"pipes_config",
"=",
"config",
".",
"get",
"(",
"'pipes'",
",",
"'config_file'",
")",
"pipes_config_path",
"... | Loads the config and handles the workers. | [
"Loads",
"the",
"config",
"and",
"handles",
"the",
"workers",
"."
] | python | valid | 30.84 |
ael-code/pyFsdb | fsdb/config.py | https://github.com/ael-code/pyFsdb/blob/de33a0d41373307cb32cdd7ba1991b85ff495ee3/fsdb/config.py#L57-L62 | def to_json_format(conf):
'''Convert fields of a python dictionary to be dumped in json format'''
if 'fmode' in conf:
conf['fmode'] = oct(conf['fmode'])[-3:]
if 'dmode' in conf:
conf['dmode'] = oct(conf['dmode'])[-3:] | [
"def",
"to_json_format",
"(",
"conf",
")",
":",
"if",
"'fmode'",
"in",
"conf",
":",
"conf",
"[",
"'fmode'",
"]",
"=",
"oct",
"(",
"conf",
"[",
"'fmode'",
"]",
")",
"[",
"-",
"3",
":",
"]",
"if",
"'dmode'",
"in",
"conf",
":",
"conf",
"[",
"'dmode'... | Convert fields of a python dictionary to be dumped in json format | [
"Convert",
"fields",
"of",
"a",
"python",
"dictionary",
"to",
"be",
"dumped",
"in",
"json",
"format"
] | python | train | 40 |
MAVENSDC/cdflib | cdflib/cdfwrite.py | https://github.com/MAVENSDC/cdflib/blob/d237c60e5db67db0f92d96054209c25c4042465c/cdflib/cdfwrite.py#L2445-L2499 | def _make_blocks(records): # @NoSelf
'''
Organizes the physical records into blocks in a list by
placing consecutive physical records into a single block, so
lesser VXRs will be created.
[[start_rec1,end_rec1,data_1], [start_rec2,enc_rec2,data_2], ...]
Parameters:
... | [
"def",
"_make_blocks",
"(",
"records",
")",
":",
"# @NoSelf",
"sparse_blocks",
"=",
"[",
"]",
"total",
"=",
"len",
"(",
"records",
")",
"if",
"(",
"total",
"==",
"0",
")",
":",
"return",
"[",
"]",
"x",
"=",
"0",
"while",
"(",
"x",
"<",
"total",
"... | Organizes the physical records into blocks in a list by
placing consecutive physical records into a single block, so
lesser VXRs will be created.
[[start_rec1,end_rec1,data_1], [start_rec2,enc_rec2,data_2], ...]
Parameters:
records: list
A list of records t... | [
"Organizes",
"the",
"physical",
"records",
"into",
"blocks",
"in",
"a",
"list",
"by",
"placing",
"consecutive",
"physical",
"records",
"into",
"a",
"single",
"block",
"so",
"lesser",
"VXRs",
"will",
"be",
"created",
".",
"[[",
"start_rec1",
"end_rec1",
"data_1... | python | train | 29.218182 |
scanny/python-pptx | pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/parts/image.py#L196-L227 | def dpi(self):
"""
A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch
resolution of this image. A default value of (72, 72) is used if the
dpi is not specified in the image file.
"""
def int_dpi(dpi):
"""
Return an integer dots-per-inch va... | [
"def",
"dpi",
"(",
"self",
")",
":",
"def",
"int_dpi",
"(",
"dpi",
")",
":",
"\"\"\"\n Return an integer dots-per-inch value corresponding to *dpi*. If\n *dpi* is |None|, a non-numeric type, less than 1 or greater than\n 2048, 72 is returned.\n \"\... | A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch
resolution of this image. A default value of (72, 72) is used if the
dpi is not specified in the image file. | [
"A",
"(",
"horz_dpi",
"vert_dpi",
")",
"2",
"-",
"tuple",
"specifying",
"the",
"dots",
"-",
"per",
"-",
"inch",
"resolution",
"of",
"this",
"image",
".",
"A",
"default",
"value",
"of",
"(",
"72",
"72",
")",
"is",
"used",
"if",
"the",
"dpi",
"is",
"... | python | train | 38.3125 |
SuperCowPowers/workbench | workbench/server/data_store.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L51-L102 | def store_sample(self, sample_bytes, filename, type_tag):
"""Store a sample into the datastore.
Args:
filename: Name of the file.
sample_bytes: Actual bytes of sample.
type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...)
Returns:
m... | [
"def",
"store_sample",
"(",
"self",
",",
"sample_bytes",
",",
"filename",
",",
"type_tag",
")",
":",
"# Temp sanity check for old clients",
"if",
"len",
"(",
"filename",
")",
">",
"1000",
":",
"print",
"'switched bytes/filename... %s %s'",
"%",
"(",
"sample_bytes",
... | Store a sample into the datastore.
Args:
filename: Name of the file.
sample_bytes: Actual bytes of sample.
type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...)
Returns:
md5 digest of the sample. | [
"Store",
"a",
"sample",
"into",
"the",
"datastore",
"."
] | python | train | 33.673077 |
CalebBell/thermo | thermo/heat_capacity.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/heat_capacity.py#L2260-L2313 | def Lastovka_solid_integral(T, similarity_variable):
r'''Integrates solid constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
Uses a explicit form as derived with Sympy.
Parameters
----------
T : float
Temperature of solid [K]
simi... | [
"def",
"Lastovka_solid_integral",
"(",
"T",
",",
"similarity_variable",
")",
":",
"A1",
"=",
"0.013183",
"A2",
"=",
"0.249381",
"theta",
"=",
"151.8675",
"C1",
"=",
"0.026526",
"C2",
"=",
"-",
"0.024942",
"D1",
"=",
"0.000025",
"D2",
"=",
"-",
"0.000123",
... | r'''Integrates solid constant-pressure heat capacitiy with the similarity
variable concept and method as shown in [1]_.
Uses a explicit form as derived with Sympy.
Parameters
----------
T : float
Temperature of solid [K]
similarity_variable : float
similarity variable as de... | [
"r",
"Integrates",
"solid",
"constant",
"-",
"pressure",
"heat",
"capacitiy",
"with",
"the",
"similarity",
"variable",
"concept",
"and",
"method",
"as",
"shown",
"in",
"[",
"1",
"]",
"_",
".",
"Uses",
"a",
"explicit",
"form",
"as",
"derived",
"with",
"Symp... | python | valid | 30.425926 |
pantsbuild/pex | pex/pex_info.py | https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/pex_info.py#L321-L327 | def merge_pex_path(self, pex_path):
"""Merges a new PEX_PATH definition into the existing one (if any).
:param string pex_path: The PEX_PATH to merge.
"""
if not pex_path:
return
self.pex_path = ':'.join(merge_split(self.pex_path, pex_path)) | [
"def",
"merge_pex_path",
"(",
"self",
",",
"pex_path",
")",
":",
"if",
"not",
"pex_path",
":",
"return",
"self",
".",
"pex_path",
"=",
"':'",
".",
"join",
"(",
"merge_split",
"(",
"self",
".",
"pex_path",
",",
"pex_path",
")",
")"
] | Merges a new PEX_PATH definition into the existing one (if any).
:param string pex_path: The PEX_PATH to merge. | [
"Merges",
"a",
"new",
"PEX_PATH",
"definition",
"into",
"the",
"existing",
"one",
"(",
"if",
"any",
")",
".",
":",
"param",
"string",
"pex_path",
":",
"The",
"PEX_PATH",
"to",
"merge",
"."
] | python | train | 37.285714 |
tisimst/mcerp | mcerp/__init__.py | https://github.com/tisimst/mcerp/blob/2bb8260c9ad2d58a806847f1b627b6451e407de1/mcerp/__init__.py#L1089-L1101 | def Uniform(low, high, tag=None):
"""
A Uniform random variate
Parameters
----------
low : scalar
Lower bound of the distribution support.
high : scalar
Upper bound of the distribution support.
"""
assert low < high, 'Uniform "low" must be less than "high"'
retur... | [
"def",
"Uniform",
"(",
"low",
",",
"high",
",",
"tag",
"=",
"None",
")",
":",
"assert",
"low",
"<",
"high",
",",
"'Uniform \"low\" must be less than \"high\"'",
"return",
"uv",
"(",
"ss",
".",
"uniform",
"(",
"loc",
"=",
"low",
",",
"scale",
"=",
"high",... | A Uniform random variate
Parameters
----------
low : scalar
Lower bound of the distribution support.
high : scalar
Upper bound of the distribution support. | [
"A",
"Uniform",
"random",
"variate",
"Parameters",
"----------",
"low",
":",
"scalar",
"Lower",
"bound",
"of",
"the",
"distribution",
"support",
".",
"high",
":",
"scalar",
"Upper",
"bound",
"of",
"the",
"distribution",
"support",
"."
] | python | train | 27.692308 |
openpaperwork/paperwork-backend | paperwork_backend/__init__.py | https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/__init__.py#L12-L47 | def init_flatpak():
"""
If we are in Flatpak, we must build a tessdata/ directory using the
.traineddata files from each locale directory
"""
tessdata_files = glob.glob("/app/share/locale/*/*.traineddata")
if len(tessdata_files) <= 0:
return os.path.exists("/app")
localdir = os.path... | [
"def",
"init_flatpak",
"(",
")",
":",
"tessdata_files",
"=",
"glob",
".",
"glob",
"(",
"\"/app/share/locale/*/*.traineddata\"",
")",
"if",
"len",
"(",
"tessdata_files",
")",
"<=",
"0",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"\"/app\"",
")",
... | If we are in Flatpak, we must build a tessdata/ directory using the
.traineddata files from each locale directory | [
"If",
"we",
"are",
"in",
"Flatpak",
"we",
"must",
"build",
"a",
"tessdata",
"/",
"directory",
"using",
"the",
".",
"traineddata",
"files",
"from",
"each",
"locale",
"directory"
] | python | train | 40.055556 |
tnkteja/myhelp | virtualEnvironment/lib/python2.7/site-packages/coverage/data.py | https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/data.py#L113-L135 | def write_file(self, filename):
"""Write the coverage data to `filename`."""
# Create the file data.
data = {}
data['lines'] = self.line_data()
arcs = self.arc_data()
if arcs:
data['arcs'] = arcs
if self.collector:
data['collector'] = se... | [
"def",
"write_file",
"(",
"self",
",",
"filename",
")",
":",
"# Create the file data.",
"data",
"=",
"{",
"}",
"data",
"[",
"'lines'",
"]",
"=",
"self",
".",
"line_data",
"(",
")",
"arcs",
"=",
"self",
".",
"arc_data",
"(",
")",
"if",
"arcs",
":",
"d... | Write the coverage data to `filename`. | [
"Write",
"the",
"coverage",
"data",
"to",
"filename",
"."
] | python | test | 26.304348 |
exekias/droplet | droplet/sudo.py | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/sudo.py#L59-L68 | def drop_privileges():
"""
Set settings.DROPLET_USER UID for the current process
After calling this, root operation will be impossible to execute
See root context manager
"""
uid = int(pwd.getpwnam(settings.DROPLET_USER).pw_uid)
os.setuid(uid) | [
"def",
"drop_privileges",
"(",
")",
":",
"uid",
"=",
"int",
"(",
"pwd",
".",
"getpwnam",
"(",
"settings",
".",
"DROPLET_USER",
")",
".",
"pw_uid",
")",
"os",
".",
"setuid",
"(",
"uid",
")"
] | Set settings.DROPLET_USER UID for the current process
After calling this, root operation will be impossible to execute
See root context manager | [
"Set",
"settings",
".",
"DROPLET_USER",
"UID",
"for",
"the",
"current",
"process"
] | python | train | 26.4 |
OSSOS/MOP | src/ossos/core/ossos/planning/megacam.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/planning/megacam.py#L5-L32 | def TAPQuery(RAdeg=180.0, DECdeg=0.0, width=1, height=1):
"""Do a query of the CADC Megacam table. Get all observations insize the box. Returns a file-like object"""
QUERY =( """ SELECT """
""" COORD1(CENTROID(Plane.position_bounds)) AS "RAJ2000", COORD2(CENTROID(Plane.position_bounds)) AS "DEJ... | [
"def",
"TAPQuery",
"(",
"RAdeg",
"=",
"180.0",
",",
"DECdeg",
"=",
"0.0",
",",
"width",
"=",
"1",
",",
"height",
"=",
"1",
")",
":",
"QUERY",
"=",
"(",
"\"\"\" SELECT \"\"\"",
"\"\"\" COORD1(CENTROID(Plane.position_bounds)) AS \"RAJ2000\", COORD2(CENTROID(Plane.positi... | Do a query of the CADC Megacam table. Get all observations insize the box. Returns a file-like object | [
"Do",
"a",
"query",
"of",
"the",
"CADC",
"Megacam",
"table",
".",
"Get",
"all",
"observations",
"insize",
"the",
"box",
".",
"Returns",
"a",
"file",
"-",
"like",
"object"
] | python | train | 42.642857 |
boxed/mutmut | mutmut/__init__.py | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__init__.py#L512-L561 | def mutate_node(node, context):
"""
:type context: Context
"""
context.stack.append(node)
try:
if node.type in ('tfpdef', 'import_from', 'import_name'):
return
if node.start_pos[0] - 1 != context.current_line_index:
context.current_line_index = node.start_pos... | [
"def",
"mutate_node",
"(",
"node",
",",
"context",
")",
":",
"context",
".",
"stack",
".",
"append",
"(",
"node",
")",
"try",
":",
"if",
"node",
".",
"type",
"in",
"(",
"'tfpdef'",
",",
"'import_from'",
",",
"'import_name'",
")",
":",
"return",
"if",
... | :type context: Context | [
":",
"type",
"context",
":",
"Context"
] | python | valid | 33.72 |
base4sistemas/satcfe | satcfe/resposta/padrao.py | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L175-L268 | def analisar_retorno(retorno,
classe_resposta=RespostaSAT, campos=RespostaSAT.CAMPOS,
campos_alternativos=[], funcao=None, manter_verbatim=True):
"""Analisa o retorno (supostamente um retorno de uma função do SAT) conforme
o padrão e campos esperados. O retorno deverá possuir dados separados ent... | [
"def",
"analisar_retorno",
"(",
"retorno",
",",
"classe_resposta",
"=",
"RespostaSAT",
",",
"campos",
"=",
"RespostaSAT",
".",
"CAMPOS",
",",
"campos_alternativos",
"=",
"[",
"]",
",",
"funcao",
"=",
"None",
",",
"manter_verbatim",
"=",
"True",
")",
":",
"if... | Analisa o retorno (supostamente um retorno de uma função do SAT) conforme
o padrão e campos esperados. O retorno deverá possuir dados separados entre
si através de pipes e o número de campos deverá coincidir com os campos
especificados.
O campos devem ser especificados como uma tupla onde cada elemento... | [
"Analisa",
"o",
"retorno",
"(",
"supostamente",
"um",
"retorno",
"de",
"uma",
"função",
"do",
"SAT",
")",
"conforme",
"o",
"padrão",
"e",
"campos",
"esperados",
".",
"O",
"retorno",
"deverá",
"possuir",
"dados",
"separados",
"entre",
"si",
"através",
"de",
... | python | train | 38.617021 |
Telefonica/toolium | toolium/utils.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/utils.py#L358-L367 | def wait_until_element_clickable(self, element, timeout=None):
"""Search element and wait until it is clickable
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param timeout: max time to wait
:returns: the web element if it is clickab... | [
"def",
"wait_until_element_clickable",
"(",
"self",
",",
"element",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_wait_until",
"(",
"self",
".",
"_expected_condition_find_element_clickable",
",",
"element",
",",
"timeout",
")"
] | Search element and wait until it is clickable
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param timeout: max time to wait
:returns: the web element if it is clickable
:rtype: selenium.webdriver.remote.webelement.WebElement or appi... | [
"Search",
"element",
"and",
"wait",
"until",
"it",
"is",
"clickable"
] | python | train | 61.4 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/reftrackitemdata.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/reftrackitemdata.py#L22-L36 | def reftrack_type_data(rt, role):
"""Return the data for the type (e.g. Asset, Alembic, Camera etc)
:param rt: the :class:`jukeboxcore.reftrack.Reftrack` holds the data
:type rt: :class:`jukeboxcore.reftrack.Reftrack`
:param role: item data role
:type role: QtCore.Qt.ItemDataRole
:returns: data... | [
"def",
"reftrack_type_data",
"(",
"rt",
",",
"role",
")",
":",
"if",
"role",
"==",
"QtCore",
".",
"Qt",
".",
"DisplayRole",
"or",
"role",
"==",
"QtCore",
".",
"Qt",
".",
"EditRole",
":",
"return",
"rt",
".",
"get_typ",
"(",
")",
"elif",
"role",
"==",... | Return the data for the type (e.g. Asset, Alembic, Camera etc)
:param rt: the :class:`jukeboxcore.reftrack.Reftrack` holds the data
:type rt: :class:`jukeboxcore.reftrack.Reftrack`
:param role: item data role
:type role: QtCore.Qt.ItemDataRole
:returns: data for the type
:rtype: depending on ro... | [
"Return",
"the",
"data",
"for",
"the",
"type",
"(",
"e",
".",
"g",
".",
"Asset",
"Alembic",
"Camera",
"etc",
")"
] | python | train | 36.466667 |
nephila/python-taiga | taiga/models/models.py | https://github.com/nephila/python-taiga/blob/5b471d6b8b59e5d410162a6f1c2f0d4188445a56/taiga/models/models.py#L1362-L1369 | def add_priority(self, name, **attrs):
"""
Add a Priority to the project and returns a :class:`Priority` object.
:param name: name of the :class:`Priority`
:param attrs: optional attributes for :class:`Priority`
"""
return Priorities(self.requester).create(self.id, name,... | [
"def",
"add_priority",
"(",
"self",
",",
"name",
",",
"*",
"*",
"attrs",
")",
":",
"return",
"Priorities",
"(",
"self",
".",
"requester",
")",
".",
"create",
"(",
"self",
".",
"id",
",",
"name",
",",
"*",
"*",
"attrs",
")"
] | Add a Priority to the project and returns a :class:`Priority` object.
:param name: name of the :class:`Priority`
:param attrs: optional attributes for :class:`Priority` | [
"Add",
"a",
"Priority",
"to",
"the",
"project",
"and",
"returns",
"a",
":",
"class",
":",
"Priority",
"object",
"."
] | python | train | 40.25 |
minhhoit/yacms | yacms/conf/forms.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L52-L72 | def _init_field(self, setting, field_class, name, code=None):
"""
Initialize a field whether it is built with a custom name for a
specific translation language or not.
"""
kwargs = {
"label": setting["label"] + ":",
"required": setting["type"] in (int, flo... | [
"def",
"_init_field",
"(",
"self",
",",
"setting",
",",
"field_class",
",",
"name",
",",
"code",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"\"label\"",
":",
"setting",
"[",
"\"label\"",
"]",
"+",
"\":\"",
",",
"\"required\"",
":",
"setting",
"[",
"\"t... | Initialize a field whether it is built with a custom name for a
specific translation language or not. | [
"Initialize",
"a",
"field",
"whether",
"it",
"is",
"built",
"with",
"a",
"custom",
"name",
"for",
"a",
"specific",
"translation",
"language",
"or",
"not",
"."
] | python | train | 43.714286 |
opencobra/cobrapy | cobra/flux_analysis/phenotype_phase_plane.py | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L22-L130 | def production_envelope(model, reactions, objective=None, carbon_sources=None,
points=20, threshold=None):
"""Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
... | [
"def",
"production_envelope",
"(",
"model",
",",
"reactions",
",",
"objective",
"=",
"None",
",",
"carbon_sources",
"=",
"None",
",",
"points",
"=",
"20",
",",
"threshold",
"=",
"None",
")",
":",
"reactions",
"=",
"model",
".",
"reactions",
".",
"get_by_an... | Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
produce a given compound conditional on the fluxes for another set of
reactions, such as the uptake rates. The model is alternately o... | [
"Calculate",
"the",
"objective",
"value",
"conditioned",
"on",
"all",
"combinations",
"of",
"fluxes",
"for",
"a",
"set",
"of",
"chosen",
"reactions"
] | python | valid | 40.678899 |
aliyun/aliyun-odps-python-sdk | odps/df/expr/reduction.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/df/expr/reduction.py#L671-L687 | def cat(expr, others=None, sep=None, na_rep=None):
"""
Concatenate strings in sequence with given separator
:param expr:
:param others: other sequences
:param sep: string or None, default None
:param na_rep: string or None default None, if None, NA in the sequence are ignored
:return:
"... | [
"def",
"cat",
"(",
"expr",
",",
"others",
"=",
"None",
",",
"sep",
"=",
"None",
",",
"na_rep",
"=",
"None",
")",
":",
"if",
"others",
"is",
"not",
"None",
":",
"from",
".",
"strings",
"import",
"_cat",
"as",
"cat_str",
"return",
"cat_str",
"(",
"ex... | Concatenate strings in sequence with given separator
:param expr:
:param others: other sequences
:param sep: string or None, default None
:param na_rep: string or None default None, if None, NA in the sequence are ignored
:return: | [
"Concatenate",
"strings",
"in",
"sequence",
"with",
"given",
"separator"
] | python | train | 28.705882 |
atztogo/phonopy | phonopy/structure/spglib.py | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L562-L631 | def get_stabilized_reciprocal_mesh(mesh,
rotations,
is_shift=None,
is_time_reversal=True,
qpoints=None,
is_dense=False):
"""Return k-point ma... | [
"def",
"get_stabilized_reciprocal_mesh",
"(",
"mesh",
",",
"rotations",
",",
"is_shift",
"=",
"None",
",",
"is_time_reversal",
"=",
"True",
",",
"qpoints",
"=",
"None",
",",
"is_dense",
"=",
"False",
")",
":",
"_set_no_error",
"(",
")",
"if",
"is_dense",
":"... | Return k-point map to the irreducible k-points and k-point grid points.
The symmetry is searched from the input rotation matrices in real space.
Parameters
----------
mesh : array_like
Uniform sampling mesh numbers.
dtype='intc', shape=(3,)
rotations : array_like
Rotation m... | [
"Return",
"k",
"-",
"point",
"map",
"to",
"the",
"irreducible",
"k",
"-",
"points",
"and",
"k",
"-",
"point",
"grid",
"points",
"."
] | python | train | 34.814286 |
mikedh/trimesh | examples/widget.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/examples/widget.py#L21-L70 | def create_scene():
"""
Create a scene with a Fuze bottle, some cubes, and an axis.
Returns
----------
scene : trimesh.Scene
Object with geometry
"""
scene = trimesh.Scene()
# plane
geom = trimesh.creation.box((0.5, 0.5, 0.01))
geom.apply_translation((0, 0, -0.005))
g... | [
"def",
"create_scene",
"(",
")",
":",
"scene",
"=",
"trimesh",
".",
"Scene",
"(",
")",
"# plane",
"geom",
"=",
"trimesh",
".",
"creation",
".",
"box",
"(",
"(",
"0.5",
",",
"0.5",
",",
"0.01",
")",
")",
"geom",
".",
"apply_translation",
"(",
"(",
"... | Create a scene with a Fuze bottle, some cubes, and an axis.
Returns
----------
scene : trimesh.Scene
Object with geometry | [
"Create",
"a",
"scene",
"with",
"a",
"Fuze",
"bottle",
"some",
"cubes",
"and",
"an",
"axis",
"."
] | python | train | 28.32 |
gccxml/pygccxml | pygccxml/parser/project_reader.py | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L373-L417 | def read_xml(self, file_configuration):
"""parses C++ code, defined on the file_configurations and returns
GCCXML generated file content"""
xml_file_path = None
delete_xml_file = True
fc = file_configuration
reader = source_reader.source_reader_t(
self.__conf... | [
"def",
"read_xml",
"(",
"self",
",",
"file_configuration",
")",
":",
"xml_file_path",
"=",
"None",
"delete_xml_file",
"=",
"True",
"fc",
"=",
"file_configuration",
"reader",
"=",
"source_reader",
".",
"source_reader_t",
"(",
"self",
".",
"__config",
",",
"None",... | parses C++ code, defined on the file_configurations and returns
GCCXML generated file content | [
"parses",
"C",
"++",
"code",
"defined",
"on",
"the",
"file_configurations",
"and",
"returns",
"GCCXML",
"generated",
"file",
"content"
] | python | train | 46.711111 |
dslackw/slpkg | slpkg/binary/greps.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/binary/greps.py#L33-L75 | def repo_data(PACKAGES_TXT, repo, flag):
"""Grap data packages
"""
(name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8))
for line in PACKAGES_TXT.splitlines():
if _meta_.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
status(0.000005... | [
"def",
"repo_data",
"(",
"PACKAGES_TXT",
",",
"repo",
",",
"flag",
")",
":",
"(",
"name",
",",
"location",
",",
"size",
",",
"unsize",
",",
"rname",
",",
"rlocation",
",",
"rsize",
",",
"runsize",
")",
"=",
"(",
"[",
"]",
"for",
"i",
"in",
"range",... | Grap data packages | [
"Grap",
"data",
"packages"
] | python | train | 32.581395 |
aquatix/ns-api | ns_api.py | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L776-L792 | def parse_departures(self, xml):
"""
Parse the NS API xml result into Departure objects
@param xml: raw XML result from the NS API
"""
obj = xmltodict.parse(xml)
departures = []
for departure in obj['ActueleVertrekTijden']['VertrekkendeTrein']:
newdep... | [
"def",
"parse_departures",
"(",
"self",
",",
"xml",
")",
":",
"obj",
"=",
"xmltodict",
".",
"parse",
"(",
"xml",
")",
"departures",
"=",
"[",
"]",
"for",
"departure",
"in",
"obj",
"[",
"'ActueleVertrekTijden'",
"]",
"[",
"'VertrekkendeTrein'",
"]",
":",
... | Parse the NS API xml result into Departure objects
@param xml: raw XML result from the NS API | [
"Parse",
"the",
"NS",
"API",
"xml",
"result",
"into",
"Departure",
"objects"
] | python | train | 31.117647 |
google/grr | grr/core/grr_response_core/lib/parsers/config_file.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L128-L138 | def GenFwdState(self):
"""Generates forwarding state rules.
The lexer will fast forward until there is string content. The
string content will be returned to the string processor.
"""
for c in self.cont:
self._AddToken("FWD", c, None, None)
for s in self.sep:
self._AddToken("FWD", s... | [
"def",
"GenFwdState",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"cont",
":",
"self",
".",
"_AddToken",
"(",
"\"FWD\"",
",",
"c",
",",
"None",
",",
"None",
")",
"for",
"s",
"in",
"self",
".",
"sep",
":",
"self",
".",
"_AddToken",
"(",
... | Generates forwarding state rules.
The lexer will fast forward until there is string content. The
string content will be returned to the string processor. | [
"Generates",
"forwarding",
"state",
"rules",
"."
] | python | train | 34.636364 |
SatelliteQE/nailgun | nailgun/entities.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L1152-L1176 | def read(self, entity=None, attrs=None, ignore=None, params=None):
"""Do extra work to fetch a complete set of attributes for this entity.
For more information, see `Bugzilla #1223540
<https://bugzilla.redhat.com/show_bug.cgi?id=1223540>`_.
Also, do not try to read the "password" field... | [
"def",
"read",
"(",
"self",
",",
"entity",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"ignore",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"attrs",
"is",
"None",
":",
"attrs",
"=",
"self",
".",
"read_json",
"(",
")",
"if",
"ignore... | Do extra work to fetch a complete set of attributes for this entity.
For more information, see `Bugzilla #1223540
<https://bugzilla.redhat.com/show_bug.cgi?id=1223540>`_.
Also, do not try to read the "password" field. No value is returned for
the field, for obvious reasons. | [
"Do",
"extra",
"work",
"to",
"fetch",
"a",
"complete",
"set",
"of",
"attributes",
"for",
"this",
"entity",
"."
] | python | train | 37.64 |
log2timeline/plaso | plaso/multi_processing/engine.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/multi_processing/engine.py#L393-L398 | def _StopStatusUpdateThread(self):
"""Stops the status update thread."""
self._status_update_active = False
if self._status_update_thread.isAlive():
self._status_update_thread.join()
self._status_update_thread = None | [
"def",
"_StopStatusUpdateThread",
"(",
"self",
")",
":",
"self",
".",
"_status_update_active",
"=",
"False",
"if",
"self",
".",
"_status_update_thread",
".",
"isAlive",
"(",
")",
":",
"self",
".",
"_status_update_thread",
".",
"join",
"(",
")",
"self",
".",
... | Stops the status update thread. | [
"Stops",
"the",
"status",
"update",
"thread",
"."
] | python | train | 38.833333 |
pantsbuild/pants | src/python/pants/backend/jvm/ivy_utils.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/ivy_utils.py#L652-L683 | def get_resolved_jars_for_coordinates(self, coordinates, memo=None):
"""Collects jars for the passed coordinates.
Because artifacts are only fetched for the "winning" version of a module, the artifacts
will not always represent the version originally declared by the library.
This method is transitive ... | [
"def",
"get_resolved_jars_for_coordinates",
"(",
"self",
",",
"coordinates",
",",
"memo",
"=",
"None",
")",
":",
"def",
"to_resolved_jar",
"(",
"jar_ref",
",",
"jar_path",
")",
":",
"return",
"ResolvedJar",
"(",
"coordinate",
"=",
"M2Coordinate",
"(",
"org",
"... | Collects jars for the passed coordinates.
Because artifacts are only fetched for the "winning" version of a module, the artifacts
will not always represent the version originally declared by the library.
This method is transitive within the passed coordinates dependencies.
:param coordinates collecti... | [
"Collects",
"jars",
"for",
"the",
"passed",
"coordinates",
"."
] | python | train | 54.03125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.