repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
cggh/scikit-allel | allel/stats/distance.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L151-L196 | def pairwise_dxy(pos, gac, start=None, stop=None, is_accessible=None):
"""Convenience function to calculate a pairwise distance matrix using
nucleotide divergence (a.k.a. Dxy) as the distance metric.
Parameters
----------
pos : array_like, int, shape (n_variants,)
Variant positions.
gac... | [
"def",
"pairwise_dxy",
"(",
"pos",
",",
"gac",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"is_accessible",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"pos",
",",
"SortedIndex",
")",
":",
"pos",
"=",
"SortedIndex",
"(",
"pos... | Convenience function to calculate a pairwise distance matrix using
nucleotide divergence (a.k.a. Dxy) as the distance metric.
Parameters
----------
pos : array_like, int, shape (n_variants,)
Variant positions.
gac : array_like, int, shape (n_variants, n_samples, n_alleles)
Per-genot... | [
"Convenience",
"function",
"to",
"calculate",
"a",
"pairwise",
"distance",
"matrix",
"using",
"nucleotide",
"divergence",
"(",
"a",
".",
"k",
".",
"a",
".",
"Dxy",
")",
"as",
"the",
"distance",
"metric",
"."
] | python | train |
gwastro/pycbc | pycbc/pnutils.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/pnutils.py#L529-L580 | def get_inspiral_tf(tc, mass1, mass2, spin1, spin2, f_low, n_points=100,
pn_2order=7, approximant='TaylorF2'):
"""Compute the time-frequency evolution of an inspiral signal.
Return a tuple of time and frequency vectors tracking the evolution of an
inspiral signal in the time-frequency plane.
""... | [
"def",
"get_inspiral_tf",
"(",
"tc",
",",
"mass1",
",",
"mass2",
",",
"spin1",
",",
"spin2",
",",
"f_low",
",",
"n_points",
"=",
"100",
",",
"pn_2order",
"=",
"7",
",",
"approximant",
"=",
"'TaylorF2'",
")",
":",
"# handle param-dependent approximant specifica... | Compute the time-frequency evolution of an inspiral signal.
Return a tuple of time and frequency vectors tracking the evolution of an
inspiral signal in the time-frequency plane. | [
"Compute",
"the",
"time",
"-",
"frequency",
"evolution",
"of",
"an",
"inspiral",
"signal",
"."
] | python | train |
pyusb/pyusb | usb/util.py | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/util.py#L151-L179 | def find_descriptor(desc, find_all=False, custom_match=None, **args):
r"""Find an inner descriptor.
find_descriptor works in the same way as the core.find() function does,
but it acts on general descriptor objects. For example, suppose you
have a Device object called dev and want a Configuration of thi... | [
"def",
"find_descriptor",
"(",
"desc",
",",
"find_all",
"=",
"False",
",",
"custom_match",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"def",
"desc_iter",
"(",
"*",
"*",
"kwargs",
")",
":",
"for",
"d",
"in",
"desc",
":",
"tests",
"=",
"(",
"val",... | r"""Find an inner descriptor.
find_descriptor works in the same way as the core.find() function does,
but it acts on general descriptor objects. For example, suppose you
have a Device object called dev and want a Configuration of this
object with its bConfigurationValue equals to 1, the code would
... | [
"r",
"Find",
"an",
"inner",
"descriptor",
"."
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/stringfunc.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/stringfunc.py#L86-L103 | def replace_in_list(stringlist: Iterable[str],
replacedict: Dict[str, str]) -> List[str]:
"""
Returns a list produced by applying :func:`multiple_replace` to every
string in ``stringlist``.
Args:
stringlist: list of source strings
replacedict: dictionary mapping "ori... | [
"def",
"replace_in_list",
"(",
"stringlist",
":",
"Iterable",
"[",
"str",
"]",
",",
"replacedict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"newlist",
"=",
"[",
"]",
"for",
"fromstring",
"in",
"stringlist",
"... | Returns a list produced by applying :func:`multiple_replace` to every
string in ``stringlist``.
Args:
stringlist: list of source strings
replacedict: dictionary mapping "original" to "replacement" strings
Returns:
list of final strings | [
"Returns",
"a",
"list",
"produced",
"by",
"applying",
":",
"func",
":",
"multiple_replace",
"to",
"every",
"string",
"in",
"stringlist",
"."
] | python | train |
saltstack/salt | salt/modules/etcd_mod.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/etcd_mod.py#L120-L171 | def update(fields, path='', profile=None, **kwargs):
'''
.. versionadded:: 2016.3.0
Sets a dictionary of values in one call. Useful for large updates
in syndic environments. The dictionary can contain a mix of formats
such as:
.. code-block:: python
{
'/some/example/key': ... | [
"def",
"update",
"(",
"fields",
",",
"path",
"=",
"''",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"__utils__",
"[",
"'etcd_util.get_conn'",
"]",
"(",
"__opts__",
",",
"profile",
",",
"*",
"*",
"kwargs",
")",
"retu... | .. versionadded:: 2016.3.0
Sets a dictionary of values in one call. Useful for large updates
in syndic environments. The dictionary can contain a mix of formats
such as:
.. code-block:: python
{
'/some/example/key': 'bar',
'/another/example/key': 'baz'
}
Or ... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | python | train |
osfclient/osfclient | osfclient/cli.py | https://github.com/osfclient/osfclient/blob/44b9a87e8c1ae6b63cdecd27a924af3fc2bf94cf/osfclient/cli.py#L140-L175 | def clone(args):
"""Copy all files from all storages of a project.
The output directory defaults to the current directory.
If the project is private you need to specify a username.
If args.update is True, overwrite any existing local files only if local and
remote files differ.
"""
osf = ... | [
"def",
"clone",
"(",
"args",
")",
":",
"osf",
"=",
"_setup_osf",
"(",
"args",
")",
"project",
"=",
"osf",
".",
"project",
"(",
"args",
".",
"project",
")",
"output_dir",
"=",
"args",
".",
"project",
"if",
"args",
".",
"output",
"is",
"not",
"None",
... | Copy all files from all storages of a project.
The output directory defaults to the current directory.
If the project is private you need to specify a username.
If args.update is True, overwrite any existing local files only if local and
remote files differ. | [
"Copy",
"all",
"files",
"from",
"all",
"storages",
"of",
"a",
"project",
"."
] | python | valid |
codenerix/django-codenerix | codenerix/djng/angular_base.py | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/angular_base.py#L166-L184 | def as_widget(self, widget=None, attrs=None, only_initial=False):
"""
Renders the field.
"""
attrs = attrs or {}
attrs.update(self.form.get_widget_attrs(self))
if hasattr(self.field, 'widget_css_classes'):
css_classes = self.field.widget_css_classes
el... | [
"def",
"as_widget",
"(",
"self",
",",
"widget",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"only_initial",
"=",
"False",
")",
":",
"attrs",
"=",
"attrs",
"or",
"{",
"}",
"attrs",
".",
"update",
"(",
"self",
".",
"form",
".",
"get_widget_attrs",
"("... | Renders the field. | [
"Renders",
"the",
"field",
"."
] | python | train |
apache/incubator-mxnet | python/mxnet/gluon/block.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/block.py#L485-L502 | def initialize(self, init=initializer.Uniform(), ctx=None, verbose=False,
force_reinit=False):
"""Initializes :py:class:`Parameter` s of this :py:class:`Block` and its children.
Equivalent to ``block.collect_params().initialize(...)``
Parameters
----------
ini... | [
"def",
"initialize",
"(",
"self",
",",
"init",
"=",
"initializer",
".",
"Uniform",
"(",
")",
",",
"ctx",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"force_reinit",
"=",
"False",
")",
":",
"self",
".",
"collect_params",
"(",
")",
".",
"initialize",... | Initializes :py:class:`Parameter` s of this :py:class:`Block` and its children.
Equivalent to ``block.collect_params().initialize(...)``
Parameters
----------
init : Initializer
Global default Initializer to be used when :py:meth:`Parameter.init` is ``None``.
Oth... | [
"Initializes",
":",
"py",
":",
"class",
":",
"Parameter",
"s",
"of",
"this",
":",
"py",
":",
"class",
":",
"Block",
"and",
"its",
"children",
".",
"Equivalent",
"to",
"block",
".",
"collect_params",
"()",
".",
"initialize",
"(",
"...",
")"
] | python | train |
Workiva/furious | furious/extras/appengine/ndb_persistence.py | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/extras/appengine/ndb_persistence.py#L187-L210 | def _check_markers(task_ids, offset=10):
"""Returns a flag for markers being found for the task_ids. If all task ids
have markers True will be returned. Otherwise it will return False as soon
as a None result is hit.
"""
shuffle(task_ids)
has_errors = False
for index in xrange(0, len(task_... | [
"def",
"_check_markers",
"(",
"task_ids",
",",
"offset",
"=",
"10",
")",
":",
"shuffle",
"(",
"task_ids",
")",
"has_errors",
"=",
"False",
"for",
"index",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"task_ids",
")",
",",
"offset",
")",
":",
"keys",
"=... | Returns a flag for markers being found for the task_ids. If all task ids
have markers True will be returned. Otherwise it will return False as soon
as a None result is hit. | [
"Returns",
"a",
"flag",
"for",
"markers",
"being",
"found",
"for",
"the",
"task_ids",
".",
"If",
"all",
"task",
"ids",
"have",
"markers",
"True",
"will",
"be",
"returned",
".",
"Otherwise",
"it",
"will",
"return",
"False",
"as",
"soon",
"as",
"a",
"None"... | python | train |
hannes-brt/hebel | hebel/utils/serial.py | https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/utils/serial.py#L248-L265 | def get_pickle_protocol():
"""
Allow configuration of the pickle protocol on a per-machine basis.
This way, if you use multiple platforms with different versions of
pickle, you can configure each of them to use the highest protocol
supported by all of the machines that you want to be able to
com... | [
"def",
"get_pickle_protocol",
"(",
")",
":",
"try",
":",
"protocol_str",
"=",
"os",
".",
"environ",
"[",
"'PYLEARN2_PICKLE_PROTOCOL'",
"]",
"except",
"KeyError",
":",
"# If not defined, we default to 0 because this is the default",
"# protocol used by cPickle.dump (and because ... | Allow configuration of the pickle protocol on a per-machine basis.
This way, if you use multiple platforms with different versions of
pickle, you can configure each of them to use the highest protocol
supported by all of the machines that you want to be able to
communicate. | [
"Allow",
"configuration",
"of",
"the",
"pickle",
"protocol",
"on",
"a",
"per",
"-",
"machine",
"basis",
".",
"This",
"way",
"if",
"you",
"use",
"multiple",
"platforms",
"with",
"different",
"versions",
"of",
"pickle",
"you",
"can",
"configure",
"each",
"of",... | python | train |
mcs07/PubChemPy | pubchempy.py | https://github.com/mcs07/PubChemPy/blob/e3c4f4a9b6120433e5cc3383464c7a79e9b2b86e/pubchempy.py#L757-L767 | def cid(self):
"""The PubChem Compound Identifier (CID).
.. note::
When searching using a SMILES or InChI query that is not present in the PubChem Compound database, an
automatically generated record may be returned that contains properties that have been calculated on the
... | [
"def",
"cid",
"(",
"self",
")",
":",
"if",
"'id'",
"in",
"self",
".",
"record",
"and",
"'id'",
"in",
"self",
".",
"record",
"[",
"'id'",
"]",
"and",
"'cid'",
"in",
"self",
".",
"record",
"[",
"'id'",
"]",
"[",
"'id'",
"]",
":",
"return",
"self",
... | The PubChem Compound Identifier (CID).
.. note::
When searching using a SMILES or InChI query that is not present in the PubChem Compound database, an
automatically generated record may be returned that contains properties that have been calculated on the
fly. These records... | [
"The",
"PubChem",
"Compound",
"Identifier",
"(",
"CID",
")",
"."
] | python | train |
piotr-rusin/spam-lists | spam_lists/structures.py | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/structures.py#L84-L94 | def is_subdomain(self, other):
"""Test if the object is a subdomain of the other.
:param other: the object to which we compare this instance
:returns: True if this instance is a subdomain of the other
"""
compared = other.value if hasattr(other, 'value') else other
try:
... | [
"def",
"is_subdomain",
"(",
"self",
",",
"other",
")",
":",
"compared",
"=",
"other",
".",
"value",
"if",
"hasattr",
"(",
"other",
",",
"'value'",
")",
"else",
"other",
"try",
":",
"return",
"self",
".",
"value",
".",
"is_subdomain",
"(",
"compared",
"... | Test if the object is a subdomain of the other.
:param other: the object to which we compare this instance
:returns: True if this instance is a subdomain of the other | [
"Test",
"if",
"the",
"object",
"is",
"a",
"subdomain",
"of",
"the",
"other",
"."
] | python | train |
LogicalDash/LiSE | ELiDE/ELiDE/board/board.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L223-L265 | def portal_touch_up(self, touch):
"""Try to create a portal between the spots the user chose."""
try:
# If the touch ended upon a spot, and there isn't
# already a portal between the origin and this
# destination, create one.
destspot = next(self.spots_at(... | [
"def",
"portal_touch_up",
"(",
"self",
",",
"touch",
")",
":",
"try",
":",
"# If the touch ended upon a spot, and there isn't",
"# already a portal between the origin and this",
"# destination, create one.",
"destspot",
"=",
"next",
"(",
"self",
".",
"spots_at",
"(",
"*",
... | Try to create a portal between the spots the user chose. | [
"Try",
"to",
"create",
"a",
"portal",
"between",
"the",
"spots",
"the",
"user",
"chose",
"."
] | python | train |
ska-sa/katcp-python | katcp/resource_client.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1717-L1740 | def monitor_resource_sync_state(resource, callback, exit_event=None):
"""Coroutine that monitors a KATCPResource's sync state.
Calls callback(True/False) whenever the resource becomes synced or unsynced. Will
always do an initial callback(False) call. Exits without calling callback() if
exit_event is s... | [
"def",
"monitor_resource_sync_state",
"(",
"resource",
",",
"callback",
",",
"exit_event",
"=",
"None",
")",
":",
"exit_event",
"=",
"exit_event",
"or",
"AsyncEvent",
"(",
")",
"callback",
"(",
"False",
")",
"# Initial condition, assume resource is not connected",
"wh... | Coroutine that monitors a KATCPResource's sync state.
Calls callback(True/False) whenever the resource becomes synced or unsynced. Will
always do an initial callback(False) call. Exits without calling callback() if
exit_event is set | [
"Coroutine",
"that",
"monitors",
"a",
"KATCPResource",
"s",
"sync",
"state",
"."
] | python | train |
ARMmbed/yotta | yotta/lib/component.py | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/component.py#L691-L708 | def getTarget(self, target_name_and_version, additional_config=None):
''' Return a derived target object representing the selected target: if
the target is not installed, or is invalid then the returned object
will test false in a boolean context.
Returns derived_target
... | [
"def",
"getTarget",
"(",
"self",
",",
"target_name_and_version",
",",
"additional_config",
"=",
"None",
")",
":",
"derived_target",
",",
"errors",
"=",
"self",
".",
"satisfyTarget",
"(",
"target_name_and_version",
",",
"additional_config",
"=",
"additional_config",
... | Return a derived target object representing the selected target: if
the target is not installed, or is invalid then the returned object
will test false in a boolean context.
Returns derived_target
Errors are not displayed. | [
"Return",
"a",
"derived",
"target",
"object",
"representing",
"the",
"selected",
"target",
":",
"if",
"the",
"target",
"is",
"not",
"installed",
"or",
"is",
"invalid",
"then",
"the",
"returned",
"object",
"will",
"test",
"false",
"in",
"a",
"boolean",
"conte... | python | valid |
portfors-lab/sparkle | sparkle/acq/players.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L183-L187 | def start_timer(self, reprate):
"""Start the digital output task that serves as the acquistion trigger"""
print 'starting digital output at rate {} Hz'.format(reprate)
self.trigger_task = DigitalOutTask(self.trigger_src, reprate)
self.trigger_task.start() | [
"def",
"start_timer",
"(",
"self",
",",
"reprate",
")",
":",
"print",
"'starting digital output at rate {} Hz'",
".",
"format",
"(",
"reprate",
")",
"self",
".",
"trigger_task",
"=",
"DigitalOutTask",
"(",
"self",
".",
"trigger_src",
",",
"reprate",
")",
"self",... | Start the digital output task that serves as the acquistion trigger | [
"Start",
"the",
"digital",
"output",
"task",
"that",
"serves",
"as",
"the",
"acquistion",
"trigger"
] | python | train |
halcy/Mastodon.py | mastodon/Mastodon.py | https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L2155-L2168 | def media_update(self, id, description=None, focus=None):
"""
Update the metadata of the media file with the given `id`. `description` and
`focus` are as in `media_post()`_ .
Returns the updated `media dict`_.
"""
id = self.__unpack_id(id)
if focus != N... | [
"def",
"media_update",
"(",
"self",
",",
"id",
",",
"description",
"=",
"None",
",",
"focus",
"=",
"None",
")",
":",
"id",
"=",
"self",
".",
"__unpack_id",
"(",
"id",
")",
"if",
"focus",
"!=",
"None",
":",
"focus",
"=",
"str",
"(",
"focus",
"[",
... | Update the metadata of the media file with the given `id`. `description` and
`focus` are as in `media_post()`_ .
Returns the updated `media dict`_. | [
"Update",
"the",
"metadata",
"of",
"the",
"media",
"file",
"with",
"the",
"given",
"id",
".",
"description",
"and",
"focus",
"are",
"as",
"in",
"media_post",
"()",
"_",
".",
"Returns",
"the",
"updated",
"media",
"dict",
"_",
"."
] | python | train |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_api_provider.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L273-L298 | def _convert_event_api(lambda_logical_id, event_properties):
"""
Converts a AWS::Serverless::Function's Event Property to an Api configuration usable by the provider.
:param str lambda_logical_id: Logical Id of the AWS::Serverless::Function
:param dict event_properties: Dictionary of th... | [
"def",
"_convert_event_api",
"(",
"lambda_logical_id",
",",
"event_properties",
")",
":",
"path",
"=",
"event_properties",
".",
"get",
"(",
"SamApiProvider",
".",
"_EVENT_PATH",
")",
"method",
"=",
"event_properties",
".",
"get",
"(",
"SamApiProvider",
".",
"_EVEN... | Converts a AWS::Serverless::Function's Event Property to an Api configuration usable by the provider.
:param str lambda_logical_id: Logical Id of the AWS::Serverless::Function
:param dict event_properties: Dictionary of the Event's Property
:return tuple: tuple of API resource name and Api name... | [
"Converts",
"a",
"AWS",
"::",
"Serverless",
"::",
"Function",
"s",
"Event",
"Property",
"to",
"an",
"Api",
"configuration",
"usable",
"by",
"the",
"provider",
"."
] | python | train |
christophertbrown/bioscripts | ctbBio/rax.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L192-L203 | def fix_tree(tree, a_id_lookup, out):
"""
get the names for sequences in the raxml tree
"""
if check(out) is False and check(tree) is True:
tree = open(tree).read()
for line in open(a_id_lookup):
id, name, header = line.strip().split('\t')
tree = tree.replace(id+'... | [
"def",
"fix_tree",
"(",
"tree",
",",
"a_id_lookup",
",",
"out",
")",
":",
"if",
"check",
"(",
"out",
")",
"is",
"False",
"and",
"check",
"(",
"tree",
")",
"is",
"True",
":",
"tree",
"=",
"open",
"(",
"tree",
")",
".",
"read",
"(",
")",
"for",
"... | get the names for sequences in the raxml tree | [
"get",
"the",
"names",
"for",
"sequences",
"in",
"the",
"raxml",
"tree"
] | python | train |
Scoppio/RagnarokEngine3 | RagnarokEngine3/RE3.py | https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L2434-L2447 | def query_state(self, StateType):
"""
Is a button depressed?
True if a button is pressed, false otherwise.
"""
if StateType == M_LEFT:
# Checking left mouse button
return self.left_pressed
elif StateType == M_MIDDLE:
# Checking middle m... | [
"def",
"query_state",
"(",
"self",
",",
"StateType",
")",
":",
"if",
"StateType",
"==",
"M_LEFT",
":",
"# Checking left mouse button",
"return",
"self",
".",
"left_pressed",
"elif",
"StateType",
"==",
"M_MIDDLE",
":",
"# Checking middle mouse button",
"return",
"sel... | Is a button depressed?
True if a button is pressed, false otherwise. | [
"Is",
"a",
"button",
"depressed?",
"True",
"if",
"a",
"button",
"is",
"pressed",
"false",
"otherwise",
"."
] | python | train |
Clinical-Genomics/scout | scout/server/blueprints/dashboard/controllers.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/dashboard/controllers.py#L243-L282 | def get_case_groups(adapter, total_cases, institute_id=None, slice_query=None):
"""Return the information about case groups
Args:
store(adapter.MongoAdapter)
total_cases(int): Total number of cases
slice_query(str): Query to filter cases to obtain statistics for.
Returns:
c... | [
"def",
"get_case_groups",
"(",
"adapter",
",",
"total_cases",
",",
"institute_id",
"=",
"None",
",",
"slice_query",
"=",
"None",
")",
":",
"# Create a group with all cases in the database",
"cases",
"=",
"[",
"{",
"'status'",
":",
"'all'",
",",
"'count'",
":",
"... | Return the information about case groups
Args:
store(adapter.MongoAdapter)
total_cases(int): Total number of cases
slice_query(str): Query to filter cases to obtain statistics for.
Returns:
cases(dict): | [
"Return",
"the",
"information",
"about",
"case",
"groups"
] | python | test |
gwpy/gwpy | gwpy/plot/bode.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/plot/bode.py#L228-L269 | def add_frequencyseries(self, spectrum, dB=True, power=False, **kwargs):
"""Plot the magnitude and phase of a complex-valued `FrequencySeries`
Parameters
----------
spectrum : `~gwpy.frequencyseries.FrequencySeries`
the (complex-valued) `FrequencySeries` to display
... | [
"def",
"add_frequencyseries",
"(",
"self",
",",
"spectrum",
",",
"dB",
"=",
"True",
",",
"power",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# parse spectrum arguments",
"kwargs",
".",
"setdefault",
"(",
"'label'",
",",
"spectrum",
".",
"name",
")",... | Plot the magnitude and phase of a complex-valued `FrequencySeries`
Parameters
----------
spectrum : `~gwpy.frequencyseries.FrequencySeries`
the (complex-valued) `FrequencySeries` to display
db : `bool`, optional, default: `True`
if `True`, display magnitude in d... | [
"Plot",
"the",
"magnitude",
"and",
"phase",
"of",
"a",
"complex",
"-",
"valued",
"FrequencySeries"
] | python | train |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L1331-L1361 | def _hide_parameters(self, file_name):
"""
hide the parameters that had been hidden
Args:
file_name: config file that has the information about which parameters are hidden
"""
try:
in_data = load_b26_file(file_name)
except:
in_data = {... | [
"def",
"_hide_parameters",
"(",
"self",
",",
"file_name",
")",
":",
"try",
":",
"in_data",
"=",
"load_b26_file",
"(",
"file_name",
")",
"except",
":",
"in_data",
"=",
"{",
"}",
"def",
"set_item_visible",
"(",
"item",
",",
"is_visible",
")",
":",
"if",
"i... | hide the parameters that had been hidden
Args:
file_name: config file that has the information about which parameters are hidden | [
"hide",
"the",
"parameters",
"that",
"had",
"been",
"hidden",
"Args",
":",
"file_name",
":",
"config",
"file",
"that",
"has",
"the",
"information",
"about",
"which",
"parameters",
"are",
"hidden"
] | python | train |
phoebe-project/phoebe2 | phoebe/parameters/parameters.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/parameters.py#L1078-L1087 | def to_list_of_dicts(self, **kwargs):
"""
Convert the :class:`ParameterSet` to a list of the dictionary representation
of each :class:`Parameter`
:return: list of dicts
"""
if kwargs:
return self.filter(**kwargs).to_list_of_dicts()
return [param.to_di... | [
"def",
"to_list_of_dicts",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"return",
"self",
".",
"filter",
"(",
"*",
"*",
"kwargs",
")",
".",
"to_list_of_dicts",
"(",
")",
"return",
"[",
"param",
".",
"to_dict",
"(",
")",
"for",... | Convert the :class:`ParameterSet` to a list of the dictionary representation
of each :class:`Parameter`
:return: list of dicts | [
"Convert",
"the",
":",
"class",
":",
"ParameterSet",
"to",
"a",
"list",
"of",
"the",
"dictionary",
"representation",
"of",
"each",
":",
"class",
":",
"Parameter"
] | python | train |
log2timeline/plaso | plaso/parsers/sqlite.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/sqlite.py#L168-L198 | def Close(self):
"""Closes the database connection and cleans up the temporary file."""
self.schema = {}
if self._is_open:
self._database.close()
self._database = None
if os.path.exists(self._temp_db_file_path):
try:
os.remove(self._temp_db_file_path)
except (OSError, IOE... | [
"def",
"Close",
"(",
"self",
")",
":",
"self",
".",
"schema",
"=",
"{",
"}",
"if",
"self",
".",
"_is_open",
":",
"self",
".",
"_database",
".",
"close",
"(",
")",
"self",
".",
"_database",
"=",
"None",
"if",
"os",
".",
"path",
".",
"exists",
"(",... | Closes the database connection and cleans up the temporary file. | [
"Closes",
"the",
"database",
"connection",
"and",
"cleans",
"up",
"the",
"temporary",
"file",
"."
] | python | train |
ze-phyr-us/django-libretto | django_libretto/decorators.py | https://github.com/ze-phyr-us/django-libretto/blob/b19d8aa21b9579ee91e81967a44d1c40f5588b17/django_libretto/decorators.py#L5-L19 | def view_decorator(function_decorator):
"""Convert a function based decorator into a class based decorator usable
on class based Views.
Can't subclass the `View` as it breaks inheritance (super in particular),
so we monkey-patch instead.
Based on http://stackoverflow.com/a/8429311
"""
def simple_decorator(Vie... | [
"def",
"view_decorator",
"(",
"function_decorator",
")",
":",
"def",
"simple_decorator",
"(",
"View",
")",
":",
"View",
".",
"dispatch",
"=",
"method_decorator",
"(",
"function_decorator",
")",
"(",
"View",
".",
"dispatch",
")",
"return",
"View",
"return",
"si... | Convert a function based decorator into a class based decorator usable
on class based Views.
Can't subclass the `View` as it breaks inheritance (super in particular),
so we monkey-patch instead.
Based on http://stackoverflow.com/a/8429311 | [
"Convert",
"a",
"function",
"based",
"decorator",
"into",
"a",
"class",
"based",
"decorator",
"usable",
"on",
"class",
"based",
"Views",
"."
] | python | test |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/tex.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/tex.py#L617-L664 | def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir, aux_files):
""" For theFile (a Node) update any file_tests and search for graphics files
then find all included files and call ScanFiles recursively for each of them"""
content = theFile.get_text_conte... | [
"def",
"ScanFiles",
"(",
"theFile",
",",
"target",
",",
"paths",
",",
"file_tests",
",",
"file_tests_search",
",",
"env",
",",
"graphics_extensions",
",",
"targetdir",
",",
"aux_files",
")",
":",
"content",
"=",
"theFile",
".",
"get_text_contents",
"(",
")",
... | For theFile (a Node) update any file_tests and search for graphics files
then find all included files and call ScanFiles recursively for each of them | [
"For",
"theFile",
"(",
"a",
"Node",
")",
"update",
"any",
"file_tests",
"and",
"search",
"for",
"graphics",
"files",
"then",
"find",
"all",
"included",
"files",
"and",
"call",
"ScanFiles",
"recursively",
"for",
"each",
"of",
"them"
] | python | train |
scopus-api/scopus | scopus/deprecated_/scopus_api.py | https://github.com/scopus-api/scopus/blob/27ce02dd3095bfdab9d3e8475543d7c17767d1ab/scopus/deprecated_/scopus_api.py#L283-L308 | def get_corresponding_author_info(self):
"""Try to get corresponding author information.
Returns (scopus-id, name, email).
"""
resp = requests.get(self.scopus_url)
from lxml import html
parsed_doc = html.fromstring(resp.content)
for div in parsed_doc.body.xpath(... | [
"def",
"get_corresponding_author_info",
"(",
"self",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"scopus_url",
")",
"from",
"lxml",
"import",
"html",
"parsed_doc",
"=",
"html",
".",
"fromstring",
"(",
"resp",
".",
"content",
")",
"for"... | Try to get corresponding author information.
Returns (scopus-id, name, email). | [
"Try",
"to",
"get",
"corresponding",
"author",
"information",
"."
] | python | train |
EmbodiedCognition/pagoda | pagoda/cooper.py | https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/cooper.py#L547-L596 | def _step_to_marker_frame(self, frame_no, dt=None):
'''Update the simulator to a specific frame of marker data.
This method returns a generator of body states for the skeleton! This
generator must be exhausted (e.g., by consuming this call in a for loop)
for the simulator to work proper... | [
"def",
"_step_to_marker_frame",
"(",
"self",
",",
"frame_no",
",",
"dt",
"=",
"None",
")",
":",
"# update the positions and velocities of the markers.",
"self",
".",
"markers",
".",
"detach",
"(",
")",
"self",
".",
"markers",
".",
"reposition",
"(",
"frame_no",
... | Update the simulator to a specific frame of marker data.
This method returns a generator of body states for the skeleton! This
generator must be exhausted (e.g., by consuming this call in a for loop)
for the simulator to work properly.
This process involves the following steps:
... | [
"Update",
"the",
"simulator",
"to",
"a",
"specific",
"frame",
"of",
"marker",
"data",
"."
] | python | valid |
CivicSpleen/ambry | ambry/bundle/concurrent.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/concurrent.py#L166-L172 | def unify_mp(b, partition_name):
"""Unify all of the segment partitions for a parent partition, then run stats on the MPR file"""
with b.progress.start('coalesce_mp',0,message="MP coalesce {}".format(partition_name)) as ps:
r = b.unify_partition(partition_name, None, ps)
return r | [
"def",
"unify_mp",
"(",
"b",
",",
"partition_name",
")",
":",
"with",
"b",
".",
"progress",
".",
"start",
"(",
"'coalesce_mp'",
",",
"0",
",",
"message",
"=",
"\"MP coalesce {}\"",
".",
"format",
"(",
"partition_name",
")",
")",
"as",
"ps",
":",
"r",
"... | Unify all of the segment partitions for a parent partition, then run stats on the MPR file | [
"Unify",
"all",
"of",
"the",
"segment",
"partitions",
"for",
"a",
"parent",
"partition",
"then",
"run",
"stats",
"on",
"the",
"MPR",
"file"
] | python | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L59-L115 | def register (type, suffixes = [], base_type = None):
""" Registers a target type, possibly derived from a 'base-type'.
If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
Also, the first element gives the suffix to be used when constructing and object of
't... | [
"def",
"register",
"(",
"type",
",",
"suffixes",
"=",
"[",
"]",
",",
"base_type",
"=",
"None",
")",
":",
"# Type names cannot contain hyphens, because when used as",
"# feature-values they will be interpreted as composite features",
"# which need to be decomposed.",
"if",
"__re... | Registers a target type, possibly derived from a 'base-type'.
If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
Also, the first element gives the suffix to be used when constructing and object of
'type'.
type: a string
suffixes: None or a seque... | [
"Registers",
"a",
"target",
"type",
"possibly",
"derived",
"from",
"a",
"base",
"-",
"type",
".",
"If",
"suffixes",
"are",
"provided",
"they",
"list",
"all",
"the",
"suffixes",
"that",
"mean",
"a",
"file",
"is",
"of",
"type",
".",
"Also",
"the",
"first",... | python | train |
Hackerfleet/hfos | modules/camera/hfos/camera/manager.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L99-L105 | def rec(self):
"""Records a single snapshot"""
try:
self._snapshot()
except Exception as e:
self.log("Timer error: ", e, type(e), lvl=error) | [
"def",
"rec",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_snapshot",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"log",
"(",
"\"Timer error: \"",
",",
"e",
",",
"type",
"(",
"e",
")",
",",
"lvl",
"=",
"error",
")"
] | Records a single snapshot | [
"Records",
"a",
"single",
"snapshot"
] | python | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1369-L1380 | def group_refresh(name, **kwargs):
"""
Refresh routing group.
If the name option is empty, this command will refresh all groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:refresh', **{
'locator': ctx.locator,
'storage': ctx.repo.create_secure_service('storage'),
... | [
"def",
"group_refresh",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:refresh'",
",",
"*",
"*",
"{",
"'locator'",
":",
"ctx",
".",
"locator",
",",
"'sto... | Refresh routing group.
If the name option is empty, this command will refresh all groups. | [
"Refresh",
"routing",
"group",
"."
] | python | train |
KenjiTakahashi/td | td/main.py | https://github.com/KenjiTakahashi/td/blob/7311eabc63efe6fe6600687c3026f0837454c2e4/td/main.py#L148-L334 | def rock(self):
"""Starts and does the parsing."""
if not self.argv:
self.arg.view()
while(self.argv):
arg = self.argv.popleft()
if arg == "-h" or arg == "--help":
print(
"""Usage: td [-h (--help)] [-v (--version)] [command]... | [
"def",
"rock",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"argv",
":",
"self",
".",
"arg",
".",
"view",
"(",
")",
"while",
"(",
"self",
".",
"argv",
")",
":",
"arg",
"=",
"self",
".",
"argv",
".",
"popleft",
"(",
")",
"if",
"arg",
"==",... | Starts and does the parsing. | [
"Starts",
"and",
"does",
"the",
"parsing",
"."
] | python | train |
secdev/scapy | scapy/utils.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1458-L1468 | def tdecode(pktlist, args=None, **kwargs):
"""
Run tshark on a list of packets.
:param args: If not specified, defaults to ``tshark -V``.
See :func:`tcpdump` for more parameters.
"""
if args is None:
args = ["-V"]
return tcpdump(pktlist, prog=conf.prog.tshark, args=args, **kwargs) | [
"def",
"tdecode",
"(",
"pktlist",
",",
"args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"\"-V\"",
"]",
"return",
"tcpdump",
"(",
"pktlist",
",",
"prog",
"=",
"conf",
".",
"prog",
".",
"tsh... | Run tshark on a list of packets.
:param args: If not specified, defaults to ``tshark -V``.
See :func:`tcpdump` for more parameters. | [
"Run",
"tshark",
"on",
"a",
"list",
"of",
"packets",
"."
] | python | train |
tjvr/kurt | kurt/scratch14/objtable.py | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L251-L298 | def decode_network(objects):
"""Return root object from ref-containing obj table entries"""
def resolve_ref(obj, objects=objects):
if isinstance(obj, Ref):
# first entry is 1
return objects[obj.index - 1]
else:
return obj
# Reading the ObjTable backwards ... | [
"def",
"decode_network",
"(",
"objects",
")",
":",
"def",
"resolve_ref",
"(",
"obj",
",",
"objects",
"=",
"objects",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Ref",
")",
":",
"# first entry is 1",
"return",
"objects",
"[",
"obj",
".",
"index",
"-",... | Return root object from ref-containing obj table entries | [
"Return",
"root",
"object",
"from",
"ref",
"-",
"containing",
"obj",
"table",
"entries"
] | python | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L575-L585 | def _check_algorithm_keys(item):
"""Check for unexpected keys in the algorithm section.
Needs to be manually updated when introducing new keys, but avoids silent bugs
with typos in key names.
"""
problem_keys = [k for k in item["algorithm"].keys() if k not in ALGORITHM_KEYS]
if len(problem_keys... | [
"def",
"_check_algorithm_keys",
"(",
"item",
")",
":",
"problem_keys",
"=",
"[",
"k",
"for",
"k",
"in",
"item",
"[",
"\"algorithm\"",
"]",
".",
"keys",
"(",
")",
"if",
"k",
"not",
"in",
"ALGORITHM_KEYS",
"]",
"if",
"len",
"(",
"problem_keys",
")",
">",... | Check for unexpected keys in the algorithm section.
Needs to be manually updated when introducing new keys, but avoids silent bugs
with typos in key names. | [
"Check",
"for",
"unexpected",
"keys",
"in",
"the",
"algorithm",
"section",
"."
] | python | train |
src-d/modelforge | modelforge/tools.py | https://github.com/src-d/modelforge/blob/4f73c2bf0318261ac01bc8b6c0d4250a5d303418/modelforge/tools.py#L13-L32 | def install_environment(args: argparse.Namespace, backend: StorageBackend, log: logging.Logger):
"""
Install the packages mentioned in the model's metadata.
:param args: :param args: :class:`argparse.Namespace` with "input", "reproduce", "backend", \
"args", "username", "password", "remote... | [
"def",
"install_environment",
"(",
"args",
":",
"argparse",
".",
"Namespace",
",",
"backend",
":",
"StorageBackend",
",",
"log",
":",
"logging",
".",
"Logger",
")",
":",
"model",
"=",
"_load_generic_model",
"(",
"args",
".",
"input",
",",
"backend",
",",
"... | Install the packages mentioned in the model's metadata.
:param args: :param args: :class:`argparse.Namespace` with "input", "reproduce", "backend", \
"args", "username", "password", "remote_repo" and "log_level".
:param backend: Backend which is responsible for working with model files.
:p... | [
"Install",
"the",
"packages",
"mentioned",
"in",
"the",
"model",
"s",
"metadata",
"."
] | python | train |
PrefPy/prefpy | prefpy/mechanismMcmc.py | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L365-L396 | def getCandScoresMapBruteForce(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile.
"""
... | [
"def",
"getCandScoresMapBruteForce",
"(",
"self",
",",
"profile",
")",
":",
"wmg",
"=",
"profile",
".",
"getWmg",
"(",
"True",
")",
"m",
"=",
"len",
"(",
"wmg",
".",
"keys",
"(",
")",
")",
"cands",
"=",
"range",
"(",
"m",
")",
"V",
"=",
"self",
"... | Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictonary",
"that",
"associates",
"the",
"integer",
"representation",
"of",
"each",
"candidate",
"with",
"the",
"bayesian",
"losses",
"that",
"we",
"calculate",
"using",
"brute",
"force",
"."
] | python | train |
google/flatbuffers | python/flatbuffers/table.py | https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L56-L64 | def VectorLen(self, off):
"""VectorLen retrieves the length of the vector whose offset is stored
at "off" in this object."""
N.enforce_number(off, N.UOffsetTFlags)
off += self.Pos
off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
ret = encode.Get(N.UOffs... | [
"def",
"VectorLen",
"(",
"self",
",",
"off",
")",
":",
"N",
".",
"enforce_number",
"(",
"off",
",",
"N",
".",
"UOffsetTFlags",
")",
"off",
"+=",
"self",
".",
"Pos",
"off",
"+=",
"encode",
".",
"Get",
"(",
"N",
".",
"UOffsetTFlags",
".",
"packer_type"... | VectorLen retrieves the length of the vector whose offset is stored
at "off" in this object. | [
"VectorLen",
"retrieves",
"the",
"length",
"of",
"the",
"vector",
"whose",
"offset",
"is",
"stored",
"at",
"off",
"in",
"this",
"object",
"."
] | python | train |
welbornprod/colr | colr/colr.py | https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1723-L1744 | def hex(self, value, text=None, back=None, style=None, rgb_mode=False):
""" A chained method that sets the fore color to an hex value.
Arguments:
value : Hex value to convert.
text : Text to style if not building up color codes.
back : Back ... | [
"def",
"hex",
"(",
"self",
",",
"value",
",",
"text",
"=",
"None",
",",
"back",
"=",
"None",
",",
"style",
"=",
"None",
",",
"rgb_mode",
"=",
"False",
")",
":",
"if",
"rgb_mode",
":",
"try",
":",
"colrval",
"=",
"hex2rgb",
"(",
"value",
",",
"all... | A chained method that sets the fore color to an hex value.
Arguments:
value : Hex value to convert.
text : Text to style if not building up color codes.
back : Back color for the text.
style : Style for the text.
r... | [
"A",
"chained",
"method",
"that",
"sets",
"the",
"fore",
"color",
"to",
"an",
"hex",
"value",
".",
"Arguments",
":",
"value",
":",
"Hex",
"value",
"to",
"convert",
".",
"text",
":",
"Text",
"to",
"style",
"if",
"not",
"building",
"up",
"color",
"codes"... | python | train |
coderanger/depot | depot/storage.py | https://github.com/coderanger/depot/blob/d1a96f13204ad7028432096d25718e611d4d3d9d/depot/storage.py#L122-L157 | def _get_storage(cls, uri):
"""
Given a URI like local:///srv/repo or s3://key:secret@apt.example.com,
return a libcloud storage or container object.
"""
driver = cls._get_driver(uri.scheme)
key = uri.username
secret = uri.password
container = uri.netloc
... | [
"def",
"_get_storage",
"(",
"cls",
",",
"uri",
")",
":",
"driver",
"=",
"cls",
".",
"_get_driver",
"(",
"uri",
".",
"scheme",
")",
"key",
"=",
"uri",
".",
"username",
"secret",
"=",
"uri",
".",
"password",
"container",
"=",
"uri",
".",
"netloc",
"dri... | Given a URI like local:///srv/repo or s3://key:secret@apt.example.com,
return a libcloud storage or container object. | [
"Given",
"a",
"URI",
"like",
"local",
":",
"///",
"srv",
"/",
"repo",
"or",
"s3",
":",
"//",
"key",
":",
"secret"
] | python | train |
jasonrollins/shareplum | shareplum/shareplum.py | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L562-L600 | def GetView(self, viewname):
"""Get Info on View Name
"""
# Build Request
soap_request = soap('GetView')
soap_request.add_parameter('listName', self.listName)
if viewname == None:
views = self.GetViewCollection()
for view in views:
... | [
"def",
"GetView",
"(",
"self",
",",
"viewname",
")",
":",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'GetView'",
")",
"soap_request",
".",
"add_parameter",
"(",
"'listName'",
",",
"self",
".",
"listName",
")",
"if",
"viewname",
"==",
"None",
":",
... | Get Info on View Name | [
"Get",
"Info",
"on",
"View",
"Name"
] | python | train |
eventbrite/pysoa | pysoa/server/django/cache.py | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/django/cache.py#L71-L78 | def close(self, for_shutdown=False, **_kwargs):
"""
Only call super().close() if the server is shutting down (not between requests).
:param for_shutdown: If `False` (the default)
"""
if for_shutdown:
super(PySOAPyLibMCCache, self).close() | [
"def",
"close",
"(",
"self",
",",
"for_shutdown",
"=",
"False",
",",
"*",
"*",
"_kwargs",
")",
":",
"if",
"for_shutdown",
":",
"super",
"(",
"PySOAPyLibMCCache",
",",
"self",
")",
".",
"close",
"(",
")"
] | Only call super().close() if the server is shutting down (not between requests).
:param for_shutdown: If `False` (the default) | [
"Only",
"call",
"super",
"()",
".",
"close",
"()",
"if",
"the",
"server",
"is",
"shutting",
"down",
"(",
"not",
"between",
"requests",
")",
"."
] | python | train |
gitpython-developers/GitPython | git/refs/symbolic.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/symbolic.py#L89-L121 | def _iter_packed_refs(cls, repo):
"""Returns an iterator yielding pairs of sha1/path pairs (as bytes) for the corresponding refs.
:note: The packed refs file will be kept open as long as we iterate"""
try:
with open(cls._get_packed_refs_path(repo), 'rt') as fp:
for li... | [
"def",
"_iter_packed_refs",
"(",
"cls",
",",
"repo",
")",
":",
"try",
":",
"with",
"open",
"(",
"cls",
".",
"_get_packed_refs_path",
"(",
"repo",
")",
",",
"'rt'",
")",
"as",
"fp",
":",
"for",
"line",
"in",
"fp",
":",
"line",
"=",
"line",
".",
"str... | Returns an iterator yielding pairs of sha1/path pairs (as bytes) for the corresponding refs.
:note: The packed refs file will be kept open as long as we iterate | [
"Returns",
"an",
"iterator",
"yielding",
"pairs",
"of",
"sha1",
"/",
"path",
"pairs",
"(",
"as",
"bytes",
")",
"for",
"the",
"corresponding",
"refs",
".",
":",
"note",
":",
"The",
"packed",
"refs",
"file",
"will",
"be",
"kept",
"open",
"as",
"long",
"a... | python | train |
dixudx/rtcclient | rtcclient/workitem.py | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L435-L452 | def getIncludedInBuilds(self):
"""Get all :class:`rtcclient.models.IncludedInBuild` objects that
have already included this workitem
WARNING: If one of the IncludedInBuilds is removed or cannot be
retrieved/found correctly, then 404 error will be raised.
:return: a :class:`list... | [
"def",
"getIncludedInBuilds",
"(",
"self",
")",
":",
"build_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.build.linktype.includedWorkItems.\"",
"\"com.ibm.team.build.common.link.includedInBuilds\"",
")",
"return",
"self",
".",
"rtc_obj",
".",
"_get_paged_resources",
"(",
"\"IncludedIn... | Get all :class:`rtcclient.models.IncludedInBuild` objects that
have already included this workitem
WARNING: If one of the IncludedInBuilds is removed or cannot be
retrieved/found correctly, then 404 error will be raised.
:return: a :class:`list` contains all the
:class:`rtc... | [
"Get",
"all",
":",
"class",
":",
"rtcclient",
".",
"models",
".",
"IncludedInBuild",
"objects",
"that",
"have",
"already",
"included",
"this",
"workitem"
] | python | train |
trustar/trustar-python | trustar/utils.py | https://github.com/trustar/trustar-python/blob/707d51adc58d68aed7de12a4ca37949cb75cf122/trustar/utils.py#L117-L138 | def parse_boolean(value):
"""
Coerce a value to boolean.
:param value: the value, could be a string, boolean, or None
:return: the value as coerced to a boolean
"""
if value is None:
return None
if isinstance(value, bool):
return value
if isinstance(value, string_type... | [
"def",
"parse_boolean",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"value",
"=... | Coerce a value to boolean.
:param value: the value, could be a string, boolean, or None
:return: the value as coerced to a boolean | [
"Coerce",
"a",
"value",
"to",
"boolean",
"."
] | python | train |
codelv/enaml-native | src/enamlnative/ios/uikit_activity_indicator.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_activity_indicator.py#L44-L61 | def init_widget(self):
""" Initialize the state of the toolkit widget.
This method is called during the top-down pass, just after the
'create_widget()' method is called. This method should init the
state of the widget. The child widgets will not yet be created.
"""
supe... | [
"def",
"init_widget",
"(",
"self",
")",
":",
"super",
"(",
"UiKitActivityIndicator",
",",
"self",
")",
".",
"init_widget",
"(",
")",
"d",
"=",
"self",
".",
"declaration",
"if",
"d",
".",
"size",
"!=",
"'normal'",
":",
"self",
".",
"set_size",
"(",
"d",... | Initialize the state of the toolkit widget.
This method is called during the top-down pass, just after the
'create_widget()' method is called. This method should init the
state of the widget. The child widgets will not yet be created. | [
"Initialize",
"the",
"state",
"of",
"the",
"toolkit",
"widget",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/grading/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/sessions.py#L5099-L5115 | def get_child_gradebook_ids(self, gradebook_id):
"""Gets the child ``Ids`` of the given gradebook.
arg: gradebook_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the gradebook
raise: NotFound - ``gradebook_id`` is not found
raise: NullArgumen... | [
"def",
"get_child_gradebook_ids",
"(",
"self",
",",
"gradebook_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bin_ids",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_sessio... | Gets the child ``Ids`` of the given gradebook.
arg: gradebook_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the gradebook
raise: NotFound - ``gradebook_id`` is not found
raise: NullArgument - ``gradebook_id`` is ``null``
raise: OperationFa... | [
"Gets",
"the",
"child",
"Ids",
"of",
"the",
"given",
"gradebook",
"."
] | python | train |
annoviko/pyclustering | pyclustering/container/cftree.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/container/cftree.py#L544-L570 | def get_farthest_successors(self, type_measurement):
"""!
@brief Find pair of farthest successors of the node in line with measurement type.
@param[in] type_measurement (measurement_type): Measurement type that is used for obtaining farthest successors.
@return (l... | [
"def",
"get_farthest_successors",
"(",
"self",
",",
"type_measurement",
")",
":",
"farthest_node1",
"=",
"None",
"farthest_node2",
"=",
"None",
"farthest_distance",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"successors",
")... | !
@brief Find pair of farthest successors of the node in line with measurement type.
@param[in] type_measurement (measurement_type): Measurement type that is used for obtaining farthest successors.
@return (list) Pair of farthest successors represented by list [cfnode1, cf... | [
"!"
] | python | valid |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py#L528-L537 | def RIBVRFRouteLimitExceeded_VRFName(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
RIBVRFRouteLimitExceeded = ET.SubElement(config, "RIBVRFRouteLimitExceeded", xmlns="http://brocade.com/ns/brocade-notification-stream")
VRFName = ET.SubElement(RIBVRFRou... | [
"def",
"RIBVRFRouteLimitExceeded_VRFName",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"RIBVRFRouteLimitExceeded",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"RIBVRFRouteLimitExceeded\"",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
log2timeline/plaso | plaso/cli/storage_media_tool.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/storage_media_tool.py#L379-L392 | def _ParseSourcePathOption(self, options):
"""Parses the source path option.
Args:
options (argparse.Namespace): command line arguments.
Raises:
BadConfigOption: if the options are invalid.
"""
self._source_path = self.ParseStringOption(options, self._SOURCE_OPTION)
if not self._so... | [
"def",
"_ParseSourcePathOption",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"_source_path",
"=",
"self",
".",
"ParseStringOption",
"(",
"options",
",",
"self",
".",
"_SOURCE_OPTION",
")",
"if",
"not",
"self",
".",
"_source_path",
":",
"raise",
"erro... | Parses the source path option.
Args:
options (argparse.Namespace): command line arguments.
Raises:
BadConfigOption: if the options are invalid. | [
"Parses",
"the",
"source",
"path",
"option",
"."
] | python | train |
clinicedc/edc-permissions | edc_permissions/utils/generic.py | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/utils/generic.py#L108-L124 | def create_permissions_from_tuples(model, codename_tpls):
"""Creates custom permissions on model "model".
"""
if codename_tpls:
model_cls = django_apps.get_model(model)
content_type = ContentType.objects.get_for_model(model_cls)
for codename_tpl in codename_tpls:
app_labe... | [
"def",
"create_permissions_from_tuples",
"(",
"model",
",",
"codename_tpls",
")",
":",
"if",
"codename_tpls",
":",
"model_cls",
"=",
"django_apps",
".",
"get_model",
"(",
"model",
")",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
... | Creates custom permissions on model "model". | [
"Creates",
"custom",
"permissions",
"on",
"model",
"model",
"."
] | python | train |
google/grr | grr/server/grr_response_server/flows/cron/system.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L70-L90 | def Add(self, category, label, age):
"""Adds another instance of this category into the active_days counter.
We automatically count the event towards all relevant active_days. For
example, if the category "Windows" was seen 8 days ago it will be counted
towards the 30 day active, 14 day active but not ... | [
"def",
"Add",
"(",
"self",
",",
"category",
",",
"label",
",",
"age",
")",
":",
"now",
"=",
"rdfvalue",
".",
"RDFDatetime",
".",
"Now",
"(",
")",
"category",
"=",
"utils",
".",
"SmartUnicode",
"(",
"category",
")",
"for",
"active_time",
"in",
"self",
... | Adds another instance of this category into the active_days counter.
We automatically count the event towards all relevant active_days. For
example, if the category "Windows" was seen 8 days ago it will be counted
towards the 30 day active, 14 day active but not against the 7 and 1 day
actives.
Ar... | [
"Adds",
"another",
"instance",
"of",
"this",
"category",
"into",
"the",
"active_days",
"counter",
"."
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_compat.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_compat.py#L85-L126 | def meta(*bases, **kwargs):
"""
Allows unique syntax similar to Python 3 for working with metaclasses in
both Python 2 and Python 3.
Examples
--------
>>> class BadMeta(type): # An usual metaclass definition
... def __new__(mcls, name, bases, namespace):
... if "bad" not in namespace: # A bad con... | [
"def",
"meta",
"(",
"*",
"bases",
",",
"*",
"*",
"kwargs",
")",
":",
"metaclass",
"=",
"kwargs",
".",
"get",
"(",
"\"metaclass\"",
",",
"type",
")",
"if",
"not",
"bases",
":",
"bases",
"=",
"(",
"object",
",",
")",
"class",
"NewMeta",
"(",
"type",
... | Allows unique syntax similar to Python 3 for working with metaclasses in
both Python 2 and Python 3.
Examples
--------
>>> class BadMeta(type): # An usual metaclass definition
... def __new__(mcls, name, bases, namespace):
... if "bad" not in namespace: # A bad constraint
... raise Exception(... | [
"Allows",
"unique",
"syntax",
"similar",
"to",
"Python",
"3",
"for",
"working",
"with",
"metaclasses",
"in",
"both",
"Python",
"2",
"and",
"Python",
"3",
"."
] | python | train |
user-cont/colin | colin/core/target.py | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L360-L366 | def mount_point(self):
""" ostree checkout -- real filesystem """
if self._mount_point is None:
self._mount_point = os.path.join(self.tmpdir, "checkout")
os.makedirs(self._mount_point)
self._checkout()
return self._mount_point | [
"def",
"mount_point",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mount_point",
"is",
"None",
":",
"self",
".",
"_mount_point",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"tmpdir",
",",
"\"checkout\"",
")",
"os",
".",
"makedirs",
"(",
"se... | ostree checkout -- real filesystem | [
"ostree",
"checkout",
"--",
"real",
"filesystem"
] | python | train |
mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L713-L792 | def _perform_emulated_reset(self):
"""! @brief Emulate a software reset by writing registers.
All core registers are written to reset values. This includes setting the initial PC and SP
to values read from the vector table, which is assumed to be located at the based of the
boot... | [
"def",
"_perform_emulated_reset",
"(",
"self",
")",
":",
"# Halt the core before making changes.",
"self",
".",
"halt",
"(",
")",
"bootMemory",
"=",
"self",
".",
"memory_map",
".",
"get_boot_memory",
"(",
")",
"if",
"bootMemory",
"is",
"None",
":",
"# Reuse curren... | ! @brief Emulate a software reset by writing registers.
All core registers are written to reset values. This includes setting the initial PC and SP
to values read from the vector table, which is assumed to be located at the based of the
boot memory region.
If the memory... | [
"!"
] | python | train |
Azure/blobxfer | blobxfer/util.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/util.py#L340-L364 | def parse_fileshare_or_file_snapshot_parameter(url):
# type: (str) -> Tuple[str, str]
"""Checks if the fileshare or file is a snapshot
:param url str: file url
:rtype: tuple
:return: (url, snapshot)
"""
if is_not_empty(url):
if '?sharesnapshot=' in url:
try:
... | [
"def",
"parse_fileshare_or_file_snapshot_parameter",
"(",
"url",
")",
":",
"# type: (str) -> Tuple[str, str]",
"if",
"is_not_empty",
"(",
"url",
")",
":",
"if",
"'?sharesnapshot='",
"in",
"url",
":",
"try",
":",
"tmp",
"=",
"url",
".",
"split",
"(",
"'?sharesnapsh... | Checks if the fileshare or file is a snapshot
:param url str: file url
:rtype: tuple
:return: (url, snapshot) | [
"Checks",
"if",
"the",
"fileshare",
"or",
"file",
"is",
"a",
"snapshot",
":",
"param",
"url",
"str",
":",
"file",
"url",
":",
"rtype",
":",
"tuple",
":",
"return",
":",
"(",
"url",
"snapshot",
")"
] | python | train |
fmfn/BayesianOptimization | bayes_opt/target_space.py | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L221-L232 | def max(self):
"""Get maximum target value found and corresponding parametes."""
try:
res = {
'target': self.target.max(),
'params': dict(
zip(self.keys, self.params[self.target.argmax()])
)
}
except Valu... | [
"def",
"max",
"(",
"self",
")",
":",
"try",
":",
"res",
"=",
"{",
"'target'",
":",
"self",
".",
"target",
".",
"max",
"(",
")",
",",
"'params'",
":",
"dict",
"(",
"zip",
"(",
"self",
".",
"keys",
",",
"self",
".",
"params",
"[",
"self",
".",
... | Get maximum target value found and corresponding parametes. | [
"Get",
"maximum",
"target",
"value",
"found",
"and",
"corresponding",
"parametes",
"."
] | python | train |
xtuml/pyxtuml | bridgepoint/oal.py | https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/oal.py#L1507-L1512 | def p_unrelate_statement_1(self, p):
'''statement : UNRELATE instance_name FROM instance_name ACROSS rel_id'''
p[0] = UnrelateNode(from_variable_name=p[2],
to_variable_name=p[4],
rel_id=p[6],
phrase=None) | [
"def",
"p_unrelate_statement_1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"UnrelateNode",
"(",
"from_variable_name",
"=",
"p",
"[",
"2",
"]",
",",
"to_variable_name",
"=",
"p",
"[",
"4",
"]",
",",
"rel_id",
"=",
"p",
"[",
"6",
"]",... | statement : UNRELATE instance_name FROM instance_name ACROSS rel_id | [
"statement",
":",
"UNRELATE",
"instance_name",
"FROM",
"instance_name",
"ACROSS",
"rel_id"
] | python | test |
SatelliteQE/nailgun | nailgun/entities.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L5220-L5227 | def create_payload(self):
"""Remove ``smart_class_parameter_id`` or ``smart_variable_id``"""
payload = super(OverrideValue, self).create_payload()
if hasattr(self, 'smart_class_parameter'):
del payload['smart_class_parameter_id']
if hasattr(self, 'smart_variable'):
... | [
"def",
"create_payload",
"(",
"self",
")",
":",
"payload",
"=",
"super",
"(",
"OverrideValue",
",",
"self",
")",
".",
"create_payload",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"'smart_class_parameter'",
")",
":",
"del",
"payload",
"[",
"'smart_class_par... | Remove ``smart_class_parameter_id`` or ``smart_variable_id`` | [
"Remove",
"smart_class_parameter_id",
"or",
"smart_variable_id"
] | python | train |
marccarre/py_sak | py_sak/validation.py | https://github.com/marccarre/py_sak/blob/8ad4cafbd725d2700a31b50526804c0330d828dd/py_sak/validation.py#L47-L49 | def is_valid_dir(path):
''' Returns True if provided directory exists and is a directory, or False otherwise. '''
return os.path.exists(path) and os.path.isdir(path) | [
"def",
"is_valid_dir",
"(",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")"
] | Returns True if provided directory exists and is a directory, or False otherwise. | [
"Returns",
"True",
"if",
"provided",
"directory",
"exists",
"and",
"is",
"a",
"directory",
"or",
"False",
"otherwise",
"."
] | python | train |
d0c-s4vage/pfp | pfp/fields.py | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L627-L640 | def _pfp__set_value(self, value):
"""Initialize the struct. Value should be an array of
fields, one each for each struct member.
:value: An array of fields to initialize the struct with
:returns: None
"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()... | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_pfp__frozen",
":",
"raise",
"errors",
".",
"UnmodifiableConst",
"(",
")",
"if",
"len",
"(",
"value",
")",
"!=",
"len",
"(",
"self",
".",
"_pfp__children",
")",
":",
"ra... | Initialize the struct. Value should be an array of
fields, one each for each struct member.
:value: An array of fields to initialize the struct with
:returns: None | [
"Initialize",
"the",
"struct",
".",
"Value",
"should",
"be",
"an",
"array",
"of",
"fields",
"one",
"each",
"for",
"each",
"struct",
"member",
"."
] | python | train |
saltstack/salt | salt/utils/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/state.py#L27-L77 | def search_onfail_requisites(sid, highstate):
'''
For a particular low chunk, search relevant onfail related states
'''
onfails = []
if '_|-' in sid:
st = salt.state.split_low_tag(sid)
else:
st = {'__id__': sid}
for fstate, fchunks in six.iteritems(highstate):
if fsta... | [
"def",
"search_onfail_requisites",
"(",
"sid",
",",
"highstate",
")",
":",
"onfails",
"=",
"[",
"]",
"if",
"'_|-'",
"in",
"sid",
":",
"st",
"=",
"salt",
".",
"state",
".",
"split_low_tag",
"(",
"sid",
")",
"else",
":",
"st",
"=",
"{",
"'__id__'",
":"... | For a particular low chunk, search relevant onfail related states | [
"For",
"a",
"particular",
"low",
"chunk",
"search",
"relevant",
"onfail",
"related",
"states"
] | python | train |
goerz/clusterjob | clusterjob/backends/sge.py | https://github.com/goerz/clusterjob/blob/361760d1a6dd3cbde49c5c2158a3acd0c314a749/clusterjob/backends/sge.py#L119-L155 | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
lines = []
for (key, val) in jobscript.resources.items():
... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
"jobscript",
".",
"resources",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"resource_replacements",
... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"~clusterjob",
".",
"JobScript",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"script"
] | python | train |
awslabs/serverless-application-model | samtranslator/model/sam_resources.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/sam_resources.py#L690-L704 | def _get_retention_policy_value(self):
"""
Sets the deletion policy on this resource. The default is 'Retain'.
:return: value for the DeletionPolicy attribute.
"""
if self.RetentionPolicy is None or self.RetentionPolicy.lower() == self.RETAIN.lower():
return self.RE... | [
"def",
"_get_retention_policy_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"RetentionPolicy",
"is",
"None",
"or",
"self",
".",
"RetentionPolicy",
".",
"lower",
"(",
")",
"==",
"self",
".",
"RETAIN",
".",
"lower",
"(",
")",
":",
"return",
"self",
"."... | Sets the deletion policy on this resource. The default is 'Retain'.
:return: value for the DeletionPolicy attribute. | [
"Sets",
"the",
"deletion",
"policy",
"on",
"this",
"resource",
".",
"The",
"default",
"is",
"Retain",
"."
] | python | train |
andymccurdy/redis-py | redis/client.py | https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L1019-L1031 | def memory_usage(self, key, samples=None):
"""
Return the total memory usage for key, its value and associated
administrative overheads.
For nested data structures, ``samples`` is the number of elements to
sample. If left unspecified, the server's default is 5. Use 0 to sample
... | [
"def",
"memory_usage",
"(",
"self",
",",
"key",
",",
"samples",
"=",
"None",
")",
":",
"args",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"samples",
",",
"int",
")",
":",
"args",
".",
"extend",
"(",
"[",
"Token",
".",
"get_token",
"(",
"'SAMPLES'",
")... | Return the total memory usage for key, its value and associated
administrative overheads.
For nested data structures, ``samples`` is the number of elements to
sample. If left unspecified, the server's default is 5. Use 0 to sample
all elements. | [
"Return",
"the",
"total",
"memory",
"usage",
"for",
"key",
"its",
"value",
"and",
"associated",
"administrative",
"overheads",
"."
] | python | train |
dereneaton/ipyrad | ipyrad/core/assembly.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/core/assembly.py#L560-L620 | def _link_barcodes(self):
"""
Private function. Links Sample barcodes in a dictionary as
[Assembly].barcodes, with barcodes parsed from the 'barcodes_path'
parameter. This function is called during set_params() when setting
the barcodes_path.
"""
## parse barcode... | [
"def",
"_link_barcodes",
"(",
"self",
")",
":",
"## parse barcodefile",
"try",
":",
"## allows fuzzy match to barcodefile name",
"barcodefile",
"=",
"glob",
".",
"glob",
"(",
"self",
".",
"paramsdict",
"[",
"\"barcodes_path\"",
"]",
")",
"[",
"0",
"]",
"## read in... | Private function. Links Sample barcodes in a dictionary as
[Assembly].barcodes, with barcodes parsed from the 'barcodes_path'
parameter. This function is called during set_params() when setting
the barcodes_path. | [
"Private",
"function",
".",
"Links",
"Sample",
"barcodes",
"in",
"a",
"dictionary",
"as",
"[",
"Assembly",
"]",
".",
"barcodes",
"with",
"barcodes",
"parsed",
"from",
"the",
"barcodes_path",
"parameter",
".",
"This",
"function",
"is",
"called",
"during",
"set_... | python | valid |
noahbenson/neuropythy | neuropythy/mri/images.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/mri/images.py#L54-L64 | def parse_type(self, hdat, dataobj=None):
'''
Parses the dtype out of the header data or the array, depending on which is given; if both,
then the header-data overrides the array; if neither, then np.float32.
'''
try: dataobj = dataobj.dataobj
except Exception: pass
... | [
"def",
"parse_type",
"(",
"self",
",",
"hdat",
",",
"dataobj",
"=",
"None",
")",
":",
"try",
":",
"dataobj",
"=",
"dataobj",
".",
"dataobj",
"except",
"Exception",
":",
"pass",
"dtype",
"=",
"np",
".",
"asarray",
"(",
"dataobj",
")",
".",
"dtype",
"i... | Parses the dtype out of the header data or the array, depending on which is given; if both,
then the header-data overrides the array; if neither, then np.float32. | [
"Parses",
"the",
"dtype",
"out",
"of",
"the",
"header",
"data",
"or",
"the",
"array",
"depending",
"on",
"which",
"is",
"given",
";",
"if",
"both",
"then",
"the",
"header",
"-",
"data",
"overrides",
"the",
"array",
";",
"if",
"neither",
"then",
"np",
"... | python | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L391-L456 | def plot_tree(booster, ax=None, tree_index=0, figsize=None,
old_graph_attr=None, old_node_attr=None, old_edge_attr=None,
show_info=None, precision=None, **kwargs):
"""Plot specified tree.
Note
----
It is preferable to use ``create_tree_digraph()`` because of its lossless qua... | [
"def",
"plot_tree",
"(",
"booster",
",",
"ax",
"=",
"None",
",",
"tree_index",
"=",
"0",
",",
"figsize",
"=",
"None",
",",
"old_graph_attr",
"=",
"None",
",",
"old_node_attr",
"=",
"None",
",",
"old_edge_attr",
"=",
"None",
",",
"show_info",
"=",
"None",... | Plot specified tree.
Note
----
It is preferable to use ``create_tree_digraph()`` because of its lossless quality
and returned objects can be also rendered and displayed directly inside a Jupyter notebook.
Parameters
----------
booster : Booster or LGBMModel
Booster or LGBMModel ins... | [
"Plot",
"specified",
"tree",
"."
] | python | train |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6561-L6595 | def getStr_to_pathlist(gs):
'''
gs = "[1]['1'][2]"
getStr_to_pathlist(gs)
gs = "['u']['u1']"
getStr_to_pathlist(gs)
'''
def numize(w):
try:
int(w)
except:
try:
float(w)
except:
return(w)
... | [
"def",
"getStr_to_pathlist",
"(",
"gs",
")",
":",
"def",
"numize",
"(",
"w",
")",
":",
"try",
":",
"int",
"(",
"w",
")",
"except",
":",
"try",
":",
"float",
"(",
"w",
")",
"except",
":",
"return",
"(",
"w",
")",
"else",
":",
"return",
"(",
"flo... | gs = "[1]['1'][2]"
getStr_to_pathlist(gs)
gs = "['u']['u1']"
getStr_to_pathlist(gs) | [
"gs",
"=",
"[",
"1",
"]",
"[",
"1",
"]",
"[",
"2",
"]",
"getStr_to_pathlist",
"(",
"gs",
")",
"gs",
"=",
"[",
"u",
"]",
"[",
"u1",
"]",
"getStr_to_pathlist",
"(",
"gs",
")"
] | python | valid |
Kaggle/kaggle-api | kaggle/api/kaggle_api.py | https://github.com/Kaggle/kaggle-api/blob/65f14b1386470c5784d4753e491478e7537660d9/kaggle/api/kaggle_api.py#L2144-L2164 | def kernel_pull(self, user_name, kernel_slug, **kwargs): # noqa: E501
"""Pull the latest code from a kernel # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_pull(user_name, ke... | [
"def",
"kernel_pull",
"(",
"self",
",",
"user_name",
",",
"kernel_slug",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"se... | Pull the latest code from a kernel # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_pull(user_name, kernel_slug, async_req=True)
>>> result = thread.get()
:param async... | [
"Pull",
"the",
"latest",
"code",
"from",
"a",
"kernel",
"#",
"noqa",
":",
"E501"
] | python | train |
senaite/senaite.core | bika/lims/setuphandlers.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/setuphandlers.py#L444-L493 | def setup_core_catalogs(portal):
"""Setup core catalogs
"""
logger.info("*** Setup Core Catalogs ***")
to_reindex = []
for catalog, name, attribute, meta_type in INDEXES:
c = api.get_tool(catalog)
indexes = c.indexes()
if name in indexes:
logger.info("*** Index '... | [
"def",
"setup_core_catalogs",
"(",
"portal",
")",
":",
"logger",
".",
"info",
"(",
"\"*** Setup Core Catalogs ***\"",
")",
"to_reindex",
"=",
"[",
"]",
"for",
"catalog",
",",
"name",
",",
"attribute",
",",
"meta_type",
"in",
"INDEXES",
":",
"c",
"=",
"api",
... | Setup core catalogs | [
"Setup",
"core",
"catalogs"
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/util.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/util.py#L43-L67 | def get_segment_token_offsets(segment_token_list, token_map):
"""
given a list of token node IDs, returns the index of its first and last
elements. this actually calculates the int indices, as there are weird
formats like RS3, which use unordered / wrongly ordered IDs.
Parameters
----------
... | [
"def",
"get_segment_token_offsets",
"(",
"segment_token_list",
",",
"token_map",
")",
":",
"token_indices",
"=",
"[",
"token_map",
"[",
"token_id",
"]",
"for",
"token_id",
"in",
"segment_token_list",
"]",
"# we need to foolproof this for nasty RS3 files or other input formats... | given a list of token node IDs, returns the index of its first and last
elements. this actually calculates the int indices, as there are weird
formats like RS3, which use unordered / wrongly ordered IDs.
Parameters
----------
segment_token_list : list of str
sorted list of token IDs (i.e. t... | [
"given",
"a",
"list",
"of",
"token",
"node",
"IDs",
"returns",
"the",
"index",
"of",
"its",
"first",
"and",
"last",
"elements",
".",
"this",
"actually",
"calculates",
"the",
"int",
"indices",
"as",
"there",
"are",
"weird",
"formats",
"like",
"RS3",
"which"... | python | train |
vals/umis | umis/umis.py | https://github.com/vals/umis/blob/e8adb8486d9e9134ab8a6cad9811a7e74dcc4a2c/umis/umis.py#L1256-L1305 | def demultiplex_samples(fastq, out_dir, nedit, barcodes):
''' Demultiplex a fastqtransformed FASTQ file into a FASTQ file for
each sample.
'''
annotations = detect_fastq_annotations(fastq)
re_string = construct_transformed_regex(annotations)
parser_re = re.compile(re_string)
if barcodes:
... | [
"def",
"demultiplex_samples",
"(",
"fastq",
",",
"out_dir",
",",
"nedit",
",",
"barcodes",
")",
":",
"annotations",
"=",
"detect_fastq_annotations",
"(",
"fastq",
")",
"re_string",
"=",
"construct_transformed_regex",
"(",
"annotations",
")",
"parser_re",
"=",
"re"... | Demultiplex a fastqtransformed FASTQ file into a FASTQ file for
each sample. | [
"Demultiplex",
"a",
"fastqtransformed",
"FASTQ",
"file",
"into",
"a",
"FASTQ",
"file",
"for",
"each",
"sample",
"."
] | python | train |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1534-L1537 | def p_if_statement_delay(self, p):
'if_statement : delays IF LPAREN cond RPAREN true_statement ELSE else_statement'
p[0] = IfStatement(p[4], p[6], p[8], lineno=p.lineno(2))
p.set_lineno(0, p.lineno(2)) | [
"def",
"p_if_statement_delay",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"IfStatement",
"(",
"p",
"[",
"4",
"]",
",",
"p",
"[",
"6",
"]",
",",
"p",
"[",
"8",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"2",
")",
")",
... | if_statement : delays IF LPAREN cond RPAREN true_statement ELSE else_statement | [
"if_statement",
":",
"delays",
"IF",
"LPAREN",
"cond",
"RPAREN",
"true_statement",
"ELSE",
"else_statement"
] | python | train |
PmagPy/PmagPy | SPD/lib/new_lib_curvature.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/new_lib_curvature.py#L29-L75 | def fitcircle(n, x, y):
# n points, x points, y points
"""c Fit circle to arbitrary number of x,y pairs, based on the
c modified least squares method of Umback and Jones (2000),
c IEEE Transactions on Instrumentation and Measurement."""
# adding in normalize vectors step
#x = numpy.array(x) / max(x)
#y... | [
"def",
"fitcircle",
"(",
"n",
",",
"x",
",",
"y",
")",
":",
"# n points, x points, y points",
"# adding in normalize vectors step",
"#x = numpy.array(x) / max(x)",
"#y = numpy.array(y) / max(y)",
"#",
"sx",
",",
"sx2",
",",
"sx3",
",",
"sy",
",",
"sy2",
",",
"sy3",
... | c Fit circle to arbitrary number of x,y pairs, based on the
c modified least squares method of Umback and Jones (2000),
c IEEE Transactions on Instrumentation and Measurement. | [
"c",
"Fit",
"circle",
"to",
"arbitrary",
"number",
"of",
"x",
"y",
"pairs",
"based",
"on",
"the",
"c",
"modified",
"least",
"squares",
"method",
"of",
"Umback",
"and",
"Jones",
"(",
"2000",
")",
"c",
"IEEE",
"Transactions",
"on",
"Instrumentation",
"and",
... | python | train |
zero-os/zerotier_client | zerotier/Network.py | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/Network.py#L15-L29 | def create(annot=None, config=None, id=None, ui=None):
"""
:type annot: dict
:type config: NetworkConfig
:type id: str
:type ui: dict
:rtype: Network
"""
return Network(
annot=annot,
config=config,
id=id,
ui... | [
"def",
"create",
"(",
"annot",
"=",
"None",
",",
"config",
"=",
"None",
",",
"id",
"=",
"None",
",",
"ui",
"=",
"None",
")",
":",
"return",
"Network",
"(",
"annot",
"=",
"annot",
",",
"config",
"=",
"config",
",",
"id",
"=",
"id",
",",
"ui",
"=... | :type annot: dict
:type config: NetworkConfig
:type id: str
:type ui: dict
:rtype: Network | [
":",
"type",
"annot",
":",
"dict",
":",
"type",
"config",
":",
"NetworkConfig",
":",
"type",
"id",
":",
"str",
":",
"type",
"ui",
":",
"dict",
":",
"rtype",
":",
"Network"
] | python | train |
deepmind/sonnet | sonnet/python/modules/batch_norm.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/batch_norm.py#L400-L442 | def _batch_norm_op(self, input_batch, mean, variance, use_batch_stats,
stat_dtype):
"""Creates a batch normalization op.
It uses the tf.nn.batch_normalization op by default and the
tf.nn.fused_batch_norm op to support fused batch normalization.
Args:
input_batch: A input Ten... | [
"def",
"_batch_norm_op",
"(",
"self",
",",
"input_batch",
",",
"mean",
",",
"variance",
",",
"use_batch_stats",
",",
"stat_dtype",
")",
":",
"if",
"self",
".",
"_fused",
":",
"# For the non-training case where not using batch stats,",
"# pass in the moving statistic varia... | Creates a batch normalization op.
It uses the tf.nn.batch_normalization op by default and the
tf.nn.fused_batch_norm op to support fused batch normalization.
Args:
input_batch: A input Tensor of arbitrary dimension.
mean: A mean tensor, of the same dtype as `input_batch`.
variance: A var... | [
"Creates",
"a",
"batch",
"normalization",
"op",
"."
] | python | train |
inveniosoftware-attic/invenio-documents | invenio_documents/api.py | https://github.com/inveniosoftware-attic/invenio-documents/blob/cdfcd21ea5d9ad26f4405f418863fcc3df636176/invenio_documents/api.py#L67-L75 | def copy(self, dst, **kwargs):
"""Copy file to a new destination.
Returns JSON Patch with proposed change pointing to new copy.
"""
_fs, filename = opener.parse(self.uri)
_fs_dst, filename_dst = opener.parse(dst)
copyfile(_fs, filename, _fs_dst, filename_dst, **kwargs)
... | [
"def",
"copy",
"(",
"self",
",",
"dst",
",",
"*",
"*",
"kwargs",
")",
":",
"_fs",
",",
"filename",
"=",
"opener",
".",
"parse",
"(",
"self",
".",
"uri",
")",
"_fs_dst",
",",
"filename_dst",
"=",
"opener",
".",
"parse",
"(",
"dst",
")",
"copyfile",
... | Copy file to a new destination.
Returns JSON Patch with proposed change pointing to new copy. | [
"Copy",
"file",
"to",
"a",
"new",
"destination",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/proto_builder.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/proto_builder.py#L44-L57 | def _GetMessageFromFactory(factory, full_name):
"""Get a proto class from the MessageFactory by name.
Args:
factory: a MessageFactory instance.
full_name: str, the fully qualified name of the proto type.
Returns:
A class, for the type identified by full_name.
Raises:
KeyError, if the proto is n... | [
"def",
"_GetMessageFromFactory",
"(",
"factory",
",",
"full_name",
")",
":",
"proto_descriptor",
"=",
"factory",
".",
"pool",
".",
"FindMessageTypeByName",
"(",
"full_name",
")",
"proto_cls",
"=",
"factory",
".",
"GetPrototype",
"(",
"proto_descriptor",
")",
"retu... | Get a proto class from the MessageFactory by name.
Args:
factory: a MessageFactory instance.
full_name: str, the fully qualified name of the proto type.
Returns:
A class, for the type identified by full_name.
Raises:
KeyError, if the proto is not found in the factory's descriptor pool. | [
"Get",
"a",
"proto",
"class",
"from",
"the",
"MessageFactory",
"by",
"name",
"."
] | python | train |
Scifabric/pybossa-client | pbclient/__init__.py | https://github.com/Scifabric/pybossa-client/blob/998d7cb0207ff5030dc800f0c2577c5692316c2c/pbclient/__init__.py#L768-L787 | def find_helping_materials(project_id, **kwargs):
"""Return a list of matched helping materials for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA HelpingMaterial members
:type info: dict
:rtype: list
:returns: A list of helping ma... | [
"def",
"find_helping_materials",
"(",
"project_id",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"kwargs",
"[",
"'project_id'",
"]",
"=",
"project_id",
"res",
"=",
"_pybossa_req",
"(",
"'get'",
",",
"'helpingmaterial'",
",",
"params",
"=",
"kwargs",
")",
... | Return a list of matched helping materials for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA HelpingMaterial members
:type info: dict
:rtype: list
:returns: A list of helping materials that match the kwargs | [
"Return",
"a",
"list",
"of",
"matched",
"helping",
"materials",
"for",
"a",
"given",
"project",
"ID",
"."
] | python | valid |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/build.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/build.py#L209-L252 | def _rmdir(path):
"""
Remove dirname(os.path.abspath(path)) and all its contents, but only if:
1. It doesn't start with BUILDPATH
2. It is a directory and not empty (otherwise continue without removing
the directory)
3. BUILDPATH and SPECPATH don't start with it
4. The --noconfirm option... | [
"def",
"_rmdir",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"if",
"not",
"path",
".",
"startswith",
"(",
"BUILDPATH",
")",
"and",... | Remove dirname(os.path.abspath(path)) and all its contents, but only if:
1. It doesn't start with BUILDPATH
2. It is a directory and not empty (otherwise continue without removing
the directory)
3. BUILDPATH and SPECPATH don't start with it
4. The --noconfirm option is set, or sys.stdout is a tt... | [
"Remove",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
"))",
"and",
"all",
"its",
"contents",
"but",
"only",
"if",
":"
] | python | train |
Syndace/python-x3dh | x3dh/state.py | https://github.com/Syndace/python-x3dh/blob/a6cec1ae858121b88bef1b178f5cda5e43d5c391/x3dh/state.py#L230-L236 | def __checkSPKTimestamp(self):
"""
Check whether the SPK is too old and generate a new one in that case.
"""
if time.time() - self.__spk["timestamp"] > self.__spk_timeout:
self.__generateSPK() | [
"def",
"__checkSPKTimestamp",
"(",
"self",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"__spk",
"[",
"\"timestamp\"",
"]",
">",
"self",
".",
"__spk_timeout",
":",
"self",
".",
"__generateSPK",
"(",
")"
] | Check whether the SPK is too old and generate a new one in that case. | [
"Check",
"whether",
"the",
"SPK",
"is",
"too",
"old",
"and",
"generate",
"a",
"new",
"one",
"in",
"that",
"case",
"."
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient/_lpar.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_lpar.py#L429-L567 | def scsi_load(self, load_address, wwpn, lun, load_parameter=None,
disk_partition_id=None,
operating_system_specific_load_parameters=None,
boot_record_logical_block_address=None, force=False,
wait_for_completion=True, operation_timeout=None,
... | [
"def",
"scsi_load",
"(",
"self",
",",
"load_address",
",",
"wwpn",
",",
"lun",
",",
"load_parameter",
"=",
"None",
",",
"disk_partition_id",
"=",
"None",
",",
"operating_system_specific_load_parameters",
"=",
"None",
",",
"boot_record_logical_block_address",
"=",
"N... | Load (boot) this LPAR from a designated SCSI device, using the
HMC operation "SCSI Load".
This HMC operation has deferred status behavior: If the asynchronous
job on the HMC is complete, it takes a few seconds until the LPAR
status has reached the desired value. If `wait_for_completion=... | [
"Load",
"(",
"boot",
")",
"this",
"LPAR",
"from",
"a",
"designated",
"SCSI",
"device",
"using",
"the",
"HMC",
"operation",
"SCSI",
"Load",
"."
] | python | train |
avelino/bottle-auth | bottle_auth/core/httputil.py | https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L191-L233 | def parse_multipart_form_data(boundary, data, arguments, files):
"""Parses a multipart/form-data body.
The boundary and data parameters are both byte strings.
The dictionaries given in the arguments and files parameters
will be updated with the contents of the body.
"""
# The standard allows fo... | [
"def",
"parse_multipart_form_data",
"(",
"boundary",
",",
"data",
",",
"arguments",
",",
"files",
")",
":",
"# The standard allows for the boundary to be quoted in the header,",
"# although it's rare (it happens at least for google app engine",
"# xmpp). I think we're also supposed to h... | Parses a multipart/form-data body.
The boundary and data parameters are both byte strings.
The dictionaries given in the arguments and files parameters
will be updated with the contents of the body. | [
"Parses",
"a",
"multipart",
"/",
"form",
"-",
"data",
"body",
"."
] | python | test |
proycon/clam | clam/common/data.py | https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/common/data.py#L1825-L1867 | def fromxml(node):
"""Static method return an OutputTemplate instance from the given XML description. Node can be a string or an etree._Element."""
if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
node = parsexmlstring(node)
assert node.tag.lower() == '... | [
"def",
"fromxml",
"(",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"ElementTree",
".",
"_Element",
")",
":",
"#pylint: disable=protected-access",
"node",
"=",
"parsexmlstring",
"(",
"node",
")",
"assert",
"node",
".",
"tag",
".",
"lower",
... | Static method return an OutputTemplate instance from the given XML description. Node can be a string or an etree._Element. | [
"Static",
"method",
"return",
"an",
"OutputTemplate",
"instance",
"from",
"the",
"given",
"XML",
"description",
".",
"Node",
"can",
"be",
"a",
"string",
"or",
"an",
"etree",
".",
"_Element",
"."
] | python | train |
mikedh/trimesh | trimesh/comparison.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/comparison.py#L107-L134 | def identifier_hash(identifier, sigfig=None):
"""
Hash an identifier array to a specified number of
significant figures.
Parameters
----------
identifier : (n,) float
Vector of properties
sigfig : (n,) int
Number of sigfigs per property
Returns
----------
md5 : str
... | [
"def",
"identifier_hash",
"(",
"identifier",
",",
"sigfig",
"=",
"None",
")",
":",
"if",
"sigfig",
"is",
"None",
":",
"sigfig",
"=",
"id_sigfig",
"# convert identifier to integers and order of magnitude",
"as_int",
",",
"multiplier",
"=",
"util",
".",
"sigfig_int",
... | Hash an identifier array to a specified number of
significant figures.
Parameters
----------
identifier : (n,) float
Vector of properties
sigfig : (n,) int
Number of sigfigs per property
Returns
----------
md5 : str
MD5 hash of identifier | [
"Hash",
"an",
"identifier",
"array",
"to",
"a",
"specified",
"number",
"of",
"significant",
"figures",
"."
] | python | train |
jashandeep-sohi/python-blowfish | blowfish.py | https://github.com/jashandeep-sohi/python-blowfish/blob/5ce7f6d54dcef7efd715b26f9a9ffee0d543047e/blowfish.py#L657-L702 | def encrypt_cbc(self, data, init_vector):
"""
Return an iterator that encrypts `data` using the Cipher-Block Chaining
(CBC) mode of operation.
CBC mode can only operate on `data` that is a multiple of the block-size
in length.
Each iteration returns a block-sized :obj:`bytes` object (i... | [
"def",
"encrypt_cbc",
"(",
"self",
",",
"data",
",",
"init_vector",
")",
":",
"S1",
",",
"S2",
",",
"S3",
",",
"S4",
"=",
"self",
".",
"S",
"P",
"=",
"self",
".",
"P",
"u4_1_pack",
"=",
"self",
".",
"_u4_1_pack",
"u1_4_unpack",
"=",
"self",
".",
... | Return an iterator that encrypts `data` using the Cipher-Block Chaining
(CBC) mode of operation.
CBC mode can only operate on `data` that is a multiple of the block-size
in length.
Each iteration returns a block-sized :obj:`bytes` object (i.e. 8 bytes)
containing the encrypted bytes of the... | [
"Return",
"an",
"iterator",
"that",
"encrypts",
"data",
"using",
"the",
"Cipher",
"-",
"Block",
"Chaining",
"(",
"CBC",
")",
"mode",
"of",
"operation",
".",
"CBC",
"mode",
"can",
"only",
"operate",
"on",
"data",
"that",
"is",
"a",
"multiple",
"of",
"the"... | python | train |
esterhui/pypu | pypu/service_facebook.py | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L500-L517 | def _already_resized_on_fb(self,fn,pid,_megapixels):
"""Checks if image file (fn) with photo_id (pid) has already
been resized on fb. If so, returns True"""
logger.debug("%s - resize requested"%(fn))
# Get width/height from fb
width_fb,height_fb=self._getphoto_originalsize(pid)
... | [
"def",
"_already_resized_on_fb",
"(",
"self",
",",
"fn",
",",
"pid",
",",
"_megapixels",
")",
":",
"logger",
".",
"debug",
"(",
"\"%s - resize requested\"",
"%",
"(",
"fn",
")",
")",
"# Get width/height from fb",
"width_fb",
",",
"height_fb",
"=",
"self",
".",... | Checks if image file (fn) with photo_id (pid) has already
been resized on fb. If so, returns True | [
"Checks",
"if",
"image",
"file",
"(",
"fn",
")",
"with",
"photo_id",
"(",
"pid",
")",
"has",
"already",
"been",
"resized",
"on",
"fb",
".",
"If",
"so",
"returns",
"True"
] | python | train |
astropy/photutils | photutils/isophote/isophote.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L259-L295 | def _compute_errors(self):
"""
Compute parameter errors based on the diagonal of the covariance
matrix of the four harmonic coefficients for harmonics n=1 and
n=2.
"""
try:
coeffs = fit_first_and_second_harmonics(self.sample.values[0],
... | [
"def",
"_compute_errors",
"(",
"self",
")",
":",
"try",
":",
"coeffs",
"=",
"fit_first_and_second_harmonics",
"(",
"self",
".",
"sample",
".",
"values",
"[",
"0",
"]",
",",
"self",
".",
"sample",
".",
"values",
"[",
"2",
"]",
")",
"covariance",
"=",
"c... | Compute parameter errors based on the diagonal of the covariance
matrix of the four harmonic coefficients for harmonics n=1 and
n=2. | [
"Compute",
"parameter",
"errors",
"based",
"on",
"the",
"diagonal",
"of",
"the",
"covariance",
"matrix",
"of",
"the",
"four",
"harmonic",
"coefficients",
"for",
"harmonics",
"n",
"=",
"1",
"and",
"n",
"=",
"2",
"."
] | python | train |
pyQode/pyqode.core | pyqode/core/widgets/output_window.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/output_window.py#L1329-L1353 | def _get_line_and_col(data):
"""
Gets line and column from a string like the following: "1;5" or "1;" or ";5"
and convers the column/line numbers to 0 base.
"""
try:
line, column = data.split(';')
except AttributeError:
line = int(data)
... | [
"def",
"_get_line_and_col",
"(",
"data",
")",
":",
"try",
":",
"line",
",",
"column",
"=",
"data",
".",
"split",
"(",
"';'",
")",
"except",
"AttributeError",
":",
"line",
"=",
"int",
"(",
"data",
")",
"column",
"=",
"1",
"# handle empty values and convert ... | Gets line and column from a string like the following: "1;5" or "1;" or ";5"
and convers the column/line numbers to 0 base. | [
"Gets",
"line",
"and",
"column",
"from",
"a",
"string",
"like",
"the",
"following",
":",
"1",
";",
"5",
"or",
"1",
";",
"or",
";",
"5"
] | python | train |
mattja/nsim | nsim/analyses1/_cwtmorlet.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/_cwtmorlet.py#L20-L69 | def roughcwt(data, wavelet, widths):
"""
Continuous wavelet transform.
Performs a continuous wavelet transform on `data`,
using the `wavelet` function. A CWT performs a convolution
with `data` using the `wavelet` function, which is characterized
by a width parameter and length parameter.
P... | [
"def",
"roughcwt",
"(",
"data",
",",
"wavelet",
",",
"widths",
")",
":",
"out_dtype",
"=",
"wavelet",
"(",
"widths",
"[",
"0",
"]",
",",
"widths",
"[",
"0",
"]",
")",
".",
"dtype",
"output",
"=",
"np",
".",
"zeros",
"(",
"[",
"len",
"(",
"widths"... | Continuous wavelet transform.
Performs a continuous wavelet transform on `data`,
using the `wavelet` function. A CWT performs a convolution
with `data` using the `wavelet` function, which is characterized
by a width parameter and length parameter.
Parameters
----------
data : (N,) ndarray
... | [
"Continuous",
"wavelet",
"transform",
"."
] | python | train |
gwastro/pycbc | pycbc/tmpltbank/partitioned_bank.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/partitioned_bank.py#L297-L361 | def calc_point_distance_vary(self, chi_coords, point_fupper, mus):
"""
Calculate distance between point and the bank allowing the metric to
vary based on varying upper frequency cutoff. Slower than
calc_point_distance, but more reliable when upper frequency cutoff can
change a lo... | [
"def",
"calc_point_distance_vary",
"(",
"self",
",",
"chi_coords",
",",
"point_fupper",
",",
"mus",
")",
":",
"chi1_bin",
",",
"chi2_bin",
"=",
"self",
".",
"find_point_bin",
"(",
"chi_coords",
")",
"min_dist",
"=",
"1000000000",
"indexes",
"=",
"None",
"for",... | Calculate distance between point and the bank allowing the metric to
vary based on varying upper frequency cutoff. Slower than
calc_point_distance, but more reliable when upper frequency cutoff can
change a lot.
Parameters
-----------
chi_coords : numpy.array
... | [
"Calculate",
"distance",
"between",
"point",
"and",
"the",
"bank",
"allowing",
"the",
"metric",
"to",
"vary",
"based",
"on",
"varying",
"upper",
"frequency",
"cutoff",
".",
"Slower",
"than",
"calc_point_distance",
"but",
"more",
"reliable",
"when",
"upper",
"fre... | python | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/feature_calculators.py | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L803-L826 | def percentage_of_reoccurring_datapoints_to_all_datapoints(x):
"""
Returns the percentage of unique values, that are present in the time series
more than once.
len(different values occurring more than once) / len(different values)
This means the percentage is normalized to the number of unique... | [
"def",
"percentage_of_reoccurring_datapoints_to_all_datapoints",
"(",
"x",
")",
":",
"if",
"len",
"(",
"x",
")",
"==",
"0",
":",
"return",
"np",
".",
"nan",
"unique",
",",
"counts",
"=",
"np",
".",
"unique",
"(",
"x",
",",
"return_counts",
"=",
"True",
"... | Returns the percentage of unique values, that are present in the time series
more than once.
len(different values occurring more than once) / len(different values)
This means the percentage is normalized to the number of unique values,
in contrast to the percentage_of_reoccurring_values_to_all_val... | [
"Returns",
"the",
"percentage",
"of",
"unique",
"values",
"that",
"are",
"present",
"in",
"the",
"time",
"series",
"more",
"than",
"once",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/internal/special_math.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/special_math.py#L157-L183 | def ndtri(p, name="ndtri"):
"""The inverse of the CDF of the Normal distribution function.
Returns x such that the area under the pdf from minus infinity to x is equal
to p.
A piece-wise rational approximation is done for the function.
This is a port of the implementation in netlib.
Args:
p: `Tensor`... | [
"def",
"ndtri",
"(",
"p",
",",
"name",
"=",
"\"ndtri\"",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
")",
":",
"p",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"p",
",",
"name",
"=",
"\"p\"",
")",
"if",
"dtype_util",
".",
... | The inverse of the CDF of the Normal distribution function.
Returns x such that the area under the pdf from minus infinity to x is equal
to p.
A piece-wise rational approximation is done for the function.
This is a port of the implementation in netlib.
Args:
p: `Tensor` of type `float32`, `float64`.
... | [
"The",
"inverse",
"of",
"the",
"CDF",
"of",
"the",
"Normal",
"distribution",
"function",
"."
] | python | test |
nezhar/updatable | updatable/__init__.py | https://github.com/nezhar/updatable/blob/654c70a40d9cabcfdd762acf82b49f66057438af/updatable/__init__.py#L24-L36 | def get_environment_requirements_list():
"""
Take the requirements list from the current running environment
:return: string
"""
requirement_list = []
requirements = check_output([sys.executable, '-m', 'pip', 'freeze'])
for requirement in requirements.split():
requirement_list.appe... | [
"def",
"get_environment_requirements_list",
"(",
")",
":",
"requirement_list",
"=",
"[",
"]",
"requirements",
"=",
"check_output",
"(",
"[",
"sys",
".",
"executable",
",",
"'-m'",
",",
"'pip'",
",",
"'freeze'",
"]",
")",
"for",
"requirement",
"in",
"requiremen... | Take the requirements list from the current running environment
:return: string | [
"Take",
"the",
"requirements",
"list",
"from",
"the",
"current",
"running",
"environment"
] | python | train |
telefonicaid/fiware-sdc | python-sdcclient/utils/logger_utils.py | https://github.com/telefonicaid/fiware-sdc/blob/d2d5f87fc574caf6bcc49594bbcb31f620ba8c51/python-sdcclient/utils/logger_utils.py#L129-L145 | def log_print_response(logger, response):
"""
Log an HTTP response data
:param logger: logger to use
:param response: HTTP response ('Requests' lib)
:return: None
"""
log_msg = '<<<<<<<<<<<<<<<<<<<<<< Response <<<<<<<<<<<<<<<<<<\n'
log_msg += '\t< Response code: {}\n'.format(str(respons... | [
"def",
"log_print_response",
"(",
"logger",
",",
"response",
")",
":",
"log_msg",
"=",
"'<<<<<<<<<<<<<<<<<<<<<< Response <<<<<<<<<<<<<<<<<<\\n'",
"log_msg",
"+=",
"'\\t< Response code: {}\\n'",
".",
"format",
"(",
"str",
"(",
"response",
".",
"status_code",
")",
")",
... | Log an HTTP response data
:param logger: logger to use
:param response: HTTP response ('Requests' lib)
:return: None | [
"Log",
"an",
"HTTP",
"response",
"data",
":",
"param",
"logger",
":",
"logger",
"to",
"use",
":",
"param",
"response",
":",
"HTTP",
"response",
"(",
"Requests",
"lib",
")",
":",
"return",
":",
"None"
] | python | train |
tensorflow/mesh | mesh_tensorflow/transformer/utils.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L499-L520 | def auto_batch_size(sequence_length,
mesh_shape,
layout_rules,
tokens_per_split=2048):
"""Automatically compute batch size.
Args:
sequence_length: an integer
mesh_shape: an input to mtf.convert_to_shape()
layout_rules: an input to mtf.convert_... | [
"def",
"auto_batch_size",
"(",
"sequence_length",
",",
"mesh_shape",
",",
"layout_rules",
",",
"tokens_per_split",
"=",
"2048",
")",
":",
"num_splits",
"=",
"mtf",
".",
"tensor_dim_to_mesh_dim_size",
"(",
"layout_rules",
",",
"mesh_shape",
",",
"mtf",
".",
"Dimens... | Automatically compute batch size.
Args:
sequence_length: an integer
mesh_shape: an input to mtf.convert_to_shape()
layout_rules: an input to mtf.convert_to_layout_rules()
tokens_per_split: an integer
Returns:
an integer | [
"Automatically",
"compute",
"batch",
"size",
"."
] | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/enrollment/models/enrollment_id.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/enrollment/models/enrollment_id.py#L61-L74 | def enrollment_identity(self, enrollment_identity):
"""
Sets the enrollment_identity of this EnrollmentId.
Enrollment identity.
:param enrollment_identity: The enrollment_identity of this EnrollmentId.
:type: str
"""
if enrollment_identity is None:
ra... | [
"def",
"enrollment_identity",
"(",
"self",
",",
"enrollment_identity",
")",
":",
"if",
"enrollment_identity",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `enrollment_identity`, must not be `None`\"",
")",
"if",
"enrollment_identity",
"is",
"not",
"... | Sets the enrollment_identity of this EnrollmentId.
Enrollment identity.
:param enrollment_identity: The enrollment_identity of this EnrollmentId.
:type: str | [
"Sets",
"the",
"enrollment_identity",
"of",
"this",
"EnrollmentId",
".",
"Enrollment",
"identity",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.