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 |
|---|---|---|---|---|---|---|---|---|---|
ray-project/ray | python/ray/monitor.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L102-L135 | def xray_heartbeat_batch_handler(self, unused_channel, data):
"""Handle an xray heartbeat batch message from Redis."""
gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry(
data, 0)
heartbeat_data = gcs_entries.Entries(0)
message = (ray.gcs_utils.HeartbeatBatchT... | [
"def",
"xray_heartbeat_batch_handler",
"(",
"self",
",",
"unused_channel",
",",
"data",
")",
":",
"gcs_entries",
"=",
"ray",
".",
"gcs_utils",
".",
"GcsTableEntry",
".",
"GetRootAsGcsTableEntry",
"(",
"data",
",",
"0",
")",
"heartbeat_data",
"=",
"gcs_entries",
... | Handle an xray heartbeat batch message from Redis. | [
"Handle",
"an",
"xray",
"heartbeat",
"batch",
"message",
"from",
"Redis",
"."
] | python | train | 44.088235 |
mitsei/dlkit | dlkit/aws_adapter/osid/queries.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/aws_adapter/osid/queries.py#L119-L132 | def _match_maximum_decimal(self, match_key, decimal_value, match):
"""Matches a minimum decimal value"""
if decimal_value is None:
raise NullArgument()
if match is None:
match = True
if match:
ltegt = '$lte'
else:
ltegt = '$gt'
... | [
"def",
"_match_maximum_decimal",
"(",
"self",
",",
"match_key",
",",
"decimal_value",
",",
"match",
")",
":",
"if",
"decimal_value",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"if",
"match",
"is",
"None",
":",
"match",
"=",
"True",
"if",
"match"... | Matches a minimum decimal value | [
"Matches",
"a",
"minimum",
"decimal",
"value"
] | python | train | 34.928571 |
lesscpy/lesscpy | lesscpy/lessc/scope.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/scope.py#L91-L107 | def variables(self, name):
"""Search for variable by name. Searches scope top down
Args:
name (string): Search term
Returns:
Variable object OR False
"""
if isinstance(name, tuple):
name = name[0]
if name.startswith('@{'):
n... | [
"def",
"variables",
"(",
"self",
",",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"tuple",
")",
":",
"name",
"=",
"name",
"[",
"0",
"]",
"if",
"name",
".",
"startswith",
"(",
"'@{'",
")",
":",
"name",
"=",
"'@'",
"+",
"name",
"[",
"... | Search for variable by name. Searches scope top down
Args:
name (string): Search term
Returns:
Variable object OR False | [
"Search",
"for",
"variable",
"by",
"name",
".",
"Searches",
"scope",
"top",
"down",
"Args",
":",
"name",
"(",
"string",
")",
":",
"Search",
"term",
"Returns",
":",
"Variable",
"object",
"OR",
"False"
] | python | valid | 30.176471 |
pjuren/pyokit | src/pyokit/statistics/beta.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L84-L103 | def reg_incomplete_beta(a, b, x):
"""
Incomplete beta function; code translated from: Numerical Recipes in C.
:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1.
"""
if (x == 0):
return 0
elif (x == 1):
return 1
else:
lbeta = (math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) +
... | [
"def",
"reg_incomplete_beta",
"(",
"a",
",",
"b",
",",
"x",
")",
":",
"if",
"(",
"x",
"==",
"0",
")",
":",
"return",
"0",
"elif",
"(",
"x",
"==",
"1",
")",
":",
"return",
"1",
"else",
":",
"lbeta",
"=",
"(",
"math",
".",
"lgamma",
"(",
"a",
... | Incomplete beta function; code translated from: Numerical Recipes in C.
:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1. | [
"Incomplete",
"beta",
"function",
";",
"code",
"translated",
"from",
":",
"Numerical",
"Recipes",
"in",
"C",
"."
] | python | train | 26.15 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/mavproxy.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/mavproxy.py#L122-L127 | def add_input(cmd, immediate=False):
'''add some command input to be processed'''
if immediate:
process_stdin(cmd)
else:
mpstate.input_queue.put(cmd) | [
"def",
"add_input",
"(",
"cmd",
",",
"immediate",
"=",
"False",
")",
":",
"if",
"immediate",
":",
"process_stdin",
"(",
"cmd",
")",
"else",
":",
"mpstate",
".",
"input_queue",
".",
"put",
"(",
"cmd",
")"
] | add some command input to be processed | [
"add",
"some",
"command",
"input",
"to",
"be",
"processed"
] | python | train | 28.666667 |
mikedh/trimesh | trimesh/path/entities.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/entities.py#L427-L440 | def explode(self):
"""
If the current Line entity consists of multiple line
break it up into n Line entities.
Returns
----------
exploded: (n,) Line entities
"""
points = np.column_stack((
self.points,
self.points)).ravel()[1:-1].r... | [
"def",
"explode",
"(",
"self",
")",
":",
"points",
"=",
"np",
".",
"column_stack",
"(",
"(",
"self",
".",
"points",
",",
"self",
".",
"points",
")",
")",
".",
"ravel",
"(",
")",
"[",
"1",
":",
"-",
"1",
"]",
".",
"reshape",
"(",
"(",
"-",
"1"... | If the current Line entity consists of multiple line
break it up into n Line entities.
Returns
----------
exploded: (n,) Line entities | [
"If",
"the",
"current",
"Line",
"entity",
"consists",
"of",
"multiple",
"line",
"break",
"it",
"up",
"into",
"n",
"Line",
"entities",
"."
] | python | train | 27.928571 |
opencast/pyCA | pyca/ingest.py | https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ingest.py#L42-L105 | def ingest(event):
'''Ingest a finished recording to the Opencast server.
'''
# Update status
set_service_status(Service.INGEST, ServiceStatus.BUSY)
notify.notify('STATUS=Uploading')
recording_state(event.uid, 'uploading')
update_event_status(event, Status.UPLOADING)
# Select ingest ser... | [
"def",
"ingest",
"(",
"event",
")",
":",
"# Update status",
"set_service_status",
"(",
"Service",
".",
"INGEST",
",",
"ServiceStatus",
".",
"BUSY",
")",
"notify",
".",
"notify",
"(",
"'STATUS=Uploading'",
")",
"recording_state",
"(",
"event",
".",
"uid",
",",
... | Ingest a finished recording to the Opencast server. | [
"Ingest",
"a",
"finished",
"recording",
"to",
"the",
"Opencast",
"server",
"."
] | python | test | 41.6875 |
abseil/abseil-py | absl/logging/__init__.py | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L284-L304 | def set_stderrthreshold(s):
"""Sets the stderr threshold to the value passed in.
Args:
s: str|int, valid strings values are case-insensitive 'debug',
'info', 'warning', 'error', and 'fatal'; valid integer values are
logging.DEBUG|INFO|WARNING|ERROR|FATAL.
Raises:
ValueError: Raised whe... | [
"def",
"set_stderrthreshold",
"(",
"s",
")",
":",
"if",
"s",
"in",
"converter",
".",
"ABSL_LEVELS",
":",
"FLAGS",
".",
"stderrthreshold",
"=",
"converter",
".",
"ABSL_LEVELS",
"[",
"s",
"]",
"elif",
"isinstance",
"(",
"s",
",",
"str",
")",
"and",
"s",
... | Sets the stderr threshold to the value passed in.
Args:
s: str|int, valid strings values are case-insensitive 'debug',
'info', 'warning', 'error', and 'fatal'; valid integer values are
logging.DEBUG|INFO|WARNING|ERROR|FATAL.
Raises:
ValueError: Raised when s is an invalid value. | [
"Sets",
"the",
"stderr",
"threshold",
"to",
"the",
"value",
"passed",
"in",
"."
] | python | train | 37.285714 |
pymupdf/PyMuPDF | examples/colordbRGB.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/colordbRGB.py#L24-L27 | def sortkey(x):
"""Return '001002003' for (colorname, 1, 2, 3)"""
k = str(x[1]).zfill(3) + str(x[2]).zfill(3) + str(x[3]).zfill(3)
return k | [
"def",
"sortkey",
"(",
"x",
")",
":",
"k",
"=",
"str",
"(",
"x",
"[",
"1",
"]",
")",
".",
"zfill",
"(",
"3",
")",
"+",
"str",
"(",
"x",
"[",
"2",
"]",
")",
".",
"zfill",
"(",
"3",
")",
"+",
"str",
"(",
"x",
"[",
"3",
"]",
")",
".",
... | Return '001002003' for (colorname, 1, 2, 3) | [
"Return",
"001002003",
"for",
"(",
"colorname",
"1",
"2",
"3",
")"
] | python | train | 37 |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L5170-L5195 | def ServiceWorker_deliverPushMessage(self, origin, registrationId, data):
"""
Function path: ServiceWorker.deliverPushMessage
Domain: ServiceWorker
Method name: deliverPushMessage
Parameters:
Required arguments:
'origin' (type: string) -> No description
'registrationId' (type: string) -> N... | [
"def",
"ServiceWorker_deliverPushMessage",
"(",
"self",
",",
"origin",
",",
"registrationId",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"origin",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'origin' must be of type '['str']'. Received type: '%s'\"",
"%"... | Function path: ServiceWorker.deliverPushMessage
Domain: ServiceWorker
Method name: deliverPushMessage
Parameters:
Required arguments:
'origin' (type: string) -> No description
'registrationId' (type: string) -> No description
'data' (type: string) -> No description
No return value. | [
"Function",
"path",
":",
"ServiceWorker",
".",
"deliverPushMessage",
"Domain",
":",
"ServiceWorker",
"Method",
"name",
":",
"deliverPushMessage",
"Parameters",
":",
"Required",
"arguments",
":",
"origin",
"(",
"type",
":",
"string",
")",
"-",
">",
"No",
"descrip... | python | train | 37 |
libtcod/python-tcod | tcod/noise.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/noise.py#L162-L196 | def sample_mgrid(self, mgrid: np.array) -> np.array:
"""Sample a mesh-grid array and return the result.
The :any:`sample_ogrid` method performs better as there is a lot of
overhead when working with large mesh-grids.
Args:
mgrid (numpy.ndarray): A mesh-grid array of points ... | [
"def",
"sample_mgrid",
"(",
"self",
",",
"mgrid",
":",
"np",
".",
"array",
")",
"->",
"np",
".",
"array",
":",
"mgrid",
"=",
"np",
".",
"ascontiguousarray",
"(",
"mgrid",
",",
"np",
".",
"float32",
")",
"if",
"mgrid",
".",
"shape",
"[",
"0",
"]",
... | Sample a mesh-grid array and return the result.
The :any:`sample_ogrid` method performs better as there is a lot of
overhead when working with large mesh-grids.
Args:
mgrid (numpy.ndarray): A mesh-grid array of points to sample.
A contiguous array of type `numpy.flo... | [
"Sample",
"a",
"mesh",
"-",
"grid",
"array",
"and",
"return",
"the",
"result",
"."
] | python | train | 37.4 |
SheffieldML/GPyOpt | GPyOpt/acquisitions/MPI_mcmc.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/MPI_mcmc.py#L41-L59 | def _compute_acq_withGradients(self, x):
"""
Integrated Expected Improvement and its derivative
"""
means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x)
fmins = self.model.get_fmin()
f_acqu = None
df_acqu = None
for m, s, fmin, dmdx, dsdx in zip... | [
"def",
"_compute_acq_withGradients",
"(",
"self",
",",
"x",
")",
":",
"means",
",",
"stds",
",",
"dmdxs",
",",
"dsdxs",
"=",
"self",
".",
"model",
".",
"predict_withGradients",
"(",
"x",
")",
"fmins",
"=",
"self",
".",
"model",
".",
"get_fmin",
"(",
")... | Integrated Expected Improvement and its derivative | [
"Integrated",
"Expected",
"Improvement",
"and",
"its",
"derivative"
] | python | train | 36.157895 |
edx/opaque-keys | opaque_keys/edx/asides.py | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/asides.py#L76-L87 | def _decode_v2(value):
"""
Decode ':' and '$' characters encoded by `_encode`.
"""
if re.search(r'(?<!\$):', value):
raise ValueError("Unescaped ':' in the encoded string")
decode_colons = value.replace('$:', ':')
if re.search(r'(?<!\$)(\$\$)*\$([^$]|\Z)', decode_colons):
raise... | [
"def",
"_decode_v2",
"(",
"value",
")",
":",
"if",
"re",
".",
"search",
"(",
"r'(?<!\\$):'",
",",
"value",
")",
":",
"raise",
"ValueError",
"(",
"\"Unescaped ':' in the encoded string\"",
")",
"decode_colons",
"=",
"value",
".",
"replace",
"(",
"'$:'",
",",
... | Decode ':' and '$' characters encoded by `_encode`. | [
"Decode",
":",
"and",
"$",
"characters",
"encoded",
"by",
"_encode",
"."
] | python | train | 33.25 |
limodou/uliweb | uliweb/lib/werkzeug/script.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L195-L219 | def print_usage(actions):
"""Print the usage information. (Help screen)"""
actions = actions.items()
actions.sort()
print('usage: %s <action> [<options>]' % basename(sys.argv[0]))
print(' %s --help' % basename(sys.argv[0]))
print()
print('actions:')
for name, (func, doc, arguments... | [
"def",
"print_usage",
"(",
"actions",
")",
":",
"actions",
"=",
"actions",
".",
"items",
"(",
")",
"actions",
".",
"sort",
"(",
")",
"print",
"(",
"'usage: %s <action> [<options>]'",
"%",
"basename",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
"p... | Print the usage information. (Help screen) | [
"Print",
"the",
"usage",
"information",
".",
"(",
"Help",
"screen",
")"
] | python | train | 35.6 |
happyleavesaoc/python-snapcast | snapcast/client/gstreamer.py | https://github.com/happyleavesaoc/python-snapcast/blob/9b3c483358677327c7fd6d0666bf474c19d87f19/snapcast/client/gstreamer.py#L59-L61 | def push(self, buf):
""" Push a buffer into the source. """
self._src.emit('push-buffer', Gst.Buffer.new_wrapped(buf)) | [
"def",
"push",
"(",
"self",
",",
"buf",
")",
":",
"self",
".",
"_src",
".",
"emit",
"(",
"'push-buffer'",
",",
"Gst",
".",
"Buffer",
".",
"new_wrapped",
"(",
"buf",
")",
")"
] | Push a buffer into the source. | [
"Push",
"a",
"buffer",
"into",
"the",
"source",
"."
] | python | train | 44 |
Yelp/kafka-utils | kafka_utils/util/monitoring.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/monitoring.py#L124-L147 | def get_watermark_for_topic(
kafka_client,
topic,
):
"""This method:
* refreshes metadata for the kafka client
* fetches watermarks
:param kafka_client: KafkaToolClient instance
:param topic: the topic
:returns: dict <topic>: [ConsumerPartitionOffsets]
"""
# Refresh clie... | [
"def",
"get_watermark_for_topic",
"(",
"kafka_client",
",",
"topic",
",",
")",
":",
"# Refresh client metadata. We do not use the topic list, because we",
"# don't want to accidentally create the topic if it does not exist.",
"# If Kafka is unavailable, let's retry loading client metadata",
... | This method:
* refreshes metadata for the kafka client
* fetches watermarks
:param kafka_client: KafkaToolClient instance
:param topic: the topic
:returns: dict <topic>: [ConsumerPartitionOffsets] | [
"This",
"method",
":",
"*",
"refreshes",
"metadata",
"for",
"the",
"kafka",
"client",
"*",
"fetches",
"watermarks"
] | python | train | 30.291667 |
Thermondo/viewflow-extensions | viewflow_extensions/views.py | https://github.com/Thermondo/viewflow-extensions/blob/5d2bbfe28ced7dda3e6832b96ea031c1b871053e/viewflow_extensions/views.py#L47-L51 | def save_task(self):
"""Transition to save the task and return to ``ASSIGNED`` state."""
task = self.request.activation.task
task.status = STATUS.ASSIGNED
task.save() | [
"def",
"save_task",
"(",
"self",
")",
":",
"task",
"=",
"self",
".",
"request",
".",
"activation",
".",
"task",
"task",
".",
"status",
"=",
"STATUS",
".",
"ASSIGNED",
"task",
".",
"save",
"(",
")"
] | Transition to save the task and return to ``ASSIGNED`` state. | [
"Transition",
"to",
"save",
"the",
"task",
"and",
"return",
"to",
"ASSIGNED",
"state",
"."
] | python | train | 38.8 |
DataBiosphere/dsub | dsub/lib/dsub_util.py | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/dsub_util.py#L55-L76 | def replace_print(fileobj=sys.stderr):
"""Sys.out replacer, by default with stderr.
Use it like this:
with replace_print_with(fileobj):
print "hello" # writes to the file
print "done" # prints to stdout
Args:
fileobj: a file object to replace stdout.
Yields:
The printer.
"""
printer = _... | [
"def",
"replace_print",
"(",
"fileobj",
"=",
"sys",
".",
"stderr",
")",
":",
"printer",
"=",
"_Printer",
"(",
"fileobj",
")",
"previous_stdout",
"=",
"sys",
".",
"stdout",
"sys",
".",
"stdout",
"=",
"printer",
"try",
":",
"yield",
"printer",
"finally",
"... | Sys.out replacer, by default with stderr.
Use it like this:
with replace_print_with(fileobj):
print "hello" # writes to the file
print "done" # prints to stdout
Args:
fileobj: a file object to replace stdout.
Yields:
The printer. | [
"Sys",
".",
"out",
"replacer",
"by",
"default",
"with",
"stderr",
"."
] | python | valid | 19.954545 |
dereneaton/ipyrad | ipyrad/analysis/raxml.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/raxml.py#L151-L207 | def run(self,
ipyclient=None,
quiet=False,
force=False,
block=False,
):
"""
Submits raxml job to run. If no ipyclient object is provided then
the function will block until the raxml run is finished. If an ipyclient
is provided then the job is se... | [
"def",
"run",
"(",
"self",
",",
"ipyclient",
"=",
"None",
",",
"quiet",
"=",
"False",
",",
"force",
"=",
"False",
",",
"block",
"=",
"False",
",",
")",
":",
"## stop before trying in raxml",
"if",
"force",
":",
"for",
"key",
",",
"oldfile",
"in",
"self... | Submits raxml job to run. If no ipyclient object is provided then
the function will block until the raxml run is finished. If an ipyclient
is provided then the job is sent to a remote engine and an asynchronous
result object is returned which can be queried or awaited until it finishes.
... | [
"Submits",
"raxml",
"job",
"to",
"run",
".",
"If",
"no",
"ipyclient",
"object",
"is",
"provided",
"then",
"the",
"function",
"will",
"block",
"until",
"the",
"raxml",
"run",
"is",
"finished",
".",
"If",
"an",
"ipyclient",
"is",
"provided",
"then",
"the",
... | python | valid | 37.035088 |
phaethon/kamene | kamene/utils6.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L400-L428 | def in6_getLocalUniquePrefix():
"""
Returns a pseudo-randomly generated Local Unique prefix. Function
follows recommandation of Section 3.2.2 of RFC 4193 for prefix
generation.
"""
# Extracted from RFC 1305 (NTP) :
# NTP timestamps are represented as a 64-bit unsigned fixed-point number,
... | [
"def",
"in6_getLocalUniquePrefix",
"(",
")",
":",
"# Extracted from RFC 1305 (NTP) :",
"# NTP timestamps are represented as a 64-bit unsigned fixed-point number, ",
"# in seconds relative to 0h on 1 January 1900. The integer part is in the ",
"# first 32 bits and the fraction part in the last 32 bit... | Returns a pseudo-randomly generated Local Unique prefix. Function
follows recommandation of Section 3.2.2 of RFC 4193 for prefix
generation. | [
"Returns",
"a",
"pseudo",
"-",
"randomly",
"generated",
"Local",
"Unique",
"prefix",
".",
"Function",
"follows",
"recommandation",
"of",
"Section",
"3",
".",
"2",
".",
"2",
"of",
"RFC",
"4193",
"for",
"prefix",
"generation",
"."
] | python | train | 41.103448 |
twitterdev/search-tweets-python | searchtweets/result_stream.py | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L276-L308 | def collect_results(rule, max_results=500, result_stream_args=None):
"""
Utility function to quickly get a list of tweets from a ``ResultStream``
without keeping the object around. Requires your args to be configured
prior to using.
Args:
rule (str): valid powertrack rule for your account, ... | [
"def",
"collect_results",
"(",
"rule",
",",
"max_results",
"=",
"500",
",",
"result_stream_args",
"=",
"None",
")",
":",
"if",
"result_stream_args",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"This function requires a configuration dict for the \"",
"\"inner Re... | Utility function to quickly get a list of tweets from a ``ResultStream``
without keeping the object around. Requires your args to be configured
prior to using.
Args:
rule (str): valid powertrack rule for your account, preferably
generated by the `gen_rule_payload` function.
max_resu... | [
"Utility",
"function",
"to",
"quickly",
"get",
"a",
"list",
"of",
"tweets",
"from",
"a",
"ResultStream",
"without",
"keeping",
"the",
"object",
"around",
".",
"Requires",
"your",
"args",
"to",
"be",
"configured",
"prior",
"to",
"using",
"."
] | python | train | 37.424242 |
KxSystems/pyq | src/pyq/magic.py | https://github.com/KxSystems/pyq/blob/ad7b807abde94615a7344aaa930bb01fb1552cc5/src/pyq/magic.py#L23-L38 | def logical_lines(lines):
"""Merge lines into chunks according to q rules"""
if isinstance(lines, string_types):
lines = StringIO(lines)
buf = []
for line in lines:
if buf and not line.startswith(' '):
chunk = ''.join(buf).strip()
if chunk:
yield c... | [
"def",
"logical_lines",
"(",
"lines",
")",
":",
"if",
"isinstance",
"(",
"lines",
",",
"string_types",
")",
":",
"lines",
"=",
"StringIO",
"(",
"lines",
")",
"buf",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"if",
"buf",
"and",
"not",
"line",
... | Merge lines into chunks according to q rules | [
"Merge",
"lines",
"into",
"chunks",
"according",
"to",
"q",
"rules"
] | python | train | 26.625 |
saltstack/salt | salt/minion.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/minion.py#L2380-L2393 | def _mine_send(self, tag, data):
'''
Send mine data to the master
'''
channel = salt.transport.client.ReqChannel.factory(self.opts)
data['tok'] = self.tok
try:
ret = channel.send(data)
return ret
except SaltReqTimeoutError:
log.... | [
"def",
"_mine_send",
"(",
"self",
",",
"tag",
",",
"data",
")",
":",
"channel",
"=",
"salt",
".",
"transport",
".",
"client",
".",
"ReqChannel",
".",
"factory",
"(",
"self",
".",
"opts",
")",
"data",
"[",
"'tok'",
"]",
"=",
"self",
".",
"tok",
"try... | Send mine data to the master | [
"Send",
"mine",
"data",
"to",
"the",
"master"
] | python | train | 30.142857 |
wbond/asn1crypto | asn1crypto/core.py | https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/core.py#L953-L968 | def dump(self, force=False):
"""
Encodes the value using DER
:param force:
If the encoded contents already exist, clear them and regenerate
to ensure they are in DER format instead of BER format
:return:
A byte string of the DER-encoded value
... | [
"def",
"dump",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"_parsed",
"is",
"None",
":",
"self",
".",
"parse",
"(",
")",
"return",
"self",
".",
"_parsed",
"[",
"0",
"]",
".",
"dump",
"(",
"force",
"=",
"force",
")"
] | Encodes the value using DER
:param force:
If the encoded contents already exist, clear them and regenerate
to ensure they are in DER format instead of BER format
:return:
A byte string of the DER-encoded value | [
"Encodes",
"the",
"value",
"using",
"DER"
] | python | train | 26.125 |
python-openxml/python-docx | docx/styles/styles.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/styles/styles.py#L141-L153 | def _get_style_id_from_style(self, style, style_type):
"""
Return the id of *style*, or |None| if it is the default style of
*style_type*. Raises |ValueError| if style is not of *style_type*.
"""
if style.type != style_type:
raise ValueError(
"assigned... | [
"def",
"_get_style_id_from_style",
"(",
"self",
",",
"style",
",",
"style_type",
")",
":",
"if",
"style",
".",
"type",
"!=",
"style_type",
":",
"raise",
"ValueError",
"(",
"\"assigned style is type %s, need type %s\"",
"%",
"(",
"style",
".",
"type",
",",
"style... | Return the id of *style*, or |None| if it is the default style of
*style_type*. Raises |ValueError| if style is not of *style_type*. | [
"Return",
"the",
"id",
"of",
"*",
"style",
"*",
"or",
"|None|",
"if",
"it",
"is",
"the",
"default",
"style",
"of",
"*",
"style_type",
"*",
".",
"Raises",
"|ValueError|",
"if",
"style",
"is",
"not",
"of",
"*",
"style_type",
"*",
"."
] | python | train | 38.230769 |
twilio/twilio-python | twilio/rest/monitor/v1/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/monitor/v1/__init__.py#L29-L35 | def alerts(self):
"""
:rtype: twilio.rest.monitor.v1.alert.AlertList
"""
if self._alerts is None:
self._alerts = AlertList(self)
return self._alerts | [
"def",
"alerts",
"(",
"self",
")",
":",
"if",
"self",
".",
"_alerts",
"is",
"None",
":",
"self",
".",
"_alerts",
"=",
"AlertList",
"(",
"self",
")",
"return",
"self",
".",
"_alerts"
] | :rtype: twilio.rest.monitor.v1.alert.AlertList | [
":",
"rtype",
":",
"twilio",
".",
"rest",
".",
"monitor",
".",
"v1",
".",
"alert",
".",
"AlertList"
] | python | train | 27.714286 |
mar10/wsgidav | wsgidav/fs_dav_provider.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/fs_dav_provider.py#L278-L287 | def delete(self):
"""Remove this resource or collection (recursive).
See DAVResource.delete()
"""
if self.provider.readonly:
raise DAVError(HTTP_FORBIDDEN)
shutil.rmtree(self._file_path, ignore_errors=False)
self.remove_all_properties(True)
self.remov... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"provider",
".",
"readonly",
":",
"raise",
"DAVError",
"(",
"HTTP_FORBIDDEN",
")",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"_file_path",
",",
"ignore_errors",
"=",
"False",
")",
"self",
".",
... | Remove this resource or collection (recursive).
See DAVResource.delete() | [
"Remove",
"this",
"resource",
"or",
"collection",
"(",
"recursive",
")",
"."
] | python | valid | 32.8 |
boriel/zxbasic | arch/zx48k/optimizer.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L537-L546 | def eq(self, r1, r2):
""" True if values of r1 and r2 registers are equal
"""
if not is_register(r1) or not is_register(r2):
return False
if self.regs[r1] is None or self.regs[r2] is None: # HINT: This's been never USED??
return False
return self.regs[r... | [
"def",
"eq",
"(",
"self",
",",
"r1",
",",
"r2",
")",
":",
"if",
"not",
"is_register",
"(",
"r1",
")",
"or",
"not",
"is_register",
"(",
"r2",
")",
":",
"return",
"False",
"if",
"self",
".",
"regs",
"[",
"r1",
"]",
"is",
"None",
"or",
"self",
"."... | True if values of r1 and r2 registers are equal | [
"True",
"if",
"values",
"of",
"r1",
"and",
"r2",
"registers",
"are",
"equal"
] | python | train | 33 |
tcalmant/ipopo | pelix/internals/registry.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/internals/registry.py#L904-L963 | def _filter_with_hooks(self, svc_event, listeners):
"""
Filters listeners with EventListenerHooks
:param svc_event: ServiceEvent being triggered
:param listeners: Listeners to filter
:return: A list of listeners with hook references
"""
svc_ref = svc_event.get_se... | [
"def",
"_filter_with_hooks",
"(",
"self",
",",
"svc_event",
",",
"listeners",
")",
":",
"svc_ref",
"=",
"svc_event",
".",
"get_service_reference",
"(",
")",
"# Get EventListenerHooks service refs from registry",
"hook_refs",
"=",
"self",
".",
"_registry",
".",
"find_s... | Filters listeners with EventListenerHooks
:param svc_event: ServiceEvent being triggered
:param listeners: Listeners to filter
:return: A list of listeners with hook references | [
"Filters",
"listeners",
"with",
"EventListenerHooks"
] | python | train | 41.033333 |
raphaelvallat/pingouin | pingouin/external/tabulate.py | https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/external/tabulate.py#L772-L781 | def _prepend_row_index(rows, index):
"""Add a left-most index column."""
if index is None or index is False:
return rows
if len(index) != len(rows):
print('index=', index)
print('rows=', rows)
raise ValueError('index must be as long as the number of data rows')
rows = [[v... | [
"def",
"_prepend_row_index",
"(",
"rows",
",",
"index",
")",
":",
"if",
"index",
"is",
"None",
"or",
"index",
"is",
"False",
":",
"return",
"rows",
"if",
"len",
"(",
"index",
")",
"!=",
"len",
"(",
"rows",
")",
":",
"print",
"(",
"'index='",
",",
"... | Add a left-most index column. | [
"Add",
"a",
"left",
"-",
"most",
"index",
"column",
"."
] | python | train | 37.2 |
developersociety/django-glitter | glitter/publisher/models.py | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L89-L104 | def _unpublish(self):
"""
Process an unpublish action on the related object, returns a boolean if a change is made.
Only objects with a current active version will be updated.
"""
obj = self.content_object
actioned = False
# Only update if needed
if obj.... | [
"def",
"_unpublish",
"(",
"self",
")",
":",
"obj",
"=",
"self",
".",
"content_object",
"actioned",
"=",
"False",
"# Only update if needed",
"if",
"obj",
".",
"current_version",
"is",
"not",
"None",
":",
"obj",
".",
"current_version",
"=",
"None",
"obj",
".",... | Process an unpublish action on the related object, returns a boolean if a change is made.
Only objects with a current active version will be updated. | [
"Process",
"an",
"unpublish",
"action",
"on",
"the",
"related",
"object",
"returns",
"a",
"boolean",
"if",
"a",
"change",
"is",
"made",
"."
] | python | train | 30.0625 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L7218-L7225 | def validatePopElement(self, doc, elem, qname):
"""Pop the element end from the validation stack. """
if doc is None: doc__o = None
else: doc__o = doc._o
if elem is None: elem__o = None
else: elem__o = elem._o
ret = libxml2mod.xmlValidatePopElement(self._o, doc__o, elem__... | [
"def",
"validatePopElement",
"(",
"self",
",",
"doc",
",",
"elem",
",",
"qname",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc__o",
"=",
"None",
"else",
":",
"doc__o",
"=",
"doc",
".",
"_o",
"if",
"elem",
"is",
"None",
":",
"elem__o",
"=",
"None",... | Pop the element end from the validation stack. | [
"Pop",
"the",
"element",
"end",
"from",
"the",
"validation",
"stack",
"."
] | python | train | 42.625 |
tensorflow/cleverhans | examples/nips17_adversarial_competition/dev_toolkit/run_attacks_and_defenses.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/dev_toolkit/run_attacks_and_defenses.py#L321-L325 | def save_target_classes(self, filename):
"""Saves target classed for all dataset images into given file."""
with open(filename, 'w') as f:
for k, v in self._target_classes.items():
f.write('{0}.png,{1}\n'.format(k, v)) | [
"def",
"save_target_classes",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_target_classes",
".",
"items",
"(",
")",
":",
"f",
".",
"write",
"(",... | Saves target classed for all dataset images into given file. | [
"Saves",
"target",
"classed",
"for",
"all",
"dataset",
"images",
"into",
"given",
"file",
"."
] | python | train | 47.2 |
dmwm/DBS | Server/Python/src/dbs/web/DBSWriterModel.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSWriterModel.py#L254-L283 | def insertBulkBlock(self):
"""
API to insert a bulk block
:param blockDump: Output of the block dump command
:type blockDump: dict
"""
try:
body = request.body.read()
indata = cjson.decode(body)
if (indata.get("file_parent_list", []) ... | [
"def",
"insertBulkBlock",
"(",
"self",
")",
":",
"try",
":",
"body",
"=",
"request",
".",
"body",
".",
"read",
"(",
")",
"indata",
"=",
"cjson",
".",
"decode",
"(",
"body",
")",
"if",
"(",
"indata",
".",
"get",
"(",
"\"file_parent_list\"",
",",
"[",
... | API to insert a bulk block
:param blockDump: Output of the block dump command
:type blockDump: dict | [
"API",
"to",
"insert",
"a",
"bulk",
"block"
] | python | train | 55.733333 |
saltstack/salt | salt/modules/serverdensity_device.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L76-L110 | def create(name, **params):
'''
Function to create device in Server Density. For more info, see the `API
docs`__.
.. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating
CLI Example:
.. code-block:: bash
salt '*' serverdensity_device.create lama
salt '*' serverden... | [
"def",
"create",
"(",
"name",
",",
"*",
"*",
"params",
")",
":",
"log",
".",
"debug",
"(",
"'Server Density params: %s'",
",",
"params",
")",
"params",
"=",
"_clean_salt_variables",
"(",
"params",
")",
"params",
"[",
"'name'",
"]",
"=",
"name",
"api_respon... | Function to create device in Server Density. For more info, see the `API
docs`__.
.. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating
CLI Example:
.. code-block:: bash
salt '*' serverdensity_device.create lama
salt '*' serverdensity_device.create rich_lama group=lama_... | [
"Function",
"to",
"create",
"device",
"in",
"Server",
"Density",
".",
"For",
"more",
"info",
"see",
"the",
"API",
"docs",
"__",
"."
] | python | train | 33.771429 |
jobovy/galpy | galpy/potential/HenonHeilesPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/HenonHeilesPotential.py#L41-L56 | def _evaluate(self,R,phi=0.,t=0.):
"""
NAME:
_evaluate
PURPOSE:
evaluate the potential at R,phi,t
INPUT:
R - Galactocentric cylindrical radius
phi - azimuth
t - time
OUTPUT:
Phi(R,phi,t)
HISTORY:
... | [
"def",
"_evaluate",
"(",
"self",
",",
"R",
",",
"phi",
"=",
"0.",
",",
"t",
"=",
"0.",
")",
":",
"return",
"0.5",
"*",
"R",
"*",
"R",
"*",
"(",
"1.",
"+",
"2.",
"/",
"3.",
"*",
"R",
"*",
"numpy",
".",
"sin",
"(",
"3.",
"*",
"phi",
")",
... | NAME:
_evaluate
PURPOSE:
evaluate the potential at R,phi,t
INPUT:
R - Galactocentric cylindrical radius
phi - azimuth
t - time
OUTPUT:
Phi(R,phi,t)
HISTORY:
2017-10-16 - Written - Bovy (UofT) | [
"NAME",
":",
"_evaluate",
"PURPOSE",
":",
"evaluate",
"the",
"potential",
"at",
"R",
"phi",
"t",
"INPUT",
":",
"R",
"-",
"Galactocentric",
"cylindrical",
"radius",
"phi",
"-",
"azimuth",
"t",
"-",
"time",
"OUTPUT",
":",
"Phi",
"(",
"R",
"phi",
"t",
")"... | python | train | 25.375 |
deepmind/pysc2 | pysc2/lib/renderer_human.py | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1079-L1094 | def draw_commands(self, surf):
"""Draw the list of available commands."""
past_abilities = {act.ability for act in self._past_actions if act.ability}
for y, cmd in enumerate(sorted(self._abilities(
lambda c: c.name != "Smart"), key=lambda c: c.name), start=2):
if self._queued_action and cmd ==... | [
"def",
"draw_commands",
"(",
"self",
",",
"surf",
")",
":",
"past_abilities",
"=",
"{",
"act",
".",
"ability",
"for",
"act",
"in",
"self",
".",
"_past_actions",
"if",
"act",
".",
"ability",
"}",
"for",
"y",
",",
"cmd",
"in",
"enumerate",
"(",
"sorted",... | Draw the list of available commands. | [
"Draw",
"the",
"list",
"of",
"available",
"commands",
"."
] | python | train | 48.6875 |
Xion/taipan | taipan/functional/combinators.py | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/functional/combinators.py#L35-L41 | def flip(f):
"""Flip the order of positonal arguments of given function."""
ensure_callable(f)
result = lambda *args, **kwargs: f(*reversed(args), **kwargs)
functools.update_wrapper(result, f, ('__name__', '__module__'))
return result | [
"def",
"flip",
"(",
"f",
")",
":",
"ensure_callable",
"(",
"f",
")",
"result",
"=",
"lambda",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"f",
"(",
"*",
"reversed",
"(",
"args",
")",
",",
"*",
"*",
"kwargs",
")",
"functools",
".",
"update_wrapper",
... | Flip the order of positonal arguments of given function. | [
"Flip",
"the",
"order",
"of",
"positonal",
"arguments",
"of",
"given",
"function",
"."
] | python | train | 35.571429 |
saltstack/salt | salt/modules/k8s.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L777-L811 | def delete_secret(namespace, name, apiserver_url=None, force=True):
'''
.. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt '*' k8s.delete_secret namespace_name secret_n... | [
"def",
"delete_secret",
"(",
"namespace",
",",
"name",
",",
"apiserver_url",
"=",
"None",
",",
"force",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"... | .. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt '*' k8s.delete_secret namespace_name secret_name
salt '*' k8s.delete_secret namespace_name secret_name http://kube-m... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | python | train | 35.828571 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_fc_auth.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fc_auth.py#L12-L24 | def fcsp_sa_fcsp_auth_proto_auth_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcsp_sa = ET.SubElement(config, "fcsp-sa", xmlns="urn:brocade.com:mgmt:brocade-fc-auth")
fcsp = ET.SubElement(fcsp_sa, "fcsp")
auth = ET.SubElement(fcsp, "auth"... | [
"def",
"fcsp_sa_fcsp_auth_proto_auth_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcsp_sa",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"fcsp-sa\"",
",",
"xmlns",
"=",
"\"urn:b... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 42.153846 |
twisted/mantissa | xmantissa/webtheme.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webtheme.py#L78-L86 | def getInstalledThemes(self, store):
"""
Collect themes from all offerings installed on this store, or (if called
multiple times) return the previously collected list.
"""
if not store in self._getInstalledThemesCache:
self._getInstalledThemesCache[store] = (self.
... | [
"def",
"getInstalledThemes",
"(",
"self",
",",
"store",
")",
":",
"if",
"not",
"store",
"in",
"self",
".",
"_getInstalledThemesCache",
":",
"self",
".",
"_getInstalledThemesCache",
"[",
"store",
"]",
"=",
"(",
"self",
".",
"_realGetInstalledThemes",
"(",
"stor... | Collect themes from all offerings installed on this store, or (if called
multiple times) return the previously collected list. | [
"Collect",
"themes",
"from",
"all",
"offerings",
"installed",
"on",
"this",
"store",
"or",
"(",
"if",
"called",
"multiple",
"times",
")",
"return",
"the",
"previously",
"collected",
"list",
"."
] | python | train | 49 |
Robin8Put/pmes | ams/utils/tornado_components/mongo.py | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L62-L85 | async def insert(self, **kwargs):
"""
Accepts request object, retrieves data from the one`s body
and creates new account.
"""
if kwargs:
# Create autoincrement for account
pk = await self.autoincrement()
kwargs.update({"id": pk})
# Create account with received data and autoincrement
await ... | [
"async",
"def",
"insert",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"# Create autoincrement for account",
"pk",
"=",
"await",
"self",
".",
"autoincrement",
"(",
")",
"kwargs",
".",
"update",
"(",
"{",
"\"id\"",
":",
"pk",
"}",
... | Accepts request object, retrieves data from the one`s body
and creates new account. | [
"Accepts",
"request",
"object",
"retrieves",
"data",
"from",
"the",
"one",
"s",
"body",
"and",
"creates",
"new",
"account",
"."
] | python | train | 22 |
PiotrDabkowski/Js2Py | js2py/internals/operations.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/internals/operations.py#L283-L289 | def in_op(self, other):
'''checks if self is in other'''
if not is_object(other):
raise MakeError(
'TypeError',
"You can\'t use 'in' operator to search in non-objects")
return other.has_property(to_string(self)) | [
"def",
"in_op",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"is_object",
"(",
"other",
")",
":",
"raise",
"MakeError",
"(",
"'TypeError'",
",",
"\"You can\\'t use 'in' operator to search in non-objects\"",
")",
"return",
"other",
".",
"has_property",
"(",
... | checks if self is in other | [
"checks",
"if",
"self",
"is",
"in",
"other"
] | python | valid | 35.571429 |
hotdoc/hotdoc | hotdoc/extensions/c/clang/cindex.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L2026-L2037 | def element_count(self):
"""Retrieve the number of elements in this type.
Returns an int.
If the Type is not an array or vector, this raises.
"""
result = conf.lib.clang_getNumElements(self)
if result < 0:
raise Exception('Type does not have elements.')
... | [
"def",
"element_count",
"(",
"self",
")",
":",
"result",
"=",
"conf",
".",
"lib",
".",
"clang_getNumElements",
"(",
"self",
")",
"if",
"result",
"<",
"0",
":",
"raise",
"Exception",
"(",
"'Type does not have elements.'",
")",
"return",
"result"
] | Retrieve the number of elements in this type.
Returns an int.
If the Type is not an array or vector, this raises. | [
"Retrieve",
"the",
"number",
"of",
"elements",
"in",
"this",
"type",
"."
] | python | train | 27.25 |
MIT-LCP/wfdb-python | wfdb/io/_signal.py | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L516-L622 | def calc_adc_params(self):
"""
Compute appropriate adc_gain and baseline parameters for adc
conversion, given the physical signal and the fmts.
Returns
-------
adc_gains : list
List of calculated `adc_gain` values for each channel.
baselines : list
... | [
"def",
"calc_adc_params",
"(",
"self",
")",
":",
"adc_gains",
"=",
"[",
"]",
"baselines",
"=",
"[",
"]",
"if",
"np",
".",
"where",
"(",
"np",
".",
"isinf",
"(",
"self",
".",
"p_signal",
")",
")",
"[",
"0",
"]",
".",
"size",
":",
"raise",
"ValueEr... | Compute appropriate adc_gain and baseline parameters for adc
conversion, given the physical signal and the fmts.
Returns
-------
adc_gains : list
List of calculated `adc_gain` values for each channel.
baselines : list
List of calculated `baseline` values ... | [
"Compute",
"appropriate",
"adc_gain",
"and",
"baseline",
"parameters",
"for",
"adc",
"conversion",
"given",
"the",
"physical",
"signal",
"and",
"the",
"fmts",
"."
] | python | train | 38.345794 |
dossier/dossier.label | dossier/label/combined_store.py | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/combined_store.py#L40-L54 | def get_related_flat(self, content_id, min_strength=None):
'''Follow coreference relationships to get full related graph.
This differs from ``get_related_coref_relationships`` in that
it returns a flat list of all identifiers found through the
coreference layer of indirection.
... | [
"def",
"get_related_flat",
"(",
"self",
",",
"content_id",
",",
"min_strength",
"=",
"None",
")",
":",
"rel_id_to_idents",
"=",
"self",
".",
"get_related_coref_relationships",
"(",
"content_id",
",",
"min_strength",
"=",
"min_strength",
")",
"flat_list",
"=",
"[",... | Follow coreference relationships to get full related graph.
This differs from ``get_related_coref_relationships`` in that
it returns a flat list of all identifiers found through the
coreference layer of indirection.
:rtype: list of identifiers | [
"Follow",
"coreference",
"relationships",
"to",
"get",
"full",
"related",
"graph",
"."
] | python | train | 39.266667 |
digidotcom/python-devicecloud | devicecloud/monitor.py | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L213-L263 | def create_http_monitor(self, topics, transport_url, transport_token=None, transport_method='PUT', connect_timeout=0,
response_timeout=0, batch_size=1, batch_duration=0, compression='none', format_type='json'):
"""Creates a HTTP Monitor instance in Device Cloud for a given list of to... | [
"def",
"create_http_monitor",
"(",
"self",
",",
"topics",
",",
"transport_url",
",",
"transport_token",
"=",
"None",
",",
"transport_method",
"=",
"'PUT'",
",",
"connect_timeout",
"=",
"0",
",",
"response_timeout",
"=",
"0",
",",
"batch_size",
"=",
"1",
",",
... | Creates a HTTP Monitor instance in Device Cloud for a given list of topics
:param topics: a string list of topics (e.g. ['DeviceCore[U]',
'FileDataCore']).
:param transport_url: URL of the customer web server.
:param transport_token: Credentials for basic authentication in the... | [
"Creates",
"a",
"HTTP",
"Monitor",
"instance",
"in",
"Device",
"Cloud",
"for",
"a",
"given",
"list",
"of",
"topics"
] | python | train | 52.352941 |
bkg/django-spillway | spillway/query.py | https://github.com/bkg/django-spillway/blob/c488a62642430b005f1e0d4a19e160d8d5964b67/spillway/query.py#L122-L157 | def tile(self, bbox, z=0, format=None, clip=True):
"""Returns a GeoQuerySet intersecting a tile boundary.
Arguments:
bbox -- tile extent as geometry
Keyword args:
z -- tile zoom level used as basis for geometry simplification
format -- vector tile format as str (pbf, geo... | [
"def",
"tile",
"(",
"self",
",",
"bbox",
",",
"z",
"=",
"0",
",",
"format",
"=",
"None",
",",
"clip",
"=",
"True",
")",
":",
"# Tile grid uses 3857, but GeoJSON coordinates should be in 4326.",
"tile_srid",
"=",
"3857",
"bbox",
"=",
"getattr",
"(",
"bbox",
"... | Returns a GeoQuerySet intersecting a tile boundary.
Arguments:
bbox -- tile extent as geometry
Keyword args:
z -- tile zoom level used as basis for geometry simplification
format -- vector tile format as str (pbf, geojson)
clip -- clip geometries to tile boundary as bool... | [
"Returns",
"a",
"GeoQuerySet",
"intersecting",
"a",
"tile",
"boundary",
"."
] | python | train | 38.25 |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L333-L353 | def check_required_fields(self, ignore_fields=list(), allow_no_resources=False):
# type: (List[str], bool) -> None
"""Check that metadata for dataset and its resources is complete. The parameter ignore_fields
should be set if required to any fields that should be ignored for the particular opera... | [
"def",
"check_required_fields",
"(",
"self",
",",
"ignore_fields",
"=",
"list",
"(",
")",
",",
"allow_no_resources",
"=",
"False",
")",
":",
"# type: (List[str], bool) -> None",
"if",
"self",
".",
"is_requestable",
"(",
")",
":",
"self",
".",
"_check_required_fiel... | Check that metadata for dataset and its resources is complete. The parameter ignore_fields
should be set if required to any fields that should be ignored for the particular operation.
Args:
ignore_fields (List[str]): Fields to ignore. Default is [].
allow_no_resources (bool): Wh... | [
"Check",
"that",
"metadata",
"for",
"dataset",
"and",
"its",
"resources",
"is",
"complete",
".",
"The",
"parameter",
"ignore_fields",
"should",
"be",
"set",
"if",
"required",
"to",
"any",
"fields",
"that",
"should",
"be",
"ignored",
"for",
"the",
"particular",... | python | train | 49.857143 |
django-salesforce/django-salesforce | salesforce/dbapi/driver.py | https://github.com/django-salesforce/django-salesforce/blob/6fd5643dba69d49c5881de50875cf90204a8f808/salesforce/dbapi/driver.py#L159-L172 | def make_session(self):
"""Authenticate and get the name of assigned SFDC data server"""
with connect_lock:
if self._sf_session is None:
sf_session = requests.Session()
# TODO configurable class Salesforce***Auth
sf_session.auth = SalesforcePas... | [
"def",
"make_session",
"(",
"self",
")",
":",
"with",
"connect_lock",
":",
"if",
"self",
".",
"_sf_session",
"is",
"None",
":",
"sf_session",
"=",
"requests",
".",
"Session",
"(",
")",
"# TODO configurable class Salesforce***Auth",
"sf_session",
".",
"auth",
"="... | Authenticate and get the name of assigned SFDC data server | [
"Authenticate",
"and",
"get",
"the",
"name",
"of",
"assigned",
"SFDC",
"data",
"server"
] | python | train | 64.428571 |
PedalPi/PluginsManager | pluginsmanager/observer/host_observer/host_observer.py | https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/observer/host_observer/host_observer.py#L120-L127 | def _load_params_of(self, effect):
"""
Called only when a effect has created
Param changes calls :meth:`~pluginsmanager.observer.host_observer.host_observer.HostObserver.on_param_value_changed()`
"""
for param in effect.params:
if param.value != param.default:
... | [
"def",
"_load_params_of",
"(",
"self",
",",
"effect",
")",
":",
"for",
"param",
"in",
"effect",
".",
"params",
":",
"if",
"param",
".",
"value",
"!=",
"param",
".",
"default",
":",
"self",
".",
"_set_param_value",
"(",
"param",
")"
] | Called only when a effect has created
Param changes calls :meth:`~pluginsmanager.observer.host_observer.host_observer.HostObserver.on_param_value_changed()` | [
"Called",
"only",
"when",
"a",
"effect",
"has",
"created",
"Param",
"changes",
"calls",
":",
"meth",
":",
"~pluginsmanager",
".",
"observer",
".",
"host_observer",
".",
"host_observer",
".",
"HostObserver",
".",
"on_param_value_changed",
"()"
] | python | train | 43.75 |
vstconsulting/vstutils | vstutils/utils.py | https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L671-L680 | def get_object(self, name, obj):
"""
:param name: -- string name of backend
:param name: str
:param obj: -- model object
:type obj: django.db.models.Model
:return: backend object
:rtype: object
"""
return self[name](obj, **self.opts(name)) | [
"def",
"get_object",
"(",
"self",
",",
"name",
",",
"obj",
")",
":",
"return",
"self",
"[",
"name",
"]",
"(",
"obj",
",",
"*",
"*",
"self",
".",
"opts",
"(",
"name",
")",
")"
] | :param name: -- string name of backend
:param name: str
:param obj: -- model object
:type obj: django.db.models.Model
:return: backend object
:rtype: object | [
":",
"param",
"name",
":",
"--",
"string",
"name",
"of",
"backend",
":",
"param",
"name",
":",
"str",
":",
"param",
"obj",
":",
"--",
"model",
"object",
":",
"type",
"obj",
":",
"django",
".",
"db",
".",
"models",
".",
"Model",
":",
"return",
":",
... | python | train | 30.2 |
micropython/micropython | examples/switch.py | https://github.com/micropython/micropython/blob/8031b7a25c21fb864fe9dd1fa40740030be66c11/examples/switch.py#L27-L42 | def run_loop(leds=all_leds):
"""
Start the loop.
:param `leds`: Which LEDs to light up upon switch press.
:type `leds`: sequence of LED objects
"""
print('Loop started.\nPress Ctrl+C to break out of the loop.')
while 1:
try:
if switch():
[led.on() for led... | [
"def",
"run_loop",
"(",
"leds",
"=",
"all_leds",
")",
":",
"print",
"(",
"'Loop started.\\nPress Ctrl+C to break out of the loop.'",
")",
"while",
"1",
":",
"try",
":",
"if",
"switch",
"(",
")",
":",
"[",
"led",
".",
"on",
"(",
")",
"for",
"led",
"in",
"... | Start the loop.
:param `leds`: Which LEDs to light up upon switch press.
:type `leds`: sequence of LED objects | [
"Start",
"the",
"loop",
"."
] | python | train | 28.9375 |
alpacahq/pylivetrader | pylivetrader/loader.py | https://github.com/alpacahq/pylivetrader/blob/fd328b6595428c0789d9f218df34623f83a02b8b/pylivetrader/loader.py#L72-L79 | def translate(script):
'''translate zipline script into pylivetrader script.
'''
tree = ast.parse(script)
ZiplineImportVisitor().visit(tree)
return astor.to_source(tree) | [
"def",
"translate",
"(",
"script",
")",
":",
"tree",
"=",
"ast",
".",
"parse",
"(",
"script",
")",
"ZiplineImportVisitor",
"(",
")",
".",
"visit",
"(",
"tree",
")",
"return",
"astor",
".",
"to_source",
"(",
"tree",
")"
] | translate zipline script into pylivetrader script. | [
"translate",
"zipline",
"script",
"into",
"pylivetrader",
"script",
"."
] | python | train | 23 |
martinpitt/python-dbusmock | dbusmock/templates/upower.py | https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/templates/upower.py#L197-L234 | def SetupDisplayDevice(self, type, state, percentage, energy, energy_full,
energy_rate, time_to_empty, time_to_full, is_present,
icon_name, warning_level):
'''Convenience method to configure DisplayDevice properties
This calls Set() for all properties that the Disp... | [
"def",
"SetupDisplayDevice",
"(",
"self",
",",
"type",
",",
"state",
",",
"percentage",
",",
"energy",
",",
"energy_full",
",",
"energy_rate",
",",
"time_to_empty",
",",
"time_to_full",
",",
"is_present",
",",
"icon_name",
",",
"warning_level",
")",
":",
"if",... | Convenience method to configure DisplayDevice properties
This calls Set() for all properties that the DisplayDevice is defined to
have, and is shorter if you have to completely set it up instead of
changing just one or two properties.
This is only available when mocking the 1.0 API. | [
"Convenience",
"method",
"to",
"configure",
"DisplayDevice",
"properties"
] | python | train | 43.868421 |
jleinonen/pytmatrix | pytmatrix/orientation.py | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/orientation.py#L78-L117 | def orient_averaged_adaptive(tm):
"""Compute the T-matrix using variable orientation scatterers.
This method uses a very slow adaptive routine and should mainly be used
for reference purposes. Uses the set particle orientation PDF, ignoring
the alpha and beta attributes.
Args:
tm: TMat... | [
"def",
"orient_averaged_adaptive",
"(",
"tm",
")",
":",
"S",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
",",
"2",
")",
",",
"dtype",
"=",
"complex",
")",
"Z",
"=",
"np",
".",
"zeros",
"(",
"(",
"4",
",",
"4",
")",
")",
"def",
"Sfunc",
"(",
"beta... | Compute the T-matrix using variable orientation scatterers.
This method uses a very slow adaptive routine and should mainly be used
for reference purposes. Uses the set particle orientation PDF, ignoring
the alpha and beta attributes.
Args:
tm: TMatrix (or descendant) instance
Returns... | [
"Compute",
"the",
"T",
"-",
"matrix",
"using",
"variable",
"orientation",
"scatterers",
".",
"This",
"method",
"uses",
"a",
"very",
"slow",
"adaptive",
"routine",
"and",
"should",
"mainly",
"be",
"used",
"for",
"reference",
"purposes",
".",
"Uses",
"the",
"s... | python | train | 32.675 |
googleapis/dialogflow-python-client-v2 | samples/knowledge_base_management.py | https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/knowledge_base_management.py#L52-L69 | def create_knowledge_base(project_id, display_name):
"""Creates a Knowledge base.
Args:
project_id: The GCP project linked with the agent.
display_name: The display name of the Knowledge base."""
import dialogflow_v2beta1 as dialogflow
client = dialogflow.KnowledgeBasesClient()
proj... | [
"def",
"create_knowledge_base",
"(",
"project_id",
",",
"display_name",
")",
":",
"import",
"dialogflow_v2beta1",
"as",
"dialogflow",
"client",
"=",
"dialogflow",
".",
"KnowledgeBasesClient",
"(",
")",
"project_path",
"=",
"client",
".",
"project_path",
"(",
"projec... | Creates a Knowledge base.
Args:
project_id: The GCP project linked with the agent.
display_name: The display name of the Knowledge base. | [
"Creates",
"a",
"Knowledge",
"base",
"."
] | python | train | 36.944444 |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L2333-L2346 | def disable_servicegroup_passive_host_checks(self, servicegroup):
"""Disable passive host checks for a servicegroup
Format of the line that triggers function call::
DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
:param servicegroup: servicegroup to disable
:type s... | [
"def",
"disable_servicegroup_passive_host_checks",
"(",
"self",
",",
"servicegroup",
")",
":",
"for",
"service_id",
"in",
"servicegroup",
".",
"get_services",
"(",
")",
":",
"if",
"service_id",
"in",
"self",
".",
"daemon",
".",
"services",
":",
"host_id",
"=",
... | Disable passive host checks for a servicegroup
Format of the line that triggers function call::
DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
:param servicegroup: servicegroup to disable
:type servicegroup: alignak.objects.servicegroup.Servicegroup
:return: None | [
"Disable",
"passive",
"host",
"checks",
"for",
"a",
"servicegroup",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train | 45.857143 |
honeynet/beeswarm | beeswarm/drones/honeypot/honeypot.py | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L181-L193 | def prepare_environment(work_dir):
"""
Performs a few maintenance tasks before the Honeypot is run. Copies the data directory,
and the config file to the cwd. The config file copied here is overwritten if
the __init__ method is called with a configuration URL.
:param... | [
"def",
"prepare_environment",
"(",
"work_dir",
")",
":",
"package_directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"beeswarm",
".",
"__file__",
")",
")",
"logger",
".",
"info",
"(",
"'Copying data files to work... | Performs a few maintenance tasks before the Honeypot is run. Copies the data directory,
and the config file to the cwd. The config file copied here is overwritten if
the __init__ method is called with a configuration URL.
:param work_dir: The directory to copy files to. | [
"Performs",
"a",
"few",
"maintenance",
"tasks",
"before",
"the",
"Honeypot",
"is",
"run",
".",
"Copies",
"the",
"data",
"directory",
"and",
"the",
"config",
"file",
"to",
"the",
"cwd",
".",
"The",
"config",
"file",
"copied",
"here",
"is",
"overwritten",
"i... | python | train | 51.615385 |
ffcalculator/fantasydata-python | fantasy_data/FantasyData.py | https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L89-L102 | def get_schedules_for_season(self, season, season_type="REG"):
"""
Game schedule for a specified season.
"""
try:
season = int(season)
if season_type not in ["REG", "PRE", "POST"]:
raise ValueError
except (ValueError, TypeError):
... | [
"def",
"get_schedules_for_season",
"(",
"self",
",",
"season",
",",
"season_type",
"=",
"\"REG\"",
")",
":",
"try",
":",
"season",
"=",
"int",
"(",
"season",
")",
"if",
"season_type",
"not",
"in",
"[",
"\"REG\"",
",",
"\"PRE\"",
",",
"\"POST\"",
"]",
":"... | Game schedule for a specified season. | [
"Game",
"schedule",
"for",
"a",
"specified",
"season",
"."
] | python | train | 38.357143 |
rwl/pylon | pylon/opf.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L216-L224 | def _pwl1_to_poly(self, generators):
""" Converts single-block piecewise-linear costs into linear
polynomial.
"""
for g in generators:
if (g.pcost_model == PW_LINEAR) and (len(g.p_cost) == 2):
g.pwl_to_poly()
return generators | [
"def",
"_pwl1_to_poly",
"(",
"self",
",",
"generators",
")",
":",
"for",
"g",
"in",
"generators",
":",
"if",
"(",
"g",
".",
"pcost_model",
"==",
"PW_LINEAR",
")",
"and",
"(",
"len",
"(",
"g",
".",
"p_cost",
")",
"==",
"2",
")",
":",
"g",
".",
"pw... | Converts single-block piecewise-linear costs into linear
polynomial. | [
"Converts",
"single",
"-",
"block",
"piecewise",
"-",
"linear",
"costs",
"into",
"linear",
"polynomial",
"."
] | python | train | 31.888889 |
androguard/androguard | androguard/core/bytecodes/apk.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/apk.py#L2084-L2104 | def ensure_final_value(packageName, arsc, value):
"""Ensure incoming value is always the value, not the resid
androguard will sometimes return the Android "resId" aka
Resource ID instead of the actual value. This checks whether
the value is actually a resId, then performs the Android
Resource look... | [
"def",
"ensure_final_value",
"(",
"packageName",
",",
"arsc",
",",
"value",
")",
":",
"if",
"value",
":",
"returnValue",
"=",
"value",
"if",
"value",
"[",
"0",
"]",
"==",
"'@'",
":",
"# TODO: @packagename:DEADBEEF is not supported here!",
"try",
":",
"# can be a... | Ensure incoming value is always the value, not the resid
androguard will sometimes return the Android "resId" aka
Resource ID instead of the actual value. This checks whether
the value is actually a resId, then performs the Android
Resource lookup as needed. | [
"Ensure",
"incoming",
"value",
"is",
"always",
"the",
"value",
"not",
"the",
"resid"
] | python | train | 38.047619 |
wummel/linkchecker | third_party/dnspython/dns/tokenizer.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/tokenizer.py#L267-L285 | def skip_whitespace(self):
"""Consume input until a non-whitespace character is encountered.
The non-whitespace character is then ungotten, and the number of
whitespace characters consumed is returned.
If the tokenizer is in multiline mode, then newlines are whitespace.
@rtype... | [
"def",
"skip_whitespace",
"(",
"self",
")",
":",
"skipped",
"=",
"0",
"while",
"True",
":",
"c",
"=",
"self",
".",
"_get_char",
"(",
")",
"if",
"c",
"!=",
"' '",
"and",
"c",
"!=",
"'\\t'",
":",
"if",
"(",
"c",
"!=",
"'\\n'",
")",
"or",
"not",
"... | Consume input until a non-whitespace character is encountered.
The non-whitespace character is then ungotten, and the number of
whitespace characters consumed is returned.
If the tokenizer is in multiline mode, then newlines are whitespace.
@rtype: int | [
"Consume",
"input",
"until",
"a",
"non",
"-",
"whitespace",
"character",
"is",
"encountered",
"."
] | python | train | 30.842105 |
cuducos/getgist | getgist/__init__.py | https://github.com/cuducos/getgist/blob/c70a0a9353eca43360b82c759d1e1514ec265d3b/getgist/__init__.py#L21-L30 | def output(self, message, color=None):
"""
A helper to used like print() or click's secho() tunneling all the
outputs to sys.stdout or sys.stderr
:param message: (str)
:param color: (str) check click.secho() documentation
:return: (None) prints to sys.stdout or sys.stderr... | [
"def",
"output",
"(",
"self",
",",
"message",
",",
"color",
"=",
"None",
")",
":",
"output_to",
"=",
"stderr",
"if",
"color",
"==",
"\"red\"",
"else",
"stdout",
"secho",
"(",
"self",
".",
"indent",
"(",
"message",
")",
",",
"fg",
"=",
"color",
",",
... | A helper to used like print() or click's secho() tunneling all the
outputs to sys.stdout or sys.stderr
:param message: (str)
:param color: (str) check click.secho() documentation
:return: (None) prints to sys.stdout or sys.stderr | [
"A",
"helper",
"to",
"used",
"like",
"print",
"()",
"or",
"click",
"s",
"secho",
"()",
"tunneling",
"all",
"the",
"outputs",
"to",
"sys",
".",
"stdout",
"or",
"sys",
".",
"stderr",
":",
"param",
"message",
":",
"(",
"str",
")",
":",
"param",
"color",... | python | train | 44.2 |
namuyan/nem-ed25519 | nem_ed25519/utils.py | https://github.com/namuyan/nem-ed25519/blob/4f506a5335eb860a4cf1d102f76fcad93f9a55fc/nem_ed25519/utils.py#L190-L202 | def scalarmult_B(e):
"""
Implements scalarmult(B, e) more efficiently.
"""
# scalarmult(B, l) is the identity
e %= L
P = IDENT
for i in range(253):
if e & 1:
P = edwards_add(P=P, Q=Bpow[i])
e //= 2
assert e == 0, e
return P | [
"def",
"scalarmult_B",
"(",
"e",
")",
":",
"# scalarmult(B, l) is the identity",
"e",
"%=",
"L",
"P",
"=",
"IDENT",
"for",
"i",
"in",
"range",
"(",
"253",
")",
":",
"if",
"e",
"&",
"1",
":",
"P",
"=",
"edwards_add",
"(",
"P",
"=",
"P",
",",
"Q",
... | Implements scalarmult(B, e) more efficiently. | [
"Implements",
"scalarmult",
"(",
"B",
"e",
")",
"more",
"efficiently",
"."
] | python | train | 21.153846 |
progrium/skypipe | skypipe/cloud.py | https://github.com/progrium/skypipe/blob/6162610a1876282ff1cc8eeca6c8669b8f605482/skypipe/cloud.py#L65-L84 | def setup_dotcloud_account(cli):
"""Gets user/pass for dotcloud, performs auth, and stores keys"""
client = RESTClient(endpoint=cli.client.endpoint)
client.authenticator = NullAuth()
urlmap = client.get('/auth/discovery').item
username = cli.prompt('dotCloud email')
password = cli.prompt('Passwo... | [
"def",
"setup_dotcloud_account",
"(",
"cli",
")",
":",
"client",
"=",
"RESTClient",
"(",
"endpoint",
"=",
"cli",
".",
"client",
".",
"endpoint",
")",
"client",
".",
"authenticator",
"=",
"NullAuth",
"(",
")",
"urlmap",
"=",
"client",
".",
"get",
"(",
"'/... | Gets user/pass for dotcloud, performs auth, and stores keys | [
"Gets",
"user",
"/",
"pass",
"for",
"dotcloud",
"performs",
"auth",
"and",
"stores",
"keys"
] | python | train | 41.35 |
SeabornGames/Table | seaborn_table/table.py | https://github.com/SeabornGames/Table/blob/0c474ef2fb00db0e7cf47e8af91e3556c2e7485a/seaborn_table/table.py#L368-L394 | def rst_to_obj(cls, file_path=None, text='', columns=None,
remove_empty_rows=True, key_on=None,
deliminator=' ', eval_cells=True):
"""
This will convert a rst file or text to a seaborn table
:param file_path: str of the path to the file
:param text: ... | [
"def",
"rst_to_obj",
"(",
"cls",
",",
"file_path",
"=",
"None",
",",
"text",
"=",
"''",
",",
"columns",
"=",
"None",
",",
"remove_empty_rows",
"=",
"True",
",",
"key_on",
"=",
"None",
",",
"deliminator",
"=",
"' '",
",",
"eval_cells",
"=",
"True",
")",... | This will convert a rst file or text to a seaborn table
:param file_path: str of the path to the file
:param text: str of the csv text
:param columns: list of str of columns to use
:param remove_empty_rows: bool if True will remove empty rows
:param key_on: list of str of columns... | [
"This",
"will",
"convert",
"a",
"rst",
"file",
"or",
"text",
"to",
"a",
"seaborn",
"table",
":",
"param",
"file_path",
":",
"str",
"of",
"the",
"path",
"to",
"the",
"file",
":",
"param",
"text",
":",
"str",
"of",
"the",
"csv",
"text",
":",
"param",
... | python | train | 45.888889 |
stanfordnlp/stanza | stanza/monitoring/progress.py | https://github.com/stanfordnlp/stanza/blob/920c55d8eaa1e7105971059c66eb448a74c100d6/stanza/monitoring/progress.py#L83-L88 | def end_task(self):
'''
Remove the current task from the stack.
'''
self.progress(self.task_stack[-1].size)
self.task_stack.pop() | [
"def",
"end_task",
"(",
"self",
")",
":",
"self",
".",
"progress",
"(",
"self",
".",
"task_stack",
"[",
"-",
"1",
"]",
".",
"size",
")",
"self",
".",
"task_stack",
".",
"pop",
"(",
")"
] | Remove the current task from the stack. | [
"Remove",
"the",
"current",
"task",
"from",
"the",
"stack",
"."
] | python | train | 27.333333 |
mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1677-L1698 | def prepare_adiabatic_limit(slh, k=None):
"""Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F... | [
"def",
"prepare_adiabatic_limit",
"(",
"slh",
",",
"k",
"=",
"None",
")",
":",
"if",
"k",
"is",
"None",
":",
"k",
"=",
"symbols",
"(",
"'k'",
",",
"positive",
"=",
"True",
")",
"Ld",
"=",
"slh",
".",
"L",
".",
"dag",
"(",
")",
"LdL",
"=",
"(",
... | Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F, G, N``
necessary to compute the limitin... | [
"Prepare",
"the",
"adiabatic",
"elimination",
"on",
"an",
"SLH",
"object"
] | python | train | 29.818182 |
bhmm/bhmm | bhmm/hmm/generic_sampled_hmm.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L185-L190 | def eigenvectors_right_samples(self):
r""" Samples of the right eigenvectors of the hidden transition matrix """
res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype)
for i in range(self.nsamples):
res[i, :, :] = self._sampled_hmms[i].eigenvectors_right
... | [
"def",
"eigenvectors_right_samples",
"(",
"self",
")",
":",
"res",
"=",
"np",
".",
"empty",
"(",
"(",
"self",
".",
"nsamples",
",",
"self",
".",
"nstates",
",",
"self",
".",
"nstates",
")",
",",
"dtype",
"=",
"config",
".",
"dtype",
")",
"for",
"i",
... | r""" Samples of the right eigenvectors of the hidden transition matrix | [
"r",
"Samples",
"of",
"the",
"right",
"eigenvectors",
"of",
"the",
"hidden",
"transition",
"matrix"
] | python | train | 54.833333 |
choderalab/pymbar | examples/heat-capacity/heat-capacity.py | https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/examples/heat-capacity/heat-capacity.py#L110-L131 | def read_simulation_temps(pathname,NumTemps):
"""Reads in the various temperatures from each TEMP#/simul.output file by knowing
beforehand the total number of temperatures (parameter at top)
"""
print("--Reading temperatures from %s/..." % pathname)
# Initialize return variable
temps_from_... | [
"def",
"read_simulation_temps",
"(",
"pathname",
",",
"NumTemps",
")",
":",
"print",
"(",
"\"--Reading temperatures from %s/...\"",
"%",
"pathname",
")",
"# Initialize return variable",
"temps_from_file",
"=",
"numpy",
".",
"zeros",
"(",
"NumTemps",
",",
"numpy",
".",... | Reads in the various temperatures from each TEMP#/simul.output file by knowing
beforehand the total number of temperatures (parameter at top) | [
"Reads",
"in",
"the",
"various",
"temperatures",
"from",
"each",
"TEMP#",
"/",
"simul",
".",
"output",
"file",
"by",
"knowing",
"beforehand",
"the",
"total",
"number",
"of",
"temperatures",
"(",
"parameter",
"at",
"top",
")"
] | python | train | 33.181818 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L317-L330 | def _example_from_allof(self, prop_spec):
"""Get the examples from an allOf section.
Args:
prop_spec: property specification you want an example of.
Returns:
An example dict
"""
example_dict = {}
for definition in prop_spec['allOf']:
... | [
"def",
"_example_from_allof",
"(",
"self",
",",
"prop_spec",
")",
":",
"example_dict",
"=",
"{",
"}",
"for",
"definition",
"in",
"prop_spec",
"[",
"'allOf'",
"]",
":",
"update",
"=",
"self",
".",
"get_example_from_prop_spec",
"(",
"definition",
",",
"True",
... | Get the examples from an allOf section.
Args:
prop_spec: property specification you want an example of.
Returns:
An example dict | [
"Get",
"the",
"examples",
"from",
"an",
"allOf",
"section",
"."
] | python | train | 30.928571 |
idmillington/layout | layout/rl_utils.py | https://github.com/idmillington/layout/blob/c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5/layout/rl_utils.py#L98-L127 | def draw_polygon(
self,
*pts,
close_path=True,
stroke=None,
stroke_width=1,
stroke_dash=None,
fill=None
) -> None:
"""Draws the given polygon."""
c = self.c
c.saveState()
if stroke is not Non... | [
"def",
"draw_polygon",
"(",
"self",
",",
"*",
"pts",
",",
"close_path",
"=",
"True",
",",
"stroke",
"=",
"None",
",",
"stroke_width",
"=",
"1",
",",
"stroke_dash",
"=",
"None",
",",
"fill",
"=",
"None",
")",
"->",
"None",
":",
"c",
"=",
"self",
"."... | Draws the given polygon. | [
"Draws",
"the",
"given",
"polygon",
"."
] | python | train | 25.3 |
blockstack/blockstack-core | blockstack/blockstackd.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2614-L2638 | def server_shutdown(server_state):
"""
Shut down server subsystems.
Remove PID file.
"""
set_running( False )
# stop API servers
rpc_stop(server_state)
api_stop(server_state)
# stop atlas node
server_atlas_shutdown(server_state)
# stopping GC
gc_stop()
# clear PID... | [
"def",
"server_shutdown",
"(",
"server_state",
")",
":",
"set_running",
"(",
"False",
")",
"# stop API servers",
"rpc_stop",
"(",
"server_state",
")",
"api_stop",
"(",
"server_state",
")",
"# stop atlas node",
"server_atlas_shutdown",
"(",
"server_state",
")",
"# stop... | Shut down server subsystems.
Remove PID file. | [
"Shut",
"down",
"server",
"subsystems",
".",
"Remove",
"PID",
"file",
"."
] | python | train | 18.12 |
hyperledger/indy-plenum | stp_zmq/authenticator.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/authenticator.py#L88-L93 | def start(self):
"""Start ZAP authentication"""
super().start()
self.__poller = zmq.asyncio.Poller()
self.__poller.register(self.zap_socket, zmq.POLLIN)
self.__task = asyncio.ensure_future(self.__handle_zap()) | [
"def",
"start",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"start",
"(",
")",
"self",
".",
"__poller",
"=",
"zmq",
".",
"asyncio",
".",
"Poller",
"(",
")",
"self",
".",
"__poller",
".",
"register",
"(",
"self",
".",
"zap_socket",
",",
"zmq",
... | Start ZAP authentication | [
"Start",
"ZAP",
"authentication"
] | python | train | 40.666667 |
manns/pyspread | pyspread/src/gui/_toolbars.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_toolbars.py#L148-L152 | def OnTool(self, event):
"""Toolbar event handler"""
msgtype = self.ids_msgs[event.GetId()]
post_command_event(self, msgtype) | [
"def",
"OnTool",
"(",
"self",
",",
"event",
")",
":",
"msgtype",
"=",
"self",
".",
"ids_msgs",
"[",
"event",
".",
"GetId",
"(",
")",
"]",
"post_command_event",
"(",
"self",
",",
"msgtype",
")"
] | Toolbar event handler | [
"Toolbar",
"event",
"handler"
] | python | train | 29.2 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L264-L269 | def _replace_scalar(self, scalar):
""" Replace scalar name with scalar value """
if not is_arg_scalar(scalar):
return scalar
name = scalar[1:]
return self.get_scalar_value(name) | [
"def",
"_replace_scalar",
"(",
"self",
",",
"scalar",
")",
":",
"if",
"not",
"is_arg_scalar",
"(",
"scalar",
")",
":",
"return",
"scalar",
"name",
"=",
"scalar",
"[",
"1",
":",
"]",
"return",
"self",
".",
"get_scalar_value",
"(",
"name",
")"
] | Replace scalar name with scalar value | [
"Replace",
"scalar",
"name",
"with",
"scalar",
"value"
] | python | train | 36 |
oauthlib/oauthlib | oauthlib/oauth2/rfc6749/clients/base.py | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth2/rfc6749/clients/base.py#L425-L446 | def prepare_refresh_body(self, body='', refresh_token=None, scope=None, **kwargs):
"""Prepare an access token request, using a refresh token.
If the authorization server issued a refresh token to the client, the
client makes a refresh request to the token endpoint by adding the
followin... | [
"def",
"prepare_refresh_body",
"(",
"self",
",",
"body",
"=",
"''",
",",
"refresh_token",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"refresh_token",
"=",
"refresh_token",
"or",
"self",
".",
"refresh_token",
"return",
"prepa... | Prepare an access token request, using a refresh token.
If the authorization server issued a refresh token to the client, the
client makes a refresh request to the token endpoint by adding the
following parameters using the "application/x-www-form-urlencoded"
format in the HTTP request ... | [
"Prepare",
"an",
"access",
"token",
"request",
"using",
"a",
"refresh",
"token",
"."
] | python | train | 52.818182 |
bwhite/hadoopy | hadoopy/_freeze.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L70-L86 | def _md5_file(fn, block_size=1048576):
"""Builds the MD5 of a file block by block
Args:
fn: File path
block_size: Size of the blocks to consider (default 1048576)
Returns:
File MD5
"""
h = hashlib.md5()
with open(fn) as fp:
d = 1
while d:
d =... | [
"def",
"_md5_file",
"(",
"fn",
",",
"block_size",
"=",
"1048576",
")",
":",
"h",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"fn",
")",
"as",
"fp",
":",
"d",
"=",
"1",
"while",
"d",
":",
"d",
"=",
"fp",
".",
"read",
"(",
"block... | Builds the MD5 of a file block by block
Args:
fn: File path
block_size: Size of the blocks to consider (default 1048576)
Returns:
File MD5 | [
"Builds",
"the",
"MD5",
"of",
"a",
"file",
"block",
"by",
"block"
] | python | train | 21.941176 |
UCBerkeleySETI/blimpy | blimpy/sigproc.py | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L143-L157 | def is_filterbank(filename):
""" Open file and confirm if it is a filterbank file or not. """
with open(filename, 'rb') as fh:
is_fil = True
# Check this is a blimpy file
try:
keyword, value, idx = read_next_header_keyword(fh)
try:
assert keyword ... | [
"def",
"is_filterbank",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"is_fil",
"=",
"True",
"# Check this is a blimpy file",
"try",
":",
"keyword",
",",
"value",
",",
"idx",
"=",
"read_next_header_keyword",
"... | Open file and confirm if it is a filterbank file or not. | [
"Open",
"file",
"and",
"confirm",
"if",
"it",
"is",
"a",
"filterbank",
"file",
"or",
"not",
"."
] | python | test | 30.933333 |
googledatalab/pydatalab | datalab/storage/_bucket.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_bucket.py#L134-L144 | def item(self, key):
"""Retrieves an Item object for the specified key in this bucket.
The item need not exist.
Args:
key: the key of the item within the bucket.
Returns:
An Item instance representing the specified key.
"""
return _item.Item(self._name, key, context=self._context) | [
"def",
"item",
"(",
"self",
",",
"key",
")",
":",
"return",
"_item",
".",
"Item",
"(",
"self",
".",
"_name",
",",
"key",
",",
"context",
"=",
"self",
".",
"_context",
")"
] | Retrieves an Item object for the specified key in this bucket.
The item need not exist.
Args:
key: the key of the item within the bucket.
Returns:
An Item instance representing the specified key. | [
"Retrieves",
"an",
"Item",
"object",
"for",
"the",
"specified",
"key",
"in",
"this",
"bucket",
"."
] | python | train | 28.090909 |
saltstack/salt | salt/modules/win_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L425-L444 | def get_all():
'''
Return all installed services
Returns:
list: Returns a list of all services on the system.
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
services = _get_services()
ret = set()
for service in services:
ret.add(service['S... | [
"def",
"get_all",
"(",
")",
":",
"services",
"=",
"_get_services",
"(",
")",
"ret",
"=",
"set",
"(",
")",
"for",
"service",
"in",
"services",
":",
"ret",
".",
"add",
"(",
"service",
"[",
"'ServiceName'",
"]",
")",
"return",
"sorted",
"(",
"ret",
")"
... | Return all installed services
Returns:
list: Returns a list of all services on the system.
CLI Example:
.. code-block:: bash
salt '*' service.get_all | [
"Return",
"all",
"installed",
"services"
] | python | train | 16.9 |
wakatime/wakatime | wakatime/packages/pygments/formatters/img.py | https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/formatters/img.py#L527-L555 | def format(self, tokensource, outfile):
"""
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.
This implementation calculates where it should draw each token on the
pixmap, then calculates the required pixmap size and draws ... | [
"def",
"format",
"(",
"self",
",",
"tokensource",
",",
"outfile",
")",
":",
"self",
".",
"_create_drawables",
"(",
"tokensource",
")",
"self",
".",
"_draw_line_numbers",
"(",
")",
"im",
"=",
"Image",
".",
"new",
"(",
"'RGB'",
",",
"self",
".",
"_get_imag... | Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.
This implementation calculates where it should draw each token on the
pixmap, then calculates the required pixmap size and draws the items. | [
"Format",
"tokensource",
"an",
"iterable",
"of",
"(",
"tokentype",
"tokenstring",
")",
"tuples",
"and",
"write",
"it",
"into",
"outfile",
"."
] | python | train | 41.206897 |
CalebBell/thermo | thermo/eos.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/eos.py#L1118-L1141 | def Trebble_Bishnoi(self, T, full=True, quick=True):
r'''Method to calculate `a_alpha` and its first and second
derivatives according to Trebble and Bishnoi (1987) [1]_. Returns `a_alpha`,
`da_alpha_dT`, and `d2a_alpha_dT2`. See `GCEOS.a_alpha_and_derivatives`
for more documentation. ... | [
"def",
"Trebble_Bishnoi",
"(",
"self",
",",
"T",
",",
"full",
"=",
"True",
",",
"quick",
"=",
"True",
")",
":",
"c1",
"=",
"self",
".",
"alpha_function_coeffs",
"T",
",",
"Tc",
",",
"a",
"=",
"self",
".",
"T",
",",
"self",
".",
"Tc",
",",
"self",... | r'''Method to calculate `a_alpha` and its first and second
derivatives according to Trebble and Bishnoi (1987) [1]_. Returns `a_alpha`,
`da_alpha_dT`, and `d2a_alpha_dT2`. See `GCEOS.a_alpha_and_derivatives`
for more documentation. One coefficient needed.
.. math::
... | [
"r",
"Method",
"to",
"calculate",
"a_alpha",
"and",
"its",
"first",
"and",
"second",
"derivatives",
"according",
"to",
"Trebble",
"and",
"Bishnoi",
"(",
"1987",
")",
"[",
"1",
"]",
"_",
".",
"Returns",
"a_alpha",
"da_alpha_dT",
"and",
"d2a_alpha_dT2",
".",
... | python | valid | 43.666667 |
penguinmenac3/starttf | starttf/estimators/tf_estimator.py | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/estimators/tf_estimator.py#L78-L201 | def easy_train_and_evaluate(hyper_params, Model=None, create_loss=None,
training_data=None, validation_data=None,
inline_plotting=False, session_config=None, log_suffix=None,
continue_training=False, continue_with_specific_checkpointpa... | [
"def",
"easy_train_and_evaluate",
"(",
"hyper_params",
",",
"Model",
"=",
"None",
",",
"create_loss",
"=",
"None",
",",
"training_data",
"=",
"None",
",",
"validation_data",
"=",
"None",
",",
"inline_plotting",
"=",
"False",
",",
"session_config",
"=",
"None",
... | Train and evaluate your model without any boilerplate code.
1) Write your data using the starttf.tfrecords.autorecords.write_data method.
2) Create your hyper parameter file containing all required fields and then load it using
starttf.utils.hyper_params.load_params method.
Minimal Sample Hyper... | [
"Train",
"and",
"evaluate",
"your",
"model",
"without",
"any",
"boilerplate",
"code",
"."
] | python | train | 50.991935 |
tipsi/aiozk | aiozk/protocol/part.py | https://github.com/tipsi/aiozk/blob/96d2f543de248c6d993b5bfe6621167dd1eb8223/aiozk/protocol/part.py#L59-L74 | def parse(cls, buff, offset):
"""
Given a buffer and offset, returns the parsed value and new offset.
Calls `parse()` on the given buffer for each sub-part in order and
creates a new instance with the results.
"""
values = {}
for name, part in cls.parts:
... | [
"def",
"parse",
"(",
"cls",
",",
"buff",
",",
"offset",
")",
":",
"values",
"=",
"{",
"}",
"for",
"name",
",",
"part",
"in",
"cls",
".",
"parts",
":",
"value",
",",
"new_offset",
"=",
"part",
".",
"parse",
"(",
"buff",
",",
"offset",
")",
"values... | Given a buffer and offset, returns the parsed value and new offset.
Calls `parse()` on the given buffer for each sub-part in order and
creates a new instance with the results. | [
"Given",
"a",
"buffer",
"and",
"offset",
"returns",
"the",
"parsed",
"value",
"and",
"new",
"offset",
"."
] | python | train | 28.625 |
tyiannak/pyAudioAnalysis | pyAudioAnalysis/audioSegmentation.py | https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioSegmentation.py#L990-L1021 | def speakerDiarizationEvaluateScript(folder_name, ldas):
'''
This function prints the cluster purity and speaker purity for
each WAV file stored in a provided directory (.SEGMENT files
are needed as ground-truth)
ARGUMENTS:
- folder_name: the full path of the folder ... | [
"def",
"speakerDiarizationEvaluateScript",
"(",
"folder_name",
",",
"ldas",
")",
":",
"types",
"=",
"(",
"'*.wav'",
",",
")",
"wavFilesList",
"=",
"[",
"]",
"for",
"files",
"in",
"types",
":",
"wavFilesList",
".",
"extend",
"(",
"glob",
".",
"glob",
"(",
... | This function prints the cluster purity and speaker purity for
each WAV file stored in a provided directory (.SEGMENT files
are needed as ground-truth)
ARGUMENTS:
- folder_name: the full path of the folder where the WAV and
SEGMENT (ground-truth) fi... | [
"This",
"function",
"prints",
"the",
"cluster",
"purity",
"and",
"speaker",
"purity",
"for",
"each",
"WAV",
"file",
"stored",
"in",
"a",
"provided",
"directory",
"(",
".",
"SEGMENT",
"files",
"are",
"needed",
"as",
"ground",
"-",
"truth",
")",
"ARGUMENTS",
... | python | train | 38.375 |
underworldcode/stripy | stripy-src/stripy/cartesian.py | https://github.com/underworldcode/stripy/blob/d4c3480c3e58c88489ded695eadbe7cd5bf94b48/stripy-src/stripy/cartesian.py#L129-L134 | def _is_collinear(self, x, y):
"""
Checks if first three points are collinear
"""
pts = np.column_stack([x[:3], y[:3], np.ones(3)])
return np.linalg.det(pts) == 0.0 | [
"def",
"_is_collinear",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"pts",
"=",
"np",
".",
"column_stack",
"(",
"[",
"x",
"[",
":",
"3",
"]",
",",
"y",
"[",
":",
"3",
"]",
",",
"np",
".",
"ones",
"(",
"3",
")",
"]",
")",
"return",
"np",
".... | Checks if first three points are collinear | [
"Checks",
"if",
"first",
"three",
"points",
"are",
"collinear"
] | python | train | 33.166667 |
developmentseed/landsat-util | landsat/image.py | https://github.com/developmentseed/landsat-util/blob/92dc81771ddaa64a8a9124a89a6516b52485374b/landsat/image.py#L161-L176 | def _unzip(self, src, dst, scene, force_unzip=False):
""" Unzip tar files """
self.output("Unzipping %s - It might take some time" % scene, normal=True, arrow=True)
try:
# check if file is already unzipped, skip
if isdir(dst) and not force_unzip:
self.out... | [
"def",
"_unzip",
"(",
"self",
",",
"src",
",",
"dst",
",",
"scene",
",",
"force_unzip",
"=",
"False",
")",
":",
"self",
".",
"output",
"(",
"\"Unzipping %s - It might take some time\"",
"%",
"scene",
",",
"normal",
"=",
"True",
",",
"arrow",
"=",
"True",
... | Unzip tar files | [
"Unzip",
"tar",
"files"
] | python | train | 42.0625 |
cloud-custodian/cloud-custodian | c7n/tags.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L758-L776 | def process_transform(self, tag_value, resource_set):
"""
Transform tag value
- Collect value from tag
- Transform Tag value
- Assign new value for key
"""
self.log.info("Transforming tag value on %s instances" % (
len(resource_set)))
key = se... | [
"def",
"process_transform",
"(",
"self",
",",
"tag_value",
",",
"resource_set",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Transforming tag value on %s instances\"",
"%",
"(",
"len",
"(",
"resource_set",
")",
")",
")",
"key",
"=",
"self",
".",
"data"... | Transform tag value
- Collect value from tag
- Transform Tag value
- Assign new value for key | [
"Transform",
"tag",
"value"
] | python | train | 29.789474 |
nerdvegas/rez | src/rez/resolved_context.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolved_context.py#L566-L571 | def read_from_buffer(cls, buf, identifier_str=None):
"""Load the context from a buffer."""
try:
return cls._read_from_buffer(buf, identifier_str)
except Exception as e:
cls._load_error(e, identifier_str) | [
"def",
"read_from_buffer",
"(",
"cls",
",",
"buf",
",",
"identifier_str",
"=",
"None",
")",
":",
"try",
":",
"return",
"cls",
".",
"_read_from_buffer",
"(",
"buf",
",",
"identifier_str",
")",
"except",
"Exception",
"as",
"e",
":",
"cls",
".",
"_load_error"... | Load the context from a buffer. | [
"Load",
"the",
"context",
"from",
"a",
"buffer",
"."
] | python | train | 41 |
vinci1it2000/schedula | schedula/utils/alg.py | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L75-L105 | def get_unused_node_id(graph, initial_guess='unknown', _format='{}<%d>'):
"""
Finds an unused node id in `graph`.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param initial_guess:
Initial node id guess.
:type initial_guess: str, optional
:... | [
"def",
"get_unused_node_id",
"(",
"graph",
",",
"initial_guess",
"=",
"'unknown'",
",",
"_format",
"=",
"'{}<%d>'",
")",
":",
"has_node",
"=",
"graph",
".",
"has_node",
"# Namespace shortcut for speed.",
"n",
"=",
"counter",
"(",
")",
"# Counter.",
"node_id_format... | Finds an unused node id in `graph`.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param initial_guess:
Initial node id guess.
:type initial_guess: str, optional
:param _format:
Format to generate the new node id if the given is already used... | [
"Finds",
"an",
"unused",
"node",
"id",
"in",
"graph",
"."
] | python | train | 26.258065 |
ArduPilot/MAVProxy | MAVProxy/modules/lib/wxhorizon_ui.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L422-L429 | def updateWPText(self):
'''Updates the current waypoint and distance to it.'''
self.wpText.set_position((self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0)))
self.wpText.set_size(self.fontSize)
if type(self.nextWPTime) is str:
self.wpText... | [
"def",
"updateWPText",
"(",
"self",
")",
":",
"self",
".",
"wpText",
".",
"set_position",
"(",
"(",
"self",
".",
"leftPos",
"+",
"(",
"1.5",
"*",
"self",
".",
"vertSize",
"/",
"10.0",
")",
",",
"0.97",
"-",
"(",
"1.5",
"*",
"self",
".",
"vertSize",... | Updates the current waypoint and distance to it. | [
"Updates",
"the",
"current",
"waypoint",
"and",
"distance",
"to",
"it",
"."
] | python | train | 65.625 |
akissa/sachannelupdate | sachannelupdate/base.py | https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/base.py#L187-L193 | def queue_files(dirpath, queue):
"""Add files in a directory to a queue"""
for root, _, files in os.walk(os.path.abspath(dirpath)):
if not files:
continue
for filename in files:
queue.put(os.path.join(root, filename)) | [
"def",
"queue_files",
"(",
"dirpath",
",",
"queue",
")",
":",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"dirpath",
")",
")",
":",
"if",
"not",
"files",
":",
"continue",
"for",
"fi... | Add files in a directory to a queue | [
"Add",
"files",
"in",
"a",
"directory",
"to",
"a",
"queue"
] | python | train | 37 |
openstack/networking-cisco | networking_cisco/ml2_drivers/ucsm/ucsm_network_driver.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/ucsm/ucsm_network_driver.py#L792-L844 | def _remove_vlan_from_all_sp_templates(self, handle, vlan_id, ucsm_ip):
"""Deletes VLAN config from all SP Templates that have it."""
sp_template_info_list = (
CONF.ml2_cisco_ucsm.ucsms[ucsm_ip].sp_template_list.values())
vlan_name = self.make_vlan_name(vlan_id)
virtio_port_... | [
"def",
"_remove_vlan_from_all_sp_templates",
"(",
"self",
",",
"handle",
",",
"vlan_id",
",",
"ucsm_ip",
")",
":",
"sp_template_info_list",
"=",
"(",
"CONF",
".",
"ml2_cisco_ucsm",
".",
"ucsms",
"[",
"ucsm_ip",
"]",
".",
"sp_template_list",
".",
"values",
"(",
... | Deletes VLAN config from all SP Templates that have it. | [
"Deletes",
"VLAN",
"config",
"from",
"all",
"SP",
"Templates",
"that",
"have",
"it",
"."
] | python | train | 45.396226 |
PinLin/KCOJ_api | KCOJ_api/api.py | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L294-L304 | def get_notices(self):
"""
[deprecated] 建議使用方法 `get_notice()` 及 `get_notice_content()`
"""
result = []
# 取得公布欄訊息列表
for date, title in self.get_notice().items():
content = self.get_notice_content(date)
result.append([date, title, content])
#... | [
"def",
"get_notices",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"# 取得公布欄訊息列表",
"for",
"date",
",",
"title",
"in",
"self",
".",
"get_notice",
"(",
")",
".",
"items",
"(",
")",
":",
"content",
"=",
"self",
".",
"get_notice_content",
"(",
"date",
... | [deprecated] 建議使用方法 `get_notice()` 及 `get_notice_content()` | [
"[",
"deprecated",
"]",
"建議使用方法",
"get_notice",
"()",
"及",
"get_notice_content",
"()"
] | python | train | 30.636364 |
taskcluster/taskcluster-client.py | taskcluster/auth.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/auth.py#L230-L243 | def listRoleIds(self, *args, **kwargs):
"""
List Role IDs
If no limit is given, the roleIds of all roles are returned. Since this
list may become long, callers can use the `limit` and `continuationToken`
query arguments to page through the responses.
This method gives o... | [
"def",
"listRoleIds",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_makeApiCall",
"(",
"self",
".",
"funcinfo",
"[",
"\"listRoleIds\"",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | List Role IDs
If no limit is given, the roleIds of all roles are returned. Since this
list may become long, callers can use the `limit` and `continuationToken`
query arguments to page through the responses.
This method gives output: ``v1/list-role-ids-response.json#``
This met... | [
"List",
"Role",
"IDs"
] | python | train | 34.071429 |
davedoesdev/dxf | dxf/__init__.py | https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L378-L435 | def push_blob(self,
filename=None,
progress=None,
data=None, digest=None,
check_exists=True):
# pylint: disable=too-many-arguments
"""
Upload a file to the registry and return its (SHA-256) hash.
The registry is con... | [
"def",
"push_blob",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"progress",
"=",
"None",
",",
"data",
"=",
"None",
",",
"digest",
"=",
"None",
",",
"check_exists",
"=",
"True",
")",
":",
"# pylint: disable=too-many-arguments",
"if",
"filename",
"is",
"... | Upload a file to the registry and return its (SHA-256) hash.
The registry is content-addressable so the file's content (aka blob)
can be retrieved later by passing the hash to :meth:`pull_blob`.
:param filename: File to upload.
:type filename: str
:param data: Data to upload i... | [
"Upload",
"a",
"file",
"to",
"the",
"registry",
"and",
"return",
"its",
"(",
"SHA",
"-",
"256",
")",
"hash",
"."
] | python | train | 44.534483 |
Alignak-monitoring/alignak | alignak/objects/contact.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contact.py#L322-L347 | def get_notification_commands(self, notifways, n_type, command_name=False):
"""Get notification commands for object type
:param notifways: list of alignak.objects.NotificationWay objects
:type notifways: NotificationWays
:param n_type: object type (host or service)
:type n_type:... | [
"def",
"get_notification_commands",
"(",
"self",
",",
"notifways",
",",
"n_type",
",",
"command_name",
"=",
"False",
")",
":",
"res",
"=",
"[",
"]",
"for",
"notifway_id",
"in",
"self",
".",
"notificationways",
":",
"notifway",
"=",
"notifways",
"[",
"notifwa... | Get notification commands for object type
:param notifways: list of alignak.objects.NotificationWay objects
:type notifways: NotificationWays
:param n_type: object type (host or service)
:type n_type: string
:param command_name: True to update the inner property with the name of... | [
"Get",
"notification",
"commands",
"for",
"object",
"type"
] | python | train | 41.5 |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L507-L525 | def check(self):
""" Check if there are records that are ready to start and return them if there are any
:return: tuple of WScheduleRecord or None (if there are no tasks to start)
"""
if self.__next_start is not None:
utc_now = utc_datetime()
if utc_now >= self.__next_start:
result = []
for task... | [
"def",
"check",
"(",
"self",
")",
":",
"if",
"self",
".",
"__next_start",
"is",
"not",
"None",
":",
"utc_now",
"=",
"utc_datetime",
"(",
")",
"if",
"utc_now",
">=",
"self",
".",
"__next_start",
":",
"result",
"=",
"[",
"]",
"for",
"task_source",
"in",
... | Check if there are records that are ready to start and return them if there are any
:return: tuple of WScheduleRecord or None (if there are no tasks to start) | [
"Check",
"if",
"there",
"are",
"records",
"that",
"are",
"ready",
"to",
"start",
"and",
"return",
"them",
"if",
"there",
"are",
"any"
] | python | train | 26.736842 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.