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 |
|---|---|---|---|---|---|---|---|---|---|
pywbem/pywbem | attic/cimxml_parse.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/attic/cimxml_parse.py#L999-L1011 | def make_parser(stream_or_string):
"""Create a xml.dom.pulldom parser."""
if isinstance(stream_or_string, six.string_types):
# XXX: the pulldom.parseString() function doesn't seem to
# like operating on unicode strings!
return pulldom.parseString(str(stream_or_string))
else:
... | [
"def",
"make_parser",
"(",
"stream_or_string",
")",
":",
"if",
"isinstance",
"(",
"stream_or_string",
",",
"six",
".",
"string_types",
")",
":",
"# XXX: the pulldom.parseString() function doesn't seem to",
"# like operating on unicode strings!",
"return",
"pulldom",
".",
"p... | Create a xml.dom.pulldom parser. | [
"Create",
"a",
"xml",
".",
"dom",
".",
"pulldom",
"parser",
"."
] | python | train | 27 |
wonambi-python/wonambi | wonambi/widgets/analysis.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/analysis.py#L1553-L1765 | def compute_freq(self, csd=False):
"""Compute frequency domain analysis.
Returns
-------
list of dict
each item is a dict where 'data' is an instance of ChanFreq for a
single segment of signal, 'name' is the event type, if applicable,
'times' is a tup... | [
"def",
"compute_freq",
"(",
"self",
",",
"csd",
"=",
"False",
")",
":",
"progress",
"=",
"QProgressDialog",
"(",
"'Computing frequency'",
",",
"'Abort'",
",",
"0",
",",
"len",
"(",
"self",
".",
"data",
")",
"-",
"1",
",",
"self",
")",
"progress",
".",
... | Compute frequency domain analysis.
Returns
-------
list of dict
each item is a dict where 'data' is an instance of ChanFreq for a
single segment of signal, 'name' is the event type, if applicable,
'times' is a tuple of the start and end times in sec, 'duratio... | [
"Compute",
"frequency",
"domain",
"analysis",
"."
] | python | train | 39.065728 |
ekzhu/SetSimilaritySearch | SetSimilaritySearch/search.py | https://github.com/ekzhu/SetSimilaritySearch/blob/30188ca0257b644501f4a359172fddb2f89bf568/SetSimilaritySearch/search.py#L65-L91 | def query(self, s):
"""Query the search index for sets similar to the query set.
Args:
s (Iterable): the query set.
Returns (list): a list of tuples `(index, similarity)` where the index
is the index of the matching sets in the original list of sets.
"""
... | [
"def",
"query",
"(",
"self",
",",
"s",
")",
":",
"s1",
"=",
"np",
".",
"sort",
"(",
"[",
"self",
".",
"order",
"[",
"token",
"]",
"for",
"token",
"in",
"s",
"if",
"token",
"in",
"self",
".",
"order",
"]",
")",
"logging",
".",
"debug",
"(",
"\... | Query the search index for sets similar to the query set.
Args:
s (Iterable): the query set.
Returns (list): a list of tuples `(index, similarity)` where the index
is the index of the matching sets in the original list of sets. | [
"Query",
"the",
"search",
"index",
"for",
"sets",
"similar",
"to",
"the",
"query",
"set",
"."
] | python | train | 43.555556 |
pypa/pipenv | pipenv/vendor/iso8601/iso8601.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/iso8601/iso8601.py#L153-L172 | def parse_timezone(matches, default_timezone=UTC):
"""Parses ISO 8601 time zone specs into tzinfo offsets
"""
if matches["timezone"] == "Z":
return UTC
# This isn't strictly correct, but it's common to encounter dates without
# timezones so I'll assume the default (which defaults to UTC).
... | [
"def",
"parse_timezone",
"(",
"matches",
",",
"default_timezone",
"=",
"UTC",
")",
":",
"if",
"matches",
"[",
"\"timezone\"",
"]",
"==",
"\"Z\"",
":",
"return",
"UTC",
"# This isn't strictly correct, but it's common to encounter dates without",
"# timezones so I'll assume t... | Parses ISO 8601 time zone specs into tzinfo offsets | [
"Parses",
"ISO",
"8601",
"time",
"zone",
"specs",
"into",
"tzinfo",
"offsets"
] | python | train | 35.3 |
log2timeline/plaso | plaso/parsers/text_parser.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/text_parser.py#L48-L91 | def PyParseRangeCheck(lower_bound, upper_bound):
"""Verify that a number is within a defined range.
This is a callback method for pyparsing setParseAction
that verifies that a read number is within a certain range.
To use this method it needs to be defined as a callback method
in setParseAction with the upp... | [
"def",
"PyParseRangeCheck",
"(",
"lower_bound",
",",
"upper_bound",
")",
":",
"# pylint: disable=unused-argument",
"def",
"CheckRange",
"(",
"string",
",",
"location",
",",
"tokens",
")",
":",
"\"\"\"Parse the arguments.\n\n Args:\n string (str): original string.\n ... | Verify that a number is within a defined range.
This is a callback method for pyparsing setParseAction
that verifies that a read number is within a certain range.
To use this method it needs to be defined as a callback method
in setParseAction with the upper and lower bound set as parameters.
Args:
low... | [
"Verify",
"that",
"a",
"number",
"is",
"within",
"a",
"defined",
"range",
"."
] | python | train | 33.409091 |
tanghaibao/jcvi | jcvi/assembly/preprocess.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/preprocess.py#L159-L246 | def expand(args):
"""
%prog expand bes.fasta reads.fastq
Expand sequences using short reads. Useful, for example for getting BAC-end
sequences. The template to use, in `bes.fasta` may just contain the junction
sequences, then align the reads to get the 'flanks' for such sequences.
"""
impor... | [
"def",
"expand",
"(",
"args",
")",
":",
"import",
"math",
"from",
"jcvi",
".",
"formats",
".",
"fasta",
"import",
"Fasta",
",",
"SeqIO",
"from",
"jcvi",
".",
"formats",
".",
"fastq",
"import",
"readlen",
",",
"first",
",",
"fasta",
"from",
"jcvi",
".",... | %prog expand bes.fasta reads.fastq
Expand sequences using short reads. Useful, for example for getting BAC-end
sequences. The template to use, in `bes.fasta` may just contain the junction
sequences, then align the reads to get the 'flanks' for such sequences. | [
"%prog",
"expand",
"bes",
".",
"fasta",
"reads",
".",
"fastq"
] | python | train | 32.022727 |
msmbuilder/osprey | osprey/config.py | https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L368-L371 | def sha1(self):
"""SHA1 hash of the config file itself."""
with open(self.path, 'rb') as f:
return hashlib.sha1(f.read()).hexdigest() | [
"def",
"sha1",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"hashlib",
".",
"sha1",
"(",
"f",
".",
"read",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | SHA1 hash of the config file itself. | [
"SHA1",
"hash",
"of",
"the",
"config",
"file",
"itself",
"."
] | python | valid | 39.5 |
saltstack/salt | salt/modules/panos.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1677-L1714 | def set_management_icmp(enabled=True, deploy=False):
'''
Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate ... | [
"def",
"set_management_icmp",
"(",
"enabled",
"=",
"True",
",",
"deploy",
"=",
"False",
")",
":",
"if",
"enabled",
"is",
"True",
":",
"value",
"=",
"\"no\"",
"elif",
"enabled",
"is",
"False",
":",
"value",
"=",
"\"yes\"",
"else",
":",
"raise",
"CommandEx... | Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-blo... | [
"Enables",
"or",
"disables",
"the",
"ICMP",
"management",
"service",
"on",
"the",
"device",
"."
] | python | train | 27.631579 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_aaa.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_aaa.py#L407-L421 | def tacacs_server_host_key(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
tacacs_server = ET.SubElement(config, "tacacs-server", xmlns="urn:brocade.com:mgmt:brocade-aaa")
host = ET.SubElement(tacacs_server, "host")
hostname_key = ET.SubElement(h... | [
"def",
"tacacs_server_host_key",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"tacacs_server",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"tacacs-server\"",
",",
"xmlns",
"=",
"\"urn:... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 42.933333 |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L333-L341 | def supprime(cls,table, **kwargs):
""" Remove entries matchin given condition
kwargs is a dict of column name : value , with length ONE.
"""
assert len(kwargs) == 1
field, value = kwargs.popitem()
req = f"""DELETE FROM {table} WHERE {field} = """ + cls.mark_style
... | [
"def",
"supprime",
"(",
"cls",
",",
"table",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"kwargs",
")",
"==",
"1",
"field",
",",
"value",
"=",
"kwargs",
".",
"popitem",
"(",
")",
"req",
"=",
"f\"\"\"DELETE FROM {table} WHERE {field} = \"\"\"",... | Remove entries matchin given condition
kwargs is a dict of column name : value , with length ONE. | [
"Remove",
"entries",
"matchin",
"given",
"condition",
"kwargs",
"is",
"a",
"dict",
"of",
"column",
"name",
":",
"value",
"with",
"length",
"ONE",
"."
] | python | train | 41.111111 |
StackStorm/pybind | pybind/slxos/v17r_2_00/hardware/profile/tcam/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_2_00/hardware/profile/tcam/__init__.py#L162-L183 | def _set_limit(self, v, load=False):
"""
Setter method for limit, mapped from YANG variable /hardware/profile/tcam/limit (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_limit is considered as a private
method. Backends looking to populate this variable sh... | [
"def",
"_set_limit",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
... | Setter method for limit, mapped from YANG variable /hardware/profile/tcam/limit (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_limit is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_limit() d... | [
"Setter",
"method",
"for",
"limit",
"mapped",
"from",
"YANG",
"variable",
"/",
"hardware",
"/",
"profile",
"/",
"tcam",
"/",
"limit",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"t... | python | train | 81.227273 |
sighingnow/parsec.py | src/parsec/__init__.py | https://github.com/sighingnow/parsec.py/blob/ed50e1e259142757470b925f8d20dfe5ad223af0/src/parsec/__init__.py#L188-L201 | def skip(self, other):
'''(<<) Ends with a specified parser, and at the end parser consumed the
end flag.'''
@Parser
def ends_with_parser(text, index):
res = self(text, index)
if not res.status:
return res
end = other(text, res.index)
... | [
"def",
"skip",
"(",
"self",
",",
"other",
")",
":",
"@",
"Parser",
"def",
"ends_with_parser",
"(",
"text",
",",
"index",
")",
":",
"res",
"=",
"self",
"(",
"text",
",",
"index",
")",
"if",
"not",
"res",
".",
"status",
":",
"return",
"res",
"end",
... | (<<) Ends with a specified parser, and at the end parser consumed the
end flag. | [
"(",
"<<",
")",
"Ends",
"with",
"a",
"specified",
"parser",
"and",
"at",
"the",
"end",
"parser",
"consumed",
"the",
"end",
"flag",
"."
] | python | train | 37.571429 |
ikalnytskyi/dooku | dooku/itertools.py | https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/itertools.py#L20-L37 | def chunk_by(n, iterable, fillvalue=None):
"""
Iterate over a given ``iterable`` by ``n`` elements at a time.
>>> for x, y in chunk_by(2, [1, 2, 3, 4, 5]):
... # iteration no 1: x=1, y=2
... # iteration no 2: x=3, y=4
... # iteration no 3: x=5, y=None
:param n: (int) a chun... | [
"def",
"chunk_by",
"(",
"n",
",",
"iterable",
",",
"fillvalue",
"=",
"None",
")",
":",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"n",
"return",
"zip_longest",
"(",
"*",
"args",
",",
"fillvalue",
"=",
"fillvalue",
")"
] | Iterate over a given ``iterable`` by ``n`` elements at a time.
>>> for x, y in chunk_by(2, [1, 2, 3, 4, 5]):
... # iteration no 1: x=1, y=2
... # iteration no 2: x=3, y=4
... # iteration no 3: x=5, y=None
:param n: (int) a chunk size number
:param iterable: (iterator) an input ... | [
"Iterate",
"over",
"a",
"given",
"iterable",
"by",
"n",
"elements",
"at",
"a",
"time",
"."
] | python | train | 39.111111 |
has2k1/mizani | mizani/transforms.py | https://github.com/has2k1/mizani/blob/312d0550ee0136fd1b0384829b33f3b2065f47c8/mizani/transforms.py#L581-L607 | def gettrans(t):
"""
Return a trans object
Parameters
----------
t : str | callable | type | trans
name of transformation function
Returns
-------
out : trans
"""
obj = t
# Make sure trans object is instantiated
if isinstance(obj, str):
name = '{}_trans'... | [
"def",
"gettrans",
"(",
"t",
")",
":",
"obj",
"=",
"t",
"# Make sure trans object is instantiated",
"if",
"isinstance",
"(",
"obj",
",",
"str",
")",
":",
"name",
"=",
"'{}_trans'",
".",
"format",
"(",
"obj",
")",
"obj",
"=",
"globals",
"(",
")",
"[",
"... | Return a trans object
Parameters
----------
t : str | callable | type | trans
name of transformation function
Returns
-------
out : trans | [
"Return",
"a",
"trans",
"object"
] | python | valid | 20.074074 |
saltstack/salt | salt/states/alternatives.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/alternatives.py#L162-L190 | def auto(name):
'''
.. versionadded:: 0.17.0
Instruct alternatives to use the highest priority
path for <name>
name
is the master name for this link group
(e.g. pager)
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
... | [
"def",
"auto",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"display",
"=",
"__salt__",
"[",
"'alternatives.display'",
"]",
"(",
"name"... | .. versionadded:: 0.17.0
Instruct alternatives to use the highest priority
path for <name>
name
is the master name for this link group
(e.g. pager) | [
"..",
"versionadded",
"::",
"0",
".",
"17",
".",
"0"
] | python | train | 24.965517 |
tensorflow/datasets | tensorflow_datasets/core/download/kaggle.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/kaggle.py#L118-L135 | def download_file(self, fname, output_dir):
"""Downloads competition file to output_dir."""
if fname not in self.competition_files: # pylint: disable=unsupported-membership-test
raise ValueError("%s is not one of the competition's "
"files: %s" % (fname, self.competition_files))
... | [
"def",
"download_file",
"(",
"self",
",",
"fname",
",",
"output_dir",
")",
":",
"if",
"fname",
"not",
"in",
"self",
".",
"competition_files",
":",
"# pylint: disable=unsupported-membership-test",
"raise",
"ValueError",
"(",
"\"%s is not one of the competition's \"",
"\"... | Downloads competition file to output_dir. | [
"Downloads",
"competition",
"file",
"to",
"output_dir",
"."
] | python | train | 33.388889 |
tdryer/hangups | hangups/client.py | https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/client.py#L519-L529 | async def get_entity_by_id(self, get_entity_by_id_request):
"""Return one or more user entities.
Searching by phone number only finds entities when their phone number
is in your contacts (and not always even then), and can't be used to
find Google Voice contacts.
"""
res... | [
"async",
"def",
"get_entity_by_id",
"(",
"self",
",",
"get_entity_by_id_request",
")",
":",
"response",
"=",
"hangouts_pb2",
".",
"GetEntityByIdResponse",
"(",
")",
"await",
"self",
".",
"_pb_request",
"(",
"'contacts/getentitybyid'",
",",
"get_entity_by_id_request",
... | Return one or more user entities.
Searching by phone number only finds entities when their phone number
is in your contacts (and not always even then), and can't be used to
find Google Voice contacts. | [
"Return",
"one",
"or",
"more",
"user",
"entities",
"."
] | python | valid | 45.636364 |
BeyondTheClouds/enoslib | enoslib/api.py | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/api.py#L135-L202 | def run_play(play_source, inventory_path=None, roles=None,
extra_vars=None, on_error_continue=False):
"""Run a play.
Args:
pattern_hosts (str): pattern to describe ansible hosts to target.
see https://docs.ansible.com/ansible/latest/intro_patterns.html
play_source (dict... | [
"def",
"run_play",
"(",
"play_source",
",",
"inventory_path",
"=",
"None",
",",
"roles",
"=",
"None",
",",
"extra_vars",
"=",
"None",
",",
"on_error_continue",
"=",
"False",
")",
":",
"# NOTE(msimonin): inventory could be infered from a host list (maybe)",
"results",
... | Run a play.
Args:
pattern_hosts (str): pattern to describe ansible hosts to target.
see https://docs.ansible.com/ansible/latest/intro_patterns.html
play_source (dict): ansible task
inventory_path (str): inventory to use
extra_vars (dict): extra_vars to use
on_err... | [
"Run",
"a",
"play",
"."
] | python | train | 33.779412 |
brews/snakebacon | snakebacon/mcmcbackends/bacon/utils.py | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/bacon/utils.py#L5-L49 | def d_cal(calibcurve, rcmean, w2, cutoff=0.0001, normal_distr=False, t_a=3, t_b=4):
"""Get calendar date probabilities
Parameters
----------
calibcurve : CalibCurve
Calibration curve.
rcmean : scalar
Reservoir-adjusted age.
w2 : scalar
r'$w^2_j(\theta)$' from pg 461 & 46... | [
"def",
"d_cal",
"(",
"calibcurve",
",",
"rcmean",
",",
"w2",
",",
"cutoff",
"=",
"0.0001",
",",
"normal_distr",
"=",
"False",
",",
"t_a",
"=",
"3",
",",
"t_b",
"=",
"4",
")",
":",
"assert",
"t_b",
"-",
"1",
"==",
"t_a",
"if",
"normal_distr",
":",
... | Get calendar date probabilities
Parameters
----------
calibcurve : CalibCurve
Calibration curve.
rcmean : scalar
Reservoir-adjusted age.
w2 : scalar
r'$w^2_j(\theta)$' from pg 461 & 463 of Blaauw and Christen 2011.
cutoff : scalar, optional
Unknown.
normal_di... | [
"Get",
"calendar",
"date",
"probabilities"
] | python | train | 37.777778 |
rsmuc/health_monitoring_plugins | health_monitoring_plugins/check_snmp_apc_ups/check_snmp_apc_ups.py | https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_apc_ups/check_snmp_apc_ups.py#L66-L99 | def check_basic_battery_status(the_session, the_helper, the_snmp_value):
"""
OID .1.3.6.1.4.1.318.1.1.1.2.1.1.0
MIB Excerpt
The status of the UPS batteries. A batteryLow(3)
value indicates the UPS will be unable to sustain the
current load, and its services will be lost if power is
not ... | [
"def",
"check_basic_battery_status",
"(",
"the_session",
",",
"the_helper",
",",
"the_snmp_value",
")",
":",
"apc_battery_states",
"=",
"{",
"'1'",
":",
"'unknown'",
",",
"'2'",
":",
"'batteryNormal'",
",",
"'3'",
":",
"'batteryLow'",
",",
"'4'",
":",
"'batteryI... | OID .1.3.6.1.4.1.318.1.1.1.2.1.1.0
MIB Excerpt
The status of the UPS batteries. A batteryLow(3)
value indicates the UPS will be unable to sustain the
current load, and its services will be lost if power is
not restored. The amount of run time in reserve at the
time of low battery can be c... | [
"OID",
".",
"1",
".",
"3",
".",
"6",
".",
"1",
".",
"4",
".",
"1",
".",
"318",
".",
"1",
".",
"1",
".",
"1",
".",
"2",
".",
"1",
".",
"1",
".",
"0",
"MIB",
"Excerpt",
"The",
"status",
"of",
"the",
"UPS",
"batteries",
".",
"A",
"batteryLow... | python | train | 31.294118 |
jayclassless/tidypy | src/tidypy/extenders/base.py | https://github.com/jayclassless/tidypy/blob/3c3497ca377fbbe937103b77b02b326c860c748f/src/tidypy/extenders/base.py#L40-L60 | def parse(cls, content, is_pyproject=False):
"""
A convenience method for parsing a TOML-serialized configuration.
:param content: a TOML string containing a TidyPy configuration
:type content: str
:param is_pyproject:
whether or not the content is (or resembles) a `... | [
"def",
"parse",
"(",
"cls",
",",
"content",
",",
"is_pyproject",
"=",
"False",
")",
":",
"parsed",
"=",
"pytoml",
".",
"loads",
"(",
"content",
")",
"if",
"is_pyproject",
":",
"parsed",
"=",
"parsed",
".",
"get",
"(",
"'tool'",
",",
"{",
"}",
")",
... | A convenience method for parsing a TOML-serialized configuration.
:param content: a TOML string containing a TidyPy configuration
:type content: str
:param is_pyproject:
whether or not the content is (or resembles) a ``pyproject.toml``
file, where the TidyPy configuratio... | [
"A",
"convenience",
"method",
"for",
"parsing",
"a",
"TOML",
"-",
"serialized",
"configuration",
"."
] | python | valid | 31.380952 |
google/gin-config | gin/selector_map.py | https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/selector_map.py#L180-L183 | def get_all_matches(self, partial_selector):
"""Returns all values matching `partial_selector` as a list."""
matching_selectors = self.matching_selectors(partial_selector)
return [self._selector_map[selector] for selector in matching_selectors] | [
"def",
"get_all_matches",
"(",
"self",
",",
"partial_selector",
")",
":",
"matching_selectors",
"=",
"self",
".",
"matching_selectors",
"(",
"partial_selector",
")",
"return",
"[",
"self",
".",
"_selector_map",
"[",
"selector",
"]",
"for",
"selector",
"in",
"mat... | Returns all values matching `partial_selector` as a list. | [
"Returns",
"all",
"values",
"matching",
"partial_selector",
"as",
"a",
"list",
"."
] | python | test | 63.25 |
apache/incubator-mxnet | example/vae-gan/vaegan_mxnet.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L288-L613 | def train(dataset, nef, ndf, ngf, nc, batch_size, Z, lr, beta1, epsilon, ctx, check_point, g_dl_weight, output_path, checkpoint_path, data_path, activation,num_epoch, save_after_every, visualize_after_every, show_after_every):
'''adversarial training of the VAE
'''
#encoder
z_mu, z_lv, z = encoder(nef,... | [
"def",
"train",
"(",
"dataset",
",",
"nef",
",",
"ndf",
",",
"ngf",
",",
"nc",
",",
"batch_size",
",",
"Z",
",",
"lr",
",",
"beta1",
",",
"epsilon",
",",
"ctx",
",",
"check_point",
",",
"g_dl_weight",
",",
"output_path",
",",
"checkpoint_path",
",",
... | adversarial training of the VAE | [
"adversarial",
"training",
"of",
"the",
"VAE"
] | python | train | 39.09816 |
istresearch/scrapy-cluster | rest/rest_service.py | https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/rest/rest_service.py#L398-L422 | def _create_consumer(self):
"""Tries to establing the Kafka consumer connection"""
if not self.closed:
try:
self.logger.debug("Creating new kafka consumer using brokers: " +
str(self.settings['KAFKA_HOSTS']) + ' and topic ' +
... | [
"def",
"_create_consumer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"closed",
":",
"try",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Creating new kafka consumer using brokers: \"",
"+",
"str",
"(",
"self",
".",
"settings",
"[",
"'KAFKA_HOSTS'",
... | Tries to establing the Kafka consumer connection | [
"Tries",
"to",
"establing",
"the",
"Kafka",
"consumer",
"connection"
] | python | train | 58.12 |
OpenKMIP/PyKMIP | kmip/services/server/crypto/engine.py | https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/services/server/crypto/engine.py#L125-L182 | def create_symmetric_key(self, algorithm, length):
"""
Create a symmetric key.
Args:
algorithm(CryptographicAlgorithm): An enumeration specifying the
algorithm for which the created key will be compliant.
length(int): The length of the key to be created. ... | [
"def",
"create_symmetric_key",
"(",
"self",
",",
"algorithm",
",",
"length",
")",
":",
"if",
"algorithm",
"not",
"in",
"self",
".",
"_symmetric_key_algorithms",
".",
"keys",
"(",
")",
":",
"raise",
"exceptions",
".",
"InvalidField",
"(",
"\"The cryptographic alg... | Create a symmetric key.
Args:
algorithm(CryptographicAlgorithm): An enumeration specifying the
algorithm for which the created key will be compliant.
length(int): The length of the key to be created. This value must
be compliant with the constraints of th... | [
"Create",
"a",
"symmetric",
"key",
"."
] | python | test | 37.965517 |
wtsi-hgi/python-hgijson | hgijson/json_converters/_serialization.py | https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/json_converters/_serialization.py#L104-L119 | def _create_deserializer(self) -> JsonObjectDeserializer:
"""
Creates a deserializer that is to be used by this decoder.
:return: the deserializer
"""
if self._deserializer_cache is None:
deserializer_cls = type(
"%sInternalDeserializer" % type(self),
... | [
"def",
"_create_deserializer",
"(",
"self",
")",
"->",
"JsonObjectDeserializer",
":",
"if",
"self",
".",
"_deserializer_cache",
"is",
"None",
":",
"deserializer_cls",
"=",
"type",
"(",
"\"%sInternalDeserializer\"",
"%",
"type",
"(",
"self",
")",
",",
"(",
"JsonO... | Creates a deserializer that is to be used by this decoder.
:return: the deserializer | [
"Creates",
"a",
"deserializer",
"that",
"is",
"to",
"be",
"used",
"by",
"this",
"decoder",
".",
":",
"return",
":",
"the",
"deserializer"
] | python | train | 41.6875 |
yt-project/unyt | unyt/unit_object.py | https://github.com/yt-project/unyt/blob/7a4eafc229f83784f4c63d639aee554f9a6b1ca0/unyt/unit_object.py#L653-L679 | def as_coeff_unit(self):
"""Factor the coefficient multiplying a unit
For units that are multiplied by a constant dimensionless
coefficient, returns a tuple containing the coefficient and
a new unit object for the unmultiplied unit.
Example
-------
>>> import u... | [
"def",
"as_coeff_unit",
"(",
"self",
")",
":",
"coeff",
",",
"mul",
"=",
"self",
".",
"expr",
".",
"as_coeff_Mul",
"(",
")",
"coeff",
"=",
"float",
"(",
"coeff",
")",
"ret",
"=",
"Unit",
"(",
"mul",
",",
"self",
".",
"base_value",
"/",
"coeff",
","... | Factor the coefficient multiplying a unit
For units that are multiplied by a constant dimensionless
coefficient, returns a tuple containing the coefficient and
a new unit object for the unmultiplied unit.
Example
-------
>>> import unyt as u
>>> unit = (u.m**2/... | [
"Factor",
"the",
"coefficient",
"multiplying",
"a",
"unit"
] | python | train | 26.37037 |
jtwhite79/pyemu | pyemu/pst/pst_handler.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L1959-L1994 | def calculate_pertubations(self):
""" experimental method to calculate finite difference parameter
pertubations. The pertubation values are added to the
Pst.parameter_data attribute
Note
----
user beware!
"""
self.build_increments()
self.paramet... | [
"def",
"calculate_pertubations",
"(",
"self",
")",
":",
"self",
".",
"build_increments",
"(",
")",
"self",
".",
"parameter_data",
".",
"loc",
"[",
":",
",",
"\"pertubation\"",
"]",
"=",
"self",
".",
"parameter_data",
".",
"parval1",
"+",
"self",
".",
"para... | experimental method to calculate finite difference parameter
pertubations. The pertubation values are added to the
Pst.parameter_data attribute
Note
----
user beware! | [
"experimental",
"method",
"to",
"calculate",
"finite",
"difference",
"parameter",
"pertubations",
".",
"The",
"pertubation",
"values",
"are",
"added",
"to",
"the",
"Pst",
".",
"parameter_data",
"attribute"
] | python | train | 41.583333 |
pymc-devs/pymc | pymc/Model.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Model.py#L632-L652 | def isample(self, *args, **kwds):
"""
Samples in interactive mode. Main thread of control stays in this function.
"""
self._exc_info = None
out = kwds.pop('out', sys.stdout)
kwds['progress_bar'] = False
def samp_targ(*args, **kwds):
try:
... | [
"def",
"isample",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"self",
".",
"_exc_info",
"=",
"None",
"out",
"=",
"kwds",
".",
"pop",
"(",
"'out'",
",",
"sys",
".",
"stdout",
")",
"kwds",
"[",
"'progress_bar'",
"]",
"=",
"False... | Samples in interactive mode. Main thread of control stays in this function. | [
"Samples",
"in",
"interactive",
"mode",
".",
"Main",
"thread",
"of",
"control",
"stays",
"in",
"this",
"function",
"."
] | python | train | 29.333333 |
econ-ark/HARK | HARK/interpolation.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/interpolation.py#L1995-L2015 | def derivativeX(self,x,y):
'''
Evaluate the first derivative with respect to x of the function at given
state space points.
Parameters
----------
x : np.array
First input values.
y : np.array
Second input values; should be of same shape ... | [
"def",
"derivativeX",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"xShift",
"=",
"self",
".",
"lowerBound",
"(",
"y",
")",
"dfdx_out",
"=",
"self",
".",
"func",
".",
"derivativeX",
"(",
"x",
"-",
"xShift",
",",
"y",
")",
"return",
"dfdx_out"
] | Evaluate the first derivative with respect to x of the function at given
state space points.
Parameters
----------
x : np.array
First input values.
y : np.array
Second input values; should be of same shape as x.
Returns
-------
... | [
"Evaluate",
"the",
"first",
"derivative",
"with",
"respect",
"to",
"x",
"of",
"the",
"function",
"at",
"given",
"state",
"space",
"points",
"."
] | python | train | 29.619048 |
ttinies/sc2players | sc2players/playerRecord.py | https://github.com/ttinies/sc2players/blob/fd9b37c268bf1005d9ef73a25e65ed97c8b7895f/sc2players/playerRecord.py#L143-L153 | def load(self, playerName=None):
"""retrieve the PlayerRecord settings from saved disk file"""
if playerName: # switch the PlayerRecord this object describes
self.name = playerName # preset value to load self.filename
try:
with open(self.filename, "rb") as f:
... | [
"def",
"load",
"(",
"self",
",",
"playerName",
"=",
"None",
")",
":",
"if",
"playerName",
":",
"# switch the PlayerRecord this object describes",
"self",
".",
"name",
"=",
"playerName",
"# preset value to load self.filename",
"try",
":",
"with",
"open",
"(",
"self",... | retrieve the PlayerRecord settings from saved disk file | [
"retrieve",
"the",
"PlayerRecord",
"settings",
"from",
"saved",
"disk",
"file"
] | python | train | 54.090909 |
LEMS/pylems | lems/run.py | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/run.py#L56-L109 | def main(args=None):
"""
Program entry point.
"""
if args is None:
args = process_args()
print('Parsing and resolving model: '+args.lems_file)
model = Model()
if args.I is not None:
for dir in args.I:
model.add_include_directory(dir)
model.import_fro... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"process_args",
"(",
")",
"print",
"(",
"'Parsing and resolving model: '",
"+",
"args",
".",
"lems_file",
")",
"model",
"=",
"Model",
"(",
")",
"if",
"args... | Program entry point. | [
"Program",
"entry",
"point",
"."
] | python | train | 27 |
openpaperwork/paperwork-backend | paperwork_backend/common/doc.py | https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L172-L180 | def __set_labels(self, labels):
"""
Add a label on the document.
"""
with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), 'w') \
as file_desc:
for label in labels:
file_desc.write("%s,%s\n" % (label.name,
... | [
"def",
"__set_labels",
"(",
"self",
",",
"labels",
")",
":",
"with",
"self",
".",
"fs",
".",
"open",
"(",
"self",
".",
"fs",
".",
"join",
"(",
"self",
".",
"path",
",",
"self",
".",
"LABEL_FILE",
")",
",",
"'w'",
")",
"as",
"file_desc",
":",
"for... | Add a label on the document. | [
"Add",
"a",
"label",
"on",
"the",
"document",
"."
] | python | train | 38.666667 |
googleapis/google-cloud-python | bigtable/google/cloud/bigtable/instance.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable/instance.py#L346-L359 | def reload(self):
"""Reload the metadata for this instance.
For example:
.. literalinclude:: snippets.py
:start-after: [START bigtable_reload_instance]
:end-before: [END bigtable_reload_instance]
"""
instance_pb = self._client.instance_admin_client.get_i... | [
"def",
"reload",
"(",
"self",
")",
":",
"instance_pb",
"=",
"self",
".",
"_client",
".",
"instance_admin_client",
".",
"get_instance",
"(",
"self",
".",
"name",
")",
"# NOTE: _update_from_pb does not check that the project and",
"# instance ID on the response match th... | Reload the metadata for this instance.
For example:
.. literalinclude:: snippets.py
:start-after: [START bigtable_reload_instance]
:end-before: [END bigtable_reload_instance] | [
"Reload",
"the",
"metadata",
"for",
"this",
"instance",
"."
] | python | train | 35.642857 |
05bit/peewee-async | peewee_async.py | https://github.com/05bit/peewee-async/blob/d15f4629da1d9975da4ec37306188e68d288c862/peewee_async.py#L964-L974 | def execute_sql(self, *args, **kwargs):
"""Sync execute SQL query, `allow_sync` must be set to True.
"""
assert self._allow_sync, (
"Error, sync query is not allowed! Call the `.set_allow_sync()` "
"or use the `.allow_sync()` context manager.")
if self._allow_sync... | [
"def",
"execute_sql",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"self",
".",
"_allow_sync",
",",
"(",
"\"Error, sync query is not allowed! Call the `.set_allow_sync()` \"",
"\"or use the `.allow_sync()` context manager.\"",
")",
"if",
"... | Sync execute SQL query, `allow_sync` must be set to True. | [
"Sync",
"execute",
"SQL",
"query",
"allow_sync",
"must",
"be",
"set",
"to",
"True",
"."
] | python | train | 50.818182 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L116-L136 | def get_driver_whitelist(driver): # noqa: E501
"""Retrieve the whitelist in the driver
Retrieve the whitelist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
i... | [
"def",
"get_driver_whitelist",
"(",
"driver",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"driver",
"... | Retrieve the whitelist in the driver
Retrieve the whitelist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response | [
"Retrieve",
"the",
"whitelist",
"in",
"the",
"driver"
] | python | train | 27 |
alvarogzp/python-sqlite-framework | sqlite_framework/component/component.py | https://github.com/alvarogzp/python-sqlite-framework/blob/29db97a64f95cfe13eb7bae1d00b624b5a37b152/sqlite_framework/component/component.py#L67-L72 | def _sql(self, sql: str, params=()):
"""
:deprecated: use self.sql instead
"""
statement = SingleSqlStatement(sql)
return self.statement(statement).execute_for_params(params).cursor | [
"def",
"_sql",
"(",
"self",
",",
"sql",
":",
"str",
",",
"params",
"=",
"(",
")",
")",
":",
"statement",
"=",
"SingleSqlStatement",
"(",
"sql",
")",
"return",
"self",
".",
"statement",
"(",
"statement",
")",
".",
"execute_for_params",
"(",
"params",
")... | :deprecated: use self.sql instead | [
":",
"deprecated",
":",
"use",
"self",
".",
"sql",
"instead"
] | python | train | 36 |
cs50/lib50 | lib50/_api.py | https://github.com/cs50/lib50/blob/941767f6c0a3b81af0cdea48c25c8d5a761086eb/lib50/_api.py#L700-L710 | def _prompt_username(prompt="Username: ", prefill=None):
"""Prompt the user for username."""
if prefill:
readline.set_startup_hook(lambda: readline.insert_text(prefill))
try:
return input(prompt).strip()
except EOFError:
print()
finally:
readline.set_startup_hook() | [
"def",
"_prompt_username",
"(",
"prompt",
"=",
"\"Username: \"",
",",
"prefill",
"=",
"None",
")",
":",
"if",
"prefill",
":",
"readline",
".",
"set_startup_hook",
"(",
"lambda",
":",
"readline",
".",
"insert_text",
"(",
"prefill",
")",
")",
"try",
":",
"re... | Prompt the user for username. | [
"Prompt",
"the",
"user",
"for",
"username",
"."
] | python | train | 28 |
sorgerlab/indra | indra/assemblers/pybel/assembler.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pybel/assembler.py#L149-L170 | def to_database(self, manager=None):
"""Send the model to the PyBEL database
This function wraps :py:func:`pybel.to_database`.
Parameters
----------
manager : Optional[pybel.manager.Manager]
A PyBEL database manager. If none, first checks the PyBEL
confi... | [
"def",
"to_database",
"(",
"self",
",",
"manager",
"=",
"None",
")",
":",
"network",
"=",
"pybel",
".",
"to_database",
"(",
"self",
".",
"model",
",",
"manager",
"=",
"manager",
")",
"return",
"network"
] | Send the model to the PyBEL database
This function wraps :py:func:`pybel.to_database`.
Parameters
----------
manager : Optional[pybel.manager.Manager]
A PyBEL database manager. If none, first checks the PyBEL
configuration for ``PYBEL_CONNECTION`` then checks th... | [
"Send",
"the",
"model",
"to",
"the",
"PyBEL",
"database"
] | python | train | 38.181818 |
manns/pyspread | pyspread/src/gui/_cairo_export_dialog.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_cairo_export_dialog.py#L248-L255 | def on_page_layout_choice(self, event):
"""Page layout choice event handler"""
width, height = self.paper_sizes_points[event.GetString()]
self.page_width_text_ctrl.SetValue(str(width / 72.0))
self.page_height_text_ctrl.SetValue(str(height / 72.0))
event.Skip() | [
"def",
"on_page_layout_choice",
"(",
"self",
",",
"event",
")",
":",
"width",
",",
"height",
"=",
"self",
".",
"paper_sizes_points",
"[",
"event",
".",
"GetString",
"(",
")",
"]",
"self",
".",
"page_width_text_ctrl",
".",
"SetValue",
"(",
"str",
"(",
"widt... | Page layout choice event handler | [
"Page",
"layout",
"choice",
"event",
"handler"
] | python | train | 36.875 |
boriel/zxbasic | api/symboltable.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L446-L460 | def access_array(self, id_, lineno, scope=None, default_type=None):
"""
Called whenever an accessed variable is expected to be an array.
ZX BASIC requires arrays to be declared before usage, so they're
checked.
Also checks for class array.
"""
if not self.check_i... | [
"def",
"access_array",
"(",
"self",
",",
"id_",
",",
"lineno",
",",
"scope",
"=",
"None",
",",
"default_type",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"check_is_declared",
"(",
"id_",
",",
"lineno",
",",
"'array'",
",",
"scope",
")",
":",
"r... | Called whenever an accessed variable is expected to be an array.
ZX BASIC requires arrays to be declared before usage, so they're
checked.
Also checks for class array. | [
"Called",
"whenever",
"an",
"accessed",
"variable",
"is",
"expected",
"to",
"be",
"an",
"array",
".",
"ZX",
"BASIC",
"requires",
"arrays",
"to",
"be",
"declared",
"before",
"usage",
"so",
"they",
"re",
"checked",
"."
] | python | train | 36.333333 |
aio-libs/aioredis | aioredis/commands/streams.py | https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/streams.py#L6-L9 | def fields_to_dict(fields, type_=OrderedDict):
"""Convert a flat list of key/values into an OrderedDict"""
fields_iterator = iter(fields)
return type_(zip(fields_iterator, fields_iterator)) | [
"def",
"fields_to_dict",
"(",
"fields",
",",
"type_",
"=",
"OrderedDict",
")",
":",
"fields_iterator",
"=",
"iter",
"(",
"fields",
")",
"return",
"type_",
"(",
"zip",
"(",
"fields_iterator",
",",
"fields_iterator",
")",
")"
] | Convert a flat list of key/values into an OrderedDict | [
"Convert",
"a",
"flat",
"list",
"of",
"key",
"/",
"values",
"into",
"an",
"OrderedDict"
] | python | train | 49.5 |
saltstack/salt | salt/engines/libvirt_events.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/libvirt_events.py#L522-L532 | def _pool_event_refresh_cb(conn, pool, opaque):
'''
Storage pool refresh events handler
'''
_salt_send_event(opaque, conn, {
'pool': {
'name': pool.name(),
'uuid': pool.UUIDString()
},
'event': opaque['event']
}) | [
"def",
"_pool_event_refresh_cb",
"(",
"conn",
",",
"pool",
",",
"opaque",
")",
":",
"_salt_send_event",
"(",
"opaque",
",",
"conn",
",",
"{",
"'pool'",
":",
"{",
"'name'",
":",
"pool",
".",
"name",
"(",
")",
",",
"'uuid'",
":",
"pool",
".",
"UUIDString... | Storage pool refresh events handler | [
"Storage",
"pool",
"refresh",
"events",
"handler"
] | python | train | 24.545455 |
Stewori/pytypes | pytypes/typechecker.py | https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/typechecker.py#L1167-L1172 | def check_argument_types(cllable = None, call_args = None, clss = None, caller_level = 0):
"""Can be called from within a function or method to apply typechecking to
the arguments that were passed in by the caller. Checking is applied w.r.t.
type hints of the function or method hosting the call to check_arg... | [
"def",
"check_argument_types",
"(",
"cllable",
"=",
"None",
",",
"call_args",
"=",
"None",
",",
"clss",
"=",
"None",
",",
"caller_level",
"=",
"0",
")",
":",
"return",
"_check_caller_type",
"(",
"False",
",",
"cllable",
",",
"call_args",
",",
"clss",
",",
... | Can be called from within a function or method to apply typechecking to
the arguments that were passed in by the caller. Checking is applied w.r.t.
type hints of the function or method hosting the call to check_argument_types. | [
"Can",
"be",
"called",
"from",
"within",
"a",
"function",
"or",
"method",
"to",
"apply",
"typechecking",
"to",
"the",
"arguments",
"that",
"were",
"passed",
"in",
"by",
"the",
"caller",
".",
"Checking",
"is",
"applied",
"w",
".",
"r",
".",
"t",
".",
"t... | python | train | 69 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/axes.py | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L94-L112 | def user_loc_value_to_class(axis_tag, user_loc):
"""Return the OS/2 weight or width class that is closest to the provided
user location. For weight the user location is between 0 and 1000 and for
width it is a percentage.
>>> user_loc_value_to_class('wght', 310)
310
>>> user_loc_value_to_class(... | [
"def",
"user_loc_value_to_class",
"(",
"axis_tag",
",",
"user_loc",
")",
":",
"if",
"axis_tag",
"==",
"\"wght\"",
":",
"return",
"int",
"(",
"user_loc",
")",
"elif",
"axis_tag",
"==",
"\"wdth\"",
":",
"return",
"min",
"(",
"sorted",
"(",
"WIDTH_CLASS_TO_VALUE"... | Return the OS/2 weight or width class that is closest to the provided
user location. For weight the user location is between 0 and 1000 and for
width it is a percentage.
>>> user_loc_value_to_class('wght', 310)
310
>>> user_loc_value_to_class('wdth', 62)
2 | [
"Return",
"the",
"OS",
"/",
"2",
"weight",
"or",
"width",
"class",
"that",
"is",
"closest",
"to",
"the",
"provided",
"user",
"location",
".",
"For",
"weight",
"the",
"user",
"location",
"is",
"between",
"0",
"and",
"1000",
"and",
"for",
"width",
"it",
... | python | train | 30.526316 |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L103-L110 | def objects(self):
"""
The objects in this listing.
:type: List[:class:`.ObjectInfo`]
"""
return [ObjectInfo(o, self._instance, self._bucket, self._client)
for o in self._proto.object] | [
"def",
"objects",
"(",
"self",
")",
":",
"return",
"[",
"ObjectInfo",
"(",
"o",
",",
"self",
".",
"_instance",
",",
"self",
".",
"_bucket",
",",
"self",
".",
"_client",
")",
"for",
"o",
"in",
"self",
".",
"_proto",
".",
"object",
"]"
] | The objects in this listing.
:type: List[:class:`.ObjectInfo`] | [
"The",
"objects",
"in",
"this",
"listing",
"."
] | python | train | 29.25 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/directory.py | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/directory.py#L4248-L4262 | def team_2_json(self):
"""
transform ariane_clip3 team object to Ariane server JSON obj
:return: Ariane JSON obj
"""
LOGGER.debug("Team.team_2_json")
json_obj = {
'teamID': self.id,
'teamName': self.name,
'teamDescription': self.descrip... | [
"def",
"team_2_json",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Team.team_2_json\"",
")",
"json_obj",
"=",
"{",
"'teamID'",
":",
"self",
".",
"id",
",",
"'teamName'",
":",
"self",
".",
"name",
",",
"'teamDescription'",
":",
"self",
".",
"des... | transform ariane_clip3 team object to Ariane server JSON obj
:return: Ariane JSON obj | [
"transform",
"ariane_clip3",
"team",
"object",
"to",
"Ariane",
"server",
"JSON",
"obj",
":",
"return",
":",
"Ariane",
"JSON",
"obj"
] | python | train | 33.133333 |
ejeschke/ginga | ginga/util/addons.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/addons.py#L44-L81 | def show_mode_indicator(viewer, tf, corner='ur'):
"""Show a keyboard mode indicator in one of the corners.
Parameters
----------
viewer : an ImageView subclass instance
If True, show the color bar; else remove it if present.
tf : bool
If True, show the mark; else remove it if prese... | [
"def",
"show_mode_indicator",
"(",
"viewer",
",",
"tf",
",",
"corner",
"=",
"'ur'",
")",
":",
"tag",
"=",
"'_$mode_indicator'",
"canvas",
"=",
"viewer",
".",
"get_private_canvas",
"(",
")",
"try",
":",
"indic",
"=",
"canvas",
".",
"get_object_by_tag",
"(",
... | Show a keyboard mode indicator in one of the corners.
Parameters
----------
viewer : an ImageView subclass instance
If True, show the color bar; else remove it if present.
tf : bool
If True, show the mark; else remove it if present.
corner : str
One of 'll', 'lr', 'ul' or ... | [
"Show",
"a",
"keyboard",
"mode",
"indicator",
"in",
"one",
"of",
"the",
"corners",
"."
] | python | train | 28.052632 |
SmokinCaterpillar/pypet | pypet/environment.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/environment.py#L210-L225 | def _configure_logging(kwargs, extract=True):
"""Requests the logging manager to configure logging.
:param extract:
If naming data should be extracted from the trajectory
"""
try:
logging_manager = kwargs['logging_manager']
if extract:
logging_manager.extract_repla... | [
"def",
"_configure_logging",
"(",
"kwargs",
",",
"extract",
"=",
"True",
")",
":",
"try",
":",
"logging_manager",
"=",
"kwargs",
"[",
"'logging_manager'",
"]",
"if",
"extract",
":",
"logging_manager",
".",
"extract_replacements",
"(",
"kwargs",
"[",
"'traj'",
... | Requests the logging manager to configure logging.
:param extract:
If naming data should be extracted from the trajectory | [
"Requests",
"the",
"logging",
"manager",
"to",
"configure",
"logging",
"."
] | python | test | 34.3125 |
buckket/twtxt | twtxt/cli.py | https://github.com/buckket/twtxt/blob/6c8ad8ef3cbcf0dd335a12285d8b6bbdf93ce851/twtxt/cli.py#L276-L327 | def quickstart():
"""Quickstart wizard for setting up twtxt."""
width = click.get_terminal_size()[0]
width = width if width <= 79 else 79
click.secho("twtxt - quickstart", fg="cyan")
click.secho("==================", fg="cyan")
click.echo()
help_text = "This wizard will generate a basic co... | [
"def",
"quickstart",
"(",
")",
":",
"width",
"=",
"click",
".",
"get_terminal_size",
"(",
")",
"[",
"0",
"]",
"width",
"=",
"width",
"if",
"width",
"<=",
"79",
"else",
"79",
"click",
".",
"secho",
"(",
"\"twtxt - quickstart\"",
",",
"fg",
"=",
"\"cyan\... | Quickstart wizard for setting up twtxt. | [
"Quickstart",
"wizard",
"for",
"setting",
"up",
"twtxt",
"."
] | python | valid | 46.788462 |
UDST/urbansim | urbansim/utils/misc.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L320-L336 | def df64bitto32bit(tbl):
"""
Convert a Pandas dataframe from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
tbl : The dataframe to convert
Returns
-------
The converted dataframe
"""
newtbl = pd.DataFrame(index=tbl.index)
for colname in... | [
"def",
"df64bitto32bit",
"(",
"tbl",
")",
":",
"newtbl",
"=",
"pd",
".",
"DataFrame",
"(",
"index",
"=",
"tbl",
".",
"index",
")",
"for",
"colname",
"in",
"tbl",
".",
"columns",
":",
"newtbl",
"[",
"colname",
"]",
"=",
"series64bitto32bit",
"(",
"tbl",... | Convert a Pandas dataframe from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
tbl : The dataframe to convert
Returns
-------
The converted dataframe | [
"Convert",
"a",
"Pandas",
"dataframe",
"from",
"64",
"bit",
"types",
"to",
"32",
"bit",
"types",
"to",
"save",
"memory",
"or",
"disk",
"space",
"."
] | python | train | 23.176471 |
XRDX/pyleap | pyleap/color.py | https://github.com/XRDX/pyleap/blob/234c722cfbe66814254ab0d8f67d16b0b774f4d5/pyleap/color.py#L40-L66 | def hsla_to_rgba(h, s, l, a):
""" 0 <= H < 360, 0 <= s,l,a < 1
"""
h = h % 360
s = max(0, min(1, s))
l = max(0, min(1, l))
a = max(0, min(1, a))
c = (1 - abs(2*l - 1)) * s
x = c * (1 - abs(h/60%2 - 1))
m = l - c/2
if h<60:
r, g, b = c, x, 0
elif h<120:
r, g,... | [
"def",
"hsla_to_rgba",
"(",
"h",
",",
"s",
",",
"l",
",",
"a",
")",
":",
"h",
"=",
"h",
"%",
"360",
"s",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"1",
",",
"s",
")",
")",
"l",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"1",
",",
"l",
")",
... | 0 <= H < 360, 0 <= s,l,a < 1 | [
"0",
"<",
"=",
"H",
"<",
"360",
"0",
"<",
"=",
"s",
"l",
"a",
"<",
"1"
] | python | train | 20.074074 |
Rapptz/discord.py | discord/guild.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L324-L331 | def text_channels(self):
"""List[:class:`TextChannel`]: A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
"""
r = [ch for ch in self._channels.values() if isinstance(ch, TextChannel)]
r.sort(key=lambda c: (... | [
"def",
"text_channels",
"(",
"self",
")",
":",
"r",
"=",
"[",
"ch",
"for",
"ch",
"in",
"self",
".",
"_channels",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"ch",
",",
"TextChannel",
")",
"]",
"r",
".",
"sort",
"(",
"key",
"=",
"lambda",
"c... | List[:class:`TextChannel`]: A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom. | [
"List",
"[",
":",
"class",
":",
"TextChannel",
"]",
":",
"A",
"list",
"of",
"text",
"channels",
"that",
"belongs",
"to",
"this",
"guild",
"."
] | python | train | 43.5 |
MacHu-GWU/rolex-project | rolex/generator.py | https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/generator.py#L281-L292 | def rnd_date_array(size, start=date(1970, 1, 1), end=None, **kwargs):
"""
Array or Matrix of random date generator.
:returns: 1d or 2d array of datetime.date
"""
if end is None:
end = date.today()
start = parser.parse_date(start)
end = parser.parse_date(end)
_assert_correct_star... | [
"def",
"rnd_date_array",
"(",
"size",
",",
"start",
"=",
"date",
"(",
"1970",
",",
"1",
",",
"1",
")",
",",
"end",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"date",
".",
"today",
"(",
")",
"st... | Array or Matrix of random date generator.
:returns: 1d or 2d array of datetime.date | [
"Array",
"or",
"Matrix",
"of",
"random",
"date",
"generator",
"."
] | python | train | 31.083333 |
learningequality/ricecooker | ricecooker/classes/files.py | https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/classes/files.py#L35-L48 | def extract_path_ext(path, default_ext=None):
"""
Extract file extension (without dot) from `path` or return `default_ext` if
path does not contain a valid extension.
"""
ext = None
_, dotext = os.path.splitext(path)
if dotext:
ext = dotext[1:]
if not ext and default_ext:
... | [
"def",
"extract_path_ext",
"(",
"path",
",",
"default_ext",
"=",
"None",
")",
":",
"ext",
"=",
"None",
"_",
",",
"dotext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
"if",
"dotext",
":",
"ext",
"=",
"dotext",
"[",
"1",
":",
"]",
"... | Extract file extension (without dot) from `path` or return `default_ext` if
path does not contain a valid extension. | [
"Extract",
"file",
"extension",
"(",
"without",
"dot",
")",
"from",
"path",
"or",
"return",
"default_ext",
"if",
"path",
"does",
"not",
"contain",
"a",
"valid",
"extension",
"."
] | python | train | 31.785714 |
MuxZeroNet/leaflet | leaflet/samtools.py | https://github.com/MuxZeroNet/leaflet/blob/e4e59005aea4e30da233dca24479b1d8a36e32c6/leaflet/samtools.py#L236-L250 | def lookup(sock, domain, cache = None):
"""lookup an I2P domain name, returning a Destination instance"""
domain = normalize_domain(domain)
# cache miss, perform lookup
reply = sam_cmd(sock, "NAMING LOOKUP NAME=%s" % domain)
b64_dest = reply.get('VALUE')
if b64_dest:
dest = Dest(b64_de... | [
"def",
"lookup",
"(",
"sock",
",",
"domain",
",",
"cache",
"=",
"None",
")",
":",
"domain",
"=",
"normalize_domain",
"(",
"domain",
")",
"# cache miss, perform lookup",
"reply",
"=",
"sam_cmd",
"(",
"sock",
",",
"\"NAMING LOOKUP NAME=%s\"",
"%",
"domain",
")",... | lookup an I2P domain name, returning a Destination instance | [
"lookup",
"an",
"I2P",
"domain",
"name",
"returning",
"a",
"Destination",
"instance"
] | python | train | 33.933333 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py#L285-L297 | def confd_state_webui_listen_tcp_port(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
confd_state = ET.SubElement(config, "confd-state", xmlns="http://tail-f.com/yang/confd-monitoring")
webui = ET.SubElement(confd_state, "webui")
listen = ET.SubE... | [
"def",
"confd_state_webui_listen_tcp_port",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"confd_state",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"confd-state\"",
",",
"xmlns",
"=",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 42 |
tanghaibao/jcvi | jcvi/formats/blast.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/blast.py#L480-L509 | def annotation(args):
"""
%prog annotation blastfile > annotations
Create simple two column files from the first two coluns in blastfile. Use
--queryids and --subjectids to switch IDs or descriptions.
"""
from jcvi.formats.base import DictFile
p = OptionParser(annotation.__doc__)
p.add... | [
"def",
"annotation",
"(",
"args",
")",
":",
"from",
"jcvi",
".",
"formats",
".",
"base",
"import",
"DictFile",
"p",
"=",
"OptionParser",
"(",
"annotation",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--queryids\"",
",",
"help",
"=",
"\"Query IDS f... | %prog annotation blastfile > annotations
Create simple two column files from the first two coluns in blastfile. Use
--queryids and --subjectids to switch IDs or descriptions. | [
"%prog",
"annotation",
"blastfile",
">",
"annotations"
] | python | train | 32.633333 |
mdgoldberg/sportsref | sportsref/nba/players.py | https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L175-L177 | def stats_per100(self, kind='R', summary=False):
"""Returns a DataFrame of per-100-possession stats."""
return self._get_stats_table('per_poss', kind=kind, summary=summary) | [
"def",
"stats_per100",
"(",
"self",
",",
"kind",
"=",
"'R'",
",",
"summary",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get_stats_table",
"(",
"'per_poss'",
",",
"kind",
"=",
"kind",
",",
"summary",
"=",
"summary",
")"
] | Returns a DataFrame of per-100-possession stats. | [
"Returns",
"a",
"DataFrame",
"of",
"per",
"-",
"100",
"-",
"possession",
"stats",
"."
] | python | test | 62 |
aio-libs/aioredis | aioredis/commands/hash.py | https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/hash.py#L36-L38 | def hincrby(self, key, field, increment=1):
"""Increment the integer value of a hash field by the given number."""
return self.execute(b'HINCRBY', key, field, increment) | [
"def",
"hincrby",
"(",
"self",
",",
"key",
",",
"field",
",",
"increment",
"=",
"1",
")",
":",
"return",
"self",
".",
"execute",
"(",
"b'HINCRBY'",
",",
"key",
",",
"field",
",",
"increment",
")"
] | Increment the integer value of a hash field by the given number. | [
"Increment",
"the",
"integer",
"value",
"of",
"a",
"hash",
"field",
"by",
"the",
"given",
"number",
"."
] | python | train | 61 |
vallis/libstempo | libstempo/toasim.py | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L704-L842 | def createGWB(psr, Amp, gam, noCorr=False, seed=None, turnover=False,
clm=[N.sqrt(4.0*N.pi)], lmax=0, f0=1e-9, beta=1,
power=1, userSpec=None, npts=600, howml=10):
"""
Function to create GW-induced residuals from a stochastic GWB as defined
in Chamberlin, Creighton, Demorest, et ... | [
"def",
"createGWB",
"(",
"psr",
",",
"Amp",
",",
"gam",
",",
"noCorr",
"=",
"False",
",",
"seed",
"=",
"None",
",",
"turnover",
"=",
"False",
",",
"clm",
"=",
"[",
"N",
".",
"sqrt",
"(",
"4.0",
"*",
"N",
".",
"pi",
")",
"]",
",",
"lmax",
"=",... | Function to create GW-induced residuals from a stochastic GWB as defined
in Chamberlin, Creighton, Demorest, et al. (2014).
:param psr: pulsar object for single pulsar
:param Amp: Amplitude of red noise in GW units
:param gam: Red noise power law spectral index
:param noCorr: Add red noise wit... | [
"Function",
"to",
"create",
"GW",
"-",
"induced",
"residuals",
"from",
"a",
"stochastic",
"GWB",
"as",
"defined",
"in",
"Chamberlin",
"Creighton",
"Demorest",
"et",
"al",
".",
"(",
"2014",
")",
".",
":",
"param",
"psr",
":",
"pulsar",
"object",
"for",
"s... | python | train | 37.100719 |
GGiecold/DBSCAN_multiplex | DBSCAN_multiplex.py | https://github.com/GGiecold/DBSCAN_multiplex/blob/075b1eec86d0e75166a9378d7d9a8974fc0a5e2e/DBSCAN_multiplex.py#L92-L148 | def memory():
"""Determine the machine's memory specifications.
Returns
-------
mem_info : dictonary
Holds the current values for the total, free and used memory of the system.
"""
mem_info = {}
if platform.linux_distribution()[0]:
with open('/proc/meminfo') as file:
... | [
"def",
"memory",
"(",
")",
":",
"mem_info",
"=",
"{",
"}",
"if",
"platform",
".",
"linux_distribution",
"(",
")",
"[",
"0",
"]",
":",
"with",
"open",
"(",
"'/proc/meminfo'",
")",
"as",
"file",
":",
"c",
"=",
"0",
"for",
"line",
"in",
"file",
":",
... | Determine the machine's memory specifications.
Returns
-------
mem_info : dictonary
Holds the current values for the total, free and used memory of the system. | [
"Determine",
"the",
"machine",
"s",
"memory",
"specifications",
"."
] | python | train | 32.719298 |
Yelp/kafka-utils | kafka_utils/util/zookeeper.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/zookeeper.py#L426-L435 | def get_cluster_assignment(self):
"""Fetch the cluster layout in form of assignment from zookeeper"""
plan = self.get_cluster_plan()
assignment = {}
for elem in plan['partitions']:
assignment[
(elem['topic'], elem['partition'])
] = elem['replicas']... | [
"def",
"get_cluster_assignment",
"(",
"self",
")",
":",
"plan",
"=",
"self",
".",
"get_cluster_plan",
"(",
")",
"assignment",
"=",
"{",
"}",
"for",
"elem",
"in",
"plan",
"[",
"'partitions'",
"]",
":",
"assignment",
"[",
"(",
"elem",
"[",
"'topic'",
"]",
... | Fetch the cluster layout in form of assignment from zookeeper | [
"Fetch",
"the",
"cluster",
"layout",
"in",
"form",
"of",
"assignment",
"from",
"zookeeper"
] | python | train | 33.8 |
belbio/bel | bel/resources/ortholog.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/resources/ortholog.py#L67-L131 | def orthologs_iterator(fo, version):
"""Ortholog node and edge iterator"""
species_list = config["bel_resources"].get("species_list", [])
fo.seek(0)
with gzip.open(fo, "rt") as f:
for line in f:
edge = json.loads(line)
if "metadata" in edge:
source = edg... | [
"def",
"orthologs_iterator",
"(",
"fo",
",",
"version",
")",
":",
"species_list",
"=",
"config",
"[",
"\"bel_resources\"",
"]",
".",
"get",
"(",
"\"species_list\"",
",",
"[",
"]",
")",
"fo",
".",
"seek",
"(",
"0",
")",
"with",
"gzip",
".",
"open",
"(",... | Ortholog node and edge iterator | [
"Ortholog",
"node",
"and",
"edge",
"iterator"
] | python | train | 36.938462 |
tanghaibao/jcvi | jcvi/assembly/allpaths.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/allpaths.py#L258-L305 | def extract_pairs(fastqfile, p1fw, p2fw, fragsfw, p, suffix=False):
"""
Take fastqfile and array of pair ID, extract adjacent pairs to outfile.
Perform check on numbers when done. p1fw, p2fw is a list of file handles,
each for one end. p is a Pairs instance.
"""
fp = open(fastqfile)
currentI... | [
"def",
"extract_pairs",
"(",
"fastqfile",
",",
"p1fw",
",",
"p2fw",
",",
"fragsfw",
",",
"p",
",",
"suffix",
"=",
"False",
")",
":",
"fp",
"=",
"open",
"(",
"fastqfile",
")",
"currentID",
"=",
"0",
"npairs",
"=",
"nfrags",
"=",
"0",
"for",
"x",
","... | Take fastqfile and array of pair ID, extract adjacent pairs to outfile.
Perform check on numbers when done. p1fw, p2fw is a list of file handles,
each for one end. p is a Pairs instance. | [
"Take",
"fastqfile",
"and",
"array",
"of",
"pair",
"ID",
"extract",
"adjacent",
"pairs",
"to",
"outfile",
".",
"Perform",
"check",
"on",
"numbers",
"when",
"done",
".",
"p1fw",
"p2fw",
"is",
"a",
"list",
"of",
"file",
"handles",
"each",
"for",
"one",
"en... | python | train | 34.666667 |
apple/turicreate | deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/benchmark.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/benchmark.py#L215-L226 | def join_images(img_files, out_file):
"""Join the list of images into the out file"""
images = [PIL.Image.open(f) for f in img_files]
joined = PIL.Image.new(
'RGB',
(sum(i.size[0] for i in images), max(i.size[1] for i in images))
)
left = 0
for img in images:
joined.paste... | [
"def",
"join_images",
"(",
"img_files",
",",
"out_file",
")",
":",
"images",
"=",
"[",
"PIL",
".",
"Image",
".",
"open",
"(",
"f",
")",
"for",
"f",
"in",
"img_files",
"]",
"joined",
"=",
"PIL",
".",
"Image",
".",
"new",
"(",
"'RGB'",
",",
"(",
"s... | Join the list of images into the out file | [
"Join",
"the",
"list",
"of",
"images",
"into",
"the",
"out",
"file"
] | python | train | 32.666667 |
hydpy-dev/hydpy | hydpy/models/dam/dam_model.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/dam/dam_model.py#L2279-L2283 | def pass_allowedremoterelieve_v1(self):
"""Update the outlet link sequence |dam_outlets.R|."""
flu = self.sequences.fluxes.fastaccess
sen = self.sequences.senders.fastaccess
sen.r[0] += flu.allowedremoterelieve | [
"def",
"pass_allowedremoterelieve_v1",
"(",
"self",
")",
":",
"flu",
"=",
"self",
".",
"sequences",
".",
"fluxes",
".",
"fastaccess",
"sen",
"=",
"self",
".",
"sequences",
".",
"senders",
".",
"fastaccess",
"sen",
".",
"r",
"[",
"0",
"]",
"+=",
"flu",
... | Update the outlet link sequence |dam_outlets.R|. | [
"Update",
"the",
"outlet",
"link",
"sequence",
"|dam_outlets",
".",
"R|",
"."
] | python | train | 44.4 |
tcalmant/ipopo | pelix/ipopo/core.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/core.py#L219-L248 | def __add_handler_factory(self, svc_ref):
# type: (ServiceReference) -> None
"""
Stores a new handler factory
:param svc_ref: ServiceReference of the new handler factory
"""
with self.__handlers_lock:
# Get the handler ID
handler_id = svc_ref.get_... | [
"def",
"__add_handler_factory",
"(",
"self",
",",
"svc_ref",
")",
":",
"# type: (ServiceReference) -> None",
"with",
"self",
".",
"__handlers_lock",
":",
"# Get the handler ID",
"handler_id",
"=",
"svc_ref",
".",
"get_property",
"(",
"handlers_const",
".",
"PROP_HANDLER... | Stores a new handler factory
:param svc_ref: ServiceReference of the new handler factory | [
"Stores",
"a",
"new",
"handler",
"factory"
] | python | train | 39.366667 |
squaresLab/BugZoo | bugzoo/mgr/container.py | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L428-L442 | def compile_with_instrumentation(self,
container: Container,
verbose: bool = False
) -> CompilationOutcome:
"""
Attempts to compile the program inside a given container with
instrumenta... | [
"def",
"compile_with_instrumentation",
"(",
"self",
",",
"container",
":",
"Container",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"CompilationOutcome",
":",
"bug",
"=",
"self",
".",
"__installation",
".",
"bugs",
"[",
"container",
".",
"bug",
"]"... | Attempts to compile the program inside a given container with
instrumentation enabled.
See: `Container.compile` | [
"Attempts",
"to",
"compile",
"the",
"program",
"inside",
"a",
"given",
"container",
"with",
"instrumentation",
"enabled",
"."
] | python | train | 48.266667 |
etobella/python-xmlsig | src/xmlsig/signature_context.py | https://github.com/etobella/python-xmlsig/blob/120a50935a4d4c2c972cfa3f8519bbce7e30d67b/src/xmlsig/signature_context.py#L171-L205 | def transform(self, transform, node):
"""
Transforms a node following the transform especification
:param transform: Transform node
:type transform: lxml.etree.Element
:param node: Element to transform
:type node: str
:return: Transformed node in a String
... | [
"def",
"transform",
"(",
"self",
",",
"transform",
",",
"node",
")",
":",
"method",
"=",
"transform",
".",
"get",
"(",
"'Algorithm'",
")",
"if",
"method",
"not",
"in",
"constants",
".",
"TransformUsageDSigTransform",
":",
"raise",
"Exception",
"(",
"'Method ... | Transforms a node following the transform especification
:param transform: Transform node
:type transform: lxml.etree.Element
:param node: Element to transform
:type node: str
:return: Transformed node in a String | [
"Transforms",
"a",
"node",
"following",
"the",
"transform",
"especification",
":",
"param",
"transform",
":",
"Transform",
"node",
":",
"type",
"transform",
":",
"lxml",
".",
"etree",
".",
"Element",
":",
"param",
"node",
":",
"Element",
"to",
"transform",
"... | python | train | 40.457143 |
readbeyond/aeneas | aeneas/adjustboundaryalgorithm.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/adjustboundaryalgorithm.py#L236-L310 | def adjust(
self,
aba_parameters,
boundary_indices,
real_wave_mfcc,
text_file,
allow_arbitrary_shift=False
):
"""
Adjust the boundaries of the text map
using the algorithm and parameters
specified in the constructor,
storing the... | [
"def",
"adjust",
"(",
"self",
",",
"aba_parameters",
",",
"boundary_indices",
",",
"real_wave_mfcc",
",",
"text_file",
",",
"allow_arbitrary_shift",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"u\"Called adjust\"",
")",
"if",
"boundary_indices",
"is",
"None... | Adjust the boundaries of the text map
using the algorithm and parameters
specified in the constructor,
storing the sync map fragment list internally.
:param dict aba_parameters: a dictionary containing the algorithm and its parameters,
as produced by ... | [
"Adjust",
"the",
"boundaries",
"of",
"the",
"text",
"map",
"using",
"the",
"algorithm",
"and",
"parameters",
"specified",
"in",
"the",
"constructor",
"storing",
"the",
"sync",
"map",
"fragment",
"list",
"internally",
"."
] | python | train | 44.266667 |
ToFuProject/tofu | tofu/utils.py | https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L925-L931 | def copy(self, strip=None, deep='ref'):
""" Return another instance of the object, with the same attributes
If deep=True, all attributes themselves are also copies
"""
dd = self.to_dict(strip=strip, deep=deep)
return self.__class__(fromdict=dd) | [
"def",
"copy",
"(",
"self",
",",
"strip",
"=",
"None",
",",
"deep",
"=",
"'ref'",
")",
":",
"dd",
"=",
"self",
".",
"to_dict",
"(",
"strip",
"=",
"strip",
",",
"deep",
"=",
"deep",
")",
"return",
"self",
".",
"__class__",
"(",
"fromdict",
"=",
"d... | Return another instance of the object, with the same attributes
If deep=True, all attributes themselves are also copies | [
"Return",
"another",
"instance",
"of",
"the",
"object",
"with",
"the",
"same",
"attributes"
] | python | train | 39.857143 |
foremast/foremast | src/foremast/utils/generate_filename.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/generate_filename.py#L19-L32 | def generate_packer_filename(provider, region, builder):
"""Generate a filename to be used by packer.
Args:
provider (str): Name of Spinnaker provider.
region (str): Name of provider region to use.
builder (str): Name of builder process type.
Returns:
str: Generated filenam... | [
"def",
"generate_packer_filename",
"(",
"provider",
",",
"region",
",",
"builder",
")",
":",
"filename",
"=",
"'{0}_{1}_{2}.json'",
".",
"format",
"(",
"provider",
",",
"region",
",",
"builder",
")",
"return",
"filename"
] | Generate a filename to be used by packer.
Args:
provider (str): Name of Spinnaker provider.
region (str): Name of provider region to use.
builder (str): Name of builder process type.
Returns:
str: Generated filename based on parameters. | [
"Generate",
"a",
"filename",
"to",
"be",
"used",
"by",
"packer",
"."
] | python | train | 30.428571 |
brendonh/pyth | pyth/plugins/xhtml/reader.py | https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/reader.py#L40-L65 | def format(self, soup):
"""format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done.
"""
# Remove all the... | [
"def",
"format",
"(",
"self",
",",
"soup",
")",
":",
"# Remove all the newline characters before a closing tag.",
"for",
"node",
"in",
"soup",
".",
"findAll",
"(",
"text",
"=",
"True",
")",
":",
"if",
"node",
".",
"rstrip",
"(",
"\" \"",
")",
".",
"endswith"... | format a BeautifulSoup document
This will transform the block elements content from
multi-lines text into single line.
This allow us to avoid having to deal with further text
rendering once this step has been done. | [
"format",
"a",
"BeautifulSoup",
"document"
] | python | train | 42.423077 |
shoeffner/cvloop | cvloop/cvloop.py | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L320-L328 | def _init_draw(self):
"""Initializes the drawing of the frames by setting the images to
random colors.
This function is called by TimedAnimation.
"""
if self.original is not None:
self.original.set_data(np.random.random((10, 10, 3)))
self.processed.set_data(n... | [
"def",
"_init_draw",
"(",
"self",
")",
":",
"if",
"self",
".",
"original",
"is",
"not",
"None",
":",
"self",
".",
"original",
".",
"set_data",
"(",
"np",
".",
"random",
".",
"random",
"(",
"(",
"10",
",",
"10",
",",
"3",
")",
")",
")",
"self",
... | Initializes the drawing of the frames by setting the images to
random colors.
This function is called by TimedAnimation. | [
"Initializes",
"the",
"drawing",
"of",
"the",
"frames",
"by",
"setting",
"the",
"images",
"to",
"random",
"colors",
"."
] | python | train | 37.888889 |
fred49/linshare-api | linshareapi/user/threadentries.py | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L84-L88 | def upload(self, thread_uuid, file_path, description=None):
""" Upload a file to LinShare using its rest api.
The uploaded document uuid will be returned"""
url = "threads/%s/entries" % thread_uuid
return self.core.upload(file_path, url, description) | [
"def",
"upload",
"(",
"self",
",",
"thread_uuid",
",",
"file_path",
",",
"description",
"=",
"None",
")",
":",
"url",
"=",
"\"threads/%s/entries\"",
"%",
"thread_uuid",
"return",
"self",
".",
"core",
".",
"upload",
"(",
"file_path",
",",
"url",
",",
"descr... | Upload a file to LinShare using its rest api.
The uploaded document uuid will be returned | [
"Upload",
"a",
"file",
"to",
"LinShare",
"using",
"its",
"rest",
"api",
".",
"The",
"uploaded",
"document",
"uuid",
"will",
"be",
"returned"
] | python | train | 55.6 |
GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L832-L867 | def adapter_add_nio_binding(self, adapter_number, port_number, nio):
"""
Adds a adapter NIO binding.
:param adapter_number: adapter number
:param port_number: port number
:param nio: NIO instance to add to the adapter/port
"""
try:
adapter = self._ad... | [
"def",
"adapter_add_nio_binding",
"(",
"self",
",",
"adapter_number",
",",
"port_number",
",",
"nio",
")",
":",
"try",
":",
"adapter",
"=",
"self",
".",
"_adapters",
"[",
"adapter_number",
"]",
"except",
"IndexError",
":",
"raise",
"IOUError",
"(",
"'Adapter {... | Adds a adapter NIO binding.
:param adapter_number: adapter number
:param port_number: port number
:param nio: NIO instance to add to the adapter/port | [
"Adds",
"a",
"adapter",
"NIO",
"binding",
"."
] | python | train | 74.111111 |
SeleniumHQ/selenium | py/selenium/webdriver/common/utils.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L46-L81 | def find_connectable_ip(host, port=None):
"""Resolve a hostname to an IP, preferring IPv4 addresses.
We prefer IPv4 so that we don't change behavior from previous IPv4-only
implementations, and because some drivers (e.g., FirefoxDriver) do not
support IPv6 connections.
If the optional port number ... | [
"def",
"find_connectable_ip",
"(",
"host",
",",
"port",
"=",
"None",
")",
":",
"try",
":",
"addrinfos",
"=",
"socket",
".",
"getaddrinfo",
"(",
"host",
",",
"None",
")",
"except",
"socket",
".",
"gaierror",
":",
"return",
"None",
"ip",
"=",
"None",
"fo... | Resolve a hostname to an IP, preferring IPv4 addresses.
We prefer IPv4 so that we don't change behavior from previous IPv4-only
implementations, and because some drivers (e.g., FirefoxDriver) do not
support IPv6 connections.
If the optional port number is provided, only IPs that listen on the given
... | [
"Resolve",
"a",
"hostname",
"to",
"an",
"IP",
"preferring",
"IPv4",
"addresses",
"."
] | python | train | 31.277778 |
RudolfCardinal/pythonlib | cardinal_pythonlib/maths_py.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/maths_py.py#L65-L86 | def safe_logit(p: Union[float, int]) -> Optional[float]:
r"""
Returns the logit (log odds) of its input probability
.. math::
\alpha = logit(p) = log(x / (1 - x))
Args:
p: :math:`p`
Returns:
:math:`\alpha`, or ``None`` if ``x`` is not in the range [0, 1].
"""
if ... | [
"def",
"safe_logit",
"(",
"p",
":",
"Union",
"[",
"float",
",",
"int",
"]",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"p",
">",
"1",
"or",
"p",
"<",
"0",
":",
"return",
"None",
"# can't take log of negative number",
"if",
"p",
"==",
"1",
... | r"""
Returns the logit (log odds) of its input probability
.. math::
\alpha = logit(p) = log(x / (1 - x))
Args:
p: :math:`p`
Returns:
:math:`\alpha`, or ``None`` if ``x`` is not in the range [0, 1]. | [
"r",
"Returns",
"the",
"logit",
"(",
"log",
"odds",
")",
"of",
"its",
"input",
"probability"
] | python | train | 22.318182 |
Kentzo/Power | power/darwin.py | https://github.com/Kentzo/Power/blob/2c99b156546225e448f7030681af3df5cd345e4b/power/darwin.py#L190-L206 | def runPowerNotificationsThread(self):
"""Main method of the spawned NSThread. Registers run loop source and runs current NSRunLoop."""
pool = NSAutoreleasePool.alloc().init()
@objc.callbackFor(IOPSNotificationCreateRunLoopSource)
def on_power_source_notification(context):
w... | [
"def",
"runPowerNotificationsThread",
"(",
"self",
")",
":",
"pool",
"=",
"NSAutoreleasePool",
".",
"alloc",
"(",
")",
".",
"init",
"(",
")",
"@",
"objc",
".",
"callbackFor",
"(",
"IOPSNotificationCreateRunLoopSource",
")",
"def",
"on_power_source_notification",
"... | Main method of the spawned NSThread. Registers run loop source and runs current NSRunLoop. | [
"Main",
"method",
"of",
"the",
"spawned",
"NSThread",
".",
"Registers",
"run",
"loop",
"source",
"and",
"runs",
"current",
"NSRunLoop",
"."
] | python | train | 53.235294 |
vertexproject/synapse | synapse/lib/jupyter.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/jupyter.py#L129-L133 | async def addFeedData(self, name, items, seqn=None):
'''
Add feed data to the cortex.
'''
return await self.core.addFeedData(name, items, seqn) | [
"async",
"def",
"addFeedData",
"(",
"self",
",",
"name",
",",
"items",
",",
"seqn",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"core",
".",
"addFeedData",
"(",
"name",
",",
"items",
",",
"seqn",
")"
] | Add feed data to the cortex. | [
"Add",
"feed",
"data",
"to",
"the",
"cortex",
"."
] | python | train | 34.2 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/parallel/apps/launcher.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/apps/launcher.py#L1060-L1069 | def parse_job_id(self, output):
"""Take the output of the submit command and return the job id."""
m = self.job_id_regexp.search(output)
if m is not None:
job_id = m.group()
else:
raise LauncherError("Job id couldn't be determined: %s" % output)
self.job_i... | [
"def",
"parse_job_id",
"(",
"self",
",",
"output",
")",
":",
"m",
"=",
"self",
".",
"job_id_regexp",
".",
"search",
"(",
"output",
")",
"if",
"m",
"is",
"not",
"None",
":",
"job_id",
"=",
"m",
".",
"group",
"(",
")",
"else",
":",
"raise",
"Launcher... | Take the output of the submit command and return the job id. | [
"Take",
"the",
"output",
"of",
"the",
"submit",
"command",
"and",
"return",
"the",
"job",
"id",
"."
] | python | test | 40.6 |
PSPC-SPAC-buyandsell/von_anchor | von_anchor/wallet/record.py | https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/record.py#L135-L146 | def tags(self, val: str) -> None:
"""
Accessor for record tags (metadata).
:param val: record tags
"""
if not StorageRecord.ok_tags(val):
LOGGER.debug('StorageRecord.__init__ <!< Tags %s must map strings to strings', val)
raise BadRecord('Tags {} must ma... | [
"def",
"tags",
"(",
"self",
",",
"val",
":",
"str",
")",
"->",
"None",
":",
"if",
"not",
"StorageRecord",
".",
"ok_tags",
"(",
"val",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'StorageRecord.__init__ <!< Tags %s must map strings to strings'",
",",
"val",
")",
... | Accessor for record tags (metadata).
:param val: record tags | [
"Accessor",
"for",
"record",
"tags",
"(",
"metadata",
")",
"."
] | python | train | 31.25 |
rsmuc/health_monitoring_plugins | health_monitoring_plugins/check_snmp_eaton_ups/check_snmp_eaton_ups.py | https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_eaton_ups/check_snmp_eaton_ups.py#L78-L90 | def check_ups_input_frequency(the_session, the_helper, the_snmp_value):
"""
OID .1.3.6.1.2.1.33.1.3.3.1.2.1
MIB excerpt
The present input frequency.
"""
a_frequency = calc_frequency_from_snmpvalue(the_snmp_value)
the_helper.add_metric(
label=the_helper.options.type,
value=a_f... | [
"def",
"check_ups_input_frequency",
"(",
"the_session",
",",
"the_helper",
",",
"the_snmp_value",
")",
":",
"a_frequency",
"=",
"calc_frequency_from_snmpvalue",
"(",
"the_snmp_value",
")",
"the_helper",
".",
"add_metric",
"(",
"label",
"=",
"the_helper",
".",
"options... | OID .1.3.6.1.2.1.33.1.3.3.1.2.1
MIB excerpt
The present input frequency. | [
"OID",
".",
"1",
".",
"3",
".",
"6",
".",
"1",
".",
"2",
".",
"1",
".",
"33",
".",
"1",
".",
"3",
".",
"3",
".",
"1",
".",
"2",
".",
"1",
"MIB",
"excerpt",
"The",
"present",
"input",
"frequency",
"."
] | python | train | 31.615385 |
tcalmant/ipopo | pelix/rsa/endpointdescription.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/endpointdescription.py#L236-L266 | def encode_endpoint_props(ed):
"""
Encodes the properties of the given EndpointDescription
"""
props = encode_osgi_props(ed)
props[ECF_RSVC_ID] = "{0}".format(ed.get_remoteservice_id()[1])
props[ECF_ENDPOINT_ID] = "{0}".format(ed.get_container_id()[1])
props[ECF_ENDPOINT_CONTAINERID_NAMESPAC... | [
"def",
"encode_endpoint_props",
"(",
"ed",
")",
":",
"props",
"=",
"encode_osgi_props",
"(",
"ed",
")",
"props",
"[",
"ECF_RSVC_ID",
"]",
"=",
"\"{0}\"",
".",
"format",
"(",
"ed",
".",
"get_remoteservice_id",
"(",
")",
"[",
"1",
"]",
")",
"props",
"[",
... | Encodes the properties of the given EndpointDescription | [
"Encodes",
"the",
"properties",
"of",
"the",
"given",
"EndpointDescription"
] | python | train | 37.612903 |
pydsigner/taskit | taskit/backend.py | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L125-L161 | def _handler(self, conn):
"""
Connection handler thread. Takes care of communication with the client
and running the proper task or applying a signal.
"""
incoming = self.recv(conn)
self.log(DEBUG, incoming)
try:
# E.g. ['twister', [7, 'invert'], {'gu... | [
"def",
"_handler",
"(",
"self",
",",
"conn",
")",
":",
"incoming",
"=",
"self",
".",
"recv",
"(",
"conn",
")",
"self",
".",
"log",
"(",
"DEBUG",
",",
"incoming",
")",
"try",
":",
"# E.g. ['twister', [7, 'invert'], {'guess_type': True}]",
"task",
",",
"args",... | Connection handler thread. Takes care of communication with the client
and running the proper task or applying a signal. | [
"Connection",
"handler",
"thread",
".",
"Takes",
"care",
"of",
"communication",
"with",
"the",
"client",
"and",
"running",
"the",
"proper",
"task",
"or",
"applying",
"a",
"signal",
"."
] | python | train | 37.027027 |
google/grr | grr/client/grr_response_client/osx/process.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/process.py#L96-L183 | def Regions(self,
skip_executable_regions=False,
skip_shared_regions=False,
skip_readonly_regions=False):
"""Iterates over the readable regions for this process.
We use mach_vm_region_recurse here to get a fine grained view of
the process' memory space. The algorit... | [
"def",
"Regions",
"(",
"self",
",",
"skip_executable_regions",
"=",
"False",
",",
"skip_shared_regions",
"=",
"False",
",",
"skip_readonly_regions",
"=",
"False",
")",
":",
"address",
"=",
"ctypes",
".",
"c_ulong",
"(",
"0",
")",
"mapsize",
"=",
"ctypes",
".... | Iterates over the readable regions for this process.
We use mach_vm_region_recurse here to get a fine grained view of
the process' memory space. The algorithm is that for some regions,
the function returns is_submap=True which means that there are
actually subregions that we need to examine by increasi... | [
"Iterates",
"over",
"the",
"readable",
"regions",
"for",
"this",
"process",
"."
] | python | train | 35.045455 |
ocaballeror/LyricFetch | lyricfetch/song.py | https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L198-L209 | def get_current_clementine():
"""
Get the current song from clementine.
"""
# mpris_version 2
try:
return get_info_mpris2('clementine')
except DBusErrorResponse:
bus_name = 'org.mpris.clementine'
path = '/Player'
interface = 'org.freedesktop.MediaPlayer'
r... | [
"def",
"get_current_clementine",
"(",
")",
":",
"# mpris_version 2",
"try",
":",
"return",
"get_info_mpris2",
"(",
"'clementine'",
")",
"except",
"DBusErrorResponse",
":",
"bus_name",
"=",
"'org.mpris.clementine'",
"path",
"=",
"'/Player'",
"interface",
"=",
"'org.fre... | Get the current song from clementine. | [
"Get",
"the",
"current",
"song",
"from",
"clementine",
"."
] | python | train | 29.916667 |
ucfopen/canvasapi | canvasapi/canvas.py | https://github.com/ucfopen/canvasapi/blob/319064b5fc97ba54250af683eb98723ef3f76cf8/canvasapi/canvas.py#L952-L977 | def get_group_participants(self, appointment_group, **kwargs):
"""
List student group participants in this appointment group.
:calls: `GET /api/v1/appointment_groups/:id/groups \
<https://canvas.instructure.com/doc/api/appointment_groups.html#method.appointment_groups.groups>`_
... | [
"def",
"get_group_participants",
"(",
"self",
",",
"appointment_group",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"canvasapi",
".",
"appointment_group",
"import",
"AppointmentGroup",
"from",
"canvasapi",
".",
"group",
"import",
"Group",
"appointment_group_id",
"=",... | List student group participants in this appointment group.
:calls: `GET /api/v1/appointment_groups/:id/groups \
<https://canvas.instructure.com/doc/api/appointment_groups.html#method.appointment_groups.groups>`_
:param appointment_group: The object or ID of the appointment group.
:type... | [
"List",
"student",
"group",
"participants",
"in",
"this",
"appointment",
"group",
"."
] | python | train | 39.538462 |
RedHatInsights/insights-core | insights/core/__init__.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/__init__.py#L1462-L1470 | def parse_content(self, content):
"""
Called automatically to process the directory listing(s) contained in
the content.
"""
self.listings = ls_parser.parse(content, self.first_path)
# No longer need the first path found, if any.
delattr(self, 'first_path') | [
"def",
"parse_content",
"(",
"self",
",",
"content",
")",
":",
"self",
".",
"listings",
"=",
"ls_parser",
".",
"parse",
"(",
"content",
",",
"self",
".",
"first_path",
")",
"# No longer need the first path found, if any.",
"delattr",
"(",
"self",
",",
"'first_pa... | Called automatically to process the directory listing(s) contained in
the content. | [
"Called",
"automatically",
"to",
"process",
"the",
"directory",
"listing",
"(",
"s",
")",
"contained",
"in",
"the",
"content",
"."
] | python | train | 34 |
ungarj/mapchete | mapchete/formats/default/png_hillshade.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/png_hillshade.py#L99-L128 | def write(self, process_tile, data):
"""
Write data from process tiles into PNG file(s).
Parameters
----------
process_tile : ``BufferedTile``
must be member of process ``TilePyramid``
"""
data = self._prepare_array(data)
if data.mask.all():
... | [
"def",
"write",
"(",
"self",
",",
"process_tile",
",",
"data",
")",
":",
"data",
"=",
"self",
".",
"_prepare_array",
"(",
"data",
")",
"if",
"data",
".",
"mask",
".",
"all",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"data empty, nothing to write\"",
... | Write data from process tiles into PNG file(s).
Parameters
----------
process_tile : ``BufferedTile``
must be member of process ``TilePyramid`` | [
"Write",
"data",
"from",
"process",
"tiles",
"into",
"PNG",
"file",
"(",
"s",
")",
"."
] | python | valid | 36.966667 |
tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L414-L449 | def schema_org(builder):
# pylint: disable=line-too-long
"""Builds schema.org microdata for DatasetSearch from DatasetBuilder.
Markup spec: https://developers.google.com/search/docs/data-types/dataset#dataset
Testing tool: https://search.google.com/structured-data/testing-tool
For Google Dataset Search: http... | [
"def",
"schema_org",
"(",
"builder",
")",
":",
"# pylint: disable=line-too-long",
"# pylint: enable=line-too-long",
"properties",
"=",
"[",
"(",
"lambda",
"x",
":",
"x",
".",
"name",
",",
"SCHEMA_ORG_NAME",
")",
",",
"(",
"lambda",
"x",
":",
"x",
".",
"descrip... | Builds schema.org microdata for DatasetSearch from DatasetBuilder.
Markup spec: https://developers.google.com/search/docs/data-types/dataset#dataset
Testing tool: https://search.google.com/structured-data/testing-tool
For Google Dataset Search: https://toolbox.google.com/datasetsearch
Microdata format was cho... | [
"Builds",
"schema",
".",
"org",
"microdata",
"for",
"DatasetSearch",
"from",
"DatasetBuilder",
"."
] | python | train | 31.194444 |
LLNL/scraper | scraper/code_gov/models.py | https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/code_gov/models.py#L363-L447 | def from_stashy(klass, repository, labor_hours=True):
"""
Handles crafting Code.gov Project for Bitbucket Server repositories
"""
# if not isinstance(repository, stashy.repos.Repository):
# raise TypeError('Repository must be a stashy Repository object')
if not isinst... | [
"def",
"from_stashy",
"(",
"klass",
",",
"repository",
",",
"labor_hours",
"=",
"True",
")",
":",
"# if not isinstance(repository, stashy.repos.Repository):",
"# raise TypeError('Repository must be a stashy Repository object')",
"if",
"not",
"isinstance",
"(",
"repository",
... | Handles crafting Code.gov Project for Bitbucket Server repositories | [
"Handles",
"crafting",
"Code",
".",
"gov",
"Project",
"for",
"Bitbucket",
"Server",
"repositories"
] | python | test | 34.023529 |
aksas/pypo4sel | core/pypo4sel/core/common.py | https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/common.py#L154-L175 | def find_element(self, by=By.ID, value=None, el_class=None):
"""
usages with ``'one string'`` selector:
- find_element(by: str) -> PageElement
- find_element(by: str, value: T <= PageElement) -> T
usages with ``'webdriver'`` By selector
- find_element(by: str, value: ... | [
"def",
"find_element",
"(",
"self",
",",
"by",
"=",
"By",
".",
"ID",
",",
"value",
"=",
"None",
",",
"el_class",
"=",
"None",
")",
":",
"el",
"=",
"self",
".",
"child_element",
"(",
"by",
",",
"value",
",",
"el_class",
")",
"el",
".",
"reload",
"... | usages with ``'one string'`` selector:
- find_element(by: str) -> PageElement
- find_element(by: str, value: T <= PageElement) -> T
usages with ``'webdriver'`` By selector
- find_element(by: str, value: str) -> PageElement
- find_element(by: str, value: str, el_class: T <= P... | [
"usages",
"with",
"one",
"string",
"selector",
":",
"-",
"find_element",
"(",
"by",
":",
"str",
")",
"-",
">",
"PageElement",
"-",
"find_element",
"(",
"by",
":",
"str",
"value",
":",
"T",
"<",
"=",
"PageElement",
")",
"-",
">",
"T"
] | python | train | 32.863636 |
matrix-org/matrix-python-sdk | matrix_client/api.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L167-L181 | def login(self, login_type, **kwargs):
"""Perform /login.
Args:
login_type (str): The value for the 'type' key.
**kwargs: Additional key/values to add to the JSON submitted.
"""
content = {
"type": login_type
}
for key in kwargs:
... | [
"def",
"login",
"(",
"self",
",",
"login_type",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"{",
"\"type\"",
":",
"login_type",
"}",
"for",
"key",
"in",
"kwargs",
":",
"if",
"kwargs",
"[",
"key",
"]",
":",
"content",
"[",
"key",
"]",
"=",
... | Perform /login.
Args:
login_type (str): The value for the 'type' key.
**kwargs: Additional key/values to add to the JSON submitted. | [
"Perform",
"/",
"login",
"."
] | python | train | 28.333333 |
gmichaeljaison/cv-utils | cv_utils/template_matching.py | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/template_matching.py#L36-L56 | def multi_feat_match(template, image, options=None):
"""
Match template and image by extracting multiple features (specified) from it.
:param template: Template image
:param image: Search image
:param options: Options include
- features: List of options for each feature
:return:
""... | [
"def",
"multi_feat_match",
"(",
"template",
",",
"image",
",",
"options",
"=",
"None",
")",
":",
"h",
",",
"w",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"scale",
"=",
"1",
"if",
"options",
"is",
"not",
"None",
"and",
"'features'",
"in",
"opt... | Match template and image by extracting multiple features (specified) from it.
:param template: Template image
:param image: Search image
:param options: Options include
- features: List of options for each feature
:return: | [
"Match",
"template",
"and",
"image",
"by",
"extracting",
"multiple",
"features",
"(",
"specified",
")",
"from",
"it",
"."
] | python | train | 37.238095 |
noxdafox/clipspy | clips/classes.py | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L84-L89 | def instances_changed(self):
"""True if any instance has changed."""
value = bool(lib.EnvGetInstancesChanged(self._env))
lib.EnvSetInstancesChanged(self._env, int(False))
return value | [
"def",
"instances_changed",
"(",
"self",
")",
":",
"value",
"=",
"bool",
"(",
"lib",
".",
"EnvGetInstancesChanged",
"(",
"self",
".",
"_env",
")",
")",
"lib",
".",
"EnvSetInstancesChanged",
"(",
"self",
".",
"_env",
",",
"int",
"(",
"False",
")",
")",
... | True if any instance has changed. | [
"True",
"if",
"any",
"instance",
"has",
"changed",
"."
] | python | train | 35.166667 |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L261-L270 | def set_active_vectors(self, name, preference='cell'):
"""Finds the vectors by name and appropriately sets it as active"""
_, field = get_scalar(self, name, preference=preference, info=True)
if field == POINT_DATA_FIELD:
self.GetPointData().SetActiveVectors(name)
elif field =... | [
"def",
"set_active_vectors",
"(",
"self",
",",
"name",
",",
"preference",
"=",
"'cell'",
")",
":",
"_",
",",
"field",
"=",
"get_scalar",
"(",
"self",
",",
"name",
",",
"preference",
"=",
"preference",
",",
"info",
"=",
"True",
")",
"if",
"field",
"==",... | Finds the vectors by name and appropriately sets it as active | [
"Finds",
"the",
"vectors",
"by",
"name",
"and",
"appropriately",
"sets",
"it",
"as",
"active"
] | python | train | 52.3 |
mcash/merchant-api-python-sdk | mcash/mapi_client/mapi_client_example.py | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client_example.py#L53-L63 | def pusher_connected(self, data):
"""Called when the pusherclient is connected
"""
# Inform user that pusher is done connecting
self.logger.info("Pusherclient connected")
# Bind the events we want to listen to
self.callback_client.bind("payment_authorized",
... | [
"def",
"pusher_connected",
"(",
"self",
",",
"data",
")",
":",
"# Inform user that pusher is done connecting",
"self",
".",
"logger",
".",
"info",
"(",
"\"Pusherclient connected\"",
")",
"# Bind the events we want to listen to",
"self",
".",
"callback_client",
".",
"bind"... | Called when the pusherclient is connected | [
"Called",
"when",
"the",
"pusherclient",
"is",
"connected"
] | python | train | 42.545455 |
saltstack/salt | salt/utils/yamlloader.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L72-L105 | def construct_mapping(self, node, deep=False):
'''
Build the mapping for YAML
'''
if not isinstance(node, MappingNode):
raise ConstructorError(
None,
None,
'expected a mapping node, but found {0}'.format(node.id),
... | [
"def",
"construct_mapping",
"(",
"self",
",",
"node",
",",
"deep",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"MappingNode",
")",
":",
"raise",
"ConstructorError",
"(",
"None",
",",
"None",
",",
"'expected a mapping node, but found {0... | Build the mapping for YAML | [
"Build",
"the",
"mapping",
"for",
"YAML"
] | python | train | 34.970588 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.