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 |
|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-python | azure-servicebus/azure/servicebus/aio/async_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_client.py#L323-L368 | def get_sender(self, message_timeout=0, session=None, **kwargs):
"""Get a Sender for the Service Bus endpoint.
A Sender represents a single open connection within which multiple send operations can be made.
:param message_timeout: The period in seconds during which messages sent with
... | [
"def",
"get_sender",
"(",
"self",
",",
"message_timeout",
"=",
"0",
",",
"session",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"handler_id",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"if",
"self",
".",
"entity",
"and",
"self",
".",... | Get a Sender for the Service Bus endpoint.
A Sender represents a single open connection within which multiple send operations can be made.
:param message_timeout: The period in seconds during which messages sent with
this Sender must be sent. If the send is not completed in this time it will ... | [
"Get",
"a",
"Sender",
"for",
"the",
"Service",
"Bus",
"endpoint",
"."
] | python | test | 42.326087 |
ismms-himc/clustergrammer2 | clustergrammer2/clustergrammer_fun/cat_pval.py | https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/cat_pval.py#L5-L54 | def main(net):
'''
calculate pvalue of category closeness
'''
# calculate the distance between the data points within the same category and
# compare to null distribution
for inst_rc in ['row', 'col']:
inst_nodes = deepcopy(net.dat['nodes'][inst_rc])
inst_index = deepcopy(net.dat['node_info'][inst... | [
"def",
"main",
"(",
"net",
")",
":",
"# calculate the distance between the data points within the same category and",
"# compare to null distribution",
"for",
"inst_rc",
"in",
"[",
"'row'",
",",
"'col'",
"]",
":",
"inst_nodes",
"=",
"deepcopy",
"(",
"net",
".",
"dat",
... | calculate pvalue of category closeness | [
"calculate",
"pvalue",
"of",
"category",
"closeness"
] | python | train | 26.42 |
gregarmer/trunserver | trunserv/autoreload.py | https://github.com/gregarmer/trunserver/blob/80906fa5331f4a35260f35c0082cf4dd299543ea/trunserv/autoreload.py#L71-L82 | def reloader_thread(softexit=False):
"""If ``soft_exit`` is True, we use sys.exit(); otherwise ``os_exit``
will be used to end the process.
"""
while RUN_RELOADER:
if code_changed():
# force reload
if softexit:
sys.exit(3)
else:
... | [
"def",
"reloader_thread",
"(",
"softexit",
"=",
"False",
")",
":",
"while",
"RUN_RELOADER",
":",
"if",
"code_changed",
"(",
")",
":",
"# force reload",
"if",
"softexit",
":",
"sys",
".",
"exit",
"(",
"3",
")",
"else",
":",
"os",
".",
"_exit",
"(",
"3",... | If ``soft_exit`` is True, we use sys.exit(); otherwise ``os_exit``
will be used to end the process. | [
"If",
"soft_exit",
"is",
"True",
"we",
"use",
"sys",
".",
"exit",
"()",
";",
"otherwise",
"os_exit",
"will",
"be",
"used",
"to",
"end",
"the",
"process",
"."
] | python | train | 28.583333 |
dcos/shakedown | shakedown/cli/helpers.py | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/helpers.py#L75-L121 | def banner():
""" Display a product banner
:return: a delightful Mesosphere logo rendered in unicode
:rtype: str
"""
banner_dict = {
'a0': click.style(chr(9601), fg='magenta'),
'a1': click.style(chr(9601), fg='magenta', bold=True),
'b0': click.style(chr(9616), fg='m... | [
"def",
"banner",
"(",
")",
":",
"banner_dict",
"=",
"{",
"'a0'",
":",
"click",
".",
"style",
"(",
"chr",
"(",
"9601",
")",
",",
"fg",
"=",
"'magenta'",
")",
",",
"'a1'",
":",
"click",
".",
"style",
"(",
"chr",
"(",
"9601",
")",
",",
"fg",
"=",
... | Display a product banner
:return: a delightful Mesosphere logo rendered in unicode
:rtype: str | [
"Display",
"a",
"product",
"banner"
] | python | train | 54.744681 |
DataONEorg/d1_python | dev_tools/src/d1_dev/src-print-redbaron-tree.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-print-redbaron-tree.py#L27-L36 | def main():
"""Print the RedBaron syntax tree for a Python module."""
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("path", help="Python module path")
args = parser.parse_args()
r = d1_dev.util.redbaron_... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
"\"path\"",
",",
"help",
"... | Print the RedBaron syntax tree for a Python module. | [
"Print",
"the",
"RedBaron",
"syntax",
"tree",
"for",
"a",
"Python",
"module",
"."
] | python | train | 36.5 |
oseledets/ttpy | tt/ksl/ksl.py | https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/ksl/ksl.py#L126-L231 | def diag_ksl(A, y0, tau, verb=1, scheme='symm', space=8, rmax=2000):
""" Dynamical tensor-train approximation based on projector splitting
This function performs one step of dynamical tensor-train approximation with diagonal matrix, i.e. it solves the equation
for the equation
.. math ::
... | [
"def",
"diag_ksl",
"(",
"A",
",",
"y0",
",",
"tau",
",",
"verb",
"=",
"1",
",",
"scheme",
"=",
"'symm'",
",",
"space",
"=",
"8",
",",
"rmax",
"=",
"2000",
")",
":",
"y0",
"=",
"y0",
".",
"round",
"(",
"1e-14",
")",
"# This will fix ranks",
"# to ... | Dynamical tensor-train approximation based on projector splitting
This function performs one step of dynamical tensor-train approximation with diagonal matrix, i.e. it solves the equation
for the equation
.. math ::
\\frac{dy}{dt} = V y, \\quad y(0) = y_0
and outputs approx... | [
"Dynamical",
"tensor",
"-",
"train",
"approximation",
"based",
"on",
"projector",
"splitting",
"This",
"function",
"performs",
"one",
"step",
"of",
"dynamical",
"tensor",
"-",
"train",
"approximation",
"with",
"diagonal",
"matrix",
"i",
".",
"e",
".",
"it",
"s... | python | train | 29.254717 |
saltstack/salt | salt/utils/gitfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1327-L1368 | def find_file(self, path, tgt_env):
'''
Find the specified file in the specified environment
'''
tree = self.get_tree(tgt_env)
if not tree:
# Branch/tag/SHA not found in repo
return None, None, None
blob = None
depth = 0
while True:... | [
"def",
"find_file",
"(",
"self",
",",
"path",
",",
"tgt_env",
")",
":",
"tree",
"=",
"self",
".",
"get_tree",
"(",
"tgt_env",
")",
"if",
"not",
"tree",
":",
"# Branch/tag/SHA not found in repo",
"return",
"None",
",",
"None",
",",
"None",
"blob",
"=",
"N... | Find the specified file in the specified environment | [
"Find",
"the",
"specified",
"file",
"in",
"the",
"specified",
"environment"
] | python | train | 38.261905 |
KelSolaar/Umbra | umbra/components/factory/components_manager_ui/models.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/components_manager_ui/models.py#L60-L76 | def initialize_model(self, root_node):
"""
Initializes the Model using given root node.
:param root_node: Graph root node.
:type root_node: DefaultNode
:return: Method success
:rtype: bool
"""
LOGGER.debug("> Initializing model with '{0}' root node.".for... | [
"def",
"initialize_model",
"(",
"self",
",",
"root_node",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Initializing model with '{0}' root node.\"",
".",
"format",
"(",
"root_node",
")",
")",
"self",
".",
"beginResetModel",
"(",
")",
"self",
".",
"root_node",
"=",... | Initializes the Model using given root node.
:param root_node: Graph root node.
:type root_node: DefaultNode
:return: Method success
:rtype: bool | [
"Initializes",
"the",
"Model",
"using",
"given",
"root",
"node",
"."
] | python | train | 28 |
ralphbean/bugwarrior | bugwarrior/config.py | https://github.com/ralphbean/bugwarrior/blob/b2a5108f7b40cb0c437509b64eaa28f941f7ac8b/bugwarrior/config.py#L52-L95 | def get_service_password(service, username, oracle=None, interactive=False):
"""
Retrieve the sensitive password for a service by:
* retrieving password from a secure store (@oracle:use_keyring, default)
* asking the password from the user (@oracle:ask_password, interactive)
* executing a com... | [
"def",
"get_service_password",
"(",
"service",
",",
"username",
",",
"oracle",
"=",
"None",
",",
"interactive",
"=",
"False",
")",
":",
"import",
"getpass",
"password",
"=",
"None",
"if",
"not",
"oracle",
"or",
"oracle",
"==",
"\"@oracle:use_keyring\"",
":",
... | Retrieve the sensitive password for a service by:
* retrieving password from a secure store (@oracle:use_keyring, default)
* asking the password from the user (@oracle:ask_password, interactive)
* executing a command and use the output as password
(@oracle:eval:<command>)
Note that the k... | [
"Retrieve",
"the",
"sensitive",
"password",
"for",
"a",
"service",
"by",
":"
] | python | test | 40.840909 |
RudolfCardinal/pythonlib | cardinal_pythonlib/deform_utils.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/deform_utils.py#L178-L198 | def debug_validator(validator: ValidatorType) -> ValidatorType:
"""
Use as a wrapper around a validator, e.g.
.. code-block:: python
self.validator = debug_validator(OneOf(["some", "values"]))
If you do this, the log will show the thinking of the validator (what it's
trying to validate, a... | [
"def",
"debug_validator",
"(",
"validator",
":",
"ValidatorType",
")",
"->",
"ValidatorType",
":",
"def",
"_validate",
"(",
"node",
":",
"SchemaNode",
",",
"value",
":",
"Any",
")",
"->",
"None",
":",
"log",
".",
"debug",
"(",
"\"Validating: {!r}\"",
",",
... | Use as a wrapper around a validator, e.g.
.. code-block:: python
self.validator = debug_validator(OneOf(["some", "values"]))
If you do this, the log will show the thinking of the validator (what it's
trying to validate, and whether it accepted or rejected the value). | [
"Use",
"as",
"a",
"wrapper",
"around",
"a",
"validator",
"e",
".",
"g",
"."
] | python | train | 30.666667 |
Microsoft/nni | tools/nni_cmd/launcher.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L343-L492 | def launch_experiment(args, experiment_config, mode, config_file_name, experiment_id=None):
'''follow steps to start rest server and start experiment'''
nni_config = Config(config_file_name)
# check packages for tuner
if experiment_config.get('tuner') and experiment_config['tuner'].get('builtinTunerName... | [
"def",
"launch_experiment",
"(",
"args",
",",
"experiment_config",
",",
"mode",
",",
"config_file_name",
",",
"experiment_id",
"=",
"None",
")",
":",
"nni_config",
"=",
"Config",
"(",
"config_file_name",
")",
"# check packages for tuner",
"if",
"experiment_config",
... | follow steps to start rest server and start experiment | [
"follow",
"steps",
"to",
"start",
"rest",
"server",
"and",
"start",
"experiment"
] | python | train | 44.413333 |
goldsmith/Wikipedia | wikipedia/wikipedia.py | https://github.com/goldsmith/Wikipedia/blob/2065c568502b19b8634241b47fd96930d1bf948d/wikipedia/wikipedia.py#L619-L633 | def categories(self):
'''
List of categories of a page.
'''
if not getattr(self, '_categories', False):
self._categories = [re.sub(r'^Category:', '', x) for x in
[link['title']
for link in self.__continued_query({
'prop': 'categories',
'cllimit': 'max'
... | [
"def",
"categories",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"'_categories'",
",",
"False",
")",
":",
"self",
".",
"_categories",
"=",
"[",
"re",
".",
"sub",
"(",
"r'^Category:'",
",",
"''",
",",
"x",
")",
"for",
"x",
"in",... | List of categories of a page. | [
"List",
"of",
"categories",
"of",
"a",
"page",
"."
] | python | train | 23.066667 |
skggm/skggm | inverse_covariance/model_average.py | https://github.com/skggm/skggm/blob/a0ed406586c4364ea3297a658f415e13b5cbdaf8/inverse_covariance/model_average.py#L46-L66 | def _fix_weights(weight_fun, *args):
"""Ensure random weight matrix is valid.
TODO: The diagonally dominant tuning currently doesn't make sense.
Our weight matrix has zeros along the diagonal, so multiplying by
a diagonal matrix results in a zero-matrix.
"""
weights = weight_fun(... | [
"def",
"_fix_weights",
"(",
"weight_fun",
",",
"*",
"args",
")",
":",
"weights",
"=",
"weight_fun",
"(",
"*",
"args",
")",
"# TODO: fix this",
"# disable checks for now",
"return",
"weights",
"# if positive semidefinite, then we're good as is",
"if",
"_check_psd",
"(",
... | Ensure random weight matrix is valid.
TODO: The diagonally dominant tuning currently doesn't make sense.
Our weight matrix has zeros along the diagonal, so multiplying by
a diagonal matrix results in a zero-matrix. | [
"Ensure",
"random",
"weight",
"matrix",
"is",
"valid",
"."
] | python | train | 33.047619 |
ThreatConnect-Inc/tcex | tcex/tcex.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L891-L906 | def safe_indicator(self, indicator, errors='strict'):
"""Indicator encode value for safe HTTP request.
Args:
indicator (string): Indicator to URL Encode
errors (string): The error handler type.
Returns:
(string): The urlencoded string
"""
if ... | [
"def",
"safe_indicator",
"(",
"self",
",",
"indicator",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"indicator",
"is",
"not",
"None",
":",
"try",
":",
"indicator",
"=",
"quote",
"(",
"self",
".",
"s",
"(",
"str",
"(",
"indicator",
")",
",",
"erro... | Indicator encode value for safe HTTP request.
Args:
indicator (string): Indicator to URL Encode
errors (string): The error handler type.
Returns:
(string): The urlencoded string | [
"Indicator",
"encode",
"value",
"for",
"safe",
"HTTP",
"request",
"."
] | python | train | 33.9375 |
mitsei/dlkit | dlkit/json_/osid/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/sessions.py#L344-L349 | def _effective_view_filter(self):
"""Returns the mongodb relationship filter for effective views"""
if self._effective_view == EFFECTIVE:
now = datetime.datetime.utcnow()
return {'startDate': {'$$lte': now}, 'endDate': {'$$gte': now}}
return {} | [
"def",
"_effective_view_filter",
"(",
"self",
")",
":",
"if",
"self",
".",
"_effective_view",
"==",
"EFFECTIVE",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"return",
"{",
"'startDate'",
":",
"{",
"'$$lte'",
":",
"now",
"}",
",... | Returns the mongodb relationship filter for effective views | [
"Returns",
"the",
"mongodb",
"relationship",
"filter",
"for",
"effective",
"views"
] | python | train | 47.833333 |
zeromake/aiko | aiko/application.py | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L143-L162 | def run(self, host: str = "0.0.0.0", port: int = 5000) -> None:
"""
debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000``
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
listen = ... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"\"0.0.0.0\"",
",",
"port",
":",
"int",
"=",
"5000",
")",
"->",
"None",
":",
"loop",
"=",
"cast",
"(",
"asyncio",
".",
"AbstractEventLoop",
",",
"self",
".",
"_loop",
")",
"listen",
"=",
"sel... | debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000`` | [
"debug",
"run",
":",
"param",
"host",
":",
"the",
"hostname",
"to",
"listen",
"on",
"default",
"is",
"0",
".",
"0",
".",
"0",
".",
"0",
":",
"param",
"port",
":",
"the",
"port",
"of",
"the",
"server",
"default",
"id",
"5000"
] | python | train | 33.25 |
botstory/botstory | botstory/ast/story_context/__init__.py | https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/__init__.py#L41-L49 | def could_scope_out(self):
"""
could bubble up from current scope
:return:
"""
return not self.waiting_for or \
isinstance(self.waiting_for, callable.EndOfStory) or \
self.is_breaking_a_loop() | [
"def",
"could_scope_out",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"waiting_for",
"or",
"isinstance",
"(",
"self",
".",
"waiting_for",
",",
"callable",
".",
"EndOfStory",
")",
"or",
"self",
".",
"is_breaking_a_loop",
"(",
")"
] | could bubble up from current scope
:return: | [
"could",
"bubble",
"up",
"from",
"current",
"scope"
] | python | train | 28.333333 |
divio/django-filer | filer/utils/compatibility.py | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/compatibility.py#L60-L66 | def upath(path):
"""
Always return a unicode path.
"""
if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding)
return path | [
"def",
"upath",
"(",
"path",
")",
":",
"if",
"six",
".",
"PY2",
"and",
"not",
"isinstance",
"(",
"path",
",",
"six",
".",
"text_type",
")",
":",
"return",
"path",
".",
"decode",
"(",
"fs_encoding",
")",
"return",
"path"
] | Always return a unicode path. | [
"Always",
"return",
"a",
"unicode",
"path",
"."
] | python | train | 24.571429 |
notanumber/xapian-haystack | xapian_backend.py | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L947-L959 | def _prepare_facet_field_spies(self, facets):
"""
Returns a list of spies based on the facets
used to count frequencies.
"""
spies = []
for facet in facets:
slot = self.column[facet]
spy = xapian.ValueCountMatchSpy(slot)
# add attribute... | [
"def",
"_prepare_facet_field_spies",
"(",
"self",
",",
"facets",
")",
":",
"spies",
"=",
"[",
"]",
"for",
"facet",
"in",
"facets",
":",
"slot",
"=",
"self",
".",
"column",
"[",
"facet",
"]",
"spy",
"=",
"xapian",
".",
"ValueCountMatchSpy",
"(",
"slot",
... | Returns a list of spies based on the facets
used to count frequencies. | [
"Returns",
"a",
"list",
"of",
"spies",
"based",
"on",
"the",
"facets",
"used",
"to",
"count",
"frequencies",
"."
] | python | train | 33.692308 |
datamachine/twx.botapi | twx/botapi/botapi.py | https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L4252-L4254 | def get_me(self, *args, **kwargs):
"""See :func:`get_me`"""
return get_me(*args, **self._merge_overrides(**kwargs)).run() | [
"def",
"get_me",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"get_me",
"(",
"*",
"args",
",",
"*",
"*",
"self",
".",
"_merge_overrides",
"(",
"*",
"*",
"kwargs",
")",
")",
".",
"run",
"(",
")"
] | See :func:`get_me` | [
"See",
":",
"func",
":",
"get_me"
] | python | train | 45 |
camptocamp/anthem | anthem/lyrics/records.py | https://github.com/camptocamp/anthem/blob/6800730764d31a2edced12049f823fefb367e9ad/anthem/lyrics/records.py#L31-L42 | def create_or_update(ctx, model, xmlid, values):
""" Create or update a record matching xmlid with values """
if isinstance(model, basestring):
model = ctx.env[model]
record = ctx.env.ref(xmlid, raise_if_not_found=False)
if record:
record.update(values)
else:
record = model.... | [
"def",
"create_or_update",
"(",
"ctx",
",",
"model",
",",
"xmlid",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"basestring",
")",
":",
"model",
"=",
"ctx",
".",
"env",
"[",
"model",
"]",
"record",
"=",
"ctx",
".",
"env",
".",
"r... | Create or update a record matching xmlid with values | [
"Create",
"or",
"update",
"a",
"record",
"matching",
"xmlid",
"with",
"values"
] | python | train | 31.583333 |
reingart/gui2py | gui/tools/inspector.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/tools/inspector.py#L200-L240 | def show_context_menu(self, item, mouse_pos=None):
"Open a popup menu with options regarding the selected object"
if item:
d = self.tree.GetItemData(item)
if d:
obj = d.GetData()
if obj:
# highligh and store the selected object:... | [
"def",
"show_context_menu",
"(",
"self",
",",
"item",
",",
"mouse_pos",
"=",
"None",
")",
":",
"if",
"item",
":",
"d",
"=",
"self",
".",
"tree",
".",
"GetItemData",
"(",
"item",
")",
"if",
"d",
":",
"obj",
"=",
"d",
".",
"GetData",
"(",
")",
"if"... | Open a popup menu with options regarding the selected object | [
"Open",
"a",
"popup",
"menu",
"with",
"options",
"regarding",
"the",
"selected",
"object"
] | python | test | 46.317073 |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L4089-L4106 | def _get_dvportgroup_out_shaping(pg_name, pg_default_port_config):
'''
Returns the out shaping policy of a distributed virtual portgroup
pg_name
The name of the portgroup
pg_default_port_config
The dafault port config of the portgroup
'''
log.trace('Retrieving portgroup\'s \'%s... | [
"def",
"_get_dvportgroup_out_shaping",
"(",
"pg_name",
",",
"pg_default_port_config",
")",
":",
"log",
".",
"trace",
"(",
"'Retrieving portgroup\\'s \\'%s\\' out shaping config'",
",",
"pg_name",
")",
"out_shaping_policy",
"=",
"pg_default_port_config",
".",
"outShapingPolicy... | Returns the out shaping policy of a distributed virtual portgroup
pg_name
The name of the portgroup
pg_default_port_config
The dafault port config of the portgroup | [
"Returns",
"the",
"out",
"shaping",
"policy",
"of",
"a",
"distributed",
"virtual",
"portgroup"
] | python | train | 39.666667 |
apache/incubator-mxnet | python/mxnet/module/base_module.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L671-L699 | def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True,
allow_extra=False):
"""Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to value (`NDArray`) mapping.
aux_params : ... | [
"def",
"set_params",
"(",
"self",
",",
"arg_params",
",",
"aux_params",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"True",
",",
"allow_extra",
"=",
"False",
")",
":",
"self",
".",
"init_params",
"(",
"initializer",
"=",
"None",
",",
"arg_p... | Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to value (`NDArray`) mapping.
aux_params : dict
Dictionary of name to value (`NDArray`) mapping.
allow_missing : bool
If ``True``, params could ... | [
"Assigns",
"parameter",
"and",
"aux",
"state",
"values",
"."
] | python | train | 47.793103 |
midasplatform/pydas | pydas/drivers.py | https://github.com/midasplatform/pydas/blob/e5f9e96e754fb2dc5da187b05e4abc77a9b2affd/pydas/drivers.py#L564-L579 | def folder_get(self, token, folder_id):
"""
Get the attributes of the specified folder.
:param token: A valid token for the user in question.
:type token: string
:param folder_id: The id of the requested folder.
:type folder_id: int | long
:returns: Dictionary of... | [
"def",
"folder_get",
"(",
"self",
",",
"token",
",",
"folder_id",
")",
":",
"parameters",
"=",
"dict",
"(",
")",
"parameters",
"[",
"'token'",
"]",
"=",
"token",
"parameters",
"[",
"'id'",
"]",
"=",
"folder_id",
"response",
"=",
"self",
".",
"request",
... | Get the attributes of the specified folder.
:param token: A valid token for the user in question.
:type token: string
:param folder_id: The id of the requested folder.
:type folder_id: int | long
:returns: Dictionary of the folder attributes.
:rtype: dict | [
"Get",
"the",
"attributes",
"of",
"the",
"specified",
"folder",
"."
] | python | valid | 34.375 |
sibirrer/lenstronomy | lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py#L31-L46 | def logL(self, kwargs_lens, kwargs_ps, kwargs_cosmo):
"""
routine to compute the log likelihood of the time delay distance
:param kwargs_lens: lens model kwargs list
:param kwargs_ps: point source kwargs list
:param kwargs_cosmo: cosmology and other kwargs
:return: log li... | [
"def",
"logL",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kwargs_cosmo",
")",
":",
"x_pos",
",",
"y_pos",
"=",
"self",
".",
"_pointSource",
".",
"image_position",
"(",
"kwargs_ps",
"=",
"kwargs_ps",
",",
"kwargs_lens",
"=",
"kwargs_lens",
")",
... | routine to compute the log likelihood of the time delay distance
:param kwargs_lens: lens model kwargs list
:param kwargs_ps: point source kwargs list
:param kwargs_cosmo: cosmology and other kwargs
:return: log likelihood of the model given the time delay data | [
"routine",
"to",
"compute",
"the",
"log",
"likelihood",
"of",
"the",
"time",
"delay",
"distance",
":",
"param",
"kwargs_lens",
":",
"lens",
"model",
"kwargs",
"list",
":",
"param",
"kwargs_ps",
":",
"point",
"source",
"kwargs",
"list",
":",
"param",
"kwargs_... | python | train | 60.375 |
pyros-dev/pyros-common | pyros_interfaces_common/basenode.py | https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/basenode.py#L270-L279 | def shutdown(self, join=True, timeout=None):
"""
Clean shutdown of the node.
:param join: optionally wait for the process to end (default : True)
:return: last exitcode from update method
"""
if self.interface is not None:
self.interface.stop()
return... | [
"def",
"shutdown",
"(",
"self",
",",
"join",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"interface",
"is",
"not",
"None",
":",
"self",
".",
"interface",
".",
"stop",
"(",
")",
"return",
"super",
"(",
"PyrosBase",
",",
"s... | Clean shutdown of the node.
:param join: optionally wait for the process to end (default : True)
:return: last exitcode from update method | [
"Clean",
"shutdown",
"of",
"the",
"node",
".",
":",
"param",
"join",
":",
"optionally",
"wait",
"for",
"the",
"process",
"to",
"end",
"(",
"default",
":",
"True",
")",
":",
"return",
":",
"last",
"exitcode",
"from",
"update",
"method"
] | python | train | 36.6 |
saltstack/salt | salt/modules/yumpkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L1158-L1720 | def install(name=None,
refresh=False,
skip_verify=False,
pkgs=None,
sources=None,
downloadonly=False,
reinstall=False,
normalize=True,
update_holds=False,
saltenv='base',
ignore_epoch=False,
... | [
"def",
"install",
"(",
"name",
"=",
"None",
",",
"refresh",
"=",
"False",
",",
"skip_verify",
"=",
"False",
",",
"pkgs",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"downloadonly",
"=",
"False",
",",
"reinstall",
"=",
"False",
",",
"normalize",
"=",... | .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
On minions running systemd>=205, `systemd-run(1)`_ is now used to
isolate commands which modify installed packages from the
``salt-minion`` daemon's control group. This is done to keep systemd
from killing any yum/dnf commands spawned by S... | [
"..",
"versionchanged",
"::",
"2015",
".",
"8",
".",
"12",
"2016",
".",
"3",
".",
"3",
"2016",
".",
"11",
".",
"0",
"On",
"minions",
"running",
"systemd",
">",
"=",
"205",
"systemd",
"-",
"run",
"(",
"1",
")",
"_",
"is",
"now",
"used",
"to",
"i... | python | train | 38.59325 |
usrlocalben/pydux | pydux/compose.py | https://github.com/usrlocalben/pydux/blob/943ca1c75357b9289f55f17ff2d997a66a3313a4/pydux/compose.py#L3-L26 | def compose(*funcs):
"""
chained function composition wrapper
creates function f, where f(x) = arg0(arg1(arg2(...argN(x))))
if *funcs is empty, an identity function is returned.
Args:
*funcs: list of functions to chain
Returns:
a new function composed of chained calls to ... | [
"def",
"compose",
"(",
"*",
"funcs",
")",
":",
"if",
"not",
"funcs",
":",
"return",
"lambda",
"*",
"args",
":",
"args",
"[",
"0",
"]",
"if",
"args",
"else",
"None",
"if",
"len",
"(",
"funcs",
")",
"==",
"1",
":",
"return",
"funcs",
"[",
"0",
"]... | chained function composition wrapper
creates function f, where f(x) = arg0(arg1(arg2(...argN(x))))
if *funcs is empty, an identity function is returned.
Args:
*funcs: list of functions to chain
Returns:
a new function composed of chained calls to *args | [
"chained",
"function",
"composition",
"wrapper"
] | python | train | 24.875 |
MacHu-GWU/windtalker-project | windtalker/asymmetric.py | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/asymmetric.py#L83-L100 | def encrypt_file(self,
path,
output_path=None,
overwrite=False,
enable_verbose=True):
"""
Encrypt a file using rsa.
RSA for big file encryption is very slow. For big file, I recommend
to use symmetric en... | [
"def",
"encrypt_file",
"(",
"self",
",",
"path",
",",
"output_path",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"enable_verbose",
"=",
"True",
")",
":",
"path",
",",
"output_path",
"=",
"files",
".",
"process_dst_overwrite_args",
"(",
"src",
"=",
"p... | Encrypt a file using rsa.
RSA for big file encryption is very slow. For big file, I recommend
to use symmetric encryption and use RSA to encrypt the password. | [
"Encrypt",
"a",
"file",
"using",
"rsa",
"."
] | python | train | 38.111111 |
israel-lugo/capidup | capidup/finddups.py | https://github.com/israel-lugo/capidup/blob/7524d04f6c7ca1e32b695e62d9894db2dc0e8705/capidup/finddups.py#L355-L438 | def find_duplicates_in_dirs(directories, exclude_dirs=None, exclude_files=None,
follow_dirlinks=False):
"""Recursively scan a list of directories, looking for duplicate files.
`exclude_dirs`, if provided, should be a list of glob patterns.
Subdirectories whose names match these patterns are exclude... | [
"def",
"find_duplicates_in_dirs",
"(",
"directories",
",",
"exclude_dirs",
"=",
"None",
",",
"exclude_files",
"=",
"None",
",",
"follow_dirlinks",
"=",
"False",
")",
":",
"if",
"exclude_dirs",
"is",
"None",
":",
"exclude_dirs",
"=",
"[",
"]",
"if",
"exclude_fi... | Recursively scan a list of directories, looking for duplicate files.
`exclude_dirs`, if provided, should be a list of glob patterns.
Subdirectories whose names match these patterns are excluded from the
scan.
`exclude_files`, if provided, should be a list of glob patterns. Files
whose names match ... | [
"Recursively",
"scan",
"a",
"list",
"of",
"directories",
"looking",
"for",
"duplicate",
"files",
"."
] | python | train | 41.047619 |
drericstrong/pyedna | pyedna/ezdna.py | https://github.com/drericstrong/pyedna/blob/b8f8f52def4f26bb4f3a993ce3400769518385f6/pyedna/ezdna.py#L559-L606 | def GetServices():
"""
Obtains all the connected eDNA services.
:return: A pandas DataFrame of connected eDNA services in the form [Name,
Description, Type, Status]
"""
# Define all required variables in the correct ctypes format
pulKey = c_ulong(0)
szType = c_char_p("".enc... | [
"def",
"GetServices",
"(",
")",
":",
"# Define all required variables in the correct ctypes format\r",
"pulKey",
"=",
"c_ulong",
"(",
"0",
")",
"szType",
"=",
"c_char_p",
"(",
"\"\"",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"szStartSvcName",
"=",
"c_char_p",
"(",... | Obtains all the connected eDNA services.
:return: A pandas DataFrame of connected eDNA services in the form [Name,
Description, Type, Status] | [
"Obtains",
"all",
"the",
"connected",
"eDNA",
"services",
".",
":",
"return",
":",
"A",
"pandas",
"DataFrame",
"of",
"connected",
"eDNA",
"services",
"in",
"the",
"form",
"[",
"Name",
"Description",
"Type",
"Status",
"]"
] | python | train | 46 |
Metatab/metapack | metapack/cli/metakan.py | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metakan.py#L403-L440 | def package_load_instructions(inst_distributions):
"""Load instructions, displayed in the package notes"""
per_package_inst = ''
for dist in inst_distributions:
if dist.type == 'zip':
per_package_inst += dedent(
"""
# Loading the ZIP Package
... | [
"def",
"package_load_instructions",
"(",
"inst_distributions",
")",
":",
"per_package_inst",
"=",
"''",
"for",
"dist",
"in",
"inst_distributions",
":",
"if",
"dist",
".",
"type",
"==",
"'zip'",
":",
"per_package_inst",
"+=",
"dedent",
"(",
"\"\"\"\n #... | Load instructions, displayed in the package notes | [
"Load",
"instructions",
"displayed",
"in",
"the",
"package",
"notes"
] | python | train | 29.052632 |
kerrickstaley/genanki | genanki/model.py | https://github.com/kerrickstaley/genanki/blob/624a9ffaf2f7868721cf7e7e55f53b238df9a04a/genanki/model.py#L27-L78 | def _req(self):
"""
List of required fields for each template. Format is [tmpl_idx, "all"|"any", [req_field_1, req_field_2, ...]].
Partial reimplementation of req computing logic from Anki. We use pystache instead of Anki's custom mustache
implementation.
The goal is to figure out which fields are... | [
"def",
"_req",
"(",
"self",
")",
":",
"sentinel",
"=",
"'SeNtInEl'",
"field_names",
"=",
"[",
"field",
"[",
"'name'",
"]",
"for",
"field",
"in",
"self",
".",
"fields",
"]",
"req",
"=",
"[",
"]",
"for",
"template_ord",
",",
"template",
"in",
"enumerate"... | List of required fields for each template. Format is [tmpl_idx, "all"|"any", [req_field_1, req_field_2, ...]].
Partial reimplementation of req computing logic from Anki. We use pystache instead of Anki's custom mustache
implementation.
The goal is to figure out which fields are "required", i.e. if they ar... | [
"List",
"of",
"required",
"fields",
"for",
"each",
"template",
".",
"Format",
"is",
"[",
"tmpl_idx",
"all",
"|",
"any",
"[",
"req_field_1",
"req_field_2",
"...",
"]]",
"."
] | python | train | 36.961538 |
rabitt/pysox | sox/transform.py | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L2710-L2751 | def stats(self, input_filepath):
'''Display time domain statistical information about the audio
channels. Audio is passed unmodified through the SoX processing chain.
Statistics are calculated and displayed for each audio channel
Unlike other Transformer methods, this does not modify th... | [
"def",
"stats",
"(",
"self",
",",
"input_filepath",
")",
":",
"effect_args",
"=",
"[",
"'channels'",
",",
"'1'",
",",
"'stats'",
"]",
"_",
",",
"_",
",",
"stats_output",
"=",
"self",
".",
"build",
"(",
"input_filepath",
",",
"None",
",",
"extra_args",
... | Display time domain statistical information about the audio
channels. Audio is passed unmodified through the SoX processing chain.
Statistics are calculated and displayed for each audio channel
Unlike other Transformer methods, this does not modify the transformer
effects chain. Instead... | [
"Display",
"time",
"domain",
"statistical",
"information",
"about",
"the",
"audio",
"channels",
".",
"Audio",
"is",
"passed",
"unmodified",
"through",
"the",
"SoX",
"processing",
"chain",
".",
"Statistics",
"are",
"calculated",
"and",
"displayed",
"for",
"each",
... | python | valid | 31.357143 |
Kortemme-Lab/klab | klab/bio/pdb.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb.py#L2115-L2234 | def GetRosettaResidueMap(self, ConvertMSEToAtom = False, RemoveIncompleteFinalResidues = False, RemoveIncompleteResidues = False):
'''Note: This function ignores any DNA.'''
raise Exception('This code looks to be deprecated. Use construct_pdb_to_rosetta_residue_map instead.')
chain = None
... | [
"def",
"GetRosettaResidueMap",
"(",
"self",
",",
"ConvertMSEToAtom",
"=",
"False",
",",
"RemoveIncompleteFinalResidues",
"=",
"False",
",",
"RemoveIncompleteResidues",
"=",
"False",
")",
":",
"raise",
"Exception",
"(",
"'This code looks to be deprecated. Use construct_pdb_t... | Note: This function ignores any DNA. | [
"Note",
":",
"This",
"function",
"ignores",
"any",
"DNA",
"."
] | python | train | 55.15 |
NoneGG/aredis | aredis/connection.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/connection.py#L651-L663 | async def on_connect(self):
"""
Initialize the connection, authenticate and select a database and send READONLY if it is
set during object initialization.
"""
if self.db:
warnings.warn('SELECT DB is not allowed in cluster mode')
self.db = ''
await ... | [
"async",
"def",
"on_connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"db",
":",
"warnings",
".",
"warn",
"(",
"'SELECT DB is not allowed in cluster mode'",
")",
"self",
".",
"db",
"=",
"''",
"await",
"super",
"(",
"ClusterConnection",
",",
"self",
")",
... | Initialize the connection, authenticate and select a database and send READONLY if it is
set during object initialization. | [
"Initialize",
"the",
"connection",
"authenticate",
"and",
"select",
"a",
"database",
"and",
"send",
"READONLY",
"if",
"it",
"is",
"set",
"during",
"object",
"initialization",
"."
] | python | train | 42.461538 |
lemieuxl/pyGenClean | pyGenClean/LaTeX/merge_reports.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/LaTeX/merge_reports.py#L196-L243 | def get_summary_files(dirnames):
"""Gets the TeX summary files for each test.
:param dirnames: the list of directories to merge data from.
:type dirnames: list
:returns: a list of summary file names.
:rtype: list
"""
# A useful regular expression to get step number in the current directo... | [
"def",
"get_summary_files",
"(",
"dirnames",
")",
":",
"# A useful regular expression to get step number in the current directory",
"step_nb_re",
"=",
"re",
".",
"compile",
"(",
"r\"^([0-9]+)_\\S+\"",
")",
"# The final list of summary files",
"final_summary_files",
"=",
"[",
"]... | Gets the TeX summary files for each test.
:param dirnames: the list of directories to merge data from.
:type dirnames: list
:returns: a list of summary file names.
:rtype: list | [
"Gets",
"the",
"TeX",
"summary",
"files",
"for",
"each",
"test",
"."
] | python | train | 31.291667 |
rwl/pylon | pylon/io/excel.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L66-L73 | def write_branch_data(self, file):
""" Writes branch data to an Excel spreadsheet.
"""
branch_sheet = self.book.add_sheet("Branches")
for i, branch in enumerate(self.case.branches):
for j, attr in enumerate(BRANCH_ATTRS):
branch_sheet.write(i, j, getattr(bran... | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
")",
":",
"branch_sheet",
"=",
"self",
".",
"book",
".",
"add_sheet",
"(",
"\"Branches\"",
")",
"for",
"i",
",",
"branch",
"in",
"enumerate",
"(",
"self",
".",
"case",
".",
"branches",
")",
":",
"fo... | Writes branch data to an Excel spreadsheet. | [
"Writes",
"branch",
"data",
"to",
"an",
"Excel",
"spreadsheet",
"."
] | python | train | 40.375 |
ianmiell/shutit | shutit_class.py | https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L2105-L2138 | def login(self,
command='su -',
user=None,
password=None,
prompt_prefix=None,
expect=None,
timeout=shutit_global.shutit_global_object.default_timeout,
escape=False,
echo=None,
note=None,
go_home=True,
... | [
"def",
"login",
"(",
"self",
",",
"command",
"=",
"'su -'",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"prompt_prefix",
"=",
"None",
",",
"expect",
"=",
"None",
",",
"timeout",
"=",
"shutit_global",
".",
"shutit_global_object",
".",
"de... | Logs user in on default child. | [
"Logs",
"user",
"in",
"on",
"default",
"child",
"."
] | python | train | 47.705882 |
librosa/librosa | librosa/core/harmonic.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/harmonic.py#L13-L104 | def salience(S, freqs, h_range, weights=None, aggregate=None,
filter_peaks=True, fill_value=np.nan, kind='linear', axis=0):
"""Harmonic salience function.
Parameters
----------
S : np.ndarray [shape=(d, n)]
input time frequency magnitude representation (stft, ifgram, etc).
... | [
"def",
"salience",
"(",
"S",
",",
"freqs",
",",
"h_range",
",",
"weights",
"=",
"None",
",",
"aggregate",
"=",
"None",
",",
"filter_peaks",
"=",
"True",
",",
"fill_value",
"=",
"np",
".",
"nan",
",",
"kind",
"=",
"'linear'",
",",
"axis",
"=",
"0",
... | Harmonic salience function.
Parameters
----------
S : np.ndarray [shape=(d, n)]
input time frequency magnitude representation (stft, ifgram, etc).
Must be real-valued and non-negative.
freqs : np.ndarray, shape=(S.shape[axis])
The frequency values corresponding to S's elements a... | [
"Harmonic",
"salience",
"function",
"."
] | python | test | 35.684783 |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L87-L91 | def do_forceescape(value):
"""Enforce HTML escaping. This will probably double escape variables."""
if hasattr(value, '__html__'):
value = value.__html__()
return escape(text_type(value)) | [
"def",
"do_forceescape",
"(",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__html__'",
")",
":",
"value",
"=",
"value",
".",
"__html__",
"(",
")",
"return",
"escape",
"(",
"text_type",
"(",
"value",
")",
")"
] | Enforce HTML escaping. This will probably double escape variables. | [
"Enforce",
"HTML",
"escaping",
".",
"This",
"will",
"probably",
"double",
"escape",
"variables",
"."
] | python | train | 40.8 |
saltstack/salt | salt/cloud/clouds/scaleway.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/scaleway.py#L127-L144 | def list_nodes_full(call=None):
''' Return a list of the BareMetal servers that are on the provider.
'''
if call == 'action':
raise SaltCloudSystemExit(
'list_nodes_full must be called with -f or --function'
)
items = query(method='servers')
# For each server, iterate o... | [
"def",
"list_nodes_full",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'list_nodes_full must be called with -f or --function'",
")",
"items",
"=",
"query",
"(",
"method",
"=",
"'servers'",
")",
"# F... | Return a list of the BareMetal servers that are on the provider. | [
"Return",
"a",
"list",
"of",
"the",
"BareMetal",
"servers",
"that",
"are",
"on",
"the",
"provider",
"."
] | python | train | 28.555556 |
skorch-dev/skorch | examples/nuclei_image_segmentation/dataset.py | https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/examples/nuclei_image_segmentation/dataset.py#L13-L22 | def calcuate_bboxes(im_shape, patch_size):
"""Calculate bound boxes based on image shape and size of the bounding box
given by `patch_size`"""
h, w = im_shape
ph, pw = patch_size
steps_h = chain(range(0, h - ph, ph), [h - ph])
steps_w = chain(range(0, w - pw, pw), [w - pw])
return product(... | [
"def",
"calcuate_bboxes",
"(",
"im_shape",
",",
"patch_size",
")",
":",
"h",
",",
"w",
"=",
"im_shape",
"ph",
",",
"pw",
"=",
"patch_size",
"steps_h",
"=",
"chain",
"(",
"range",
"(",
"0",
",",
"h",
"-",
"ph",
",",
"ph",
")",
",",
"[",
"h",
"-",
... | Calculate bound boxes based on image shape and size of the bounding box
given by `patch_size` | [
"Calculate",
"bound",
"boxes",
"based",
"on",
"image",
"shape",
"and",
"size",
"of",
"the",
"bounding",
"box",
"given",
"by",
"patch_size"
] | python | train | 32.8 |
bitesofcode/projexui | projexui/widgets/xnodewidget/xnode.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L667-L679 | def drawHotspots(self, painter):
"""
Draws all the hotspots for the renderer.
:param painter | <QPaint>
"""
# draw hotspots
for hotspot in (self._hotspots + self._dropzones):
hstyle = hotspot.style()
if hstyle == XNode.HotspotStyle.In... | [
"def",
"drawHotspots",
"(",
"self",
",",
"painter",
")",
":",
"# draw hotspots",
"for",
"hotspot",
"in",
"(",
"self",
".",
"_hotspots",
"+",
"self",
".",
"_dropzones",
")",
":",
"hstyle",
"=",
"hotspot",
".",
"style",
"(",
")",
"if",
"hstyle",
"==",
"X... | Draws all the hotspots for the renderer.
:param painter | <QPaint> | [
"Draws",
"all",
"the",
"hotspots",
"for",
"the",
"renderer",
".",
":",
"param",
"painter",
"|",
"<QPaint",
">"
] | python | train | 30.461538 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L284-L367 | def unpack(self, token):
"""
Unpack a received signed or signed and encrypted Json Web Token
:param token: The Json Web Token
:return: If decryption and signature verification work the payload
will be returned as a Message instance if possible.
"""
if not tok... | [
"def",
"unpack",
"(",
"self",
",",
"token",
")",
":",
"if",
"not",
"token",
":",
"raise",
"KeyError",
"_jwe_header",
"=",
"_jws_header",
"=",
"None",
"# Check if it's an encrypted JWT",
"darg",
"=",
"{",
"}",
"if",
"self",
".",
"allowed_enc_encs",
":",
"darg... | Unpack a received signed or signed and encrypted Json Web Token
:param token: The Json Web Token
:return: If decryption and signature verification work the payload
will be returned as a Message instance if possible. | [
"Unpack",
"a",
"received",
"signed",
"or",
"signed",
"and",
"encrypted",
"Json",
"Web",
"Token"
] | python | train | 33.369048 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L175-L188 | def translate_alias(self, alias, namespace=None, target_namespaces=None, translate_ncbi_namespace=None):
"""given an alias and optional namespace, return a list of all other
aliases for same sequence
"""
if translate_ncbi_namespace is None:
translate_ncbi_namespace = self.t... | [
"def",
"translate_alias",
"(",
"self",
",",
"alias",
",",
"namespace",
"=",
"None",
",",
"target_namespaces",
"=",
"None",
",",
"translate_ncbi_namespace",
"=",
"None",
")",
":",
"if",
"translate_ncbi_namespace",
"is",
"None",
":",
"translate_ncbi_namespace",
"=",... | given an alias and optional namespace, return a list of all other
aliases for same sequence | [
"given",
"an",
"alias",
"and",
"optional",
"namespace",
"return",
"a",
"list",
"of",
"all",
"other",
"aliases",
"for",
"same",
"sequence"
] | python | train | 49.642857 |
tmr232/Sark | sark/ui.py | https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/ui.py#L240-L257 | def _make_unique_title(self, title):
"""Make the title unique.
Adds a counter to the title to prevent duplicates.
Prior to IDA 6.8, two graphs with the same title could crash IDA.
This has been fixed (https://www.hex-rays.com/products/ida/6.8/index.shtml).
The code will not cha... | [
"def",
"_make_unique_title",
"(",
"self",
",",
"title",
")",
":",
"unique_title",
"=",
"title",
"for",
"counter",
"in",
"itertools",
".",
"count",
"(",
")",
":",
"unique_title",
"=",
"\"{}-{}\"",
".",
"format",
"(",
"title",
",",
"counter",
")",
"if",
"n... | Make the title unique.
Adds a counter to the title to prevent duplicates.
Prior to IDA 6.8, two graphs with the same title could crash IDA.
This has been fixed (https://www.hex-rays.com/products/ida/6.8/index.shtml).
The code will not change for support of older versions and as it is
... | [
"Make",
"the",
"title",
"unique",
"."
] | python | train | 34.666667 |
ray-project/ray | python/ray/rllib/evaluation/sampler.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L230-L339 | def _env_runner(base_env, extra_batch_callback, policies, policy_mapping_fn,
unroll_length, horizon, preprocessors, obs_filters,
clip_rewards, clip_actions, pack, callbacks, tf_sess,
perf_stats, soft_horizon):
"""This implements the common experience collection logic.... | [
"def",
"_env_runner",
"(",
"base_env",
",",
"extra_batch_callback",
",",
"policies",
",",
"policy_mapping_fn",
",",
"unroll_length",
",",
"horizon",
",",
"preprocessors",
",",
"obs_filters",
",",
"clip_rewards",
",",
"clip_actions",
",",
"pack",
",",
"callbacks",
... | This implements the common experience collection logic.
Args:
base_env (BaseEnv): env implementing BaseEnv.
extra_batch_callback (fn): function to send extra batch data to.
policies (dict): Map of policy ids to PolicyGraph instances.
policy_mapping_fn (func): Function that maps agen... | [
"This",
"implements",
"the",
"common",
"experience",
"collection",
"logic",
"."
] | python | train | 43.427273 |
log2timeline/dfvfs | dfvfs/helpers/volume_scanner.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/helpers/volume_scanner.py#L546-L588 | def ScanForWindowsVolume(self, source_path):
"""Scans for a Windows volume.
Args:
source_path (str): source path.
Returns:
bool: True if a Windows volume was found.
Raises:
ScannerError: if the source path does not exists, or if the source path
is not a file or directory, ... | [
"def",
"ScanForWindowsVolume",
"(",
"self",
",",
"source_path",
")",
":",
"windows_path_specs",
"=",
"self",
".",
"GetBasePathSpecs",
"(",
"source_path",
")",
"if",
"(",
"not",
"windows_path_specs",
"or",
"self",
".",
"_source_type",
"==",
"definitions",
".",
"S... | Scans for a Windows volume.
Args:
source_path (str): source path.
Returns:
bool: True if a Windows volume was found.
Raises:
ScannerError: if the source path does not exists, or if the source path
is not a file or directory, or if the format of or within the source
f... | [
"Scans",
"for",
"a",
"Windows",
"volume",
"."
] | python | train | 32.255814 |
isislovecruft/python-gnupg | pretty_bad_protocol/_parsers.py | https://github.com/isislovecruft/python-gnupg/blob/784571449032e811587249743e183fc5e908a673/pretty_bad_protocol/_parsers.py#L127-L141 | def _fix_unsafe(shell_input):
"""Find characters used to escape from a string into a shell, and wrap them in
quotes if they exist. Regex pilfered from Python3 :mod:`shlex` module.
:param str shell_input: The input intended for the GnuPG process.
"""
_unsafe = re.compile(r'[^\w@%+=:,./-]', 256)
... | [
"def",
"_fix_unsafe",
"(",
"shell_input",
")",
":",
"_unsafe",
"=",
"re",
".",
"compile",
"(",
"r'[^\\w@%+=:,./-]'",
",",
"256",
")",
"try",
":",
"if",
"len",
"(",
"_unsafe",
".",
"findall",
"(",
"shell_input",
")",
")",
"==",
"0",
":",
"return",
"shel... | Find characters used to escape from a string into a shell, and wrap them in
quotes if they exist. Regex pilfered from Python3 :mod:`shlex` module.
:param str shell_input: The input intended for the GnuPG process. | [
"Find",
"characters",
"used",
"to",
"escape",
"from",
"a",
"string",
"into",
"a",
"shell",
"and",
"wrap",
"them",
"in",
"quotes",
"if",
"they",
"exist",
".",
"Regex",
"pilfered",
"from",
"Python3",
":",
"mod",
":",
"shlex",
"module",
"."
] | python | train | 36.6 |
nabla-c0d3/nassl | nassl/ocsp_response.py | https://github.com/nabla-c0d3/nassl/blob/7dce9a2235f4324191865d58dcbeec5c3a2097a3/nassl/ocsp_response.py#L41-L59 | def verify(self, verify_locations: str) -> None:
"""Verify that the OCSP response is trusted.
Args:
verify_locations: The file path to a trust store containing pem-formatted certificates, to be used for
validating the OCSP response.
Raises OcspResponseNotTrustedError if... | [
"def",
"verify",
"(",
"self",
",",
"verify_locations",
":",
"str",
")",
"->",
"None",
":",
"# Ensure the file exists",
"with",
"open",
"(",
"verify_locations",
")",
":",
"pass",
"try",
":",
"self",
".",
"_ocsp_response",
".",
"basic_verify",
"(",
"verify_locat... | Verify that the OCSP response is trusted.
Args:
verify_locations: The file path to a trust store containing pem-formatted certificates, to be used for
validating the OCSP response.
Raises OcspResponseNotTrustedError if the validation failed ie. the OCSP response is not trusted. | [
"Verify",
"that",
"the",
"OCSP",
"response",
"is",
"trusted",
"."
] | python | train | 37.789474 |
phalt/beckett | beckett/resources.py | https://github.com/phalt/beckett/blob/555a7b1744d0063023fecd70a81ae090096362f3/beckett/resources.py#L146-L163 | def get_url(cls, url, uid, **kwargs):
"""
Construct the URL for talking to an individual resource.
http://myapi.com/api/resource/1
Args:
url: The url for this resource
uid: The unique identifier for an individual resource
kwargs: Additional keyword a... | [
"def",
"get_url",
"(",
"cls",
",",
"url",
",",
"uid",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"uid",
":",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"url",
",",
"uid",
")",
"else",
":",
"url",
"=",
"url",
"return",
"cls",
".",
"_parse_url_and_va... | Construct the URL for talking to an individual resource.
http://myapi.com/api/resource/1
Args:
url: The url for this resource
uid: The unique identifier for an individual resource
kwargs: Additional keyword argueents
returns:
final_url: The URL f... | [
"Construct",
"the",
"URL",
"for",
"talking",
"to",
"an",
"individual",
"resource",
"."
] | python | train | 30.166667 |
NoneGG/aredis | aredis/commands/sets.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/sets.py#L40-L43 | async def sdiff(self, keys, *args):
"Return the difference of sets specified by ``keys``"
args = list_or_args(keys, args)
return await self.execute_command('SDIFF', *args) | [
"async",
"def",
"sdiff",
"(",
"self",
",",
"keys",
",",
"*",
"args",
")",
":",
"args",
"=",
"list_or_args",
"(",
"keys",
",",
"args",
")",
"return",
"await",
"self",
".",
"execute_command",
"(",
"'SDIFF'",
",",
"*",
"args",
")"
] | Return the difference of sets specified by ``keys`` | [
"Return",
"the",
"difference",
"of",
"sets",
"specified",
"by",
"keys"
] | python | train | 48 |
hawkowl/towncrier | src/towncrier/_builder.py | https://github.com/hawkowl/towncrier/blob/ecd438c9c0ef132a92aba2eecc4dc672ccf9ec63/src/towncrier/_builder.py#L87-L95 | def indent(text, prefix):
"""
Adds `prefix` to the beginning of non-empty lines in `text`.
"""
# Based on Python 3's textwrap.indent
def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if line.strip() else line)
return u"".join(prefixed_lines()) | [
"def",
"indent",
"(",
"text",
",",
"prefix",
")",
":",
"# Based on Python 3's textwrap.indent",
"def",
"prefixed_lines",
"(",
")",
":",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
"True",
")",
":",
"yield",
"(",
"prefix",
"+",
"line",
"if",
"line"... | Adds `prefix` to the beginning of non-empty lines in `text`. | [
"Adds",
"prefix",
"to",
"the",
"beginning",
"of",
"non",
"-",
"empty",
"lines",
"in",
"text",
"."
] | python | train | 34.111111 |
wonambi-python/wonambi | wonambi/widgets/notes.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/notes.py#L1433-L1455 | def markers_to_events(self, keep_name=False):
"""Copy all markers in dataset to event type. """
markers = self.parent.info.markers
if markers is None:
self.parent.statusBar.showMessage('No markers in dataset.')
return
if not keep_name:
... | [
"def",
"markers_to_events",
"(",
"self",
",",
"keep_name",
"=",
"False",
")",
":",
"markers",
"=",
"self",
".",
"parent",
".",
"info",
".",
"markers",
"if",
"markers",
"is",
"None",
":",
"self",
".",
"parent",
".",
"statusBar",
".",
"showMessage",
"(",
... | Copy all markers in dataset to event type. | [
"Copy",
"all",
"markers",
"in",
"dataset",
"to",
"event",
"type",
"."
] | python | train | 32.304348 |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/apps_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/apps_v1_api.py#L4523-L4547 | def patch_namespaced_stateful_set_scale(self, name, namespace, body, **kwargs): # noqa: E501
"""patch_namespaced_stateful_set_scale # noqa: E501
partially update scale of the specified StatefulSet # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynch... | [
"def",
"patch_namespaced_stateful_set_scale",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'... | patch_namespaced_stateful_set_scale # noqa: E501
partially update scale of the specified StatefulSet # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_namespaced_stateful_set_sc... | [
"patch_namespaced_stateful_set_scale",
"#",
"noqa",
":",
"E501"
] | python | train | 62.76 |
ArabellaTech/ydcommon | ydcommon/fab.py | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L36-L60 | def switch(stage):
"""
Switch to given stage (dev/qa/production) + pull
"""
stage = stage.lower()
local("git pull")
if stage in ['dev', 'devel', 'develop']:
branch_name = 'develop'
elif stage in ['qa', 'release']:
branches = local('git branch -r', capture=True)
po... | [
"def",
"switch",
"(",
"stage",
")",
":",
"stage",
"=",
"stage",
".",
"lower",
"(",
")",
"local",
"(",
"\"git pull\"",
")",
"if",
"stage",
"in",
"[",
"'dev'",
",",
"'devel'",
",",
"'develop'",
"]",
":",
"branch_name",
"=",
"'develop'",
"elif",
"stage",
... | Switch to given stage (dev/qa/production) + pull | [
"Switch",
"to",
"given",
"stage",
"(",
"dev",
"/",
"qa",
"/",
"production",
")",
"+",
"pull"
] | python | train | 36.84 |
ambitioninc/python-logentries-api | logentries_api/special_alerts.py | https://github.com/ambitioninc/python-logentries-api/blob/77ff1a7a2995d7ea2725b74e34c0f880f4ee23bc/logentries_api/special_alerts.py#L364-L377 | def list_scheduled_queries(self):
"""
List all scheduled_queries
:return: A list of all scheduled query dicts
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Lo... | [
"def",
"list_scheduled_queries",
"(",
"self",
")",
":",
"url",
"=",
"'https://logentries.com/rest/{account_id}/api/scheduled_queries/'",
".",
"format",
"(",
"account_id",
"=",
"self",
".",
"account_id",
")",
"return",
"self",
".",
"_api_get",
"(",
"url",
"=",
"url",... | List all scheduled_queries
:return: A list of all scheduled query dicts
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Logentries | [
"List",
"all",
"scheduled_queries"
] | python | test | 37.071429 |
a1ezzz/wasp-general | wasp_general/task/thread_tracker.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L559-L569 | def task_postponed(self):
""" Track (if required) postponing event and do the same job as :meth:`.WScheduleRecord.task_postponed`
method do
:return: None
"""
tracker = self.task().tracker_storage()
if tracker is not None and self.track_wait() is True:
details = self.task().event_details(WTrackerEvents.w... | [
"def",
"task_postponed",
"(",
"self",
")",
":",
"tracker",
"=",
"self",
".",
"task",
"(",
")",
".",
"tracker_storage",
"(",
")",
"if",
"tracker",
"is",
"not",
"None",
"and",
"self",
".",
"track_wait",
"(",
")",
"is",
"True",
":",
"details",
"=",
"sel... | Track (if required) postponing event and do the same job as :meth:`.WScheduleRecord.task_postponed`
method do
:return: None | [
"Track",
"(",
"if",
"required",
")",
"postponing",
"event",
"and",
"do",
"the",
"same",
"job",
"as",
":",
"meth",
":",
".",
"WScheduleRecord",
".",
"task_postponed",
"method",
"do"
] | python | train | 37.636364 |
rackerlabs/timid | timid/environment.py | https://github.com/rackerlabs/timid/blob/b1c6aa159ab380a033740f4aa392cf0d125e0ac6/timid/environment.py#L179-L188 | def insert(self, idx, value):
"""
Inserts a value in the ``ListVariable`` at an appropriate index.
:param idx: The index before which to insert the new value.
:param value: The value to insert.
"""
self._value.insert(idx, value)
self._rebuild() | [
"def",
"insert",
"(",
"self",
",",
"idx",
",",
"value",
")",
":",
"self",
".",
"_value",
".",
"insert",
"(",
"idx",
",",
"value",
")",
"self",
".",
"_rebuild",
"(",
")"
] | Inserts a value in the ``ListVariable`` at an appropriate index.
:param idx: The index before which to insert the new value.
:param value: The value to insert. | [
"Inserts",
"a",
"value",
"in",
"the",
"ListVariable",
"at",
"an",
"appropriate",
"index",
"."
] | python | test | 29.3 |
VasilyStepanov/pywidl | pywidl/grammar.py | https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L452-L455 | def p_OperationRest(p):
"""OperationRest : ReturnType OptionalIdentifier "(" ArgumentList ")" ";"
"""
p[0] = model.Operation(return_type=p[1], name=p[2], arguments=p[4]) | [
"def",
"p_OperationRest",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"model",
".",
"Operation",
"(",
"return_type",
"=",
"p",
"[",
"1",
"]",
",",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"arguments",
"=",
"p",
"[",
"4",
"]",
")"
] | OperationRest : ReturnType OptionalIdentifier "(" ArgumentList ")" ";" | [
"OperationRest",
":",
"ReturnType",
"OptionalIdentifier",
"(",
"ArgumentList",
")",
";"
] | python | train | 43 |
funilrys/PyFunceble | PyFunceble/lookup.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/lookup.py#L75-L145 | def nslookup(cls):
"""
Implementation of UNIX nslookup.
"""
try:
# We try to get the addresse information of the given domain or IP.
if "current_test_data" in PyFunceble.INTERN: # pragma: no cover
# The end-user want more information whith his t... | [
"def",
"nslookup",
"(",
"cls",
")",
":",
"try",
":",
"# We try to get the addresse information of the given domain or IP.",
"if",
"\"current_test_data\"",
"in",
"PyFunceble",
".",
"INTERN",
":",
"# pragma: no cover",
"# The end-user want more information whith his test.",
"if",
... | Implementation of UNIX nslookup. | [
"Implementation",
"of",
"UNIX",
"nslookup",
"."
] | python | test | 38.84507 |
iotile/coretools | transport_plugins/jlink/iotile_transport_jlink/jlink.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink.py#L250-L281 | def connect_async(self, connection_id, connection_string, callback):
"""Connect to a device by its connection_string
This function asynchronously connects to a device by its BLE address
passed in the connection_string parameter and calls callback when
finished. Callback is called on ei... | [
"def",
"connect_async",
"(",
"self",
",",
"connection_id",
",",
"connection_string",
",",
"callback",
")",
":",
"self",
".",
"_try_connect",
"(",
"connection_string",
")",
"def",
"_on_finished",
"(",
"_name",
",",
"control_info",
",",
"exception",
")",
":",
"i... | Connect to a device by its connection_string
This function asynchronously connects to a device by its BLE address
passed in the connection_string parameter and calls callback when
finished. Callback is called on either success or failure with the
signature:
callback(conection_... | [
"Connect",
"to",
"a",
"device",
"by",
"its",
"connection_string"
] | python | train | 44.3125 |
alfred82santa/dirty-models | dirty_models/models.py | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L984-L993 | def get_validated_object(self, field_type, value):
"""
Returns the value validated by the field_type
"""
if field_type.check_value(value) or field_type.can_use_value(value):
data = field_type.use_value(value)
self._prepare_child(data)
return data
... | [
"def",
"get_validated_object",
"(",
"self",
",",
"field_type",
",",
"value",
")",
":",
"if",
"field_type",
".",
"check_value",
"(",
"value",
")",
"or",
"field_type",
".",
"can_use_value",
"(",
"value",
")",
":",
"data",
"=",
"field_type",
".",
"use_value",
... | Returns the value validated by the field_type | [
"Returns",
"the",
"value",
"validated",
"by",
"the",
"field_type"
] | python | train | 34.3 |
gwastro/pycbc | pycbc/workflow/jobsetup.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/jobsetup.py#L608-L621 | def get_data_times_for_job_legacy(self, num_job):
""" Get the data that this job will need to read in. """
# Should all be integers, so no rounding needed
shift_dur = self.curr_seg[0] + int(self.job_time_shift * num_job)
job_data_seg = self.data_chunk.shift(shift_dur)
# If this ... | [
"def",
"get_data_times_for_job_legacy",
"(",
"self",
",",
"num_job",
")",
":",
"# Should all be integers, so no rounding needed",
"shift_dur",
"=",
"self",
".",
"curr_seg",
"[",
"0",
"]",
"+",
"int",
"(",
"self",
".",
"job_time_shift",
"*",
"num_job",
")",
"job_da... | Get the data that this job will need to read in. | [
"Get",
"the",
"data",
"that",
"this",
"job",
"will",
"need",
"to",
"read",
"in",
"."
] | python | train | 50.928571 |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L243-L253 | def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag.
"""
if not nx.... | [
"def",
"validate",
"(",
"self",
",",
"graph",
")",
":",
"if",
"not",
"nx",
".",
"is_directed_acyclic_graph",
"(",
"graph",
")",
":",
"raise",
"DirectedAcyclicGraphInvalid",
"(",
"graph_name",
"=",
"self",
".",
"_name",
")"
] | Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag. | [
"Validate",
"the",
"graph",
"by",
"checking",
"whether",
"it",
"is",
"a",
"directed",
"acyclic",
"graph",
"."
] | python | train | 37.454545 |
LonamiWebs/Telethon | telethon/client/downloads.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/downloads.py#L385-L406 | def _get_kind_and_names(attributes):
"""Gets kind and possible names for :tl:`DocumentAttribute`."""
kind = 'document'
possible_names = []
for attr in attributes:
if isinstance(attr, types.DocumentAttributeFilename):
possible_names.insert(0, attr.file_name)
... | [
"def",
"_get_kind_and_names",
"(",
"attributes",
")",
":",
"kind",
"=",
"'document'",
"possible_names",
"=",
"[",
"]",
"for",
"attr",
"in",
"attributes",
":",
"if",
"isinstance",
"(",
"attr",
",",
"types",
".",
"DocumentAttributeFilename",
")",
":",
"possible_... | Gets kind and possible names for :tl:`DocumentAttribute`. | [
"Gets",
"kind",
"and",
"possible",
"names",
"for",
":",
"tl",
":",
"DocumentAttribute",
"."
] | python | train | 39.272727 |
keenlabs/KeenClient-Python | keen/client.py | https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/client.py#L163-L176 | def delete_events(self, event_collection, timeframe=None, timezone=None, filters=None):
""" Deletes events.
:param event_collection: string, the event collection from which event are being deleted
:param timeframe: string or dict, the timeframe in which the events happened
example: "pre... | [
"def",
"delete_events",
"(",
"self",
",",
"event_collection",
",",
"timeframe",
"=",
"None",
",",
"timezone",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"params",
"=",
"self",
".",
"get_params",
"(",
"timeframe",
"=",
"timeframe",
",",
"timezone",... | Deletes events.
:param event_collection: string, the event collection from which event are being deleted
:param timeframe: string or dict, the timeframe in which the events happened
example: "previous_7_days"
:param timezone: int, the timezone you'd like to use for the timeframe
... | [
"Deletes",
"events",
"."
] | python | train | 55.714286 |
fudge-py/fudge | fudge/__init__.py | https://github.com/fudge-py/fudge/blob/b283fbc1a41900f3f5845b10b8c2ef9136a67ebc/fudge/__init__.py#L1098-L1110 | def returns(self, val):
"""Set the last call to return a value.
Set a static value to return when a method is called. I.E.::
>>> f = Fake().provides('get_number').returns(64)
>>> f.get_number()
64
"""
exp = self._get_current_call()
exp.retu... | [
"def",
"returns",
"(",
"self",
",",
"val",
")",
":",
"exp",
"=",
"self",
".",
"_get_current_call",
"(",
")",
"exp",
".",
"return_val",
"=",
"val",
"return",
"self"
] | Set the last call to return a value.
Set a static value to return when a method is called. I.E.::
>>> f = Fake().provides('get_number').returns(64)
>>> f.get_number()
64 | [
"Set",
"the",
"last",
"call",
"to",
"return",
"a",
"value",
"."
] | python | train | 26.153846 |
pylast/pylast | src/pylast/__init__.py | https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L2423-L2428 | def is_subscriber(self):
"""Returns whether the user is a subscriber or not. True or False."""
doc = self._request(self.ws_prefix + ".getInfo", True)
return _extract(doc, "subscriber") == "1" | [
"def",
"is_subscriber",
"(",
"self",
")",
":",
"doc",
"=",
"self",
".",
"_request",
"(",
"self",
".",
"ws_prefix",
"+",
"\".getInfo\"",
",",
"True",
")",
"return",
"_extract",
"(",
"doc",
",",
"\"subscriber\"",
")",
"==",
"\"1\""
] | Returns whether the user is a subscriber or not. True or False. | [
"Returns",
"whether",
"the",
"user",
"is",
"a",
"subscriber",
"or",
"not",
".",
"True",
"or",
"False",
"."
] | python | train | 35.333333 |
Dentosal/python-sc2 | sc2/bot_ai.py | https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/bot_ai.py#L415-L432 | async def build(self, building: UnitTypeId, near: Union[Point2, Point3], max_distance: int=20, unit: Optional[Unit]=None, random_alternative: bool=True, placement_step: int=2):
"""Build a building."""
if isinstance(near, Unit):
near = near.position.to2
elif near is not None:
... | [
"async",
"def",
"build",
"(",
"self",
",",
"building",
":",
"UnitTypeId",
",",
"near",
":",
"Union",
"[",
"Point2",
",",
"Point3",
"]",
",",
"max_distance",
":",
"int",
"=",
"20",
",",
"unit",
":",
"Optional",
"[",
"Unit",
"]",
"=",
"None",
",",
"r... | Build a building. | [
"Build",
"a",
"building",
"."
] | python | train | 41.722222 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L445-L461 | def format_diff_xml(a_xml, b_xml):
"""Create a diff between two XML documents.
Args:
a_xml: str
b_xml: str
Returns:
str : `Differ`-style delta
"""
return '\n'.join(
difflib.ndiff(
reformat_to_pretty_xml(a_xml).splitlines(),
reformat_to_pretty_xml(... | [
"def",
"format_diff_xml",
"(",
"a_xml",
",",
"b_xml",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"difflib",
".",
"ndiff",
"(",
"reformat_to_pretty_xml",
"(",
"a_xml",
")",
".",
"splitlines",
"(",
")",
",",
"reformat_to_pretty_xml",
"(",
"b_xml",
")",
"... | Create a diff between two XML documents.
Args:
a_xml: str
b_xml: str
Returns:
str : `Differ`-style delta | [
"Create",
"a",
"diff",
"between",
"two",
"XML",
"documents",
"."
] | python | train | 20 |
libnano/primer3-py | primer3/wrappers.py | https://github.com/libnano/primer3-py/blob/0901c0ef3ac17afd69329d23db71136c00bcb635/primer3/wrappers.py#L70-L94 | def calcTm(seq, mv_conc=50, dv_conc=0, dntp_conc=0.8, dna_conc=50,
max_nn_length=60, tm_method='santalucia',
salt_corrections_method='santalucia'):
''' Return the tm of `seq` as a float.
'''
tm_meth = _tm_methods.get(tm_method)
if tm_meth is None:
raise ValueError('{} is no... | [
"def",
"calcTm",
"(",
"seq",
",",
"mv_conc",
"=",
"50",
",",
"dv_conc",
"=",
"0",
",",
"dntp_conc",
"=",
"0.8",
",",
"dna_conc",
"=",
"50",
",",
"max_nn_length",
"=",
"60",
",",
"tm_method",
"=",
"'santalucia'",
",",
"salt_corrections_method",
"=",
"'san... | Return the tm of `seq` as a float. | [
"Return",
"the",
"tm",
"of",
"seq",
"as",
"a",
"float",
"."
] | python | train | 42.24 |
etingof/pysmi | pysmi/parser/smi.py | https://github.com/etingof/pysmi/blob/379a0a384c81875731be51a054bdacced6260fd8/pysmi/parser/smi.py#L637-L644 | def p_range(self, p):
"""range : value DOT_DOT value
| value"""
n = len(p)
if n == 2:
p[0] = (p[1],)
elif n == 4:
p[0] = (p[1], p[3]) | [
"def",
"p_range",
"(",
"self",
",",
"p",
")",
":",
"n",
"=",
"len",
"(",
"p",
")",
"if",
"n",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"1",
"]",
",",
")",
"elif",
"n",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p"... | range : value DOT_DOT value
| value | [
"range",
":",
"value",
"DOT_DOT",
"value",
"|",
"value"
] | python | valid | 24.875 |
assamite/creamas | creamas/image.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/image.py#L49-L67 | def channel_portion(image, channel):
'''Estimates the amount of a color relative to other colors.
:param image: numpy.ndarray
:param channel: int
:returns: portion of a channel in an image
:rtype: float
'''
# Separate color channels
rgb = []
for i in range(3):
rgb.append(im... | [
"def",
"channel_portion",
"(",
"image",
",",
"channel",
")",
":",
"# Separate color channels",
"rgb",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"rgb",
".",
"append",
"(",
"image",
"[",
":",
",",
":",
",",
"i",
"]",
".",
"astype"... | Estimates the amount of a color relative to other colors.
:param image: numpy.ndarray
:param channel: int
:returns: portion of a channel in an image
:rtype: float | [
"Estimates",
"the",
"amount",
"of",
"a",
"color",
"relative",
"to",
"other",
"colors",
"."
] | python | train | 27.789474 |
diging/tethne | tethne/classes/feature.py | https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/classes/feature.py#L538-L580 | def transform(self, func):
"""
Apply a transformation to tokens in this :class:`.FeatureSet`\.
Parameters
----------
func : callable
Should take four parameters: token, value in document (e.g. count),
value in :class:`.FeatureSet` (e.g. overall count), an... | [
"def",
"transform",
"(",
"self",
",",
"func",
")",
":",
"features",
"=",
"{",
"}",
"for",
"i",
",",
"feature",
"in",
"self",
".",
"features",
".",
"iteritems",
"(",
")",
":",
"feature_",
"=",
"[",
"]",
"for",
"f",
",",
"v",
"in",
"feature",
":",
... | Apply a transformation to tokens in this :class:`.FeatureSet`\.
Parameters
----------
func : callable
Should take four parameters: token, value in document (e.g. count),
value in :class:`.FeatureSet` (e.g. overall count), and document
count (i.e. number of do... | [
"Apply",
"a",
"transformation",
"to",
"tokens",
"in",
"this",
":",
"class",
":",
".",
"FeatureSet",
"\\",
"."
] | python | train | 31.302326 |
tensorflow/probability | tensorflow_probability/python/optimizer/differential_evolution.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/optimizer/differential_evolution.py#L554-L602 | def _get_starting_population(initial_population,
initial_position,
population_size,
population_stddev,
seed):
"""Constructs the initial population.
If an initial population is not already provided, t... | [
"def",
"_get_starting_population",
"(",
"initial_population",
",",
"initial_position",
",",
"population_size",
",",
"population_stddev",
",",
"seed",
")",
":",
"if",
"initial_population",
"is",
"not",
"None",
":",
"return",
"[",
"tf",
".",
"convert_to_tensor",
"(",
... | Constructs the initial population.
If an initial population is not already provided, this function constructs
a population by adding random normal noise to the initial position.
Args:
initial_population: None or a list of `Tensor`s. The initial population.
initial_position: None or a list of `Tensor`s. ... | [
"Constructs",
"the",
"initial",
"population",
"."
] | python | test | 48.77551 |
project-rig/rig | rig/machine_control/machine_controller.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L764-L802 | def read_vcpu_struct_field(self, field_name, x, y, p):
"""Read a value out of the VCPU struct for a specific core.
Similar to :py:meth:`.read_struct_field` except this method accesses
the individual VCPU struct for to each core and contains application
runtime status.
Parameter... | [
"def",
"read_vcpu_struct_field",
"(",
"self",
",",
"field_name",
",",
"x",
",",
"y",
",",
"p",
")",
":",
"# Get the base address of the VCPU struct for this chip, then advance",
"# to get the correct VCPU struct for the requested core.",
"field",
",",
"address",
",",
"pack_ch... | Read a value out of the VCPU struct for a specific core.
Similar to :py:meth:`.read_struct_field` except this method accesses
the individual VCPU struct for to each core and contains application
runtime status.
Parameters
----------
field_name : string
Name ... | [
"Read",
"a",
"value",
"out",
"of",
"the",
"VCPU",
"struct",
"for",
"a",
"specific",
"core",
"."
] | python | train | 35.615385 |
phoebe-project/phoebe2 | phoebe/frontend/bundle.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L3339-L3353 | def rename_model(self, old_model, new_model):
"""
Change the label of a model attached to the Bundle
:parameter str old_model: the current name of the model
(must exist)
:parameter str new_model: the desired new name of the model
(must not exist)
:return:... | [
"def",
"rename_model",
"(",
"self",
",",
"old_model",
",",
"new_model",
")",
":",
"# TODO: raise error if old_feature not found?",
"self",
".",
"_check_label",
"(",
"new_model",
")",
"self",
".",
"_rename_label",
"(",
"'model'",
",",
"old_model",
",",
"new_model",
... | Change the label of a model attached to the Bundle
:parameter str old_model: the current name of the model
(must exist)
:parameter str new_model: the desired new name of the model
(must not exist)
:return: None
:raises ValueError: if the new_model is forbidden | [
"Change",
"the",
"label",
"of",
"a",
"model",
"attached",
"to",
"the",
"Bundle"
] | python | train | 35.4 |
saltstack/salt | salt/runners/net.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/net.py#L243-L431 | def interfaces(device=None,
interface=None,
title=None,
pattern=None,
ipnet=None,
best=True,
display=_DEFAULT_DISPLAY):
'''
Search for interfaces details in the following mine functions:
- net.interfaces
- net.ipa... | [
"def",
"interfaces",
"(",
"device",
"=",
"None",
",",
"interface",
"=",
"None",
",",
"title",
"=",
"None",
",",
"pattern",
"=",
"None",
",",
"ipnet",
"=",
"None",
",",
"best",
"=",
"True",
",",
"display",
"=",
"_DEFAULT_DISPLAY",
")",
":",
"def",
"_i... | Search for interfaces details in the following mine functions:
- net.interfaces
- net.ipaddrs
Optional arguments:
device
Return interface data from a certain device only.
interface
Return data selecting by interface name.
pattern
Return interfaces that contain a cert... | [
"Search",
"for",
"interfaces",
"details",
"in",
"the",
"following",
"mine",
"functions",
":"
] | python | train | 41.904762 |
Rapptz/discord.py | discord/guild.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L530-L535 | def shard_id(self):
"""Returns the shard ID for this guild if applicable."""
count = self._state.shard_count
if count is None:
return None
return (self.id >> 22) % count | [
"def",
"shard_id",
"(",
"self",
")",
":",
"count",
"=",
"self",
".",
"_state",
".",
"shard_count",
"if",
"count",
"is",
"None",
":",
"return",
"None",
"return",
"(",
"self",
".",
"id",
">>",
"22",
")",
"%",
"count"
] | Returns the shard ID for this guild if applicable. | [
"Returns",
"the",
"shard",
"ID",
"for",
"this",
"guild",
"if",
"applicable",
"."
] | python | train | 34.666667 |
glut23/webvtt-py | webvtt/cli.py | https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/cli.py#L35-L47 | def segment(f, output, target_duration, mpegts):
"""Segment command."""
try:
target_duration = int(target_duration)
except ValueError:
exit('Error: Invalid target duration.')
try:
mpegts = int(mpegts)
except ValueError:
exit('Error: Invalid MPEGTS value.')
WebVT... | [
"def",
"segment",
"(",
"f",
",",
"output",
",",
"target_duration",
",",
"mpegts",
")",
":",
"try",
":",
"target_duration",
"=",
"int",
"(",
"target_duration",
")",
"except",
"ValueError",
":",
"exit",
"(",
"'Error: Invalid target duration.'",
")",
"try",
":",
... | Segment command. | [
"Segment",
"command",
"."
] | python | train | 28 |
cisco-sas/kitty | kitty/model/low_level/container.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/container.py#L1017-L1039 | def get_info(self):
'''
Get info regarding the current template state
:return: info dictionary
'''
self.render()
info = super(Template, self).get_info()
res = {}
res['name'] = self.get_name()
res['mutation'] = {
'current_index': self._... | [
"def",
"get_info",
"(",
"self",
")",
":",
"self",
".",
"render",
"(",
")",
"info",
"=",
"super",
"(",
"Template",
",",
"self",
")",
".",
"get_info",
"(",
")",
"res",
"=",
"{",
"}",
"res",
"[",
"'name'",
"]",
"=",
"self",
".",
"get_name",
"(",
"... | Get info regarding the current template state
:return: info dictionary | [
"Get",
"info",
"regarding",
"the",
"current",
"template",
"state"
] | python | train | 29.608696 |
albahnsen/CostSensitiveClassification | costcla/sampling/cost_sampling.py | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/sampling/cost_sampling.py#L11-L123 | def cost_sampling(X, y, cost_mat, method='RejectionSampling', oversampling_norm=0.1, max_wc=97.5):
"""Cost-proportionate sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground... | [
"def",
"cost_sampling",
"(",
"X",
",",
"y",
",",
"cost_mat",
",",
"method",
"=",
"'RejectionSampling'",
",",
"oversampling_norm",
"=",
"0.1",
",",
"max_wc",
"=",
"97.5",
")",
":",
"#TODO: Check consistency of input",
"# The methods are construct only for the misclassifi... | Cost-proportionate sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix ... | [
"Cost",
"-",
"proportionate",
"sampling",
"."
] | python | train | 40.955752 |
ggravlingen/pytradfri | pytradfri/device.py | https://github.com/ggravlingen/pytradfri/blob/63750fa8fb27158c013d24865cdaa7fb82b3ab53/pytradfri/device.py#L238-L247 | def set_hex_color(self, color, *, index=0, transition_time=None):
"""Set hex color of the light."""
values = {
ATTR_LIGHT_COLOR_HEX: color,
}
if transition_time is not None:
values[ATTR_TRANSITION_TIME] = transition_time
return self.set_values(values, in... | [
"def",
"set_hex_color",
"(",
"self",
",",
"color",
",",
"*",
",",
"index",
"=",
"0",
",",
"transition_time",
"=",
"None",
")",
":",
"values",
"=",
"{",
"ATTR_LIGHT_COLOR_HEX",
":",
"color",
",",
"}",
"if",
"transition_time",
"is",
"not",
"None",
":",
"... | Set hex color of the light. | [
"Set",
"hex",
"color",
"of",
"the",
"light",
"."
] | python | train | 32.1 |
juju/charm-helpers | charmhelpers/contrib/peerstorage/__init__.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L125-L140 | def relation_set(relation_id=None, relation_settings=None, **kwargs):
"""Attempt to use leader-set if supported in the current version of Juju,
otherwise falls back on relation-set.
Note that we only attempt to use leader-set if the provided relation_id is
a peer relation id or no relation id is provid... | [
"def",
"relation_set",
"(",
"relation_id",
"=",
"None",
",",
"relation_settings",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"relation_id",
"in",
"relation_ids",
"(",
"'cluster'",
")",
":",
"return",
"leader_set",
"(",
"settings",
"=... | Attempt to use leader-set if supported in the current version of Juju,
otherwise falls back on relation-set.
Note that we only attempt to use leader-set if the provided relation_id is
a peer relation id or no relation id is provided (in which case we assume
we are within the peer relation context). | [
"Attempt",
"to",
"use",
"leader",
"-",
"set",
"if",
"supported",
"in",
"the",
"current",
"version",
"of",
"Juju",
"otherwise",
"falls",
"back",
"on",
"relation",
"-",
"set",
"."
] | python | train | 45.5 |
mojaie/chorus | chorus/draw/helper.py | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L67-L110 | def scale_and_center(mol):
"""Center and Scale molecule 2D coordinates.
This method changes mol coordinates directly to center but not scale.
This method returns width, height and MLB(median length of bond)
and scaling will be done by drawer method with these values.
Returns:
width: float
... | [
"def",
"scale_and_center",
"(",
"mol",
")",
":",
"cnt",
"=",
"mol",
".",
"atom_count",
"(",
")",
"if",
"cnt",
"<",
"2",
":",
"mol",
".",
"size2d",
"=",
"(",
"0",
",",
"0",
",",
"1",
")",
"mol",
".",
"descriptors",
".",
"add",
"(",
"\"ScaleAndCent... | Center and Scale molecule 2D coordinates.
This method changes mol coordinates directly to center but not scale.
This method returns width, height and MLB(median length of bond)
and scaling will be done by drawer method with these values.
Returns:
width: float
height: float
mlb: ... | [
"Center",
"and",
"Scale",
"molecule",
"2D",
"coordinates",
".",
"This",
"method",
"changes",
"mol",
"coordinates",
"directly",
"to",
"center",
"but",
"not",
"scale",
".",
"This",
"method",
"returns",
"width",
"height",
"and",
"MLB",
"(",
"median",
"length",
... | python | train | 33.136364 |
jtwhite79/pyemu | pyemu/pst/pst_handler.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L2239-L2300 | def get_res_stats(self,nonzero=True):
""" get some common residual stats from the current obsvals,
weights and grouping in self.observation_data and the modelled values in
self.res. The key here is 'current' because if obsval, weights and/or
groupings have changed in self.observation_da... | [
"def",
"get_res_stats",
"(",
"self",
",",
"nonzero",
"=",
"True",
")",
":",
"res",
"=",
"self",
".",
"res",
".",
"copy",
"(",
")",
"res",
".",
"loc",
"[",
":",
",",
"\"obsnme\"",
"]",
"=",
"res",
".",
"pop",
"(",
"\"name\"",
")",
"res",
".",
"i... | get some common residual stats from the current obsvals,
weights and grouping in self.observation_data and the modelled values in
self.res. The key here is 'current' because if obsval, weights and/or
groupings have changed in self.observation_data since the res file was generated
then t... | [
"get",
"some",
"common",
"residual",
"stats",
"from",
"the",
"current",
"obsvals",
"weights",
"and",
"grouping",
"in",
"self",
".",
"observation_data",
"and",
"the",
"modelled",
"values",
"in",
"self",
".",
"res",
".",
"The",
"key",
"here",
"is",
"current",
... | python | train | 36.596774 |
cloudmesh-cmd3/cmd3 | cmd3/plugins/py.py | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/py.py#L39-L98 | def do_py(self, arg):
"""
::
Usage:
py
py COMMAND
Arguments:
COMMAND the command to be executed
Description:
The command without a parameter will be executed and the
interactive pyth... | [
"def",
"do_py",
"(",
"self",
",",
"arg",
")",
":",
"self",
".",
"pystate",
"[",
"'self'",
"]",
"=",
"self",
"arg",
"=",
"arg",
".",
"strip",
"(",
")",
"localvars",
"=",
"(",
"self",
".",
"locals_in_py",
"and",
"self",
".",
"pystate",
")",
"or",
"... | ::
Usage:
py
py COMMAND
Arguments:
COMMAND the command to be executed
Description:
The command without a parameter will be executed and the
interactive python mode is entered. The python mode can be... | [
"::"
] | python | train | 36.416667 |
Knoema/knoema-python-driver | knoema/api_client.py | https://github.com/Knoema/knoema-python-driver/blob/e98b13db3e4df51c208c272e2977bfbe4c6e5532/knoema/api_client.py#L142-L156 | def upload_file(self, file):
"""The method is posting file to the remote server"""
url = self._get_url('/api/1.0/upload/post')
fcontent = FileContent(file)
binary_data = fcontent.get_binary()
headers = self._get_request_headers()
req = urllib.request.Request(u... | [
"def",
"upload_file",
"(",
"self",
",",
"file",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"'/api/1.0/upload/post'",
")",
"fcontent",
"=",
"FileContent",
"(",
"file",
")",
"binary_data",
"=",
"fcontent",
".",
"get_binary",
"(",
")",
"headers",
"="... | The method is posting file to the remote server | [
"The",
"method",
"is",
"posting",
"file",
"to",
"the",
"remote",
"server"
] | python | train | 38.666667 |
mattja/nsim | nsim/timeseries.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L499-L509 | def transpose(self, *axes):
"""Permute the dimensions of a Timeseries."""
if self.ndim <= 1:
return self
ar = np.asarray(self).transpose(*axes)
if axes[0] != 0:
# then axis 0 is unaffected by the transposition
newlabels = [self.labels[ax] for ax in axe... | [
"def",
"transpose",
"(",
"self",
",",
"*",
"axes",
")",
":",
"if",
"self",
".",
"ndim",
"<=",
"1",
":",
"return",
"self",
"ar",
"=",
"np",
".",
"asarray",
"(",
"self",
")",
".",
"transpose",
"(",
"*",
"axes",
")",
"if",
"axes",
"[",
"0",
"]",
... | Permute the dimensions of a Timeseries. | [
"Permute",
"the",
"dimensions",
"of",
"a",
"Timeseries",
"."
] | python | train | 36.818182 |
buildinspace/peru | peru/cache.py | https://github.com/buildinspace/peru/blob/76e4012c6c34e85fb53a4c6d85f4ac3633d93f77/peru/cache.py#L331-L423 | async def export_tree(self,
tree,
dest,
previous_tree=None,
*,
force=False,
previous_index_file=None):
'''This method is the core of `peru sync`. If the con... | [
"async",
"def",
"export_tree",
"(",
"self",
",",
"tree",
",",
"dest",
",",
"previous_tree",
"=",
"None",
",",
"*",
",",
"force",
"=",
"False",
",",
"previous_index_file",
"=",
"None",
")",
":",
"tree",
"=",
"tree",
"or",
"(",
"await",
"self",
".",
"g... | This method is the core of `peru sync`. If the contents of "dest"
match "previous_tree", then export_tree() updates them to match "tree".
If not, it raises an error and doesn't touch any files.
Because it's important for the no-op `peru sync` to be fast, we make an
extra optimization fo... | [
"This",
"method",
"is",
"the",
"core",
"of",
"peru",
"sync",
".",
"If",
"the",
"contents",
"of",
"dest",
"match",
"previous_tree",
"then",
"export_tree",
"()",
"updates",
"them",
"to",
"match",
"tree",
".",
"If",
"not",
"it",
"raises",
"an",
"error",
"an... | python | train | 49.193548 |
titusjan/argos | argos/config/configtreemodel.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/configtreemodel.py#L55-L64 | def debug(self, topLeftIndex, bottomRightIndex):
""" Temporary debug to test the dataChanged signal. TODO: remove.
"""
if topLeftIndex.isValid() and bottomRightIndex.isValid():
topRow = topLeftIndex.row()
bottomRow = bottomRightIndex.row()
for row in range(top... | [
"def",
"debug",
"(",
"self",
",",
"topLeftIndex",
",",
"bottomRightIndex",
")",
":",
"if",
"topLeftIndex",
".",
"isValid",
"(",
")",
"and",
"bottomRightIndex",
".",
"isValid",
"(",
")",
":",
"topRow",
"=",
"topLeftIndex",
".",
"row",
"(",
")",
"bottomRow",... | Temporary debug to test the dataChanged signal. TODO: remove. | [
"Temporary",
"debug",
"to",
"test",
"the",
"dataChanged",
"signal",
".",
"TODO",
":",
"remove",
"."
] | python | train | 51.1 |
saltstack/salt | salt/sdb/cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/cache.py#L85-L95 | def delete(key, service=None, profile=None): # pylint: disable=W0613
'''
Get a value from the cache service
'''
key, profile = _parse_key(key, profile)
cache = salt.cache.Cache(__opts__)
try:
cache.flush(profile['bank'], key=key)
return True
except Exception:
return ... | [
"def",
"delete",
"(",
"key",
",",
"service",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=W0613",
"key",
",",
"profile",
"=",
"_parse_key",
"(",
"key",
",",
"profile",
")",
"cache",
"=",
"salt",
".",
"cache",
".",
"Cache",
"("... | Get a value from the cache service | [
"Get",
"a",
"value",
"from",
"the",
"cache",
"service"
] | python | train | 28.636364 |
django-extensions/django-extensions | django_extensions/__init__.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/__init__.py#L5-L15 | def get_version(version):
"""Dynamically calculate the version based on VERSION tuple."""
if len(version) > 2 and version[2] is not None:
if isinstance(version[2], int):
str_version = "%s.%s.%s" % version[:3]
else:
str_version = "%s.%s_%s" % version[:3]
else:
... | [
"def",
"get_version",
"(",
"version",
")",
":",
"if",
"len",
"(",
"version",
")",
">",
"2",
"and",
"version",
"[",
"2",
"]",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"version",
"[",
"2",
"]",
",",
"int",
")",
":",
"str_version",
"=",
"\... | Dynamically calculate the version based on VERSION tuple. | [
"Dynamically",
"calculate",
"the",
"version",
"based",
"on",
"VERSION",
"tuple",
"."
] | python | train | 33.545455 |
fusepy/fusepy | fusell.py | https://github.com/fusepy/fusepy/blob/5d997d6706cc0204e1b3ca679651485a7e7dda49/fusell.py#L738-L745 | def mknod(self, req, parent, name, mode, rdev):
"""Create file node
Valid replies:
reply_entry
reply_err
"""
self.reply_err(req, errno.EROFS) | [
"def",
"mknod",
"(",
"self",
",",
"req",
",",
"parent",
",",
"name",
",",
"mode",
",",
"rdev",
")",
":",
"self",
".",
"reply_err",
"(",
"req",
",",
"errno",
".",
"EROFS",
")"
] | Create file node
Valid replies:
reply_entry
reply_err | [
"Create",
"file",
"node"
] | python | train | 23.875 |
googlemaps/google-maps-services-python | googlemaps/places.py | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/places.py#L308-L342 | def _places(client, url_part, query=None, location=None, radius=None,
keyword=None, language=None, min_price=0, max_price=4, name=None,
open_now=False, rank_by=None, type=None, region=None, page_token=None):
"""
Internal handler for ``places``, ``places_nearby``, and ``places_radar``.
... | [
"def",
"_places",
"(",
"client",
",",
"url_part",
",",
"query",
"=",
"None",
",",
"location",
"=",
"None",
",",
"radius",
"=",
"None",
",",
"keyword",
"=",
"None",
",",
"language",
"=",
"None",
",",
"min_price",
"=",
"0",
",",
"max_price",
"=",
"4",
... | Internal handler for ``places``, ``places_nearby``, and ``places_radar``.
See each method's docs for arg details. | [
"Internal",
"handler",
"for",
"places",
"places_nearby",
"and",
"places_radar",
".",
"See",
"each",
"method",
"s",
"docs",
"for",
"arg",
"details",
"."
] | python | train | 31.028571 |
jkenlooper/chill | src/chill/public.py | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L241-L276 | def route_handler(context, content, pargs, kwargs):
"""
Route shortcode works a lot like rendering a page based on the url or
route. This allows inserting in rendered HTML within another page.
Activate it with the 'shortcodes' template filter. Within the content use
the chill route shortcode: "[ch... | [
"def",
"route_handler",
"(",
"context",
",",
"content",
",",
"pargs",
",",
"kwargs",
")",
":",
"(",
"node",
",",
"rule_kw",
")",
"=",
"node_from_uri",
"(",
"pargs",
"[",
"0",
"]",
")",
"if",
"node",
"==",
"None",
":",
"return",
"u\"<!-- 404 '{0}' -->\"",... | Route shortcode works a lot like rendering a page based on the url or
route. This allows inserting in rendered HTML within another page.
Activate it with the 'shortcodes' template filter. Within the content use
the chill route shortcode: "[chill route /path/to/something/]" where the
'[chill' and ']' a... | [
"Route",
"shortcode",
"works",
"a",
"lot",
"like",
"rendering",
"a",
"page",
"based",
"on",
"the",
"url",
"or",
"route",
".",
"This",
"allows",
"inserting",
"in",
"rendered",
"HTML",
"within",
"another",
"page",
"."
] | python | train | 35.166667 |
IEMLdev/ieml | ieml/dictionary/script/parser/parser.py | https://github.com/IEMLdev/ieml/blob/4c842ba7e6165e2f1b4a4e2e98759f9f33af5f25/ieml/dictionary/script/parser/parser.py#L110-L117 | def p_sum_lvl_1(self, p):
""" sum_lvl_1 : script_lvl_1
| script_lvl_1 PLUS sum_lvl_1"""
if len(p) == 4:
p[3].append(p[1])
p[0] = p[3]
else:
p[0] = [p[1]] | [
"def",
"p_sum_lvl_1",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"3",
"]",
".",
"append",
"(",
"p",
"[",
"1",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"3",
"]",
"else",
":",
"p",
"[",
"0... | sum_lvl_1 : script_lvl_1
| script_lvl_1 PLUS sum_lvl_1 | [
"sum_lvl_1",
":",
"script_lvl_1",
"|",
"script_lvl_1",
"PLUS",
"sum_lvl_1"
] | python | test | 28.375 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.