repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
scrapinghub/exporters | exporters/readers/kafka_random_reader.py | https://github.com/scrapinghub/exporters/blob/c9fb01db1771ada4672bbffd67cb46e1f7802ab9/exporters/readers/kafka_random_reader.py#L136-L141 | def decompress_messages(self, offmsgs):
""" Decompress pre-defined compressed fields for each message.
Msgs should be unpacked before this step. """
for offmsg in offmsgs:
yield offmsg.message.key, self.decompress_fun(offmsg.message.value) | [
"def",
"decompress_messages",
"(",
"self",
",",
"offmsgs",
")",
":",
"for",
"offmsg",
"in",
"offmsgs",
":",
"yield",
"offmsg",
".",
"message",
".",
"key",
",",
"self",
".",
"decompress_fun",
"(",
"offmsg",
".",
"message",
".",
"value",
")"
] | Decompress pre-defined compressed fields for each message.
Msgs should be unpacked before this step. | [
"Decompress",
"pre",
"-",
"defined",
"compressed",
"fields",
"for",
"each",
"message",
".",
"Msgs",
"should",
"be",
"unpacked",
"before",
"this",
"step",
"."
] | python | train | 45.833333 |
allenai/allennlp | allennlp/common/params.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L209-L232 | def add_file_to_archive(self, name: str) -> None:
"""
Any class in its ``from_params`` method can request that some of its
input files be added to the archive by calling this method.
For example, if some class ``A`` had an ``input_file`` parameter, it could call
```
par... | [
"def",
"add_file_to_archive",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"loading_from_archive",
":",
"self",
".",
"files_to_archive",
"[",
"f\"{self.history}{name}\"",
"]",
"=",
"cached_path",
"(",
"self",
".",
"... | Any class in its ``from_params`` method can request that some of its
input files be added to the archive by calling this method.
For example, if some class ``A`` had an ``input_file`` parameter, it could call
```
params.add_file_to_archive("input_file")
```
which would... | [
"Any",
"class",
"in",
"its",
"from_params",
"method",
"can",
"request",
"that",
"some",
"of",
"its",
"input",
"files",
"be",
"added",
"to",
"the",
"archive",
"by",
"calling",
"this",
"method",
"."
] | python | train | 44.666667 |
shoebot/shoebot | shoebot/grammar/nodebox.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L554-L561 | def stroke(self, *args):
'''Set a stroke color, applying it to new paths.
:param args: color in supported format
'''
if args is not None:
self._canvas.strokecolor = self.color(*args)
return self._canvas.strokecolor | [
"def",
"stroke",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"args",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"strokecolor",
"=",
"self",
".",
"color",
"(",
"*",
"args",
")",
"return",
"self",
".",
"_canvas",
".",
"strokecolor"
] | Set a stroke color, applying it to new paths.
:param args: color in supported format | [
"Set",
"a",
"stroke",
"color",
"applying",
"it",
"to",
"new",
"paths",
"."
] | python | valid | 32.5 |
limpyd/redis-limpyd | limpyd/database.py | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/database.py#L157-L169 | def support_zrangebylex(self):
"""
Returns True if zrangebylex is available. Checks are done in the client
library (redis-py) AND the redis server. Result is cached, so done only
one time.
"""
if not hasattr(self, '_support_zrangebylex'):
try:
... | [
"def",
"support_zrangebylex",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_support_zrangebylex'",
")",
":",
"try",
":",
"self",
".",
"_support_zrangebylex",
"=",
"self",
".",
"redis_version",
">=",
"(",
"2",
",",
"8",
",",
"9",
")"... | Returns True if zrangebylex is available. Checks are done in the client
library (redis-py) AND the redis server. Result is cached, so done only
one time. | [
"Returns",
"True",
"if",
"zrangebylex",
"is",
"available",
".",
"Checks",
"are",
"done",
"in",
"the",
"client",
"library",
"(",
"redis",
"-",
"py",
")",
"AND",
"the",
"redis",
"server",
".",
"Result",
"is",
"cached",
"so",
"done",
"only",
"one",
"time",
... | python | train | 41.846154 |
dagster-io/dagster | python_modules/dagster/dagster/core/definitions/repository.py | https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/definitions/repository.py#L102-L112 | def get_all_pipelines(self):
'''Return all pipelines as a list
Returns:
List[PipelineDefinition]:
'''
pipelines = list(map(self.get_pipeline, self.pipeline_dict.keys()))
# This does uniqueness check
self._construct_solid_defs(pipelines)
return pipeli... | [
"def",
"get_all_pipelines",
"(",
"self",
")",
":",
"pipelines",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"get_pipeline",
",",
"self",
".",
"pipeline_dict",
".",
"keys",
"(",
")",
")",
")",
"# This does uniqueness check",
"self",
".",
"_construct_solid_defs",... | Return all pipelines as a list
Returns:
List[PipelineDefinition]: | [
"Return",
"all",
"pipelines",
"as",
"a",
"list"
] | python | test | 28.454545 |
thomasdelaet/python-velbus | velbus/messages/blind_status.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/blind_status.py#L127-L140 | def data_to_binary(self):
"""
:return: bytes
"""
return bytes([
COMMAND_CODE,
self.channels_to_byte([self.channel]),
self.timeout,
self.status,
self.led_status,
self.blind_position,
self.locked_inhibit_fo... | [
"def",
"data_to_binary",
"(",
"self",
")",
":",
"return",
"bytes",
"(",
"[",
"COMMAND_CODE",
",",
"self",
".",
"channels_to_byte",
"(",
"[",
"self",
".",
"channel",
"]",
")",
",",
"self",
".",
"timeout",
",",
"self",
".",
"status",
",",
"self",
".",
... | :return: bytes | [
":",
"return",
":",
"bytes"
] | python | train | 26.428571 |
kytos/kytos-utils | kytos/cli/commands/napps/api.py | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L213-L233 | def list(cls, args): # pylint: disable=unused-argument
"""List all installed NApps and inform whether they are enabled."""
mgr = NAppsManager()
# Add status
napps = [napp + ('[ie]',) for napp in mgr.get_enabled()]
napps += [napp + ('[i-]',) for napp in mgr.get_disabled()]
... | [
"def",
"list",
"(",
"cls",
",",
"args",
")",
":",
"# pylint: disable=unused-argument",
"mgr",
"=",
"NAppsManager",
"(",
")",
"# Add status",
"napps",
"=",
"[",
"napp",
"+",
"(",
"'[ie]'",
",",
")",
"for",
"napp",
"in",
"mgr",
".",
"get_enabled",
"(",
")"... | List all installed NApps and inform whether they are enabled. | [
"List",
"all",
"installed",
"NApps",
"and",
"inform",
"whether",
"they",
"are",
"enabled",
"."
] | python | train | 35.904762 |
Kortemme-Lab/klab | klab/bio/smallmolecule.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/smallmolecule.py#L110-L145 | def align_to_other(self, other, mapping, self_root_pair, other_root_pair = None):
'''
root atoms are atom which all other unmapped atoms will be mapped off of
'''
if other_root_pair == None:
other_root_pair = self_root_pair
assert( len(self_root_pair) == len(other_ro... | [
"def",
"align_to_other",
"(",
"self",
",",
"other",
",",
"mapping",
",",
"self_root_pair",
",",
"other_root_pair",
"=",
"None",
")",
":",
"if",
"other_root_pair",
"==",
"None",
":",
"other_root_pair",
"=",
"self_root_pair",
"assert",
"(",
"len",
"(",
"self_roo... | root atoms are atom which all other unmapped atoms will be mapped off of | [
"root",
"atoms",
"are",
"atom",
"which",
"all",
"other",
"unmapped",
"atoms",
"will",
"be",
"mapped",
"off",
"of"
] | python | train | 43.916667 |
htm-community/menorah | menorah/confluencefactory.py | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/confluencefactory.py#L25-L40 | def create(streamIds, **kwargs):
"""
Creates and loads data into a Confluence, which is a collection of River
Streams.
:param streamIds: (list) Each data id in this list is a list of strings:
1. river name
2. stream name
3. field name
:param kwargs... | [
"def",
"create",
"(",
"streamIds",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"\"Creating Confluence for the following RiverStreams:\"",
"\"\\n\\t%s\"",
"%",
"\",\\n\\t\"",
".",
"join",
"(",
"[",
"\":\"",
".",
"join",
"(",
"row",
")",
"for",
"row",
"in",
"str... | Creates and loads data into a Confluence, which is a collection of River
Streams.
:param streamIds: (list) Each data id in this list is a list of strings:
1. river name
2. stream name
3. field name
:param kwargs: Passed into Confluence constructor
:r... | [
"Creates",
"and",
"loads",
"data",
"into",
"a",
"Confluence",
"which",
"is",
"a",
"collection",
"of",
"River",
"Streams",
".",
":",
"param",
"streamIds",
":",
"(",
"list",
")",
"Each",
"data",
"id",
"in",
"this",
"list",
"is",
"a",
"list",
"of",
"strin... | python | train | 37 |
pgmpy/pgmpy | pgmpy/factors/distributions/GaussianDistribution.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L151-L216 | def marginalize(self, variables, inplace=True):
"""
Modifies the distribution with marginalized values.
Parameters
----------
variables: iterator over any hashable object.
List of variables over which marginalization is to be done.
inplace: boolean
... | [
"def",
"marginalize",
"(",
"self",
",",
"variables",
",",
"inplace",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"variables",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"variables: Expected type list or array-like,\"",
"\"got type {var_type}\"",
... | Modifies the distribution with marginalized values.
Parameters
----------
variables: iterator over any hashable object.
List of variables over which marginalization is to be done.
inplace: boolean
If inplace=True it will modify the distribution itself,
... | [
"Modifies",
"the",
"distribution",
"with",
"marginalized",
"values",
"."
] | python | train | 32 |
DataBiosphere/toil | attic/toil-sort-example.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/attic/toil-sort-example.py#L107-L115 | def copy_subrange_of_file(input_file, file_start, file_end, output_filehandle):
"""Copies the range (in bytes) between fileStart and fileEnd to the given
output file handle.
"""
with open(input_file, 'r') as fileHandle:
fileHandle.seek(file_start)
data = fileHandle.read(file_end - file_s... | [
"def",
"copy_subrange_of_file",
"(",
"input_file",
",",
"file_start",
",",
"file_end",
",",
"output_filehandle",
")",
":",
"with",
"open",
"(",
"input_file",
",",
"'r'",
")",
"as",
"fileHandle",
":",
"fileHandle",
".",
"seek",
"(",
"file_start",
")",
"data",
... | Copies the range (in bytes) between fileStart and fileEnd to the given
output file handle. | [
"Copies",
"the",
"range",
"(",
"in",
"bytes",
")",
"between",
"fileStart",
"and",
"fileEnd",
"to",
"the",
"given",
"output",
"file",
"handle",
"."
] | python | train | 45 |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L341-L393 | def parse_config_for_selected_keys(content, keys):
""" Parse a config from a magic cell body for selected config keys.
For example, if 'content' is:
config_item1: value1
config_item2: value2
config_item3: value3
and 'keys' are: [config_item1, config_item3]
The results will be a tuple of
1. The p... | [
"def",
"parse_config_for_selected_keys",
"(",
"content",
",",
"keys",
")",
":",
"config_items",
"=",
"{",
"key",
":",
"None",
"for",
"key",
"in",
"keys",
"}",
"if",
"not",
"content",
":",
"return",
"config_items",
",",
"content",
"stripped",
"=",
"content",
... | Parse a config from a magic cell body for selected config keys.
For example, if 'content' is:
config_item1: value1
config_item2: value2
config_item3: value3
and 'keys' are: [config_item1, config_item3]
The results will be a tuple of
1. The parsed config items (dict): {config_item1: value1, config_... | [
"Parse",
"a",
"config",
"from",
"a",
"magic",
"cell",
"body",
"for",
"selected",
"config",
"keys",
"."
] | python | train | 27.169811 |
gabstopper/smc-python | smc/core/route.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/route.py#L914-L938 | def _which_ip_protocol(element):
"""
Validate the protocol addresses for the element. Most elements can
have an IPv4 or IPv6 address assigned on the same element. This
allows elements to be validated and placed on the right network.
:return: boolean tuple
:rtype: tuple(ipv4, ipv6)
"""
... | [
"def",
"_which_ip_protocol",
"(",
"element",
")",
":",
"try",
":",
"if",
"element",
".",
"typeof",
"in",
"(",
"'host'",
",",
"'router'",
")",
":",
"return",
"getattr",
"(",
"element",
",",
"'address'",
",",
"False",
")",
",",
"getattr",
"(",
"element",
... | Validate the protocol addresses for the element. Most elements can
have an IPv4 or IPv6 address assigned on the same element. This
allows elements to be validated and placed on the right network.
:return: boolean tuple
:rtype: tuple(ipv4, ipv6) | [
"Validate",
"the",
"protocol",
"addresses",
"for",
"the",
"element",
".",
"Most",
"elements",
"can",
"have",
"an",
"IPv4",
"or",
"IPv6",
"address",
"assigned",
"on",
"the",
"same",
"element",
".",
"This",
"allows",
"elements",
"to",
"be",
"validated",
"and",... | python | train | 45.48 |
rosshamish/hexgrid | hexgrid.py | https://github.com/rosshamish/hexgrid/blob/16abb1822dc2789cb355f54fb06c7774eea1d9f2/hexgrid.py#L260-L275 | def node_coord_in_direction(tile_id, direction):
"""
Returns the node coordinate in the given direction at the given tile identifier.
:param tile_id: tile identifier, int
:param direction: direction, str
:return: node coord, int
"""
tile_coord = tile_id_to_coord(tile_id)
for node_coord ... | [
"def",
"node_coord_in_direction",
"(",
"tile_id",
",",
"direction",
")",
":",
"tile_coord",
"=",
"tile_id_to_coord",
"(",
"tile_id",
")",
"for",
"node_coord",
"in",
"nodes_touching_tile",
"(",
"tile_id",
")",
":",
"if",
"tile_node_offset_to_direction",
"(",
"node_co... | Returns the node coordinate in the given direction at the given tile identifier.
:param tile_id: tile identifier, int
:param direction: direction, str
:return: node coord, int | [
"Returns",
"the",
"node",
"coordinate",
"in",
"the",
"given",
"direction",
"at",
"the",
"given",
"tile",
"identifier",
"."
] | python | train | 35.25 |
sosreport/sos | sos/policies/redhat.py | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L274-L295 | def check(cls):
"""Test to see if the running host is a RHEL installation.
Checks for the presence of the "Red Hat Enterprise Linux"
release string at the beginning of the NAME field in the
`/etc/os-release` file and returns ``True`` if it is
found, and ``False``... | [
"def",
"check",
"(",
"cls",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"OS_RELEASE",
")",
":",
"return",
"False",
"with",
"open",
"(",
"OS_RELEASE",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line"... | Test to see if the running host is a RHEL installation.
Checks for the presence of the "Red Hat Enterprise Linux"
release string at the beginning of the NAME field in the
`/etc/os-release` file and returns ``True`` if it is
found, and ``False`` otherwise.
:r... | [
"Test",
"to",
"see",
"if",
"the",
"running",
"host",
"is",
"a",
"RHEL",
"installation",
"."
] | python | train | 37.181818 |
brutasse/graphite-api | graphite_api/render/glyph.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L511-L524 | def computeSlop(self, step, divisor):
"""Compute the slop that would result from step and divisor.
Return the slop, or None if this combination can't cover the full
range. See chooseStep() for the definition of "slop".
"""
bottom = step * math.floor(self.minValue / float(step) ... | [
"def",
"computeSlop",
"(",
"self",
",",
"step",
",",
"divisor",
")",
":",
"bottom",
"=",
"step",
"*",
"math",
".",
"floor",
"(",
"self",
".",
"minValue",
"/",
"float",
"(",
"step",
")",
"+",
"EPSILON",
")",
"top",
"=",
"bottom",
"+",
"step",
"*",
... | Compute the slop that would result from step and divisor.
Return the slop, or None if this combination can't cover the full
range. See chooseStep() for the definition of "slop". | [
"Compute",
"the",
"slop",
"that",
"would",
"result",
"from",
"step",
"and",
"divisor",
"."
] | python | train | 36.571429 |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1948-L1951 | def p_generate_if_woelse(self, p):
'generate_if : IF LPAREN cond RPAREN gif_true_item'
p[0] = IfStatement(p[3], p[5], None, lineno=p.lineno(1))
p.set_lineno(0, p.lineno(1)) | [
"def",
"p_generate_if_woelse",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"IfStatement",
"(",
"p",
"[",
"3",
"]",
",",
"p",
"[",
"5",
"]",
",",
"None",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")",
"p",
".",
"se... | generate_if : IF LPAREN cond RPAREN gif_true_item | [
"generate_if",
":",
"IF",
"LPAREN",
"cond",
"RPAREN",
"gif_true_item"
] | python | train | 48.25 |
econ-ark/HARK | HARK/core.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/core.py#L308-L323 | def addToTimeInv(self,*params):
'''
Adds any number of parameters to time_inv for this instance.
Parameters
----------
params : string
Any number of strings naming attributes to be added to time_inv
Returns
-------
None
'''
fo... | [
"def",
"addToTimeInv",
"(",
"self",
",",
"*",
"params",
")",
":",
"for",
"param",
"in",
"params",
":",
"if",
"param",
"not",
"in",
"self",
".",
"time_inv",
":",
"self",
".",
"time_inv",
".",
"append",
"(",
"param",
")"
] | Adds any number of parameters to time_inv for this instance.
Parameters
----------
params : string
Any number of strings naming attributes to be added to time_inv
Returns
-------
None | [
"Adds",
"any",
"number",
"of",
"parameters",
"to",
"time_inv",
"for",
"this",
"instance",
"."
] | python | train | 25.625 |
galaxy-genome-annotation/python-apollo | arrow/commands/annotations/get_features.py | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/commands/annotations/get_features.py#L20-L27 | def cli(ctx, organism="", sequence=""):
"""Get the features for an organism / sequence
Output:
A standard apollo feature dictionary ({"features": [{...}]})
"""
return ctx.gi.annotations.get_features(organism=organism, sequence=sequence) | [
"def",
"cli",
"(",
"ctx",
",",
"organism",
"=",
"\"\"",
",",
"sequence",
"=",
"\"\"",
")",
":",
"return",
"ctx",
".",
"gi",
".",
"annotations",
".",
"get_features",
"(",
"organism",
"=",
"organism",
",",
"sequence",
"=",
"sequence",
")"
] | Get the features for an organism / sequence
Output:
A standard apollo feature dictionary ({"features": [{...}]}) | [
"Get",
"the",
"features",
"for",
"an",
"organism",
"/",
"sequence"
] | python | train | 30.875 |
eventable/vobject | vobject/vcard.py | https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/vcard.py#L229-L237 | def serialize(cls, obj, buf, lineLength, validate):
"""
Apple's Address Book is *really* weird with images, it expects
base64 data to have very specific whitespace. It seems Address Book
can handle PHOTO if it's not wrapped, so don't wrap it.
"""
if wacky_apple_photo_ser... | [
"def",
"serialize",
"(",
"cls",
",",
"obj",
",",
"buf",
",",
"lineLength",
",",
"validate",
")",
":",
"if",
"wacky_apple_photo_serialize",
":",
"lineLength",
"=",
"REALLY_LARGE",
"VCardTextBehavior",
".",
"serialize",
"(",
"obj",
",",
"buf",
",",
"lineLength",... | Apple's Address Book is *really* weird with images, it expects
base64 data to have very specific whitespace. It seems Address Book
can handle PHOTO if it's not wrapped, so don't wrap it. | [
"Apple",
"s",
"Address",
"Book",
"is",
"*",
"really",
"*",
"weird",
"with",
"images",
"it",
"expects",
"base64",
"data",
"to",
"have",
"very",
"specific",
"whitespace",
".",
"It",
"seems",
"Address",
"Book",
"can",
"handle",
"PHOTO",
"if",
"it",
"s",
"no... | python | train | 47.222222 |
CityOfZion/neo-python | neo/Core/Block.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/Block.py#L116-L124 | def Size(self):
"""
Get the total size in bytes of the object.
Returns:
int: size.
"""
s = super(Block, self).Size() + GetVarSize(self.Transactions)
return s | [
"def",
"Size",
"(",
"self",
")",
":",
"s",
"=",
"super",
"(",
"Block",
",",
"self",
")",
".",
"Size",
"(",
")",
"+",
"GetVarSize",
"(",
"self",
".",
"Transactions",
")",
"return",
"s"
] | Get the total size in bytes of the object.
Returns:
int: size. | [
"Get",
"the",
"total",
"size",
"in",
"bytes",
"of",
"the",
"object",
"."
] | python | train | 23.333333 |
ssato/python-anytemplate | anytemplate/engine.py | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engine.py#L50-L57 | def list_engines_by_priority(engines=None):
"""
Return a list of engines supported sorted by each priority.
"""
if engines is None:
engines = ENGINES
return sorted(engines, key=operator.methodcaller("priority")) | [
"def",
"list_engines_by_priority",
"(",
"engines",
"=",
"None",
")",
":",
"if",
"engines",
"is",
"None",
":",
"engines",
"=",
"ENGINES",
"return",
"sorted",
"(",
"engines",
",",
"key",
"=",
"operator",
".",
"methodcaller",
"(",
"\"priority\"",
")",
")"
] | Return a list of engines supported sorted by each priority. | [
"Return",
"a",
"list",
"of",
"engines",
"supported",
"sorted",
"by",
"each",
"priority",
"."
] | python | train | 29.125 |
bitcraft/pyscroll | pyscroll/orthographic.py | https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L396-L423 | def _queue_edge_tiles(self, dx, dy):
""" Queue edge tiles and clear edge areas on buffer if needed
:param dx: Edge along X axis to enqueue
:param dy: Edge along Y axis to enqueue
:return: None
"""
v = self._tile_view
tw, th = self.data.tile_size
self._til... | [
"def",
"_queue_edge_tiles",
"(",
"self",
",",
"dx",
",",
"dy",
")",
":",
"v",
"=",
"self",
".",
"_tile_view",
"tw",
",",
"th",
"=",
"self",
".",
"data",
".",
"tile_size",
"self",
".",
"_tile_queue",
"=",
"iter",
"(",
"[",
"]",
")",
"def",
"append",... | Queue edge tiles and clear edge areas on buffer if needed
:param dx: Edge along X axis to enqueue
:param dy: Edge along Y axis to enqueue
:return: None | [
"Queue",
"edge",
"tiles",
"and",
"clear",
"edge",
"areas",
"on",
"buffer",
"if",
"needed"
] | python | train | 37.214286 |
sorgerlab/indra | indra/databases/relevance_client.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/relevance_client.py#L17-L40 | def get_heat_kernel(network_id):
"""Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given netw... | [
"def",
"get_heat_kernel",
"(",
"network_id",
")",
":",
"url",
"=",
"ndex_relevance",
"+",
"'/%s/generate_ndex_heat_kernel'",
"%",
"network_id",
"res",
"=",
"ndex_client",
".",
"send_request",
"(",
"url",
",",
"{",
"}",
",",
"is_json",
"=",
"True",
",",
"use_ge... | Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given network. | [
"Return",
"the",
"identifier",
"of",
"a",
"heat",
"kernel",
"calculated",
"for",
"a",
"given",
"network",
"."
] | python | train | 31.5 |
googleads/googleads-python-lib | googleads/adwords.py | https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/adwords.py#L2070-L2074 | def _CreateSingleValueCondition(self, value, operator):
"""Creates a single-value condition with the provided value and operator."""
if isinstance(value, str) or isinstance(value, unicode):
value = '"%s"' % value
return '%s %s %s' % (self._field, operator, value) | [
"def",
"_CreateSingleValueCondition",
"(",
"self",
",",
"value",
",",
"operator",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
"or",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"value",
"=",
"'\"%s\"'",
"%",
"value",
"return",
"... | Creates a single-value condition with the provided value and operator. | [
"Creates",
"a",
"single",
"-",
"value",
"condition",
"with",
"the",
"provided",
"value",
"and",
"operator",
"."
] | python | train | 55.4 |
PmagPy/PmagPy | dialogs/pmag_er_magic_dialogs.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/pmag_er_magic_dialogs.py#L1145-L1169 | def onSelectRow(self, event):
"""
Highlight or unhighlight a row for possible deletion.
"""
grid = self.grid
row = event.Row
default = (255, 255, 255, 255)
highlight = (191, 216, 216, 255)
cell_color = grid.GetCellBackgroundColour(row, 0)
attr = wx... | [
"def",
"onSelectRow",
"(",
"self",
",",
"event",
")",
":",
"grid",
"=",
"self",
".",
"grid",
"row",
"=",
"event",
".",
"Row",
"default",
"=",
"(",
"255",
",",
"255",
",",
"255",
",",
"255",
")",
"highlight",
"=",
"(",
"191",
",",
"216",
",",
"2... | Highlight or unhighlight a row for possible deletion. | [
"Highlight",
"or",
"unhighlight",
"a",
"row",
"for",
"possible",
"deletion",
"."
] | python | train | 33 |
a1ezzz/wasp-general | wasp_general/crypto/aes.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L92-L102 | def pad(self, data, block_size):
""" :meth:`.WBlockPadding.pad` method implementation
"""
padding_symbol = self.padding_symbol()
blocks_count = (len(data) // block_size)
if (len(data) % block_size) != 0:
blocks_count += 1
total_length = blocks_count * block_size
return self._fill(data, total_length, ... | [
"def",
"pad",
"(",
"self",
",",
"data",
",",
"block_size",
")",
":",
"padding_symbol",
"=",
"self",
".",
"padding_symbol",
"(",
")",
"blocks_count",
"=",
"(",
"len",
"(",
"data",
")",
"//",
"block_size",
")",
"if",
"(",
"len",
"(",
"data",
")",
"%",
... | :meth:`.WBlockPadding.pad` method implementation | [
":",
"meth",
":",
".",
"WBlockPadding",
".",
"pad",
"method",
"implementation"
] | python | train | 29.545455 |
ladybug-tools/ladybug | ladybug/datatype/base.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/datatype/base.py#L196-L211 | def _to_unit_base(self, base_unit, values, unit, from_unit):
"""Return values in a given unit given the input from_unit."""
self._is_numeric(values)
namespace = {'self': self, 'values': values}
if not from_unit == base_unit:
self.is_unit_acceptable(from_unit, True)
... | [
"def",
"_to_unit_base",
"(",
"self",
",",
"base_unit",
",",
"values",
",",
"unit",
",",
"from_unit",
")",
":",
"self",
".",
"_is_numeric",
"(",
"values",
")",
"namespace",
"=",
"{",
"'self'",
":",
"self",
",",
"'values'",
":",
"values",
"}",
"if",
"not... | Return values in a given unit given the input from_unit. | [
"Return",
"values",
"in",
"a",
"given",
"unit",
"given",
"the",
"input",
"from_unit",
"."
] | python | train | 50.375 |
google/prettytensor | prettytensor/pretty_tensor_loss_methods.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/pretty_tensor_loss_methods.py#L55-L76 | def _convert_and_assert_per_example_weights_compatible(
input_, per_example_weights, dtype):
"""Converts per_example_weights to a tensor and validates the shape."""
per_example_weights = tf.convert_to_tensor(
per_example_weights, name='per_example_weights', dtype=dtype)
if input_.get_shape().ndims:
... | [
"def",
"_convert_and_assert_per_example_weights_compatible",
"(",
"input_",
",",
"per_example_weights",
",",
"dtype",
")",
":",
"per_example_weights",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"per_example_weights",
",",
"name",
"=",
"'per_example_weights'",
",",
"dtype",... | Converts per_example_weights to a tensor and validates the shape. | [
"Converts",
"per_example_weights",
"to",
"a",
"tensor",
"and",
"validates",
"the",
"shape",
"."
] | python | train | 43.5 |
google/openhtf | openhtf/util/timeouts.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/timeouts.py#L154-L172 | def loop_until_timeout_or_true(timeout_s, function, sleep_s=1): # pylint: disable=invalid-name
"""Loops until the specified function returns True or a timeout is reached.
Note: The function may return anything which evaluates to implicit True. This
function will loop calling it as long as it continues to retur... | [
"def",
"loop_until_timeout_or_true",
"(",
"timeout_s",
",",
"function",
",",
"sleep_s",
"=",
"1",
")",
":",
"# pylint: disable=invalid-name",
"return",
"loop_until_timeout_or_valid",
"(",
"timeout_s",
",",
"function",
",",
"lambda",
"x",
":",
"x",
",",
"sleep_s",
... | Loops until the specified function returns True or a timeout is reached.
Note: The function may return anything which evaluates to implicit True. This
function will loop calling it as long as it continues to return something
which evaluates to False. We ensure this method is called at least once
regardless o... | [
"Loops",
"until",
"the",
"specified",
"function",
"returns",
"True",
"or",
"a",
"timeout",
"is",
"reached",
"."
] | python | train | 47.736842 |
jmgilman/Neolib | neolib/pyamf/util/pure.py | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/pure.py#L477-L485 | def read_utf8_string(self, length):
"""
Reads a UTF-8 string from the stream.
@rtype: C{unicode}
"""
s = struct.unpack("%s%ds" % (self.endian, length), self.read(length))[0]
return s.decode('utf-8') | [
"def",
"read_utf8_string",
"(",
"self",
",",
"length",
")",
":",
"s",
"=",
"struct",
".",
"unpack",
"(",
"\"%s%ds\"",
"%",
"(",
"self",
".",
"endian",
",",
"length",
")",
",",
"self",
".",
"read",
"(",
"length",
")",
")",
"[",
"0",
"]",
"return",
... | Reads a UTF-8 string from the stream.
@rtype: C{unicode} | [
"Reads",
"a",
"UTF",
"-",
"8",
"string",
"from",
"the",
"stream",
"."
] | python | train | 26.666667 |
andymccurdy/redis-py | redis/client.py | https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L48-L56 | def timestamp_to_datetime(response):
"Converts a unix timestamp to a Python datetime object"
if not response:
return None
try:
response = int(response)
except ValueError:
return None
return datetime.datetime.fromtimestamp(response) | [
"def",
"timestamp_to_datetime",
"(",
"response",
")",
":",
"if",
"not",
"response",
":",
"return",
"None",
"try",
":",
"response",
"=",
"int",
"(",
"response",
")",
"except",
"ValueError",
":",
"return",
"None",
"return",
"datetime",
".",
"datetime",
".",
... | Converts a unix timestamp to a Python datetime object | [
"Converts",
"a",
"unix",
"timestamp",
"to",
"a",
"Python",
"datetime",
"object"
] | python | train | 29.666667 |
dmwm/DBS | Server/Python/src/dbs/web/DBSReaderModel.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSReaderModel.py#L284-L488 | def listDatasets(self, dataset="", parent_dataset="", is_dataset_valid=1,
release_version="", pset_hash="", app_name="", output_module_label="", global_tag="",
processing_version=0, acquisition_era_name="", run_num=-1,
physics_group_name="", logical_file_name="", primary_ds_name="", primary_ds_t... | [
"def",
"listDatasets",
"(",
"self",
",",
"dataset",
"=",
"\"\"",
",",
"parent_dataset",
"=",
"\"\"",
",",
"is_dataset_valid",
"=",
"1",
",",
"release_version",
"=",
"\"\"",
",",
"pset_hash",
"=",
"\"\"",
",",
"app_name",
"=",
"\"\"",
",",
"output_module_labe... | API to list dataset(s) in DBS
* You can use ANY combination of these parameters in this API
* In absence of parameters, all valid datasets known to the DBS instance will be returned
:param dataset: Full dataset (path) of the dataset.
:type dataset: str
:param parent_dataset: Fu... | [
"API",
"to",
"list",
"dataset",
"(",
"s",
")",
"in",
"DBS",
"*",
"You",
"can",
"use",
"ANY",
"combination",
"of",
"these",
"parameters",
"in",
"this",
"API",
"*",
"In",
"absence",
"of",
"parameters",
"all",
"valid",
"datasets",
"known",
"to",
"the",
"D... | python | train | 55.219512 |
cggh/scikit-allel | allel/stats/sf.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/sf.py#L333-L367 | def joint_sfs_folded_scaled(ac1, ac2, n1=None, n2=None):
"""Compute the joint folded site frequency spectrum between two
populations, scaled such that a constant value is expected across the
spectrum for neutral variation, constant population size and unrelated
populations.
Parameters
---------... | [
"def",
"joint_sfs_folded_scaled",
"(",
"ac1",
",",
"ac2",
",",
"n1",
"=",
"None",
",",
"n2",
"=",
"None",
")",
":",
"# noqa",
"# check inputs",
"ac1",
",",
"n1",
"=",
"_check_ac_n",
"(",
"ac1",
",",
"n1",
")",
"ac2",
",",
"n2",
"=",
"_check_ac_n",
"(... | Compute the joint folded site frequency spectrum between two
populations, scaled such that a constant value is expected across the
spectrum for neutral variation, constant population size and unrelated
populations.
Parameters
----------
ac1 : array_like, int, shape (n_variants, 2)
Allel... | [
"Compute",
"the",
"joint",
"folded",
"site",
"frequency",
"spectrum",
"between",
"two",
"populations",
"scaled",
"such",
"that",
"a",
"constant",
"value",
"is",
"expected",
"across",
"the",
"spectrum",
"for",
"neutral",
"variation",
"constant",
"population",
"size... | python | train | 32.314286 |
cloudant/python-cloudant | src/cloudant/database.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/database.py#L166-L199 | def create_document(self, data, throw_on_exists=False):
"""
Creates a new document in the remote and locally cached database, using
the data provided. If an _id is included in the data then depending on
that _id either a :class:`~cloudant.document.Document` or a
:class:`~cloudan... | [
"def",
"create_document",
"(",
"self",
",",
"data",
",",
"throw_on_exists",
"=",
"False",
")",
":",
"docid",
"=",
"data",
".",
"get",
"(",
"'_id'",
",",
"None",
")",
"doc",
"=",
"None",
"if",
"docid",
"and",
"docid",
".",
"startswith",
"(",
"'_design/'... | Creates a new document in the remote and locally cached database, using
the data provided. If an _id is included in the data then depending on
that _id either a :class:`~cloudant.document.Document` or a
:class:`~cloudant.design_document.DesignDocument`
object will be added to the locall... | [
"Creates",
"a",
"new",
"document",
"in",
"the",
"remote",
"and",
"locally",
"cached",
"database",
"using",
"the",
"data",
"provided",
".",
"If",
"an",
"_id",
"is",
"included",
"in",
"the",
"data",
"then",
"depending",
"on",
"that",
"_id",
"either",
"a",
... | python | train | 42.088235 |
sirfoga/pyhal | hal/cvs/versioning.py | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/cvs/versioning.py#L218-L226 | def increase_by_changes(self, changes_amount, ratio):
"""Increase version by amount of changes
:param changes_amount: Number of changes done
:param ratio: Ratio changes
:return: Increases version accordingly to changes
"""
increases = round(changes_amount * ratio)
... | [
"def",
"increase_by_changes",
"(",
"self",
",",
"changes_amount",
",",
"ratio",
")",
":",
"increases",
"=",
"round",
"(",
"changes_amount",
"*",
"ratio",
")",
"return",
"self",
".",
"increase",
"(",
"int",
"(",
"increases",
")",
")"
] | Increase version by amount of changes
:param changes_amount: Number of changes done
:param ratio: Ratio changes
:return: Increases version accordingly to changes | [
"Increase",
"version",
"by",
"amount",
"of",
"changes"
] | python | train | 38.888889 |
saltstack/salt | salt/cloud/clouds/gce.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L183-L201 | def get_conn():
'''
Return a conn object for the passed VM data
'''
driver = get_driver(Provider.GCE)
provider = get_configured_provider()
project = config.get_cloud_config_value('project', provider, __opts__)
email = config.get_cloud_config_value(
'service_account_email_address',
... | [
"def",
"get_conn",
"(",
")",
":",
"driver",
"=",
"get_driver",
"(",
"Provider",
".",
"GCE",
")",
"provider",
"=",
"get_configured_provider",
"(",
")",
"project",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'project'",
",",
"provider",
",",
"__opts__",
... | Return a conn object for the passed VM data | [
"Return",
"a",
"conn",
"object",
"for",
"the",
"passed",
"VM",
"data"
] | python | train | 34.894737 |
twilio/twilio-python | twilio/rest/verify/v2/service/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/verify/v2/service/__init__.py#L38-L72 | def create(self, friendly_name, code_length=values.unset,
lookup_enabled=values.unset, skip_sms_to_landlines=values.unset,
dtmf_input_required=values.unset, tts_name=values.unset,
psd2_enabled=values.unset):
"""
Create a new ServiceInstance
:param un... | [
"def",
"create",
"(",
"self",
",",
"friendly_name",
",",
"code_length",
"=",
"values",
".",
"unset",
",",
"lookup_enabled",
"=",
"values",
".",
"unset",
",",
"skip_sms_to_landlines",
"=",
"values",
".",
"unset",
",",
"dtmf_input_required",
"=",
"values",
".",
... | Create a new ServiceInstance
:param unicode friendly_name: A string to describe the verification service
:param unicode code_length: The length of the verification code to generate
:param bool lookup_enabled: Whether to perform a lookup with each verification
:param bool skip_sms_to_lan... | [
"Create",
"a",
"new",
"ServiceInstance"
] | python | train | 46.114286 |
GetmeUK/MongoFrames | mongoframes/factory/__init__.py | https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/factory/__init__.py#L52-L63 | def finish(self, blueprint, documents):
"""Finish a list of pre-assembled documents"""
# Reset the blueprint
blueprint.reset()
# Finish the documents
finished = []
for document in documents:
finished.append(blueprint.finish(document))
return finishe... | [
"def",
"finish",
"(",
"self",
",",
"blueprint",
",",
"documents",
")",
":",
"# Reset the blueprint",
"blueprint",
".",
"reset",
"(",
")",
"# Finish the documents",
"finished",
"=",
"[",
"]",
"for",
"document",
"in",
"documents",
":",
"finished",
".",
"append",... | Finish a list of pre-assembled documents | [
"Finish",
"a",
"list",
"of",
"pre",
"-",
"assembled",
"documents"
] | python | train | 25.833333 |
partofthething/ace | ace/ace.py | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L64-L72 | def solve(self):
"""Run the ACE calculational loop."""
self._initialize()
while self._outer_error_is_decreasing() and self._outer_iters < MAX_OUTERS:
print('* Starting outer iteration {0:03d}. Current err = {1:12.5E}'
''.format(self._outer_iters, self._last_outer_er... | [
"def",
"solve",
"(",
"self",
")",
":",
"self",
".",
"_initialize",
"(",
")",
"while",
"self",
".",
"_outer_error_is_decreasing",
"(",
")",
"and",
"self",
".",
"_outer_iters",
"<",
"MAX_OUTERS",
":",
"print",
"(",
"'* Starting outer iteration {0:03d}. Current err =... | Run the ACE calculational loop. | [
"Run",
"the",
"ACE",
"calculational",
"loop",
"."
] | python | train | 49.111111 |
bukun/TorCMS | torcms/handlers/collect_handler.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/collect_handler.py#L54-L76 | def show_list(self, the_list, cur_p=''):
'''
List of the user collections.
'''
current_page_num = int(cur_p) if cur_p else 1
current_page_num = 1 if current_page_num < 1 else current_page_num
num_of_cat = MCollect.count_of_user(self.userinfo.uid)
page_num = int(... | [
"def",
"show_list",
"(",
"self",
",",
"the_list",
",",
"cur_p",
"=",
"''",
")",
":",
"current_page_num",
"=",
"int",
"(",
"cur_p",
")",
"if",
"cur_p",
"else",
"1",
"current_page_num",
"=",
"1",
"if",
"current_page_num",
"<",
"1",
"else",
"current_page_num"... | List of the user collections. | [
"List",
"of",
"the",
"user",
"collections",
"."
] | python | train | 40.043478 |
Azure/azure-sdk-for-python | azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L187-L203 | def operations(self):
"""Instance depends on the API version:
* 2018-03-31: :class:`Operations<azure.mgmt.containerservice.v2018_03_31.operations.Operations>`
* 2018-08-01-preview: :class:`Operations<azure.mgmt.containerservice.v2018_08_01_preview.operations.Operations>`
* 2019... | [
"def",
"operations",
"(",
"self",
")",
":",
"api_version",
"=",
"self",
".",
"_get_api_version",
"(",
"'operations'",
")",
"if",
"api_version",
"==",
"'2018-03-31'",
":",
"from",
".",
"v2018_03_31",
".",
"operations",
"import",
"Operations",
"as",
"OperationClas... | Instance depends on the API version:
* 2018-03-31: :class:`Operations<azure.mgmt.containerservice.v2018_03_31.operations.Operations>`
* 2018-08-01-preview: :class:`Operations<azure.mgmt.containerservice.v2018_08_01_preview.operations.Operations>`
* 2019-02-01: :class:`Operations<azure.... | [
"Instance",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | test | 64 |
Alignak-monitoring/alignak | alignak/http/arbiter_interface.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/arbiter_interface.py#L84-L133 | def backend_notification(self, event=None, parameters=None):
"""The Alignak backend raises an event to the Alignak arbiter
-----
Possible events are:
- creation, for a realm or an host creation
- deletion, for a realm or an host deletion
Calls the reload configuration fu... | [
"def",
"backend_notification",
"(",
"self",
",",
"event",
"=",
"None",
",",
"parameters",
"=",
"None",
")",
":",
"# request_parameters = cherrypy.request.json",
"# event = request_parameters.get('event', event)",
"# parameters = request_parameters.get('parameters', parameters)",
"i... | The Alignak backend raises an event to the Alignak arbiter
-----
Possible events are:
- creation, for a realm or an host creation
- deletion, for a realm or an host deletion
Calls the reload configuration function if event is creation or deletion
Else, nothing for the m... | [
"The",
"Alignak",
"backend",
"raises",
"an",
"event",
"to",
"the",
"Alignak",
"arbiter",
"-----",
"Possible",
"events",
"are",
":",
"-",
"creation",
"for",
"a",
"realm",
"or",
"an",
"host",
"creation",
"-",
"deletion",
"for",
"a",
"realm",
"or",
"an",
"h... | python | train | 42.66 |
appointlet/span | span/__init__.py | https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L66-L73 | def encompasses(self, span):
"""
Returns true if the given span fits inside this one
"""
if isinstance(span, list):
return [sp for sp in span if self._encompasses(sp)]
return self._encompasses(span) | [
"def",
"encompasses",
"(",
"self",
",",
"span",
")",
":",
"if",
"isinstance",
"(",
"span",
",",
"list",
")",
":",
"return",
"[",
"sp",
"for",
"sp",
"in",
"span",
"if",
"self",
".",
"_encompasses",
"(",
"sp",
")",
"]",
"return",
"self",
".",
"_encom... | Returns true if the given span fits inside this one | [
"Returns",
"true",
"if",
"the",
"given",
"span",
"fits",
"inside",
"this",
"one"
] | python | train | 30.5 |
pyroscope/pyrocore | src/pyrocore/scripts/base.py | https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/base.py#L162-L169 | def add_bool_option(self, *args, **kwargs):
""" Add a boolean option.
@keyword help: Option description.
"""
dest = [o for o in args if o.startswith("--")][0].replace("--", "").replace("-", "_")
self.parser.add_option(dest=dest, action="store_true", default=False,
... | [
"def",
"add_bool_option",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dest",
"=",
"[",
"o",
"for",
"o",
"in",
"args",
"if",
"o",
".",
"startswith",
"(",
"\"--\"",
")",
"]",
"[",
"0",
"]",
".",
"replace",
"(",
"\"--\"",
",... | Add a boolean option.
@keyword help: Option description. | [
"Add",
"a",
"boolean",
"option",
"."
] | python | train | 42.75 |
DarkEnergySurvey/ugali | ugali/analysis/kernel.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/kernel.py#L196-L222 | def sample_lonlat(self, n):
"""
Sample 2D distribution of points in lon, lat
"""
# From http://en.wikipedia.org/wiki/Ellipse#General_parametric_form
# However, Martin et al. (2009) use PA theta "from North to East"
# Definition of phi (position angle) is offset by pi/4
... | [
"def",
"sample_lonlat",
"(",
"self",
",",
"n",
")",
":",
"# From http://en.wikipedia.org/wiki/Ellipse#General_parametric_form",
"# However, Martin et al. (2009) use PA theta \"from North to East\"",
"# Definition of phi (position angle) is offset by pi/4",
"# Definition of t (eccentric anamoly... | Sample 2D distribution of points in lon, lat | [
"Sample",
"2D",
"distribution",
"of",
"points",
"in",
"lon",
"lat"
] | python | train | 40.481481 |
saltstack/salt | salt/cloud/clouds/profitbricks.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/profitbricks.py#L954-L1030 | def destroy(name, call=None):
'''
destroy a machine by name
:param name: name given to the machine
:param call: call value in this case is 'action'
:return: array of booleans , true if successfully stopped and true if
successfully removed
CLI Example:
.. code-block:: bash
... | [
"def",
"destroy",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a or --action.'",
")",
"__utils__",
"[",
"'cloud.fire_event'",
... | destroy a machine by name
:param name: name given to the machine
:param call: call value in this case is 'action'
:return: array of booleans , true if successfully stopped and true if
successfully removed
CLI Example:
.. code-block:: bash
salt-cloud -d vm_name | [
"destroy",
"a",
"machine",
"by",
"name"
] | python | train | 26.948052 |
GochoMugo/firecall | firecall/sync.py | https://github.com/GochoMugo/firecall/blob/6b99ff72b3c056f51a5901f2be32030c7e68961a/firecall/sync.py#L144-L154 | def put_sync(self, **kwargs):
'''
PUT: puts data into the Firebase.
Requires the 'point' parameter as a keyworded argument.
'''
self.amust(("point", "data"), kwargs)
response = requests.put(self.url_correct(kwargs["point"],
kwargs.get("aut... | [
"def",
"put_sync",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"amust",
"(",
"(",
"\"point\"",
",",
"\"data\"",
")",
",",
"kwargs",
")",
"response",
"=",
"requests",
".",
"put",
"(",
"self",
".",
"url_correct",
"(",
"kwargs",
"[",
... | PUT: puts data into the Firebase.
Requires the 'point' parameter as a keyworded argument. | [
"PUT",
":",
"puts",
"data",
"into",
"the",
"Firebase",
".",
"Requires",
"the",
"point",
"parameter",
"as",
"a",
"keyworded",
"argument",
"."
] | python | valid | 41.818182 |
globality-corp/microcosm-flask | microcosm_flask/audit.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/audit.py#L361-L387 | def configure_audit_decorator(graph):
"""
Configure the audit decorator.
Example Usage:
@graph.audit
def login(username, password):
...
"""
include_request_body = int(graph.config.audit.include_request_body)
include_response_body = int(graph.config.audit.include_res... | [
"def",
"configure_audit_decorator",
"(",
"graph",
")",
":",
"include_request_body",
"=",
"int",
"(",
"graph",
".",
"config",
".",
"audit",
".",
"include_request_body",
")",
"include_response_body",
"=",
"int",
"(",
"graph",
".",
"config",
".",
"audit",
".",
"i... | Configure the audit decorator.
Example Usage:
@graph.audit
def login(username, password):
... | [
"Configure",
"the",
"audit",
"decorator",
"."
] | python | train | 34.407407 |
gagneurlab/concise | concise/metrics.py | https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L48-L52 | def tnr(y, z):
"""True negative rate `tn / (tn + fp)`
"""
tp, tn, fp, fn = contingency_table(y, z)
return tn / (tn + fp) | [
"def",
"tnr",
"(",
"y",
",",
"z",
")",
":",
"tp",
",",
"tn",
",",
"fp",
",",
"fn",
"=",
"contingency_table",
"(",
"y",
",",
"z",
")",
"return",
"tn",
"/",
"(",
"tn",
"+",
"fp",
")"
] | True negative rate `tn / (tn + fp)` | [
"True",
"negative",
"rate",
"tn",
"/",
"(",
"tn",
"+",
"fp",
")"
] | python | train | 26.4 |
anchore/anchore | anchore/util/resources.py | https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L317-L323 | def _flush(self):
"""
Flush metadata to the backing file
:return:
"""
with open(self.metadata_file, 'w') as f:
json.dump(self.metadata, f) | [
"def",
"_flush",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"metadata_file",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"self",
".",
"metadata",
",",
"f",
")"
] | Flush metadata to the backing file
:return: | [
"Flush",
"metadata",
"to",
"the",
"backing",
"file",
":",
"return",
":"
] | python | train | 26.285714 |
lucapinello/Haystack | haystack/external.py | https://github.com/lucapinello/Haystack/blob/cc080d741f36cd77b07c0b59d08ea6a4cf0ef2f7/haystack/external.py#L855-L891 | def _scan_smaller(self, seq, threshold=''):
"""
m._scan_smaller(seq, threshold='') -- Internal utility function for performing sequence scans
The sequence is smaller than the PSSM. Are there
good matches to regions of the PSSM?
"""
ll = self.ll #Shortcut for Log-likelih... | [
"def",
"_scan_smaller",
"(",
"self",
",",
"seq",
",",
"threshold",
"=",
"''",
")",
":",
"ll",
"=",
"self",
".",
"ll",
"#Shortcut for Log-likelihood matrix",
"matches",
"=",
"[",
"]",
"endpoints",
"=",
"[",
"]",
"scores",
"=",
"[",
"]",
"w",
"=",
"self"... | m._scan_smaller(seq, threshold='') -- Internal utility function for performing sequence scans
The sequence is smaller than the PSSM. Are there
good matches to regions of the PSSM? | [
"m",
".",
"_scan_smaller",
"(",
"seq",
"threshold",
"=",
")",
"--",
"Internal",
"utility",
"function",
"for",
"performing",
"sequence",
"scans"
] | python | train | 47.027027 |
zhmcclient/python-zhmcclient | zhmcclient/_session.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_session.py#L542-L564 | def is_logon(self, verify=False):
"""
Return a boolean indicating whether the session is currently logged on
to the HMC.
By default, this method checks whether there is a session-id set
and considers that sufficient for determining that the session is
logged on. The `ver... | [
"def",
"is_logon",
"(",
"self",
",",
"verify",
"=",
"False",
")",
":",
"if",
"self",
".",
"_session_id",
"is",
"None",
":",
"return",
"False",
"if",
"verify",
":",
"try",
":",
"self",
".",
"get",
"(",
"'/api/console'",
",",
"logon_required",
"=",
"True... | Return a boolean indicating whether the session is currently logged on
to the HMC.
By default, this method checks whether there is a session-id set
and considers that sufficient for determining that the session is
logged on. The `verify` parameter can be used to verify the validity
... | [
"Return",
"a",
"boolean",
"indicating",
"whether",
"the",
"session",
"is",
"currently",
"logged",
"on",
"to",
"the",
"HMC",
"."
] | python | train | 35.869565 |
ArchiveTeam/wpull | wpull/network/connection.py | https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/network/connection.py#L36-L41 | def _schedule(self):
'''Schedule check function.'''
if self._running:
_logger.debug('Schedule check function.')
self._call_later_handle = self._event_loop.call_later(
self._timeout, self._check) | [
"def",
"_schedule",
"(",
"self",
")",
":",
"if",
"self",
".",
"_running",
":",
"_logger",
".",
"debug",
"(",
"'Schedule check function.'",
")",
"self",
".",
"_call_later_handle",
"=",
"self",
".",
"_event_loop",
".",
"call_later",
"(",
"self",
".",
"_timeout... | Schedule check function. | [
"Schedule",
"check",
"function",
"."
] | python | train | 40.833333 |
rhayes777/PyAutoFit | autofit/tools/path_util.py | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/path_util.py#L42-L77 | def make_and_return_path_from_path_and_folder_names(path, folder_names):
""" For a given path, create a directory structure composed of a set of folders and return the path to the \
inner-most folder.
For example, if path='/path/to/folders', and folder_names=['folder1', 'folder2'], the directory created wi... | [
"def",
"make_and_return_path_from_path_and_folder_names",
"(",
"path",
",",
"folder_names",
")",
":",
"for",
"folder_name",
"in",
"folder_names",
":",
"path",
"+=",
"folder_name",
"+",
"'/'",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"except",
"FileEx... | For a given path, create a directory structure composed of a set of folders and return the path to the \
inner-most folder.
For example, if path='/path/to/folders', and folder_names=['folder1', 'folder2'], the directory created will be
'/path/to/folders/folder1/folder2/' and the returned path will be '/pat... | [
"For",
"a",
"given",
"path",
"create",
"a",
"directory",
"structure",
"composed",
"of",
"a",
"set",
"of",
"folders",
"and",
"return",
"the",
"path",
"to",
"the",
"\\",
"inner",
"-",
"most",
"folder",
"."
] | python | train | 30.277778 |
RedHatInsights/insights-core | insights/specs/default.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/specs/default.py#L778-L782 | def block(broker):
"""Path: /sys/block directories starting with . or ram or dm- or loop"""
remove = (".", "ram", "dm-", "loop")
tmp = "/dev/%s"
return[(tmp % f) for f in os.listdir("/sys/block") if not f.startswith(remove)] | [
"def",
"block",
"(",
"broker",
")",
":",
"remove",
"=",
"(",
"\".\"",
",",
"\"ram\"",
",",
"\"dm-\"",
",",
"\"loop\"",
")",
"tmp",
"=",
"\"/dev/%s\"",
"return",
"[",
"(",
"tmp",
"%",
"f",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"\"/sys/bl... | Path: /sys/block directories starting with . or ram or dm- or loop | [
"Path",
":",
"/",
"sys",
"/",
"block",
"directories",
"starting",
"with",
".",
"or",
"ram",
"or",
"dm",
"-",
"or",
"loop"
] | python | train | 50.4 |
django-danceschool/django-danceschool | danceschool/core/utils/emails.py | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/utils/emails.py#L4-L31 | def get_text_for_html(html_content):
'''
Take the HTML content (from, for example, an email)
and construct a simple plain text version of that content
(for example, for inclusion in a multipart email message).
'''
soup = BeautifulSoup(html_content)
# kill all script and style elem... | [
"def",
"get_text_for_html",
"(",
"html_content",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"html_content",
")",
"# kill all script and style elements\r",
"for",
"script",
"in",
"soup",
"(",
"[",
"\"script\"",
",",
"\"style\"",
"]",
")",
":",
"script",
".",
"e... | Take the HTML content (from, for example, an email)
and construct a simple plain text version of that content
(for example, for inclusion in a multipart email message). | [
"Take",
"the",
"HTML",
"content",
"(",
"from",
"for",
"example",
"an",
"email",
")",
"and",
"construct",
"a",
"simple",
"plain",
"text",
"version",
"of",
"that",
"content",
"(",
"for",
"example",
"for",
"inclusion",
"in",
"a",
"multipart",
"email",
"messag... | python | train | 34.821429 |
danilobellini/audiolazy | audiolazy/lazy_text.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_text.py#L299-L354 | def small_doc(obj, indent="", max_width=80):
"""
Finds a useful small doc representation of an object.
Parameters
----------
obj :
Any object, which the documentation representation should be taken from.
indent :
Result indentation string to be insert in front of all lines.
max_width :
Each l... | [
"def",
"small_doc",
"(",
"obj",
",",
"indent",
"=",
"\"\"",
",",
"max_width",
"=",
"80",
")",
":",
"if",
"not",
"getattr",
"(",
"obj",
",",
"\"__doc__\"",
",",
"False",
")",
":",
"data",
"=",
"[",
"el",
".",
"strip",
"(",
")",
"for",
"el",
"in",
... | Finds a useful small doc representation of an object.
Parameters
----------
obj :
Any object, which the documentation representation should be taken from.
indent :
Result indentation string to be insert in front of all lines.
max_width :
Each line of the result may have at most this length.
Re... | [
"Finds",
"a",
"useful",
"small",
"doc",
"representation",
"of",
"an",
"object",
"."
] | python | train | 31.482143 |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L14-L23 | def add_genelist(self, list_id, gene_ids, case_obj=None):
"""Create a new gene list and optionally link to cases."""
new_genelist = GeneList(list_id=list_id)
new_genelist.gene_ids = gene_ids
if case_obj:
new_genelist.cases.append(case_obj)
self.session.add(new_geneli... | [
"def",
"add_genelist",
"(",
"self",
",",
"list_id",
",",
"gene_ids",
",",
"case_obj",
"=",
"None",
")",
":",
"new_genelist",
"=",
"GeneList",
"(",
"list_id",
"=",
"list_id",
")",
"new_genelist",
".",
"gene_ids",
"=",
"gene_ids",
"if",
"case_obj",
":",
"new... | Create a new gene list and optionally link to cases. | [
"Create",
"a",
"new",
"gene",
"list",
"and",
"optionally",
"link",
"to",
"cases",
"."
] | python | train | 36.2 |
gwastro/pycbc | pycbc/pool.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/pool.py#L31-L41 | def _lockstep_fcn(values):
""" Wrapper to ensure that all processes execute together """
numrequired, fcn, args = values
with _process_lock:
_numdone.value += 1
# yep this is an ugly busy loop, do something better please
# when we care about the performance of this call and not just the
... | [
"def",
"_lockstep_fcn",
"(",
"values",
")",
":",
"numrequired",
",",
"fcn",
",",
"args",
"=",
"values",
"with",
"_process_lock",
":",
"_numdone",
".",
"value",
"+=",
"1",
"# yep this is an ugly busy loop, do something better please",
"# when we care about the performance ... | Wrapper to ensure that all processes execute together | [
"Wrapper",
"to",
"ensure",
"that",
"all",
"processes",
"execute",
"together"
] | python | train | 39.727273 |
inveniosoftware/invenio-queues | invenio_queues/ext.py | https://github.com/inveniosoftware/invenio-queues/blob/1dd9112d7c5fe72a428c86f21f6d02cdb0595921/invenio_queues/ext.py#L90-L98 | def init_app(self, app, entry_point_group='invenio_queues.queues'):
"""Flask application initialization."""
self.init_config(app)
app.extensions['invenio-queues'] = _InvenioQueuesState(
app,
app.config['QUEUES_CONNECTION_POOL'],
entry_point_group=entry_point_g... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"entry_point_group",
"=",
"'invenio_queues.queues'",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"app",
".",
"extensions",
"[",
"'invenio-queues'",
"]",
"=",
"_InvenioQueuesState",
"(",
"app",
",",
... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | python | train | 38.333333 |
tensorflow/tensor2tensor | tensor2tensor/models/research/glow_ops.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L184-L198 | def get_dropout(x, rate=0.0, init=True):
"""Dropout x with dropout_rate = rate.
Apply zero dropout during init or prediction time.
Args:
x: 4-D Tensor, shape=(NHWC).
rate: Dropout rate.
init: Initialization.
Returns:
x: activations after dropout.
"""
if init or rate == 0:
return x
re... | [
"def",
"get_dropout",
"(",
"x",
",",
"rate",
"=",
"0.0",
",",
"init",
"=",
"True",
")",
":",
"if",
"init",
"or",
"rate",
"==",
"0",
":",
"return",
"x",
"return",
"tf",
".",
"layers",
".",
"dropout",
"(",
"x",
",",
"rate",
"=",
"rate",
",",
"tra... | Dropout x with dropout_rate = rate.
Apply zero dropout during init or prediction time.
Args:
x: 4-D Tensor, shape=(NHWC).
rate: Dropout rate.
init: Initialization.
Returns:
x: activations after dropout. | [
"Dropout",
"x",
"with",
"dropout_rate",
"=",
"rate",
"."
] | python | train | 23.8 |
hyperledger/indy-plenum | plenum/server/primary_decider.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/primary_decider.py#L99-L108 | async def serviceQueues(self, limit=None) -> int:
"""
Service at most `limit` messages from the inBox.
:param limit: the maximum number of messages to service
:return: the number of messages successfully processed
"""
return await self.inBoxRouter.handleAll(self.filterM... | [
"async",
"def",
"serviceQueues",
"(",
"self",
",",
"limit",
"=",
"None",
")",
"->",
"int",
":",
"return",
"await",
"self",
".",
"inBoxRouter",
".",
"handleAll",
"(",
"self",
".",
"filterMsgs",
"(",
"self",
".",
"inBox",
")",
",",
"limit",
")"
] | Service at most `limit` messages from the inBox.
:param limit: the maximum number of messages to service
:return: the number of messages successfully processed | [
"Service",
"at",
"most",
"limit",
"messages",
"from",
"the",
"inBox",
"."
] | python | train | 38.2 |
daler/trackhub | trackhub/track.py | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L474-L479 | def add_subtrack(self, subtrack):
"""
Add a child :class:`Track`.
"""
self.add_child(subtrack)
self.subtracks.append(subtrack) | [
"def",
"add_subtrack",
"(",
"self",
",",
"subtrack",
")",
":",
"self",
".",
"add_child",
"(",
"subtrack",
")",
"self",
".",
"subtracks",
".",
"append",
"(",
"subtrack",
")"
] | Add a child :class:`Track`. | [
"Add",
"a",
"child",
":",
"class",
":",
"Track",
"."
] | python | train | 26.833333 |
google/grr | grr/server/grr_response_server/flows/general/administrative.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/administrative.py#L287-L289 | def ProcessMessage(self, message):
"""Processes a stats response from the client."""
self.ProcessResponse(message.source.Basename(), message.payload) | [
"def",
"ProcessMessage",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"ProcessResponse",
"(",
"message",
".",
"source",
".",
"Basename",
"(",
")",
",",
"message",
".",
"payload",
")"
] | Processes a stats response from the client. | [
"Processes",
"a",
"stats",
"response",
"from",
"the",
"client",
"."
] | python | train | 51.666667 |
brendonh/pyth | pyth/document.py | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/document.py#L30-L59 | def append(self, item):
"""
Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L ... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"okay",
"=",
"True",
"if",
"not",
"isinstance",
"(",
"item",
",",
"self",
".",
"contentType",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"contentType",
",",
"'contentType'",
")",
":",
"try",
":",... | Try to add an item to this element.
If the item is of the wrong type, and if this element has a sub-type,
then try to create such a sub-type and insert the item into that, instead.
This happens recursively, so (in python-markup):
L [ u'Foo' ]
actually creates:
... | [
"Try",
"to",
"add",
"an",
"item",
"to",
"this",
"element",
"."
] | python | train | 32.3 |
ouroboroscoding/reconsider | reconsider.py | https://github.com/ouroboroscoding/reconsider/blob/155061d72e757665f9d3fee5a8a9d6f31f6872ed/reconsider.py#L56-L84 | def printHelp(script):
"""Print Help
Prints out the arguments needs to run the script
Returns:
None
"""
print 'Reconsider cli script copyright 2016 OuroborosCoding'
print ''
print script + ' --source=localhost:28015 --destination=somedomain.com:28015'
print script + ' --destination=somedomain.com:28015 --d... | [
"def",
"printHelp",
"(",
"script",
")",
":",
"print",
"'Reconsider cli script copyright 2016 OuroborosCoding'",
"print",
"''",
"print",
"script",
"+",
"' --source=localhost:28015 --destination=somedomain.com:28015'",
"print",
"script",
"+",
"' --destination=somedomain.com:28015 --d... | Print Help
Prints out the arguments needs to run the script
Returns:
None | [
"Print",
"Help"
] | python | train | 46.482759 |
erinxocon/requests-xml | requests_xml.py | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L133-L135 | def links(self) -> _Links:
"""All found links on page, in as–is form. Only works for Atom feeds."""
return list(set(x.text for x in self.xpath('//link'))) | [
"def",
"links",
"(",
"self",
")",
"->",
"_Links",
":",
"return",
"list",
"(",
"set",
"(",
"x",
".",
"text",
"for",
"x",
"in",
"self",
".",
"xpath",
"(",
"'//link'",
")",
")",
")"
] | All found links on page, in as–is form. Only works for Atom feeds. | [
"All",
"found",
"links",
"on",
"page",
"in",
"as–is",
"form",
".",
"Only",
"works",
"for",
"Atom",
"feeds",
"."
] | python | train | 56.333333 |
sorgerlab/indra | indra/sources/tees/processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L154-L186 | def find_event_with_outgoing_edges(self, event_name, desired_relations):
"""Gets a list of event nodes with the specified event_name and
outgoing edges annotated with each of the specified relations.
Parameters
----------
event_name : str
Look for event nodes with th... | [
"def",
"find_event_with_outgoing_edges",
"(",
"self",
",",
"event_name",
",",
"desired_relations",
")",
":",
"G",
"=",
"self",
".",
"G",
"desired_relations",
"=",
"set",
"(",
"desired_relations",
")",
"desired_event_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
... | Gets a list of event nodes with the specified event_name and
outgoing edges annotated with each of the specified relations.
Parameters
----------
event_name : str
Look for event nodes with this name
desired_relations : list[str]
Look for event nodes with ... | [
"Gets",
"a",
"list",
"of",
"event",
"nodes",
"with",
"the",
"specified",
"event_name",
"and",
"outgoing",
"edges",
"annotated",
"with",
"each",
"of",
"the",
"specified",
"relations",
"."
] | python | train | 37.181818 |
noxdafox/vminspect | vminspect/usnjrnl.py | https://github.com/noxdafox/vminspect/blob/e685282564877e2d1950f1e09b292f4f4db1dbcd/vminspect/usnjrnl.py#L128-L133 | def usn_v4_record(header, record):
"""Extracts USN V4 record information."""
length, major_version, minor_version = header
fields = V4_RECORD.unpack_from(record, RECORD_HEADER.size)
raise NotImplementedError('Not implemented') | [
"def",
"usn_v4_record",
"(",
"header",
",",
"record",
")",
":",
"length",
",",
"major_version",
",",
"minor_version",
"=",
"header",
"fields",
"=",
"V4_RECORD",
".",
"unpack_from",
"(",
"record",
",",
"RECORD_HEADER",
".",
"size",
")",
"raise",
"NotImplemented... | Extracts USN V4 record information. | [
"Extracts",
"USN",
"V4",
"record",
"information",
"."
] | python | train | 39.666667 |
riptano/ccm | ccmlib/remote.py | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L342-L360 | def __remove_dir(self, ftp, remote_path):
"""
Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove
"""
# Iterate over the remote path and perform remove operation... | [
"def",
"__remove_dir",
"(",
"self",
",",
"ftp",
",",
"remote_path",
")",
":",
"# Iterate over the remote path and perform remove operations",
"files",
"=",
"ftp",
".",
"listdir",
"(",
"remote_path",
")",
"for",
"filename",
"in",
"files",
":",
"# Attempt to remove the ... | Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove | [
"Helper",
"function",
"to",
"perform",
"delete",
"operation",
"on",
"the",
"remote",
"server"
] | python | train | 37.789474 |
UCL-INGI/INGInious | inginious/frontend/pages/tasks.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/tasks.py#L85-L176 | def GET(self, courseid, taskid, isLTI):
""" GET request """
username = self.user_manager.session_username()
# Fetch the course
try:
course = self.course_factory.get_course(courseid)
except exceptions.CourseNotFoundException as ex:
raise web.notfound(str(e... | [
"def",
"GET",
"(",
"self",
",",
"courseid",
",",
"taskid",
",",
"isLTI",
")",
":",
"username",
"=",
"self",
".",
"user_manager",
".",
"session_username",
"(",
")",
"# Fetch the course",
"try",
":",
"course",
"=",
"self",
".",
"course_factory",
".",
"get_co... | GET request | [
"GET",
"request"
] | python | train | 50.434783 |
PythonOptimizers/cygenja | cygenja/treemap/treemap.py | https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L237-L254 | def retrieve_element_or_default(self, location, default=None):
"""
Args:
location:
default:
Returns:
"""
loc_descriptor = self._get_location_descriptor(location)
# find node
node = None
try:
node = sel... | [
"def",
"retrieve_element_or_default",
"(",
"self",
",",
"location",
",",
"default",
"=",
"None",
")",
":",
"loc_descriptor",
"=",
"self",
".",
"_get_location_descriptor",
"(",
"location",
")",
"# find node",
"node",
"=",
"None",
"try",
":",
"node",
"=",
"self"... | Args:
location:
default:
Returns: | [
"Args",
":",
"location",
":",
"default",
":",
"Returns",
":"
] | python | train | 23.5 |
inspirehep/harvesting-kit | harvestingkit/pos_package.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/pos_package.py#L117-L166 | def get_record(self, record):
""" Reads a dom xml element in oaidc format and
returns the bibrecord object """
self.document = record
rec = create_record()
language = self._get_language()
if language and language != 'en':
record_add_field(rec, '041', subfi... | [
"def",
"get_record",
"(",
"self",
",",
"record",
")",
":",
"self",
".",
"document",
"=",
"record",
"rec",
"=",
"create_record",
"(",
")",
"language",
"=",
"self",
".",
"_get_language",
"(",
")",
"if",
"language",
"and",
"language",
"!=",
"'en'",
":",
"... | Reads a dom xml element in oaidc format and
returns the bibrecord object | [
"Reads",
"a",
"dom",
"xml",
"element",
"in",
"oaidc",
"format",
"and",
"returns",
"the",
"bibrecord",
"object"
] | python | valid | 46.9 |
QUANTAXIS/QUANTAXIS | QUANTAXIS/QAData/dsmethods.py | https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAData/dsmethods.py#L169-L189 | def QDS_StockDayWarpper(func):
"""
日线QDS装饰器
"""
def warpper(*args, **kwargs):
data = func(*args, **kwargs)
if isinstance(data.index, pd.MultiIndex):
return QA_DataStruct_Stock_day(data)
else:
return QA_DataStruct_Stock_day(
data.assign(d... | [
"def",
"QDS_StockDayWarpper",
"(",
"func",
")",
":",
"def",
"warpper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"data",
".",
"index",
",",
"... | 日线QDS装饰器 | [
"日线QDS装饰器"
] | python | train | 26 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/zmq/eventloops.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/eventloops.py#L92-L115 | def loop_tk(kernel):
"""Start a kernel with the Tk event loop."""
import Tkinter
doi = kernel.do_one_iteration
# Tk uses milliseconds
poll_interval = int(1000*kernel._poll_interval)
# For Tkinter, we create a Tk object and call its withdraw method.
class Timer(object):
def __init__(... | [
"def",
"loop_tk",
"(",
"kernel",
")",
":",
"import",
"Tkinter",
"doi",
"=",
"kernel",
".",
"do_one_iteration",
"# Tk uses milliseconds",
"poll_interval",
"=",
"int",
"(",
"1000",
"*",
"kernel",
".",
"_poll_interval",
")",
"# For Tkinter, we create a Tk object and call... | Start a kernel with the Tk event loop. | [
"Start",
"a",
"kernel",
"with",
"the",
"Tk",
"event",
"loop",
"."
] | python | test | 28.958333 |
mlouielu/twstock | twstock/legacy.py | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/legacy.py#L27-L38 | def moving_average(self, data, days):
""" 計算移動平均數
:rtype: 序列 舊→新
"""
result = []
data = data[:]
for dummy in range(len(data) - int(days) + 1):
result.append(round(sum(data[-days:]) / days, 2))
data.pop()
result.reverse()
return... | [
"def",
"moving_average",
"(",
"self",
",",
"data",
",",
"days",
")",
":",
"result",
"=",
"[",
"]",
"data",
"=",
"data",
"[",
":",
"]",
"for",
"dummy",
"in",
"range",
"(",
"len",
"(",
"data",
")",
"-",
"int",
"(",
"days",
")",
"+",
"1",
")",
"... | 計算移動平均數
:rtype: 序列 舊→新 | [
"計算移動平均數"
] | python | train | 26.333333 |
SiLab-Bonn/pyBAR | pybar/fei4_run_base.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1445-L1457 | def interval_timer(interval, func, *args, **kwargs):
'''Interval timer function.
Taken from: http://stackoverflow.com/questions/22498038/improvement-on-interval-python/22498708
'''
stopped = Event()
def loop():
while not stopped.wait(interval): # the first call is after interval
... | [
"def",
"interval_timer",
"(",
"interval",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"stopped",
"=",
"Event",
"(",
")",
"def",
"loop",
"(",
")",
":",
"while",
"not",
"stopped",
".",
"wait",
"(",
"interval",
")",
":",
"# the f... | Interval timer function.
Taken from: http://stackoverflow.com/questions/22498038/improvement-on-interval-python/22498708 | [
"Interval",
"timer",
"function",
"."
] | python | train | 32 |
vsjha18/nsetools | nse.py | https://github.com/vsjha18/nsetools/blob/c306b568471701c19195d2f17e112cc92022d3e0/nse.py#L434-L448 | def download_bhavcopy(self, d):
"""returns bhavcopy as csv file."""
# ex_url = "https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip"
url = self.get_bhavcopy_url(d)
filename = self.get_bhavcopy_filename(d)
# response = requests.get(url, headers=se... | [
"def",
"download_bhavcopy",
"(",
"self",
",",
"d",
")",
":",
"# ex_url = \"https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip\"",
"url",
"=",
"self",
".",
"get_bhavcopy_url",
"(",
"d",
")",
"filename",
"=",
"self",
".",
"get_bhavcopy_filen... | returns bhavcopy as csv file. | [
"returns",
"bhavcopy",
"as",
"csv",
"file",
"."
] | python | train | 42.733333 |
ejeschke/ginga | ginga/canvas/render.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/canvas/render.py#L107-L116 | def reorder(self, dst_order, arr, src_order=None):
"""Reorder the output array to match that needed by the viewer."""
if dst_order is None:
dst_order = self.viewer.rgb_order
if src_order is None:
src_order = self.rgb_order
if src_order != dst_order:
ar... | [
"def",
"reorder",
"(",
"self",
",",
"dst_order",
",",
"arr",
",",
"src_order",
"=",
"None",
")",
":",
"if",
"dst_order",
"is",
"None",
":",
"dst_order",
"=",
"self",
".",
"viewer",
".",
"rgb_order",
"if",
"src_order",
"is",
"None",
":",
"src_order",
"=... | Reorder the output array to match that needed by the viewer. | [
"Reorder",
"the",
"output",
"array",
"to",
"match",
"that",
"needed",
"by",
"the",
"viewer",
"."
] | python | train | 38.2 |
yahoo/TensorFlowOnSpark | examples/mnist/mnist_data_setup.py | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/mnist_data_setup.py#L27-L31 | def fromTFExample(bytestr):
"""Deserializes a TFExample from a byte string"""
example = tf.train.Example()
example.ParseFromString(bytestr)
return example | [
"def",
"fromTFExample",
"(",
"bytestr",
")",
":",
"example",
"=",
"tf",
".",
"train",
".",
"Example",
"(",
")",
"example",
".",
"ParseFromString",
"(",
"bytestr",
")",
"return",
"example"
] | Deserializes a TFExample from a byte string | [
"Deserializes",
"a",
"TFExample",
"from",
"a",
"byte",
"string"
] | python | train | 31.6 |
jepegit/cellpy | cellpy/utils/batch_old.py | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L956-L1107 | def read_and_save_data(info_df, raw_dir, sep=";", force_raw=False,
force_cellpy=False,
export_cycles=False, shifted_cycles=False,
export_raw=True,
export_ica=False, save=True, use_cellpy_stat_file=False,
p... | [
"def",
"read_and_save_data",
"(",
"info_df",
",",
"raw_dir",
",",
"sep",
"=",
"\";\"",
",",
"force_raw",
"=",
"False",
",",
"force_cellpy",
"=",
"False",
",",
"export_cycles",
"=",
"False",
",",
"shifted_cycles",
"=",
"False",
",",
"export_raw",
"=",
"True",... | Reads and saves cell data defined by the info-DataFrame.
The function iterates through the ``info_df`` and loads data from the runs.
It saves individual data for each run (if selected), as well as returns a
list of ``cellpy`` summary DataFrames, a list of the indexes (one for each
run; same as used as ... | [
"Reads",
"and",
"saves",
"cell",
"data",
"defined",
"by",
"the",
"info",
"-",
"DataFrame",
"."
] | python | train | 41.657895 |
DataDog/integrations-core | mcache/datadog_checks/mcache/mcache.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mcache/datadog_checks/mcache/mcache.py#L112-L123 | def _process_response(cls, response):
"""
Examine the response and raise an error is something is off
"""
if len(response) != 1:
raise BadResponseError("Malformed response: {}".format(response))
stats = list(itervalues(response))[0]
if not len(stats):
... | [
"def",
"_process_response",
"(",
"cls",
",",
"response",
")",
":",
"if",
"len",
"(",
"response",
")",
"!=",
"1",
":",
"raise",
"BadResponseError",
"(",
"\"Malformed response: {}\"",
".",
"format",
"(",
"response",
")",
")",
"stats",
"=",
"list",
"(",
"iter... | Examine the response and raise an error is something is off | [
"Examine",
"the",
"response",
"and",
"raise",
"an",
"error",
"is",
"something",
"is",
"off"
] | python | train | 33.916667 |
mikicz/arca | arca/backend/docker.py | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/backend/docker.py#L580-L601 | def try_pull_image_from_registry(self, image_name, image_tag):
"""
Tries to pull a image with the tag ``image_tag`` from registry set by ``use_registry_name``.
After the image is pulled, it's tagged with ``image_name``:``image_tag`` so lookup can
be made locally next time.
:retu... | [
"def",
"try_pull_image_from_registry",
"(",
"self",
",",
"image_name",
",",
"image_tag",
")",
":",
"try",
":",
"image",
"=",
"self",
".",
"client",
".",
"images",
".",
"pull",
"(",
"self",
".",
"use_registry_name",
",",
"image_tag",
")",
"except",
"(",
"do... | Tries to pull a image with the tag ``image_tag`` from registry set by ``use_registry_name``.
After the image is pulled, it's tagged with ``image_name``:``image_tag`` so lookup can
be made locally next time.
:return: A :class:`Image <docker.models.images.Image>` instance if the image exists, ``N... | [
"Tries",
"to",
"pull",
"a",
"image",
"with",
"the",
"tag",
"image_tag",
"from",
"registry",
"set",
"by",
"use_registry_name",
".",
"After",
"the",
"image",
"is",
"pulled",
"it",
"s",
"tagged",
"with",
"image_name",
":",
"image_tag",
"so",
"lookup",
"can",
... | python | train | 50.227273 |
Jaymon/prom | prom/interface/base.py | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L43-L60 | def transaction_start(self, name):
"""
start a transaction
this will increment transaction semaphore and pass it to _transaction_start()
"""
if not name:
raise ValueError("Transaction name cannot be empty")
#uid = id(self)
self.transaction_count ... | [
"def",
"transaction_start",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"\"Transaction name cannot be empty\"",
")",
"#uid = id(self)",
"self",
".",
"transaction_count",
"+=",
"1",
"logger",
".",
"debug",
"(",
"\"{}.... | start a transaction
this will increment transaction semaphore and pass it to _transaction_start() | [
"start",
"a",
"transaction"
] | python | train | 31.555556 |
GNS3/gns3-server | gns3server/compute/base_node.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_node.py#L303-L327 | def close(self):
"""
Close the node process.
"""
if self._closed:
return False
log.info("{module}: '{name}' [{id}]: is closing".format(module=self.manager.module_name,
name=self.name,
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"return",
"False",
"log",
".",
"info",
"(",
"\"{module}: '{name}' [{id}]: is closing\"",
".",
"format",
"(",
"module",
"=",
"self",
".",
"manager",
".",
"module_name",
",",
"name",
"... | Close the node process. | [
"Close",
"the",
"node",
"process",
"."
] | python | train | 34.44 |
programa-stic/barf-project | barf/core/reil/emulator/tainter.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/core/reil/emulator/tainter.py#L182-L193 | def __taint_store(self, instr):
"""Taint STM instruction.
"""
# Get memory address.
op2_val = self.__emu.read_operand(instr.operands[2])
# Get taint information.
op0_size = instr.operands[0].size
op0_taint = self.get_operand_taint(instr.operands[0])
# Pr... | [
"def",
"__taint_store",
"(",
"self",
",",
"instr",
")",
":",
"# Get memory address.",
"op2_val",
"=",
"self",
".",
"__emu",
".",
"read_operand",
"(",
"instr",
".",
"operands",
"[",
"2",
"]",
")",
"# Get taint information.",
"op0_size",
"=",
"instr",
".",
"op... | Taint STM instruction. | [
"Taint",
"STM",
"instruction",
"."
] | python | train | 32.333333 |
opencobra/memote | memote/support/consistency_helpers.py | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L43-L62 | def add_reaction_constraints(model, reactions, Constraint):
"""
Add the stoichiometric coefficients as constraints.
Parameters
----------
model : optlang.Model
The transposed stoichiometric matrix representation.
reactions : iterable
Container of `cobra.Reaction` instances.
... | [
"def",
"add_reaction_constraints",
"(",
"model",
",",
"reactions",
",",
"Constraint",
")",
":",
"constraints",
"=",
"[",
"]",
"for",
"rxn",
"in",
"reactions",
":",
"expression",
"=",
"add",
"(",
"[",
"c",
"*",
"model",
".",
"variables",
"[",
"m",
".",
... | Add the stoichiometric coefficients as constraints.
Parameters
----------
model : optlang.Model
The transposed stoichiometric matrix representation.
reactions : iterable
Container of `cobra.Reaction` instances.
Constraint : optlang.Constraint
The constraint class for the spe... | [
"Add",
"the",
"stoichiometric",
"coefficients",
"as",
"constraints",
"."
] | python | train | 32.55 |
kodexlab/reliure | reliure/pipeline.py | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L327-L340 | def check(call_fct):
""" Decorator for optionable __call__ method
It check the given option values
"""
# wrap the method
@wraps(call_fct)
def checked_call(self, *args, **kwargs):
self.set_options_values(kwargs, parse=False, strict=True)
options_val... | [
"def",
"check",
"(",
"call_fct",
")",
":",
"# wrap the method",
"@",
"wraps",
"(",
"call_fct",
")",
"def",
"checked_call",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_options_values",
"(",
"kwargs",
",",
"parse",
... | Decorator for optionable __call__ method
It check the given option values | [
"Decorator",
"for",
"optionable",
"__call__",
"method",
"It",
"check",
"the",
"given",
"option",
"values"
] | python | train | 41.928571 |
rm-hull/OPi.GPIO | OPi/GPIO.py | https://github.com/rm-hull/OPi.GPIO/blob/d151885eb0f0fc25d4a86266eefebc105700f3fd/OPi/GPIO.py#L414-L452 | def wait_for_edge(channel, trigger, timeout=-1):
"""
This function is designed to block execution of your program until an edge
is detected.
:param channel: the channel based on the numbering system you have specified
(:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`).
:p... | [
"def",
"wait_for_edge",
"(",
"channel",
",",
"trigger",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"_check_configured",
"(",
"channel",
",",
"direction",
"=",
"IN",
")",
"pin",
"=",
"get_gpio_pin",
"(",
"_mode",
",",
"channel",
")",
"if",
"event",
".",
"... | This function is designed to block execution of your program until an edge
is detected.
:param channel: the channel based on the numbering system you have specified
(:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`).
:param trigger: The event to detect, one of: :py:attr:`GPIO.RIS... | [
"This",
"function",
"is",
"designed",
"to",
"block",
"execution",
"of",
"your",
"program",
"until",
"an",
"edge",
"is",
"detected",
"."
] | python | train | 37.358974 |
flowersteam/explauto | explauto/sensorimotor_model/inverse/cma.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7092-L7122 | def indices(self, fit):
"""return the set of indices to be reevaluated for noise
measurement.
Given the first values are the earliest, this is a useful policy also
with a time changing objective.
"""
## meta_parameters.noise_reeval_multiplier == 1.0
lam_reev = 1... | [
"def",
"indices",
"(",
"self",
",",
"fit",
")",
":",
"## meta_parameters.noise_reeval_multiplier == 1.0",
"lam_reev",
"=",
"1.0",
"*",
"(",
"self",
".",
"lam_reeval",
"if",
"self",
".",
"lam_reeval",
"else",
"2",
"+",
"len",
"(",
"fit",
")",
"/",
"20",
")"... | return the set of indices to be reevaluated for noise
measurement.
Given the first values are the earliest, this is a useful policy also
with a time changing objective. | [
"return",
"the",
"set",
"of",
"indices",
"to",
"be",
"reevaluated",
"for",
"noise",
"measurement",
"."
] | python | train | 47.903226 |
craffel/mir_eval | mir_eval/beat.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L580-L639 | def information_gain(reference_beats,
estimated_beats,
bins=41):
"""Get the information gain - K-L divergence of the beat error histogram
to a uniform histogram
Examples
--------
>>> reference_beats = mir_eval.io.load_events('reference.txt')
>>> referen... | [
"def",
"information_gain",
"(",
"reference_beats",
",",
"estimated_beats",
",",
"bins",
"=",
"41",
")",
":",
"validate",
"(",
"reference_beats",
",",
"estimated_beats",
")",
"# If an even number of bins is provided,",
"# there will be no bin centered at zero, so warn the user."... | Get the information gain - K-L divergence of the beat error histogram
to a uniform histogram
Examples
--------
>>> reference_beats = mir_eval.io.load_events('reference.txt')
>>> reference_beats = mir_eval.beat.trim_beats(reference_beats)
>>> estimated_beats = mir_eval.io.load_events('estimated.... | [
"Get",
"the",
"information",
"gain",
"-",
"K",
"-",
"L",
"divergence",
"of",
"the",
"beat",
"error",
"histogram",
"to",
"a",
"uniform",
"histogram"
] | python | train | 41.116667 |
creare-com/pydem | pydem/dem_processing.py | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L332-L344 | def fill_n_todo(self):
"""
Calculate and record the number of edge pixels left to do on each tile
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_chunks):
self.n_todo.ravel()[i] = np.sum([left.... | [
"def",
"fill_n_todo",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
"right",
"=",
"self",
".",
"right",
"top",
"=",
"self",
".",
"top",
"bottom",
"=",
"self",
".",
"bottom",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
")",
... | Calculate and record the number of edge pixels left to do on each tile | [
"Calculate",
"and",
"record",
"the",
"number",
"of",
"edge",
"pixels",
"left",
"to",
"do",
"on",
"each",
"tile"
] | python | train | 41 |
minhhoit/yacms | yacms/conf/__init__.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/__init__.py#L178-L223 | def _load(self):
"""
Load editable settings from the database and return them as a dict.
Delete any settings from the database that are no longer registered,
and emit a warning if there are settings that are defined in both
settings.py and the database.
"""
from y... | [
"def",
"_load",
"(",
"self",
")",
":",
"from",
"yacms",
".",
"conf",
".",
"models",
"import",
"Setting",
"removed_settings",
"=",
"[",
"]",
"conflicting_settings",
"=",
"[",
"]",
"new_cache",
"=",
"{",
"}",
"for",
"setting_obj",
"in",
"Setting",
".",
"ob... | Load editable settings from the database and return them as a dict.
Delete any settings from the database that are no longer registered,
and emit a warning if there are settings that are defined in both
settings.py and the database. | [
"Load",
"editable",
"settings",
"from",
"the",
"database",
"and",
"return",
"them",
"as",
"a",
"dict",
".",
"Delete",
"any",
"settings",
"from",
"the",
"database",
"that",
"are",
"no",
"longer",
"registered",
"and",
"emit",
"a",
"warning",
"if",
"there",
"... | python | train | 40.304348 |
AshleySetter/optoanalysis | optoanalysis/optoanalysis/optoanalysis.py | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/optoanalysis.py#L3780-L3842 | def fit_radius_from_potentials(z, SampleFreq, Damping, HistBins=100, show_fig=False):
"""
Fits the dynamical potential to the Steady
State Potential by varying the Radius.
z : ndarray
Position data
SampleFreq : float
frequency at which the position data was
sampled
... | [
"def",
"fit_radius_from_potentials",
"(",
"z",
",",
"SampleFreq",
",",
"Damping",
",",
"HistBins",
"=",
"100",
",",
"show_fig",
"=",
"False",
")",
":",
"dt",
"=",
"1",
"/",
"SampleFreq",
"boltzmann",
"=",
"Boltzmann",
"temp",
"=",
"300",
"# why halved??",
... | Fits the dynamical potential to the Steady
State Potential by varying the Radius.
z : ndarray
Position data
SampleFreq : float
frequency at which the position data was
sampled
Damping : float
value of damping (in radians/second)
HistBins : int
number of... | [
"Fits",
"the",
"dynamical",
"potential",
"to",
"the",
"Steady",
"State",
"Potential",
"by",
"varying",
"the",
"Radius",
".",
"z",
":",
"ndarray",
"Position",
"data",
"SampleFreq",
":",
"float",
"frequency",
"at",
"which",
"the",
"position",
"data",
"was",
"s... | python | train | 33.15873 |
Jammy2211/PyAutoLens | autolens/data/array/grids.py | https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/grids.py#L186-L206 | def grid_stack_for_simulation(cls, shape, pixel_scale, psf_shape, sub_grid_size=2):
"""Setup a grid-stack of grid_stack for simulating an image of a strong lens, whereby the grid's use \
padded-grid_stack to ensure that the PSF blurring in the simulation routine (*ccd.PrepatoryImage.simulate*) \
... | [
"def",
"grid_stack_for_simulation",
"(",
"cls",
",",
"shape",
",",
"pixel_scale",
",",
"psf_shape",
",",
"sub_grid_size",
"=",
"2",
")",
":",
"return",
"cls",
".",
"padded_grid_stack_from_mask_sub_grid_size_and_psf_shape",
"(",
"mask",
"=",
"msk",
".",
"Mask",
"("... | Setup a grid-stack of grid_stack for simulating an image of a strong lens, whereby the grid's use \
padded-grid_stack to ensure that the PSF blurring in the simulation routine (*ccd.PrepatoryImage.simulate*) \
is not degraded due to edge effects.
Parameters
-----------
shape : (... | [
"Setup",
"a",
"grid",
"-",
"stack",
"of",
"grid_stack",
"for",
"simulating",
"an",
"image",
"of",
"a",
"strong",
"lens",
"whereby",
"the",
"grid",
"s",
"use",
"\\",
"padded",
"-",
"grid_stack",
"to",
"ensure",
"that",
"the",
"PSF",
"blurring",
"in",
"the... | python | valid | 63.285714 |
dmwm/DBS | Server/Python/src/dbs/business/DBSFile.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/business/DBSFile.py#L118-L129 | def listFileParentsByLumi(self, block_name='', logical_file_name=[]):
"""
required parameter: block_name
returns: [{child_parent_id_list: [(cid1, pid1), (cid2, pid2), ... (cidn, pidn)]}]
"""
#self.logger.debug("lfn %s, block_name %s" % (logical_file_name, block_name))
if... | [
"def",
"listFileParentsByLumi",
"(",
"self",
",",
"block_name",
"=",
"''",
",",
"logical_file_name",
"=",
"[",
"]",
")",
":",
"#self.logger.debug(\"lfn %s, block_name %s\" % (logical_file_name, block_name))",
"if",
"not",
"block_name",
":",
"dbsExceptionHandler",
"(",
"'d... | required parameter: block_name
returns: [{child_parent_id_list: [(cid1, pid1), (cid2, pid2), ... (cidn, pidn)]}] | [
"required",
"parameter",
":",
"block_name",
"returns",
":",
"[",
"{",
"child_parent_id_list",
":",
"[",
"(",
"cid1",
"pid1",
")",
"(",
"cid2",
"pid2",
")",
"...",
"(",
"cidn",
"pidn",
")",
"]",
"}",
"]"
] | python | train | 57.833333 |
saltstack/salt | salt/modules/virt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L493-L513 | def _libvirt_creds():
'''
Returns the user and group that the disk images should be owned by
'''
g_cmd = 'grep ^\\s*group /etc/libvirt/qemu.conf'
u_cmd = 'grep ^\\s*user /etc/libvirt/qemu.conf'
try:
stdout = subprocess.Popen(g_cmd,
shell=True,
... | [
"def",
"_libvirt_creds",
"(",
")",
":",
"g_cmd",
"=",
"'grep ^\\\\s*group /etc/libvirt/qemu.conf'",
"u_cmd",
"=",
"'grep ^\\\\s*user /etc/libvirt/qemu.conf'",
"try",
":",
"stdout",
"=",
"subprocess",
".",
"Popen",
"(",
"g_cmd",
",",
"shell",
"=",
"True",
",",
"stdou... | Returns the user and group that the disk images should be owned by | [
"Returns",
"the",
"user",
"and",
"group",
"that",
"the",
"disk",
"images",
"should",
"be",
"owned",
"by"
] | python | train | 38.238095 |
mdiener/grace | grace/py27/pyjsdoc.py | https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/pyjsdoc.py#L332-L338 | def parse_comments_for_file(filename):
"""
Return a list of all parsed comments in a file. Mostly for testing &
interactive use.
"""
return [parse_comment(strip_stars(comment), next_line)
for comment, next_line in get_doc_comments(read_file(filename))] | [
"def",
"parse_comments_for_file",
"(",
"filename",
")",
":",
"return",
"[",
"parse_comment",
"(",
"strip_stars",
"(",
"comment",
")",
",",
"next_line",
")",
"for",
"comment",
",",
"next_line",
"in",
"get_doc_comments",
"(",
"read_file",
"(",
"filename",
")",
"... | Return a list of all parsed comments in a file. Mostly for testing &
interactive use. | [
"Return",
"a",
"list",
"of",
"all",
"parsed",
"comments",
"in",
"a",
"file",
".",
"Mostly",
"for",
"testing",
"&",
"interactive",
"use",
"."
] | python | train | 39.857143 |
mozilla/python_moztelemetry | moztelemetry/spark.py | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/spark.py#L176-L200 | def get_one_ping_per_client(pings):
"""
Returns a single ping for each client in the RDD.
THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially
selected at random. It is also expensive as it requires data to be
shuffled around. It should be run only after extracting a subset with
... | [
"def",
"get_one_ping_per_client",
"(",
"pings",
")",
":",
"if",
"isinstance",
"(",
"pings",
".",
"first",
"(",
")",
",",
"binary_type",
")",
":",
"pings",
"=",
"pings",
".",
"map",
"(",
"lambda",
"p",
":",
"json",
".",
"loads",
"(",
"p",
".",
"decode... | Returns a single ping for each client in the RDD.
THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially
selected at random. It is also expensive as it requires data to be
shuffled around. It should be run only after extracting a subset with
get_pings_properties. | [
"Returns",
"a",
"single",
"ping",
"for",
"each",
"client",
"in",
"the",
"RDD",
"."
] | python | train | 35.08 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.