repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
merll/docker-map | dockermap/map/policy/cache.py | https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/policy/cache.py#L85-L94 | def refresh(self):
"""
Fetches all current network names from the client.
"""
if not self._client:
return
current_volumes = self._client.volumes()['Volumes']
self.clear()
if current_volumes:
self.update(vol['Name'] for vol in current_volume... | [
"def",
"refresh",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_client",
":",
"return",
"current_volumes",
"=",
"self",
".",
"_client",
".",
"volumes",
"(",
")",
"[",
"'Volumes'",
"]",
"self",
".",
"clear",
"(",
")",
"if",
"current_volumes",
":",
... | Fetches all current network names from the client. | [
"Fetches",
"all",
"current",
"network",
"names",
"from",
"the",
"client",
"."
] | python | train |
rwl/pylon | contrib/public/services/simplejson/__init__.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/simplejson/__init__.py#L83-L124 | def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, **kw):
"""
Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).
If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic type... | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"skipkeys",
"=",
"False",
",",
"ensure_ascii",
"=",
"True",
",",
"check_circular",
"=",
"True",
",",
"allow_nan",
"=",
"True",
",",
"cls",
"=",
"None",
",",
"indent",
"=",
"None",
",",
"*",
"*",
"kw",
")",... | Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).
If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
will be skipped instead of raising a ``TypeError``.
... | [
"Serialize",
"obj",
"as",
"a",
"JSON",
"formatted",
"stream",
"to",
"fp",
"(",
"a",
".",
"write",
"()",
"-",
"supporting",
"file",
"-",
"like",
"object",
")",
"."
] | python | train |
sykora/djournal | djournal/views.py | https://github.com/sykora/djournal/blob/c074e1f94e07e2630034a00c7dbd768e933f85e2/djournal/views.py#L10-L26 | def entry_index(request, limit=0, template='djournal/entry_index.html'):
'''Returns a reponse of a fixed number of entries; all of them, by default. '''
entries = Entry.public.all()
if limit > 0:
entries = entries[:limit]
context = {
'entries': entries,
}
return render_to_res... | [
"def",
"entry_index",
"(",
"request",
",",
"limit",
"=",
"0",
",",
"template",
"=",
"'djournal/entry_index.html'",
")",
":",
"entries",
"=",
"Entry",
".",
"public",
".",
"all",
"(",
")",
"if",
"limit",
">",
"0",
":",
"entries",
"=",
"entries",
"[",
":"... | Returns a reponse of a fixed number of entries; all of them, by default. | [
"Returns",
"a",
"reponse",
"of",
"a",
"fixed",
"number",
"of",
"entries",
";",
"all",
"of",
"them",
"by",
"default",
"."
] | python | train |
jlmadurga/listenclosely | listenclosely/services/console.py | https://github.com/jlmadurga/listenclosely/blob/d6df9110c3ed6fd337e0236cccbe4d931bf217b0/listenclosely/services/console.py#L16-L28 | def send_message(self, id_service, content):
"""Write all messages to the stream in a thread-safe way."""
if not content:
return
with self._lock:
try:
message = "Message: %s to %s" % (content, id_service)
self.write_message(message)
... | [
"def",
"send_message",
"(",
"self",
",",
"id_service",
",",
"content",
")",
":",
"if",
"not",
"content",
":",
"return",
"with",
"self",
".",
"_lock",
":",
"try",
":",
"message",
"=",
"\"Message: %s to %s\"",
"%",
"(",
"content",
",",
"id_service",
")",
"... | Write all messages to the stream in a thread-safe way. | [
"Write",
"all",
"messages",
"to",
"the",
"stream",
"in",
"a",
"thread",
"-",
"safe",
"way",
"."
] | python | train |
happyleavesaoc/python-firetv | firetv/__main__.py | https://github.com/happyleavesaoc/python-firetv/blob/3dd953376c0d5af502e775ae14ed0afe03224781/firetv/__main__.py#L78-L93 | def add(device_id, host, adbkey='', adb_server_ip='', adb_server_port=5037):
""" Add a device.
Creates FireTV instance associated with device identifier.
:param device_id: Device identifier.
:param host: Host in <address>:<port> format.
:param adbkey: The path to the "adbkey" file
:param adb_s... | [
"def",
"add",
"(",
"device_id",
",",
"host",
",",
"adbkey",
"=",
"''",
",",
"adb_server_ip",
"=",
"''",
",",
"adb_server_port",
"=",
"5037",
")",
":",
"valid",
"=",
"is_valid_device_id",
"(",
"device_id",
")",
"and",
"is_valid_host",
"(",
"host",
")",
"i... | Add a device.
Creates FireTV instance associated with device identifier.
:param device_id: Device identifier.
:param host: Host in <address>:<port> format.
:param adbkey: The path to the "adbkey" file
:param adb_server_ip: the IP address for the ADB server
:param adb_server_port: the port for ... | [
"Add",
"a",
"device",
"."
] | python | train |
dtmilano/AndroidViewClient | src/com/dtmilano/android/viewclient.py | https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/viewclient.py#L3781-L3789 | def findViewsContainingPoint(self, (x, y), _filter=None):
'''
Finds the list of Views that contain the point (x, y).
'''
if not _filter:
_filter = lambda v: True
return [v for v in self.views if (v.containsPoint((x,y)) and _filter(v))] | [
"def",
"findViewsContainingPoint",
"(",
"self",
",",
"(",
"x",
",",
"y",
")",
",",
"_filter",
"=",
"None",
")",
":",
"if",
"not",
"_filter",
":",
"_filter",
"=",
"lambda",
"v",
":",
"True",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"views"... | Finds the list of Views that contain the point (x, y). | [
"Finds",
"the",
"list",
"of",
"Views",
"that",
"contain",
"the",
"point",
"(",
"x",
"y",
")",
"."
] | python | train |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/master_controller/master_controller_healthcheck.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/master_controller/master_controller_healthcheck.py#L66-L85 | def get_overall_services_health(self) -> str:
"""Get the overall health of all the services.
Returns:
str, overall health status
"""
services_health_status = self.get_services_health()
# Evaluate overall health
health_status = all(status == "Healthy" for st... | [
"def",
"get_overall_services_health",
"(",
"self",
")",
"->",
"str",
":",
"services_health_status",
"=",
"self",
".",
"get_services_health",
"(",
")",
"# Evaluate overall health",
"health_status",
"=",
"all",
"(",
"status",
"==",
"\"Healthy\"",
"for",
"status",
"in"... | Get the overall health of all the services.
Returns:
str, overall health status | [
"Get",
"the",
"overall",
"health",
"of",
"all",
"the",
"services",
"."
] | python | train |
dslackw/slpkg | slpkg/tracking.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/tracking.py#L170-L181 | def check_used(self, pkg):
"""Check if dependencies used
"""
used = []
dep_path = self.meta.log_path + "dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
for dep in deps.splitlines():
... | [
"def",
"check_used",
"(",
"self",
",",
"pkg",
")",
":",
"used",
"=",
"[",
"]",
"dep_path",
"=",
"self",
".",
"meta",
".",
"log_path",
"+",
"\"dep/\"",
"logs",
"=",
"find_package",
"(",
"\"\"",
",",
"dep_path",
")",
"for",
"log",
"in",
"logs",
":",
... | Check if dependencies used | [
"Check",
"if",
"dependencies",
"used"
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L234-L241 | def _get_hanging_wall_coeffs_rrup(self, dists):
"""
Returns the hanging wall rrup term defined in equation 13
"""
fhngrrup = np.ones(len(dists.rrup))
idx = dists.rrup > 0.0
fhngrrup[idx] = (dists.rrup[idx] - dists.rjb[idx]) / dists.rrup[idx]
return fhngrrup | [
"def",
"_get_hanging_wall_coeffs_rrup",
"(",
"self",
",",
"dists",
")",
":",
"fhngrrup",
"=",
"np",
".",
"ones",
"(",
"len",
"(",
"dists",
".",
"rrup",
")",
")",
"idx",
"=",
"dists",
".",
"rrup",
">",
"0.0",
"fhngrrup",
"[",
"idx",
"]",
"=",
"(",
"... | Returns the hanging wall rrup term defined in equation 13 | [
"Returns",
"the",
"hanging",
"wall",
"rrup",
"term",
"defined",
"in",
"equation",
"13"
] | python | train |
stevelittlefish/littlefish | littlefish/pager.py | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/pager.py#L153-L160 | def render_seo_links(self, scheme=None):
"""Render the rel=canonical, rel=prev and rel=next links to a Markup object for injection into a template"""
out = self.render_prev_next_links(scheme=scheme)
if self.total_pages == 1:
out += self.render_canonical_link(scheme=scheme)
... | [
"def",
"render_seo_links",
"(",
"self",
",",
"scheme",
"=",
"None",
")",
":",
"out",
"=",
"self",
".",
"render_prev_next_links",
"(",
"scheme",
"=",
"scheme",
")",
"if",
"self",
".",
"total_pages",
"==",
"1",
":",
"out",
"+=",
"self",
".",
"render_canoni... | Render the rel=canonical, rel=prev and rel=next links to a Markup object for injection into a template | [
"Render",
"the",
"rel",
"=",
"canonical",
"rel",
"=",
"prev",
"and",
"rel",
"=",
"next",
"links",
"to",
"a",
"Markup",
"object",
"for",
"injection",
"into",
"a",
"template"
] | python | test |
twisted/txaws | txaws/wsdl.py | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L281-L285 | def _get_namespace_tag(self, tag):
"""Return the given C{tag} with the namespace prefix added, if any."""
if self._namespace is not None:
tag = "{%s}%s" % (self._namespace, tag)
return tag | [
"def",
"_get_namespace_tag",
"(",
"self",
",",
"tag",
")",
":",
"if",
"self",
".",
"_namespace",
"is",
"not",
"None",
":",
"tag",
"=",
"\"{%s}%s\"",
"%",
"(",
"self",
".",
"_namespace",
",",
"tag",
")",
"return",
"tag"
] | Return the given C{tag} with the namespace prefix added, if any. | [
"Return",
"the",
"given",
"C",
"{",
"tag",
"}",
"with",
"the",
"namespace",
"prefix",
"added",
"if",
"any",
"."
] | python | train |
gwastro/pycbc-glue | pycbc_glue/pipeline.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L3841-L3848 | def set_end(self,time):
"""
Set the end time of the datafind query.
@param time: GPS end time of query.
"""
self.add_var_opt('gps-end-time', time)
self.__end = time
self.__set_output() | [
"def",
"set_end",
"(",
"self",
",",
"time",
")",
":",
"self",
".",
"add_var_opt",
"(",
"'gps-end-time'",
",",
"time",
")",
"self",
".",
"__end",
"=",
"time",
"self",
".",
"__set_output",
"(",
")"
] | Set the end time of the datafind query.
@param time: GPS end time of query. | [
"Set",
"the",
"end",
"time",
"of",
"the",
"datafind",
"query",
"."
] | python | train |
phaethon/kamene | kamene/modules/p0f.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/p0f.py#L329-L497 | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | [
"def",
"p0f_impersonate",
"(",
"pkt",
",",
"osgenre",
"=",
"None",
",",
"osdetails",
"=",
"None",
",",
"signature",
"=",
"None",
",",
"extrahops",
"=",
"0",
",",
"mtu",
"=",
"1500",
",",
"uptime",
"=",
"None",
")",
":",
"pkt",
"=",
"pkt",
".",
"cop... | Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also None,
we use a local signature (using p0f_getlocalsigs). If signature is
specified (as a tuple), we use the signature.
For now, only T... | [
"Modifies",
"pkt",
"so",
"that",
"p0f",
"will",
"think",
"it",
"has",
"been",
"sent",
"by",
"a",
"specific",
"OS",
".",
"If",
"osdetails",
"is",
"None",
"then",
"we",
"randomly",
"pick",
"up",
"a",
"personality",
"matching",
"osgenre",
".",
"If",
"osgenr... | python | train |
sorgerlab/indra | indra/sources/sofia/api.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sofia/api.py#L35-L80 | def process_text(text, out_file='sofia_output.json', auth=None):
"""Return processor by processing text given as a string.
Parameters
----------
text : str
A string containing the text to be processed with Sofia.
out_file : Optional[str]
The path to a file to save the reader's outpu... | [
"def",
"process_text",
"(",
"text",
",",
"out_file",
"=",
"'sofia_output.json'",
",",
"auth",
"=",
"None",
")",
":",
"text_json",
"=",
"{",
"'text'",
":",
"text",
"}",
"if",
"not",
"auth",
":",
"user",
",",
"password",
"=",
"_get_sofia_auth",
"(",
")",
... | Return processor by processing text given as a string.
Parameters
----------
text : str
A string containing the text to be processed with Sofia.
out_file : Optional[str]
The path to a file to save the reader's output into.
Default: sofia_output.json
auth : Optional[list]
... | [
"Return",
"processor",
"by",
"processing",
"text",
"given",
"as",
"a",
"string",
"."
] | python | train |
SeabornGames/Table | seaborn_table/table.py | https://github.com/SeabornGames/Table/blob/0c474ef2fb00db0e7cf47e8af91e3556c2e7485a/seaborn_table/table.py#L577-L590 | def obj_to_txt(self, file_path=None, deliminator=None, tab=None,
quote_numbers=True, quote_empty_str=False):
"""
This will return a simple str table.
:param file_path: str of the path to the file
:param keys: list of str of the order of keys to use
... | [
"def",
"obj_to_txt",
"(",
"self",
",",
"file_path",
"=",
"None",
",",
"deliminator",
"=",
"None",
",",
"tab",
"=",
"None",
",",
"quote_numbers",
"=",
"True",
",",
"quote_empty_str",
"=",
"False",
")",
":",
"return",
"self",
".",
"obj_to_str",
"(",
"file_... | This will return a simple str table.
:param file_path: str of the path to the file
:param keys: list of str of the order of keys to use
:param tab: string of offset of the table
:param quote_numbers: bool if True will quote numbers that are strings
... | [
"This",
"will",
"return",
"a",
"simple",
"str",
"table",
".",
":",
"param",
"file_path",
":",
"str",
"of",
"the",
"path",
"to",
"the",
"file",
":",
"param",
"keys",
":",
"list",
"of",
"str",
"of",
"the",
"order",
"of",
"keys",
"to",
"use",
":",
"pa... | python | train |
gem/oq-engine | openquake/hazardlib/geo/geodetic.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L528-L540 | def _prepare_coords(lons1, lats1, lons2, lats2):
"""
Convert two pairs of spherical coordinates in decimal degrees
to numpy arrays of radians. Makes sure that respective coordinates
in pairs have the same shape.
"""
lons1 = numpy.radians(lons1)
lats1 = numpy.radians(lats1)
assert lons1.s... | [
"def",
"_prepare_coords",
"(",
"lons1",
",",
"lats1",
",",
"lons2",
",",
"lats2",
")",
":",
"lons1",
"=",
"numpy",
".",
"radians",
"(",
"lons1",
")",
"lats1",
"=",
"numpy",
".",
"radians",
"(",
"lats1",
")",
"assert",
"lons1",
".",
"shape",
"==",
"la... | Convert two pairs of spherical coordinates in decimal degrees
to numpy arrays of radians. Makes sure that respective coordinates
in pairs have the same shape. | [
"Convert",
"two",
"pairs",
"of",
"spherical",
"coordinates",
"in",
"decimal",
"degrees",
"to",
"numpy",
"arrays",
"of",
"radians",
".",
"Makes",
"sure",
"that",
"respective",
"coordinates",
"in",
"pairs",
"have",
"the",
"same",
"shape",
"."
] | python | train |
santoshphilip/eppy | eppy/EPlusInterfaceFunctions/eplusdata.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/eplusdata.py#L146-L174 | def initdict(self, fname):
"""create a blank dictionary"""
if isinstance(fname, Idd):
self.dt, self.dtls = fname.dt, fname.dtls
return self.dt, self.dtls
astr = mylib2.readfile(fname)
nocom = removecomment(astr, '!')
idfst = nocom
alist = idfst.sp... | [
"def",
"initdict",
"(",
"self",
",",
"fname",
")",
":",
"if",
"isinstance",
"(",
"fname",
",",
"Idd",
")",
":",
"self",
".",
"dt",
",",
"self",
".",
"dtls",
"=",
"fname",
".",
"dt",
",",
"fname",
".",
"dtls",
"return",
"self",
".",
"dt",
",",
"... | create a blank dictionary | [
"create",
"a",
"blank",
"dictionary"
] | python | train |
Yelp/detect-secrets | detect_secrets/core/secrets_collection.py | https://github.com/Yelp/detect-secrets/blob/473923ea71f1ac2b5ea1eacc49b98f97967e3d05/detect_secrets/core/secrets_collection.py#L274-L294 | def _results_accumulator(self, filename):
"""
:type filename: str
:param filename: name of file, used as a key to store in self.data
:yields: (dict, detect_secrets.plugins.base.BasePlugin)
Caller is responsible for updating the dictionary with
results o... | [
"def",
"_results_accumulator",
"(",
"self",
",",
"filename",
")",
":",
"file_results",
"=",
"{",
"}",
"for",
"plugin",
"in",
"self",
".",
"plugins",
":",
"yield",
"file_results",
",",
"plugin",
"if",
"not",
"file_results",
":",
"return",
"if",
"filename",
... | :type filename: str
:param filename: name of file, used as a key to store in self.data
:yields: (dict, detect_secrets.plugins.base.BasePlugin)
Caller is responsible for updating the dictionary with
results of plugin analysis. | [
":",
"type",
"filename",
":",
"str",
":",
"param",
"filename",
":",
"name",
"of",
"file",
"used",
"as",
"a",
"key",
"to",
"store",
"in",
"self",
".",
"data"
] | python | train |
pachyderm/python-pachyderm | src/python_pachyderm/pfs_client.py | https://github.com/pachyderm/python-pachyderm/blob/1c58cf91d30e03716a4f45213989e890f7b8a78c/src/python_pachyderm/pfs_client.py#L157-L165 | def inspect_commit(self, commit):
"""
Returns info about a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit.
"""
req = proto.InspectCommitRequest(commit=commit_from(commit))
return self.stub.InspectCommit(req, metadata=... | [
"def",
"inspect_commit",
"(",
"self",
",",
"commit",
")",
":",
"req",
"=",
"proto",
".",
"InspectCommitRequest",
"(",
"commit",
"=",
"commit_from",
"(",
"commit",
")",
")",
"return",
"self",
".",
"stub",
".",
"InspectCommit",
"(",
"req",
",",
"metadata",
... | Returns info about a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit. | [
"Returns",
"info",
"about",
"a",
"specific",
"Commit",
"."
] | python | train |
bioidiap/bob.bio.spear | bob/bio/spear/utils/extraction.py | https://github.com/bioidiap/bob.bio.spear/blob/9f5d13d2e52d3b0c818f4abaa07cda15f62a34cd/bob/bio/spear/utils/extraction.py#L40-L51 | def calc_std(c0, c1=[]):
""" Calculates the variance of the data."""
if c1 == []:
return numpy.std(c0, 0)
prop = float(len(c0)) / float(len(c1))
if prop < 1:
p0 = int(math.ceil(1 / prop))
p1 = 1
else:
p0 = 1
p1 = int(math.ceil(prop))
return numpy.std(numpy... | [
"def",
"calc_std",
"(",
"c0",
",",
"c1",
"=",
"[",
"]",
")",
":",
"if",
"c1",
"==",
"[",
"]",
":",
"return",
"numpy",
".",
"std",
"(",
"c0",
",",
"0",
")",
"prop",
"=",
"float",
"(",
"len",
"(",
"c0",
")",
")",
"/",
"float",
"(",
"len",
"... | Calculates the variance of the data. | [
"Calculates",
"the",
"variance",
"of",
"the",
"data",
"."
] | python | train |
DataDog/integrations-core | agent_metrics/datadog_checks/agent_metrics/agent_metrics.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/agent_metrics/datadog_checks/agent_metrics/agent_metrics.py#L87-L117 | def _register_psutil_metrics(self, stats, names_to_metric_types, tags=None):
"""
Saves sample metrics from psutil
:param stats: a dictionary that looks like:
{
'memory_info': OrderedDict([('rss', 24395776), ('vms', 144666624)]),
'io_counters': OrderedDict([('read_count... | [
"def",
"_register_psutil_metrics",
"(",
"self",
",",
"stats",
",",
"names_to_metric_types",
",",
"tags",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"]",
"base_metric",
"=",
"'datadog.agent.collector.{0}.{1}'",
"# TODO: May have to ca... | Saves sample metrics from psutil
:param stats: a dictionary that looks like:
{
'memory_info': OrderedDict([('rss', 24395776), ('vms', 144666624)]),
'io_counters': OrderedDict([('read_count', 4536),
('write_count', 100),
... | [
"Saves",
"sample",
"metrics",
"from",
"psutil"
] | python | train |
bslatkin/dpxdt | dpxdt/server/api.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L598-L617 | def upload():
"""Uploads an artifact referenced by a run."""
build = g.build
utils.jsonify_assert(len(request.files) == 1,
'Need exactly one uploaded file')
file_storage = request.files.values()[0]
data = file_storage.read()
content_type, _ = mimetypes.guess_type(file_s... | [
"def",
"upload",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"utils",
".",
"jsonify_assert",
"(",
"len",
"(",
"request",
".",
"files",
")",
"==",
"1",
",",
"'Need exactly one uploaded file'",
")",
"file_storage",
"=",
"request",
".",
"files",
".",
"v... | Uploads an artifact referenced by a run. | [
"Uploads",
"an",
"artifact",
"referenced",
"by",
"a",
"run",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L20184-L20277 | def process_create_ex(self, executable, arguments, environment_changes, flags, timeout_ms, priority, affinity):
"""Creates a new process running in the guest with the extended options
for setting the process priority and affinity.
See :py:func:`IGuestSession.process_create` for more in... | [
"def",
"process_create_ex",
"(",
"self",
",",
"executable",
",",
"arguments",
",",
"environment_changes",
",",
"flags",
",",
"timeout_ms",
",",
"priority",
",",
"affinity",
")",
":",
"if",
"not",
"isinstance",
"(",
"executable",
",",
"basestring",
")",
":",
... | Creates a new process running in the guest with the extended options
for setting the process priority and affinity.
See :py:func:`IGuestSession.process_create` for more information.
in executable of type str
Full path to the file to execute in the guest. The file has to
... | [
"Creates",
"a",
"new",
"process",
"running",
"in",
"the",
"guest",
"with",
"the",
"extended",
"options",
"for",
"setting",
"the",
"process",
"priority",
"and",
"affinity",
".",
"See",
":",
"py",
":",
"func",
":",
"IGuestSession",
".",
"process_create",
"for"... | python | train |
CameronLonsdale/lantern | lantern/modules/simplesubstitution.py | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/simplesubstitution.py#L63-L81 | def decrypt(key, ciphertext):
"""Decrypt Simple Substitution enciphered ``ciphertext`` using ``key``.
Example:
>>> decrypt("PQSTUVWXYZCODEBRAKINGFHJLM", "XUOOB")
HELLO
Args:
key (iterable): The key to use
ciphertext (str): The text to decrypt
Returns:
Decrypted... | [
"def",
"decrypt",
"(",
"key",
",",
"ciphertext",
")",
":",
"# TODO: Is it worth keeping this here I should I only accept strings?",
"key",
"=",
"''",
".",
"join",
"(",
"key",
")",
"alphabet",
"=",
"string",
".",
"ascii_letters",
"cipher_alphabet",
"=",
"key",
".",
... | Decrypt Simple Substitution enciphered ``ciphertext`` using ``key``.
Example:
>>> decrypt("PQSTUVWXYZCODEBRAKINGFHJLM", "XUOOB")
HELLO
Args:
key (iterable): The key to use
ciphertext (str): The text to decrypt
Returns:
Decrypted ciphertext | [
"Decrypt",
"Simple",
"Substitution",
"enciphered",
"ciphertext",
"using",
"key",
"."
] | python | train |
pybel/pybel-tools | src/pybel_tools/mutation/expansion.py | https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L216-L221 | def enrich_complexes(graph: BELGraph) -> None:
"""Add all of the members of the complex abundances to the graph."""
nodes = list(get_nodes_by_function(graph, COMPLEX))
for u in nodes:
for v in u.members:
graph.add_has_component(u, v) | [
"def",
"enrich_complexes",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"None",
":",
"nodes",
"=",
"list",
"(",
"get_nodes_by_function",
"(",
"graph",
",",
"COMPLEX",
")",
")",
"for",
"u",
"in",
"nodes",
":",
"for",
"v",
"in",
"u",
".",
"members",
":",
... | Add all of the members of the complex abundances to the graph. | [
"Add",
"all",
"of",
"the",
"members",
"of",
"the",
"complex",
"abundances",
"to",
"the",
"graph",
"."
] | python | valid |
WhyNotHugo/django-afip | django_afip/models.py | https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L307-L319 | def get_certificate_expiration(self):
"""
Gets the certificate expiration from the certificate
Gets the certificate expiration from the certificate file. Note that
this value is stored into ``certificate_expiration`` when an instance
is saved, so you should generally prefer tha... | [
"def",
"get_certificate_expiration",
"(",
"self",
")",
":",
"datestring",
"=",
"self",
".",
"certificate_object",
".",
"get_notAfter",
"(",
")",
".",
"decode",
"(",
")",
"dt",
"=",
"datetime",
".",
"strptime",
"(",
"datestring",
",",
"'%Y%m%d%H%M%SZ'",
")",
... | Gets the certificate expiration from the certificate
Gets the certificate expiration from the certificate file. Note that
this value is stored into ``certificate_expiration`` when an instance
is saved, so you should generally prefer that method (since this one
requires reading and pars... | [
"Gets",
"the",
"certificate",
"expiration",
"from",
"the",
"certificate"
] | python | train |
hellosign/hellosign-python-sdk | hellosign_sdk/hsclient.py | https://github.com/hellosign/hellosign-python-sdk/blob/4325a29ad5766380a214eac3914511f62f7ecba4/hellosign_sdk/hsclient.py#L517-L533 | def cancel_signature_request(self, signature_request_id):
''' Cancels a SignatureRequest
Cancels a SignatureRequest. After canceling, no one will be able to sign
or access the SignatureRequest or its documents. Only the requester can
cancel and only before everyone has signed.
... | [
"def",
"cancel_signature_request",
"(",
"self",
",",
"signature_request_id",
")",
":",
"request",
"=",
"self",
".",
"_get_request",
"(",
")",
"request",
".",
"post",
"(",
"url",
"=",
"self",
".",
"SIGNATURE_REQUEST_CANCEL_URL",
"+",
"signature_request_id",
",",
... | Cancels a SignatureRequest
Cancels a SignatureRequest. After canceling, no one will be able to sign
or access the SignatureRequest or its documents. Only the requester can
cancel and only before everyone has signed.
Args:
signing_request_id (str): The id of the signature r... | [
"Cancels",
"a",
"SignatureRequest"
] | python | train |
sosy-lab/benchexec | benchexec/runexecutor.py | https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/runexecutor.py#L1094-L1111 | def check_for_new_files_in_home(self):
"""Check that the user account's home directory now does not contain more files than
when this instance was created, and warn otherwise.
Does nothing if no user account was given to RunExecutor.
@return set of newly created files
"""
... | [
"def",
"check_for_new_files_in_home",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_user",
":",
"return",
"None",
"try",
":",
"created_files",
"=",
"set",
"(",
"self",
".",
"_listdir",
"(",
"self",
".",
"_home_dir",
")",
")",
".",
"difference",
"(",... | Check that the user account's home directory now does not contain more files than
when this instance was created, and warn otherwise.
Does nothing if no user account was given to RunExecutor.
@return set of newly created files | [
"Check",
"that",
"the",
"user",
"account",
"s",
"home",
"directory",
"now",
"does",
"not",
"contain",
"more",
"files",
"than",
"when",
"this",
"instance",
"was",
"created",
"and",
"warn",
"otherwise",
".",
"Does",
"nothing",
"if",
"no",
"user",
"account",
... | python | train |
bronto/javasphinx | javasphinx/compiler.py | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L221-L288 | def compile_type_document(self, imports_block, package, name, declaration):
""" Compile a complete document, documenting a type and its members """
outer_type = name.rpartition('.')[0]
document = util.Document()
document.add(imports_block)
document.add_heading(name, '=')
... | [
"def",
"compile_type_document",
"(",
"self",
",",
"imports_block",
",",
"package",
",",
"name",
",",
"declaration",
")",
":",
"outer_type",
"=",
"name",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
"document",
"=",
"util",
".",
"Document",
"(",
")"... | Compile a complete document, documenting a type and its members | [
"Compile",
"a",
"complete",
"document",
"documenting",
"a",
"type",
"and",
"its",
"members"
] | python | train |
jobovy/galpy | galpy/df/streamgapdf.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/streamgapdf.py#L1617-L1679 | def impulse_deltav_plummerstream_curvedstream(v,x,t,b,w,x0,v0,GSigma,rs,
galpot,tmin=None,tmax=None):
"""
NAME:
impulse_deltav_plummerstream_curvedstream
PURPOSE:
calculate the delta velocity to due an encounter with a Plummer sphere in the impu... | [
"def",
"impulse_deltav_plummerstream_curvedstream",
"(",
"v",
",",
"x",
",",
"t",
",",
"b",
",",
"w",
",",
"x0",
",",
"v0",
",",
"GSigma",
",",
"rs",
",",
"galpot",
",",
"tmin",
"=",
"None",
",",
"tmax",
"=",
"None",
")",
":",
"galpot",
"=",
"flatt... | NAME:
impulse_deltav_plummerstream_curvedstream
PURPOSE:
calculate the delta velocity to due an encounter with a Plummer sphere in the impulse approximation; allows for arbitrary velocity vectors, and arbitrary position along the stream; velocities and positions are assumed to lie along an orbit
... | [
"NAME",
":"
] | python | train |
python-xlib/python-xlib | Xlib/protocol/rq.py | https://github.com/python-xlib/python-xlib/blob/8901e831737e79fe5645f48089d70e1d1046d2f2/Xlib/protocol/rq.py#L457-L469 | def pack_value(self, val):
"""Convert 8-byte string into 16-byte list"""
if isinstance(val, bytes):
val = list(iterbytes(val))
slen = len(val)
if self.pad:
pad = b'\0\0' * (slen % 2)
else:
pad = b''
return struct.pack('>' + 'H' * sle... | [
"def",
"pack_value",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"bytes",
")",
":",
"val",
"=",
"list",
"(",
"iterbytes",
"(",
"val",
")",
")",
"slen",
"=",
"len",
"(",
"val",
")",
"if",
"self",
".",
"pad",
":",
"pad... | Convert 8-byte string into 16-byte list | [
"Convert",
"8",
"-",
"byte",
"string",
"into",
"16",
"-",
"byte",
"list"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/tone_analyzer_v3.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/tone_analyzer_v3.py#L342-L354 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'tones') and self.tones is not None:
_dict['tones'] = [x._to_dict() for x in self.tones]
if hasattr(self,
'tone_categories') and self.tone_categories is ... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'tones'",
")",
"and",
"self",
".",
"tones",
"is",
"not",
"None",
":",
"_dict",
"[",
"'tones'",
"]",
"=",
"[",
"x",
".",
"_to_dict",
"(",
")",
... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
planetarypy/pvl | pvl/__init__.py | https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L100-L113 | def loads(data, cls=PVLDecoder, strict=True, **kwargs):
"""Deserialize ``data`` as a pvl module.
:param data: a pvl module as a byte or unicode string
:param cls: the decoder class used to deserialize the pvl module. You may
use the default ``PVLDecoder`` class or provide a custom sublcass.
:... | [
"def",
"loads",
"(",
"data",
",",
"cls",
"=",
"PVLDecoder",
",",
"strict",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"decoder",
"=",
"__create_decoder",
"(",
"cls",
",",
"strict",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"isinstance",
"(",
... | Deserialize ``data`` as a pvl module.
:param data: a pvl module as a byte or unicode string
:param cls: the decoder class used to deserialize the pvl module. You may
use the default ``PVLDecoder`` class or provide a custom sublcass.
:param **kwargs: the keyword arguments to pass to the decoder cl... | [
"Deserialize",
"data",
"as",
"a",
"pvl",
"module",
"."
] | python | train |
sys-git/certifiable | certifiable/complex.py | https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L326-L372 | def certify_tuple(value, certifier=None, min_len=None, max_len=None, required=True, schema=None):
"""
Validates a tuple, checking it against an optional schema.
The schema should be a list of expected values replaced by functions which will be called to
with the corresponding value in the input.
A... | [
"def",
"certify_tuple",
"(",
"value",
",",
"certifier",
"=",
"None",
",",
"min_len",
"=",
"None",
",",
"max_len",
"=",
"None",
",",
"required",
"=",
"True",
",",
"schema",
"=",
"None",
")",
":",
"certify_iterable",
"(",
"value",
"=",
"value",
",",
"typ... | Validates a tuple, checking it against an optional schema.
The schema should be a list of expected values replaced by functions which will be called to
with the corresponding value in the input.
A simple example:
>>> certifier = certify_tuple(schema=(
... certify_key(kind='Model'),
... | [
"Validates",
"a",
"tuple",
"checking",
"it",
"against",
"an",
"optional",
"schema",
"."
] | python | train |
waqasbhatti/astrobase | astrobase/varbase/trends.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/varbase/trends.py#L150-L175 | def smooth_magseries_savgol(mags, windowsize, polyorder=2):
'''This smooths the magseries with a Savitsky-Golay filter.
Parameters
----------
mags : np.array
The input mags/flux time-series to smooth.
windowsize : int
This is a odd integer containing the smoothing window size.
... | [
"def",
"smooth_magseries_savgol",
"(",
"mags",
",",
"windowsize",
",",
"polyorder",
"=",
"2",
")",
":",
"smoothed",
"=",
"savgol_filter",
"(",
"mags",
",",
"windowsize",
",",
"polyorder",
")",
"return",
"smoothed"
] | This smooths the magseries with a Savitsky-Golay filter.
Parameters
----------
mags : np.array
The input mags/flux time-series to smooth.
windowsize : int
This is a odd integer containing the smoothing window size.
polyorder : int
This is an integer containing the polynom... | [
"This",
"smooths",
"the",
"magseries",
"with",
"a",
"Savitsky",
"-",
"Golay",
"filter",
"."
] | python | valid |
pyrogram/pyrogram | pyrogram/client/methods/password/enable_cloud_password.py | https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/methods/password/enable_cloud_password.py#L27-L75 | def enable_cloud_password(
self,
password: str,
hint: str = "",
email: str = None
) -> bool:
"""Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account.
This password will be asked when you log-in on a new device in addit... | [
"def",
"enable_cloud_password",
"(",
"self",
",",
"password",
":",
"str",
",",
"hint",
":",
"str",
"=",
"\"\"",
",",
"email",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"r",
"=",
"self",
".",
"send",
"(",
"functions",
".",
"account",
".",
"Ge... | Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account.
This password will be asked when you log-in on a new device in addition to the SMS code.
Args:
password (``str``):
Your password.
hint (``str``, *optional*):
... | [
"Use",
"this",
"method",
"to",
"enable",
"the",
"Two",
"-",
"Step",
"Verification",
"security",
"feature",
"(",
"Cloud",
"Password",
")",
"on",
"your",
"account",
"."
] | python | train |
xolox/python-vcs-repo-mgr | vcs_repo_mgr/__init__.py | https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/__init__.py#L1372-L1391 | def generate_control_field(self, revision=None):
"""
Generate a Debian control file field referring for this repository and revision.
:param revision: A reference to a revision, most likely the name of a
branch (a string, defaults to :attr:`default_revision`).
:... | [
"def",
"generate_control_field",
"(",
"self",
",",
"revision",
"=",
"None",
")",
":",
"value",
"=",
"\"%s#%s\"",
"%",
"(",
"self",
".",
"remote",
"or",
"self",
".",
"local",
",",
"self",
".",
"find_revision_id",
"(",
"revision",
")",
")",
"return",
"self... | Generate a Debian control file field referring for this repository and revision.
:param revision: A reference to a revision, most likely the name of a
branch (a string, defaults to :attr:`default_revision`).
:returns: A tuple with two strings: The name of the field and the valu... | [
"Generate",
"a",
"Debian",
"control",
"file",
"field",
"referring",
"for",
"this",
"repository",
"and",
"revision",
"."
] | python | train |
potash/drain | drain/model.py | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/model.py#L394-L424 | def perturb(estimator, X, bins, columns=None):
"""
Predict on peturbations of a feature vector
estimator: a fitted sklearn estimator
index: the index of the example to perturb
bins: a dictionary of column:bins arrays
columns: list of columns if bins doesn't cover all columns
TODO make this w... | [
"def",
"perturb",
"(",
"estimator",
",",
"X",
",",
"bins",
",",
"columns",
"=",
"None",
")",
":",
"if",
"columns",
"is",
"None",
":",
"if",
"len",
"(",
"bins",
")",
"!=",
"X",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Must ... | Predict on peturbations of a feature vector
estimator: a fitted sklearn estimator
index: the index of the example to perturb
bins: a dictionary of column:bins arrays
columns: list of columns if bins doesn't cover all columns
TODO make this work when index is multiple rows | [
"Predict",
"on",
"peturbations",
"of",
"a",
"feature",
"vector",
"estimator",
":",
"a",
"fitted",
"sklearn",
"estimator",
"index",
":",
"the",
"index",
"of",
"the",
"example",
"to",
"perturb",
"bins",
":",
"a",
"dictionary",
"of",
"column",
":",
"bins",
"a... | python | train |
rigetti/quantumflow | quantumflow/ops.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/ops.py#L168-L172 | def evolve(self, rho: Density) -> Density:
"""Apply the action of this gate upon a density"""
# TODO: implement without explicit channel creation?
chan = self.aschannel()
return chan.evolve(rho) | [
"def",
"evolve",
"(",
"self",
",",
"rho",
":",
"Density",
")",
"->",
"Density",
":",
"# TODO: implement without explicit channel creation?",
"chan",
"=",
"self",
".",
"aschannel",
"(",
")",
"return",
"chan",
".",
"evolve",
"(",
"rho",
")"
] | Apply the action of this gate upon a density | [
"Apply",
"the",
"action",
"of",
"this",
"gate",
"upon",
"a",
"density"
] | python | train |
saltstack/salt | salt/modules/nilrt_ip.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L109-L117 | def _get_services():
'''
Returns a list with all connman services
'''
serv = []
services = pyconnman.ConnManager().get_services()
for path, _ in services:
serv.append(six.text_type(path[len(SERVICE_PATH):]))
return serv | [
"def",
"_get_services",
"(",
")",
":",
"serv",
"=",
"[",
"]",
"services",
"=",
"pyconnman",
".",
"ConnManager",
"(",
")",
".",
"get_services",
"(",
")",
"for",
"path",
",",
"_",
"in",
"services",
":",
"serv",
".",
"append",
"(",
"six",
".",
"text_typ... | Returns a list with all connman services | [
"Returns",
"a",
"list",
"with",
"all",
"connman",
"services"
] | python | train |
kgaughan/dbkit | dbkit.py | https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L693-L702 | def execute(stmt, args=()):
"""
Execute an SQL statement. Returns the number of affected rows.
"""
ctx = Context.current()
with ctx.mdr:
cursor = ctx.execute(stmt, args)
row_count = cursor.rowcount
_safe_close(cursor)
return row_count | [
"def",
"execute",
"(",
"stmt",
",",
"args",
"=",
"(",
")",
")",
":",
"ctx",
"=",
"Context",
".",
"current",
"(",
")",
"with",
"ctx",
".",
"mdr",
":",
"cursor",
"=",
"ctx",
".",
"execute",
"(",
"stmt",
",",
"args",
")",
"row_count",
"=",
"cursor",... | Execute an SQL statement. Returns the number of affected rows. | [
"Execute",
"an",
"SQL",
"statement",
".",
"Returns",
"the",
"number",
"of",
"affected",
"rows",
"."
] | python | train |
Lucretiel/Dispatch | dispatching.py | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L113-L118 | def dispatch(self, func):
'''
Adds the decorated function to this dispatch.
'''
self.callees.append(self._make_dispatch(func))
return self._make_wrapper(func) | [
"def",
"dispatch",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"callees",
".",
"append",
"(",
"self",
".",
"_make_dispatch",
"(",
"func",
")",
")",
"return",
"self",
".",
"_make_wrapper",
"(",
"func",
")"
] | Adds the decorated function to this dispatch. | [
"Adds",
"the",
"decorated",
"function",
"to",
"this",
"dispatch",
"."
] | python | valid |
rflamary/POT | ot/utils.py | https://github.com/rflamary/POT/blob/c5108efc7b6702e1af3928bef1032e6b37734d1c/ot/utils.py#L169-L199 | def cost_normalization(C, norm=None):
""" Apply normalization to the loss matrix
Parameters
----------
C : np.array (n1, n2)
The cost matrix to normalize.
norm : str
type of normalization from 'median','max','log','loglog'. Any other
value do not normalize.
Returns
... | [
"def",
"cost_normalization",
"(",
"C",
",",
"norm",
"=",
"None",
")",
":",
"if",
"norm",
"==",
"\"median\"",
":",
"C",
"/=",
"float",
"(",
"np",
".",
"median",
"(",
"C",
")",
")",
"elif",
"norm",
"==",
"\"max\"",
":",
"C",
"/=",
"float",
"(",
"np... | Apply normalization to the loss matrix
Parameters
----------
C : np.array (n1, n2)
The cost matrix to normalize.
norm : str
type of normalization from 'median','max','log','loglog'. Any other
value do not normalize.
Returns
-------
C : np.array (n1, n2)
T... | [
"Apply",
"normalization",
"to",
"the",
"loss",
"matrix"
] | python | train |
trombastic/PyScada | pyscada/utils/scheduler.py | https://github.com/trombastic/PyScada/blob/c5fc348a25f0df1340336f694ee9bc1aea62516a/pyscada/utils/scheduler.py#L598-L614 | def pre_init_process(self):
"""
will be executed after process fork
"""
db.connections.close_all()
# update process info
BackgroundProcess.objects.filter(pk=self.process_id).update(
pid=self.pid,
last_update=now(),
running_since=now(),
... | [
"def",
"pre_init_process",
"(",
"self",
")",
":",
"db",
".",
"connections",
".",
"close_all",
"(",
")",
"# update process info",
"BackgroundProcess",
".",
"objects",
".",
"filter",
"(",
"pk",
"=",
"self",
".",
"process_id",
")",
".",
"update",
"(",
"pid",
... | will be executed after process fork | [
"will",
"be",
"executed",
"after",
"process",
"fork"
] | python | train |
saltstack/salt-pylint | saltpylint/pep8.py | https://github.com/saltstack/salt-pylint/blob/524a419d3bfc7dbd91c9c85040bc64935a275b24/saltpylint/pep8.py#L462-L479 | def register(linter):
'''
required method to auto register this checker
'''
if HAS_PEP8 is False:
return
linter.register_checker(PEP8Indentation(linter))
linter.register_checker(PEP8Whitespace(linter))
linter.register_checker(PEP8BlankLine(linter))
linter.register_checker(PEP8Im... | [
"def",
"register",
"(",
"linter",
")",
":",
"if",
"HAS_PEP8",
"is",
"False",
":",
"return",
"linter",
".",
"register_checker",
"(",
"PEP8Indentation",
"(",
"linter",
")",
")",
"linter",
".",
"register_checker",
"(",
"PEP8Whitespace",
"(",
"linter",
")",
")",... | required method to auto register this checker | [
"required",
"method",
"to",
"auto",
"register",
"this",
"checker"
] | python | train |
redapple/parslepy | parslepy/base.py | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L338-L429 | def _compile(self, parselet_node, level=0):
"""
Build part of the abstract Parsley extraction tree
Arguments:
parselet_node (dict) -- part of the Parsley tree to compile
(can be the root dict/node)
level (int) -- current recursion depth (... | [
"def",
"_compile",
"(",
"self",
",",
"parselet_node",
",",
"level",
"=",
"0",
")",
":",
"if",
"self",
".",
"DEBUG",
":",
"debug_offset",
"=",
"\"\"",
".",
"join",
"(",
"[",
"\" \"",
"for",
"x",
"in",
"range",
"(",
"level",
")",
"]",
")",
"if",
... | Build part of the abstract Parsley extraction tree
Arguments:
parselet_node (dict) -- part of the Parsley tree to compile
(can be the root dict/node)
level (int) -- current recursion depth (used for debug) | [
"Build",
"part",
"of",
"the",
"abstract",
"Parsley",
"extraction",
"tree"
] | python | valid |
open511/open511 | open511/converter/o5xml.py | https://github.com/open511/open511/blob/3d573f59d7efa06ff1b5419ea5ff4d90a90b3cf8/open511/converter/o5xml.py#L116-L146 | def geojson_to_gml(gj, set_srs=True):
"""Given a dict deserialized from a GeoJSON object, returns an lxml Element
of the corresponding GML geometry."""
tag = G(gj['type'])
if set_srs:
tag.set('srsName', 'urn:ogc:def:crs:EPSG::4326')
if gj['type'] == 'Point':
tag.append(G.pos(_revers... | [
"def",
"geojson_to_gml",
"(",
"gj",
",",
"set_srs",
"=",
"True",
")",
":",
"tag",
"=",
"G",
"(",
"gj",
"[",
"'type'",
"]",
")",
"if",
"set_srs",
":",
"tag",
".",
"set",
"(",
"'srsName'",
",",
"'urn:ogc:def:crs:EPSG::4326'",
")",
"if",
"gj",
"[",
"'ty... | Given a dict deserialized from a GeoJSON object, returns an lxml Element
of the corresponding GML geometry. | [
"Given",
"a",
"dict",
"deserialized",
"from",
"a",
"GeoJSON",
"object",
"returns",
"an",
"lxml",
"Element",
"of",
"the",
"corresponding",
"GML",
"geometry",
"."
] | python | valid |
gem/oq-engine | openquake/hazardlib/gsim/dowrickrhoades_2005.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/dowrickrhoades_2005.py#L145-L190 | def _get_site_class(self, vs30, mmi_mean):
"""
Return site class flag for:
Class E - Very Soft Soil vs30 < 180
Class D - Deep or Soft Soil vs30 >= 180 and vs30 <= 360
Class C - Shallow Soil vs30 > 360 and vs30 <= 760
Class B - Rock vs3... | [
"def",
"_get_site_class",
"(",
"self",
",",
"vs30",
",",
"mmi_mean",
")",
":",
"if",
"vs30",
"[",
"0",
"]",
"<",
"180",
":",
"c1",
"=",
"1.0",
"c2",
"=",
"-",
"0.25",
"d",
"=",
"0.5",
"elif",
"vs30",
"[",
"0",
"]",
">=",
"180",
"and",
"vs30",
... | Return site class flag for:
Class E - Very Soft Soil vs30 < 180
Class D - Deep or Soft Soil vs30 >= 180 and vs30 <= 360
Class C - Shallow Soil vs30 > 360 and vs30 <= 760
Class B - Rock vs30 > 760 and vs30 <= 1500
Class A - Strong Rock ... | [
"Return",
"site",
"class",
"flag",
"for",
":",
"Class",
"E",
"-",
"Very",
"Soft",
"Soil",
"vs30",
"<",
"180",
"Class",
"D",
"-",
"Deep",
"or",
"Soft",
"Soil",
"vs30",
">",
"=",
"180",
"and",
"vs30",
"<",
"=",
"360",
"Class",
"C",
"-",
"Shallow",
... | python | train |
mehmetg/streak_client | streak_client/streak_client.py | https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_client.py#L222-L234 | def delete_all_pipelines(self):
'''Deletes all pipelines
Args:
returns OK for overall success or last error code, resp data.
'''
code, data = self.get_pipeline()
if code == requests.codes.ok:
for pl_data in data:
c, d = self.delete_pipeline(pl_data['pipelineKey'])
if c != requests.codes.ok:
... | [
"def",
"delete_all_pipelines",
"(",
"self",
")",
":",
"code",
",",
"data",
"=",
"self",
".",
"get_pipeline",
"(",
")",
"if",
"code",
"==",
"requests",
".",
"codes",
".",
"ok",
":",
"for",
"pl_data",
"in",
"data",
":",
"c",
",",
"d",
"=",
"self",
".... | Deletes all pipelines
Args:
returns OK for overall success or last error code, resp data. | [
"Deletes",
"all",
"pipelines",
"Args",
":",
"returns",
"OK",
"for",
"overall",
"success",
"or",
"last",
"error",
"code",
"resp",
"data",
"."
] | python | train |
gaqzi/py-gocd | gocd/api/template_config.py | https://github.com/gaqzi/py-gocd/blob/6fe5b62dea51e665c11a343aba5fc98e130c5c63/gocd/api/template_config.py#L77-L92 | def delete(self):
"""Delete template config for specified template name.
.. __: https://api.go.cd/current/#delete-a-template
Returns:
Response: :class:`gocd.api.response.Response` object
"""
headers = self._default_headers()
return self._request(self.name,
... | [
"def",
"delete",
"(",
"self",
")",
":",
"headers",
"=",
"self",
".",
"_default_headers",
"(",
")",
"return",
"self",
".",
"_request",
"(",
"self",
".",
"name",
",",
"ok_status",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"headers",
"... | Delete template config for specified template name.
.. __: https://api.go.cd/current/#delete-a-template
Returns:
Response: :class:`gocd.api.response.Response` object | [
"Delete",
"template",
"config",
"for",
"specified",
"template",
"name",
"."
] | python | valid |
asweigart/pybresenham | pybresenham/__init__.py | https://github.com/asweigart/pybresenham/blob/5183f39af58d899cf736075d2b27c892824bb563/pybresenham/__init__.py#L437-L514 | def floodFill(points, startx, starty):
"""
Returns a set of the (x, y) points of a filled in area.
`points` is an iterable of (x, y) tuples of an arbitrary shape.
`startx` and `starty` mark the starting point (likely inside the
arbitrary shape) to begin filling from.
>>> drawPoints(polygon(5,... | [
"def",
"floodFill",
"(",
"points",
",",
"startx",
",",
"starty",
")",
":",
"# Note: We're not going to use recursion here because 1) recursion is",
"# overrated 2) on a large enough shape it would cause a stackoverflow",
"# 3) flood fill doesn't strictly need recursion because it doesn't req... | Returns a set of the (x, y) points of a filled in area.
`points` is an iterable of (x, y) tuples of an arbitrary shape.
`startx` and `starty` mark the starting point (likely inside the
arbitrary shape) to begin filling from.
>>> drawPoints(polygon(5, 5, 4, 5))
,,,O,,,
,,O,O,,
,O,,,O,
... | [
"Returns",
"a",
"set",
"of",
"the",
"(",
"x",
"y",
")",
"points",
"of",
"a",
"filled",
"in",
"area",
"."
] | python | train |
eng-tools/geofound | geofound/models.py | https://github.com/eng-tools/geofound/blob/6b1b097d5db998907bdcb5b4798fb4629674c770/geofound/models.py#L37-L51 | def create_foundation(length, width, depth=0.0, height=0.0):
"""
Can define a Foundation Object from dimensions.
:param length: Foundation length
:param width: Foundation width
:param depth: Foundation depth
:param height: Foundation height
:return: A Foundation object
"""
a_foundati... | [
"def",
"create_foundation",
"(",
"length",
",",
"width",
",",
"depth",
"=",
"0.0",
",",
"height",
"=",
"0.0",
")",
":",
"a_foundation",
"=",
"FoundationRaft",
"(",
")",
"a_foundation",
".",
"length",
"=",
"length",
"a_foundation",
".",
"width",
"=",
"width... | Can define a Foundation Object from dimensions.
:param length: Foundation length
:param width: Foundation width
:param depth: Foundation depth
:param height: Foundation height
:return: A Foundation object | [
"Can",
"define",
"a",
"Foundation",
"Object",
"from",
"dimensions",
".",
":",
"param",
"length",
":",
"Foundation",
"length",
":",
"param",
"width",
":",
"Foundation",
"width",
":",
"param",
"depth",
":",
"Foundation",
"depth",
":",
"param",
"height",
":",
... | python | test |
saltstack/salt | salt/netapi/rest_cherrypy/event_processor.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/event_processor.py#L35-L48 | def publish_minions(self):
'''
Publishes minions as a list of dicts.
'''
minions = []
for minion, minion_info in six.iteritems(self.minions):
curr_minion = {}
curr_minion.update(minion_info)
curr_minion.update({'id': minion})
minio... | [
"def",
"publish_minions",
"(",
"self",
")",
":",
"minions",
"=",
"[",
"]",
"for",
"minion",
",",
"minion_info",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"minions",
")",
":",
"curr_minion",
"=",
"{",
"}",
"curr_minion",
".",
"update",
"(",
"mini... | Publishes minions as a list of dicts. | [
"Publishes",
"minions",
"as",
"a",
"list",
"of",
"dicts",
"."
] | python | train |
apache/incubator-mxnet | python/mxnet/gluon/parameter.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L287-L298 | def _init_impl(self, data, ctx_list):
"""Sets data and grad."""
self._ctx_list = list(ctx_list)
self._ctx_map = [[], []]
for i, ctx in enumerate(self._ctx_list):
dev_list = self._ctx_map[ctx.device_typeid&1]
while len(dev_list) <= ctx.device_id:
de... | [
"def",
"_init_impl",
"(",
"self",
",",
"data",
",",
"ctx_list",
")",
":",
"self",
".",
"_ctx_list",
"=",
"list",
"(",
"ctx_list",
")",
"self",
".",
"_ctx_map",
"=",
"[",
"[",
"]",
",",
"[",
"]",
"]",
"for",
"i",
",",
"ctx",
"in",
"enumerate",
"("... | Sets data and grad. | [
"Sets",
"data",
"and",
"grad",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/visualization/bloch.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L380-L415 | def render(self, title=''):
"""
Render the Bloch sphere and its data sets in on given figure and axes.
"""
if self._rendered:
self.axes.clear()
self._rendered = True
# Figure instance for Bloch sphere plot
if not self._ext_fig:
self.fig =... | [
"def",
"render",
"(",
"self",
",",
"title",
"=",
"''",
")",
":",
"if",
"self",
".",
"_rendered",
":",
"self",
".",
"axes",
".",
"clear",
"(",
")",
"self",
".",
"_rendered",
"=",
"True",
"# Figure instance for Bloch sphere plot",
"if",
"not",
"self",
".",... | Render the Bloch sphere and its data sets in on given figure and axes. | [
"Render",
"the",
"Bloch",
"sphere",
"and",
"its",
"data",
"sets",
"in",
"on",
"given",
"figure",
"and",
"axes",
"."
] | python | test |
kubernetes-client/python | kubernetes/client/apis/apps_v1_api.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/apps_v1_api.py#L4848-L4871 | def read_namespaced_daemon_set(self, name, namespace, **kwargs):
"""
read the specified DaemonSet
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_daemon_set(name, namespace,... | [
"def",
"read_namespaced_daemon_set",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
"."... | read the specified DaemonSet
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_daemon_set(name, namespace, async_req=True)
>>> result = thread.get()
:param async_req bool
... | [
"read",
"the",
"specified",
"DaemonSet",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"pass",
"async_req",
"=",
"True",
">>>",
"thread",
"=",
"api",
"... | python | train |
omza/azurestoragewrap | azurestoragewrap/queue.py | https://github.com/omza/azurestoragewrap/blob/976878e95d82ff0f7d8a00a5e4a7a3fb6268ab08/azurestoragewrap/queue.py#L361-L376 | def delete(self, storagemodel:object, modeldefinition = None) -> bool:
""" delete the message in queue """
deleted = False
if (storagemodel.id != '') and (storagemodel.pop_receipt != '') and (not storagemodel.id is None) and (not storagemodel.pop_receipt is None):
try:
... | [
"def",
"delete",
"(",
"self",
",",
"storagemodel",
":",
"object",
",",
"modeldefinition",
"=",
"None",
")",
"->",
"bool",
":",
"deleted",
"=",
"False",
"if",
"(",
"storagemodel",
".",
"id",
"!=",
"''",
")",
"and",
"(",
"storagemodel",
".",
"pop_receipt",... | delete the message in queue | [
"delete",
"the",
"message",
"in",
"queue"
] | python | train |
mitsei/dlkit | dlkit/records/assessment/analytic/irt.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/analytic/irt.py#L121-L125 | def set_difficulty_value(self, difficulty):
"""stub"""
if not isinstance(difficulty, float):
raise InvalidArgument('difficulty value must be a decimal')
self.add_decimal_value(difficulty, 'difficulty') | [
"def",
"set_difficulty_value",
"(",
"self",
",",
"difficulty",
")",
":",
"if",
"not",
"isinstance",
"(",
"difficulty",
",",
"float",
")",
":",
"raise",
"InvalidArgument",
"(",
"'difficulty value must be a decimal'",
")",
"self",
".",
"add_decimal_value",
"(",
"dif... | stub | [
"stub"
] | python | train |
deepmipt/DeepPavlov | deeppavlov/utils/alexa/conversation.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/utils/alexa/conversation.py#L101-L116 | def _act(self, utterance: str) -> list:
"""Infers DeepPavlov agent with raw user input extracted from Alexa request.
Args:
utterance: Raw user input extracted from Alexa request.
Returns:
response: DeepPavlov agent response.
"""
if self.stateful:
... | [
"def",
"_act",
"(",
"self",
",",
"utterance",
":",
"str",
")",
"->",
"list",
":",
"if",
"self",
".",
"stateful",
":",
"utterance",
"=",
"[",
"[",
"utterance",
"]",
",",
"[",
"self",
".",
"key",
"]",
"]",
"else",
":",
"utterance",
"=",
"[",
"[",
... | Infers DeepPavlov agent with raw user input extracted from Alexa request.
Args:
utterance: Raw user input extracted from Alexa request.
Returns:
response: DeepPavlov agent response. | [
"Infers",
"DeepPavlov",
"agent",
"with",
"raw",
"user",
"input",
"extracted",
"from",
"Alexa",
"request",
"."
] | python | test |
tensorflow/lucid | lucid/misc/tfutil.py | https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/tfutil.py#L19-L31 | def create_session(target='', timeout_sec=10):
'''Create an intractive TensorFlow session.
Helper function that creates TF session that uses growing GPU memory
allocation and opration timeout. 'allow_growth' flag prevents TF
from allocating the whole GPU memory an once, which is useful
when having multiple p... | [
"def",
"create_session",
"(",
"target",
"=",
"''",
",",
"timeout_sec",
"=",
"10",
")",
":",
"graph",
"=",
"tf",
".",
"Graph",
"(",
")",
"config",
"=",
"tf",
".",
"ConfigProto",
"(",
")",
"config",
".",
"gpu_options",
".",
"allow_growth",
"=",
"True",
... | Create an intractive TensorFlow session.
Helper function that creates TF session that uses growing GPU memory
allocation and opration timeout. 'allow_growth' flag prevents TF
from allocating the whole GPU memory an once, which is useful
when having multiple python sessions sharing the same GPU. | [
"Create",
"an",
"intractive",
"TensorFlow",
"session",
"."
] | python | train |
Scifabric/pybossa-client | pbclient/__init__.py | https://github.com/Scifabric/pybossa-client/blob/998d7cb0207ff5030dc800f0c2577c5692316c2c/pbclient/__init__.py#L329-L345 | def get_category(category_id):
"""Return a PYBOSSA Category for the category_id.
:param category_id: PYBOSSA Category ID
:type category_id: integer
:rtype: PYBOSSA Category
:returns: A PYBOSSA Category object
"""
try:
res = _pybossa_req('get', 'category', category_id)
if re... | [
"def",
"get_category",
"(",
"category_id",
")",
":",
"try",
":",
"res",
"=",
"_pybossa_req",
"(",
"'get'",
",",
"'category'",
",",
"category_id",
")",
"if",
"res",
".",
"get",
"(",
"'id'",
")",
":",
"return",
"Category",
"(",
"res",
")",
"else",
":",
... | Return a PYBOSSA Category for the category_id.
:param category_id: PYBOSSA Category ID
:type category_id: integer
:rtype: PYBOSSA Category
:returns: A PYBOSSA Category object | [
"Return",
"a",
"PYBOSSA",
"Category",
"for",
"the",
"category_id",
"."
] | python | valid |
codeforamerica/epa_python | epa/pcs/pcs.py | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/epa/pcs/pcs.py#L24-L33 | def admin_penalty(self, column=None, value=None, **kwargs):
"""
An enforcement action that results in levying the permit holder with a
penalty or fine. It is used to track judicial hearing dates, penalty
amounts, and type of administrative penalty order.
>>> PCS().admin_penalty(... | [
"def",
"admin_penalty",
"(",
"self",
",",
"column",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_resolve_call",
"(",
"'PCS_ADMIN_PENALTY_ORDER'",
",",
"column",
",",
"value",
",",
"*",
"*",
"kwargs",... | An enforcement action that results in levying the permit holder with a
penalty or fine. It is used to track judicial hearing dates, penalty
amounts, and type of administrative penalty order.
>>> PCS().admin_penalty('enfor_action_date', '16-MAR-01') | [
"An",
"enforcement",
"action",
"that",
"results",
"in",
"levying",
"the",
"permit",
"holder",
"with",
"a",
"penalty",
"or",
"fine",
".",
"It",
"is",
"used",
"to",
"track",
"judicial",
"hearing",
"dates",
"penalty",
"amounts",
"and",
"type",
"of",
"administra... | python | train |
pandas-dev/pandas | pandas/core/groupby/groupby.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1251-L1324 | def _add_numeric_operations(cls):
"""
Add numeric operations to the GroupBy generically.
"""
def groupby_function(name, alias, npfunc,
numeric_only=True, _convert=False,
min_count=-1):
_local_template = "Compute %(f)... | [
"def",
"_add_numeric_operations",
"(",
"cls",
")",
":",
"def",
"groupby_function",
"(",
"name",
",",
"alias",
",",
"npfunc",
",",
"numeric_only",
"=",
"True",
",",
"_convert",
"=",
"False",
",",
"min_count",
"=",
"-",
"1",
")",
":",
"_local_template",
"=",... | Add numeric operations to the GroupBy generically. | [
"Add",
"numeric",
"operations",
"to",
"the",
"GroupBy",
"generically",
"."
] | python | train |
mehcode/python-saml | saml/signature.py | https://github.com/mehcode/python-saml/blob/33ed62018efa9ec15b551f309429de510fa44321/saml/signature.py#L11-L110 | def sign(xml, stream, password=None):
"""
Sign an XML document with the given private key file. This will add a
<Signature> element to the document.
:param lxml.etree._Element xml: The document to sign
:param file stream: The private key to sign the document with
:param str password: The passwo... | [
"def",
"sign",
"(",
"xml",
",",
"stream",
",",
"password",
"=",
"None",
")",
":",
"# Import xmlsec here to delay initializing the C library in",
"# case we don't need it.",
"import",
"xmlsec",
"# Resolve the SAML/2.0 element in question.",
"from",
"saml",
".",
"schema",
"."... | Sign an XML document with the given private key file. This will add a
<Signature> element to the document.
:param lxml.etree._Element xml: The document to sign
:param file stream: The private key to sign the document with
:param str password: The password used to access the private key
:rtype: Non... | [
"Sign",
"an",
"XML",
"document",
"with",
"the",
"given",
"private",
"key",
"file",
".",
"This",
"will",
"add",
"a",
"<Signature",
">",
"element",
"to",
"the",
"document",
"."
] | python | valid |
CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L864-L870 | def secp256k1():
"""
create the secp256k1 curve
"""
GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
ec = EllipticCurve(GFp, 0, 7)
return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062... | [
"def",
"secp256k1",
"(",
")",
":",
"GFp",
"=",
"FiniteField",
"(",
"2",
"**",
"256",
"-",
"2",
"**",
"32",
"-",
"977",
")",
"# This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F",
"ec",
"=",
"EllipticCurve",
"(",
"GFp",
",",... | create the secp256k1 curve | [
"create",
"the",
"secp256k1",
"curve"
] | python | train |
Projectplace/basepage | basepage/base_page.py | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/base_page.py#L418-L430 | def get_visible_element(self, locator, params=None, timeout=None):
"""
Get element both present AND visible in the DOM.
If timeout is 0 (zero) return WebElement instance or None, else we wait and retry for timeout and raise
TimeoutException should the element not be found.
:par... | [
"def",
"get_visible_element",
"(",
"self",
",",
"locator",
",",
"params",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_present_element",
"(",
"locator",
",",
"params",
",",
"timeout",
",",
"True",
")"
] | Get element both present AND visible in the DOM.
If timeout is 0 (zero) return WebElement instance or None, else we wait and retry for timeout and raise
TimeoutException should the element not be found.
:param locator: locator tuple
:param params: (optional) locator params
:par... | [
"Get",
"element",
"both",
"present",
"AND",
"visible",
"in",
"the",
"DOM",
"."
] | python | train |
svenkreiss/databench | databench/datastore.py | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore.py#L98-L109 | def set(self, key, value):
"""Set a value at key and return a Future.
:rtype: Iterable[tornado.concurrent.Future]
"""
value_encoded = encode(value)
if key in self.data and self.data[key] == value_encoded:
return []
self.data[key] = value_encoded
ret... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"value_encoded",
"=",
"encode",
"(",
"value",
")",
"if",
"key",
"in",
"self",
".",
"data",
"and",
"self",
".",
"data",
"[",
"key",
"]",
"==",
"value_encoded",
":",
"return",
"[",
"]",
... | Set a value at key and return a Future.
:rtype: Iterable[tornado.concurrent.Future] | [
"Set",
"a",
"value",
"at",
"key",
"and",
"return",
"a",
"Future",
"."
] | python | train |
pkkid/python-plexapi | plexapi/library.py | https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/library.py#L423-L426 | def cancelUpdate(self):
""" Cancel update of this Library Section. """
key = '/library/sections/%s/refresh' % self.key
self._server.query(key, method=self._server._session.delete) | [
"def",
"cancelUpdate",
"(",
"self",
")",
":",
"key",
"=",
"'/library/sections/%s/refresh'",
"%",
"self",
".",
"key",
"self",
".",
"_server",
".",
"query",
"(",
"key",
",",
"method",
"=",
"self",
".",
"_server",
".",
"_session",
".",
"delete",
")"
] | Cancel update of this Library Section. | [
"Cancel",
"update",
"of",
"this",
"Library",
"Section",
"."
] | python | train |
saltstack/salt | salt/modules/heat.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/heat.py#L286-L314 | def list_stack(profile=None):
'''
Return a list of available stack (heat stack-list)
profile
Profile to use
CLI Example:
.. code-block:: bash
salt '*' heat.list_stack profile=openstack1
'''
ret = {}
h_client = _auth(profile)
for stack in h_client.stacks.list():
... | [
"def",
"list_stack",
"(",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"h_client",
"=",
"_auth",
"(",
"profile",
")",
"for",
"stack",
"in",
"h_client",
".",
"stacks",
".",
"list",
"(",
")",
":",
"links",
"=",
"{",
"}",
"for",
"link",
"... | Return a list of available stack (heat stack-list)
profile
Profile to use
CLI Example:
.. code-block:: bash
salt '*' heat.list_stack profile=openstack1 | [
"Return",
"a",
"list",
"of",
"available",
"stack",
"(",
"heat",
"stack",
"-",
"list",
")"
] | python | train |
pandas-dev/pandas | pandas/core/ops.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/ops.py#L1628-L1646 | def _align_method_SERIES(left, right, align_asobject=False):
""" align lhs and rhs Series """
# ToDo: Different from _align_method_FRAME, list, tuple and ndarray
# are not coerced here
# because Series has inconsistencies described in #13637
if isinstance(right, ABCSeries):
# avoid repeate... | [
"def",
"_align_method_SERIES",
"(",
"left",
",",
"right",
",",
"align_asobject",
"=",
"False",
")",
":",
"# ToDo: Different from _align_method_FRAME, list, tuple and ndarray",
"# are not coerced here",
"# because Series has inconsistencies described in #13637",
"if",
"isinstance",
... | align lhs and rhs Series | [
"align",
"lhs",
"and",
"rhs",
"Series"
] | python | train |
mukulhase/WebWhatsapp-Wrapper | sample/flask/webapi.py | https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L473-L479 | def create_client():
"""Create a new client driver. The driver is automatically created in
before_request function."""
result = False
if g.client_id in drivers:
result = True
return jsonify({'Success': result}) | [
"def",
"create_client",
"(",
")",
":",
"result",
"=",
"False",
"if",
"g",
".",
"client_id",
"in",
"drivers",
":",
"result",
"=",
"True",
"return",
"jsonify",
"(",
"{",
"'Success'",
":",
"result",
"}",
")"
] | Create a new client driver. The driver is automatically created in
before_request function. | [
"Create",
"a",
"new",
"client",
"driver",
".",
"The",
"driver",
"is",
"automatically",
"created",
"in",
"before_request",
"function",
"."
] | python | train |
StorjOld/pyp2p | pyp2p/rendezvous_client.py | https://github.com/StorjOld/pyp2p/blob/7024208c3af20511496a652ff212f54c420e0464/pyp2p/rendezvous_client.py#L544-L557 | def parse_remote_port(self, reply):
"""
Parses a remote port from a Rendezvous Server's
response.
"""
remote_port = re.findall("^REMOTE (TCP|UDP) ([0-9]+)$", reply)
if not len(remote_port):
remote_port = 0
else:
remote_port = int... | [
"def",
"parse_remote_port",
"(",
"self",
",",
"reply",
")",
":",
"remote_port",
"=",
"re",
".",
"findall",
"(",
"\"^REMOTE (TCP|UDP) ([0-9]+)$\"",
",",
"reply",
")",
"if",
"not",
"len",
"(",
"remote_port",
")",
":",
"remote_port",
"=",
"0",
"else",
":",
"r... | Parses a remote port from a Rendezvous Server's
response. | [
"Parses",
"a",
"remote",
"port",
"from",
"a",
"Rendezvous",
"Server",
"s",
"response",
"."
] | python | train |
HDI-Project/BTB | btb/selection/best.py | https://github.com/HDI-Project/BTB/blob/7f489ebc5591bd0886652ef743098c022d7f7460/btb/selection/best.py#L71-L81 | def compute_rewards(self, scores):
"""Compute the velocity of the best scores
The velocities are the k distances between the k+1 best scores.
"""
k = self.k
m = max(len(scores) - k, 0)
best_scores = sorted(scores)[-k - 1:]
velocities = np.diff(best_scores)
... | [
"def",
"compute_rewards",
"(",
"self",
",",
"scores",
")",
":",
"k",
"=",
"self",
".",
"k",
"m",
"=",
"max",
"(",
"len",
"(",
"scores",
")",
"-",
"k",
",",
"0",
")",
"best_scores",
"=",
"sorted",
"(",
"scores",
")",
"[",
"-",
"k",
"-",
"1",
"... | Compute the velocity of the best scores
The velocities are the k distances between the k+1 best scores. | [
"Compute",
"the",
"velocity",
"of",
"the",
"best",
"scores"
] | python | train |
Unidata/MetPy | metpy/calc/cross_sections.py | https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/calc/cross_sections.py#L221-L258 | def tangential_component(data_x, data_y, index='index'):
r"""Obtain the tangential component of a cross-section of a vector field.
Parameters
----------
data_x : `xarray.DataArray`
The input DataArray of the x-component (in terms of data projection) of the vector
field.
data_y : `xa... | [
"def",
"tangential_component",
"(",
"data_x",
",",
"data_y",
",",
"index",
"=",
"'index'",
")",
":",
"# Get the unit vectors",
"unit_tang",
",",
"_",
"=",
"unit_vectors_from_cross_section",
"(",
"data_x",
",",
"index",
"=",
"index",
")",
"# Take the dot products",
... | r"""Obtain the tangential component of a cross-section of a vector field.
Parameters
----------
data_x : `xarray.DataArray`
The input DataArray of the x-component (in terms of data projection) of the vector
field.
data_y : `xarray.DataArray`
The input DataArray of the y-componen... | [
"r",
"Obtain",
"the",
"tangential",
"component",
"of",
"a",
"cross",
"-",
"section",
"of",
"a",
"vector",
"field",
"."
] | python | train |
google/transitfeed | transitfeed/schedule.py | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L770-L804 | def GenerateDateTripsDeparturesList(self, date_start, date_end):
"""Return a list of (date object, number of trips, number of departures).
The list is generated for dates in the range [date_start, date_end).
Args:
date_start: The first date in the list, a date object
date_end: The first date a... | [
"def",
"GenerateDateTripsDeparturesList",
"(",
"self",
",",
"date_start",
",",
"date_end",
")",
":",
"service_id_to_trips",
"=",
"defaultdict",
"(",
"lambda",
":",
"0",
")",
"service_id_to_departures",
"=",
"defaultdict",
"(",
"lambda",
":",
"0",
")",
"for",
"tr... | Return a list of (date object, number of trips, number of departures).
The list is generated for dates in the range [date_start, date_end).
Args:
date_start: The first date in the list, a date object
date_end: The first date after the list, a date object
Returns:
a list of (date object,... | [
"Return",
"a",
"list",
"of",
"(",
"date",
"object",
"number",
"of",
"trips",
"number",
"of",
"departures",
")",
"."
] | python | train |
10gen/mongo-orchestration | mongo_orchestration/servers.py | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/servers.py#L525-L532 | def remove(self, server_id):
"""remove server and data stuff
Args:
server_id - server identity
"""
server = self._storage.pop(server_id)
server.stop()
server.cleanup() | [
"def",
"remove",
"(",
"self",
",",
"server_id",
")",
":",
"server",
"=",
"self",
".",
"_storage",
".",
"pop",
"(",
"server_id",
")",
"server",
".",
"stop",
"(",
")",
"server",
".",
"cleanup",
"(",
")"
] | remove server and data stuff
Args:
server_id - server identity | [
"remove",
"server",
"and",
"data",
"stuff",
"Args",
":",
"server_id",
"-",
"server",
"identity"
] | python | train |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L58-L68 | def add(self, *args):
"""Adds new functions to the end of the pipeline.
Functions must accept three arguments:
- Token: A lunr.Token object which will be updated
- i: The index of the token in the set
- tokens: A list of tokens representing the set
"""
for fn in ... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"fn",
"in",
"args",
":",
"self",
".",
"warn_if_function_not_registered",
"(",
"fn",
")",
"self",
".",
"_stack",
".",
"append",
"(",
"fn",
")"
] | Adds new functions to the end of the pipeline.
Functions must accept three arguments:
- Token: A lunr.Token object which will be updated
- i: The index of the token in the set
- tokens: A list of tokens representing the set | [
"Adds",
"new",
"functions",
"to",
"the",
"end",
"of",
"the",
"pipeline",
"."
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/conventions/crud.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/conventions/crud.py#L139-L171 | def configure_updatebatch(self, ns, definition):
"""
Register an update batch endpoint.
The definition's func should be an update function, which must:
- accept kwargs for the request and path data
- return a new item
:param ns: the namespace
:param definition: ... | [
"def",
"configure_updatebatch",
"(",
"self",
",",
"ns",
",",
"definition",
")",
":",
"operation",
"=",
"Operation",
".",
"UpdateBatch",
"@",
"self",
".",
"add_route",
"(",
"ns",
".",
"collection_path",
",",
"operation",
",",
"ns",
")",
"@",
"request",
"(",... | Register an update batch endpoint.
The definition's func should be an update function, which must:
- accept kwargs for the request and path data
- return a new item
:param ns: the namespace
:param definition: the endpoint definition | [
"Register",
"an",
"update",
"batch",
"endpoint",
"."
] | python | train |
mattupstate/cubric | cubric/providers/amazon.py | https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/providers/amazon.py#L11-L55 | def create_server():
"""Creates an EC2 Server"""
try:
import boto
except ImportError:
sys.exit("boto library required for creating servers with Amazon.")
print(green("Creating EC2 server"))
conn = boto.connect_ec2(
get_or_prompt('ec2_key', 'API Key'),
get_or_prompt... | [
"def",
"create_server",
"(",
")",
":",
"try",
":",
"import",
"boto",
"except",
"ImportError",
":",
"sys",
".",
"exit",
"(",
"\"boto library required for creating servers with Amazon.\"",
")",
"print",
"(",
"green",
"(",
"\"Creating EC2 server\"",
")",
")",
"conn",
... | Creates an EC2 Server | [
"Creates",
"an",
"EC2",
"Server"
] | python | train |
chrisjsewell/jsonextended | jsonextended/ejson.py | https://github.com/chrisjsewell/jsonextended/blob/c3a7a880cc09789b3c61204265dcbb127be76c8a/jsonextended/ejson.py#L137-L211 | def jkeys(jfile, key_path=None, in_memory=True, ignore_prefix=('.', '_')):
""" get keys for initial json level, or at level after following key_path
Parameters
----------
jfile : str, file_like or path_like
if str, must be existing file or folder,
if file_like, must have 'read' method
... | [
"def",
"jkeys",
"(",
"jfile",
",",
"key_path",
"=",
"None",
",",
"in_memory",
"=",
"True",
",",
"ignore_prefix",
"=",
"(",
"'.'",
",",
"'_'",
")",
")",
":",
"key_path",
"=",
"[",
"]",
"if",
"key_path",
"is",
"None",
"else",
"key_path",
"def",
"eval_f... | get keys for initial json level, or at level after following key_path
Parameters
----------
jfile : str, file_like or path_like
if str, must be existing file or folder,
if file_like, must have 'read' method
if path_like, must have 'iterdir' method (see pathlib.Path)
key_path : l... | [
"get",
"keys",
"for",
"initial",
"json",
"level",
"or",
"at",
"level",
"after",
"following",
"key_path"
] | python | train |
VingtCinq/python-resize-image | resizeimage/resizeimage.py | https://github.com/VingtCinq/python-resize-image/blob/a4e645792ef30c5fcc558df6da6de18b1ecb95ea/resizeimage/resizeimage.py#L78-L95 | def resize_cover(image, size, resample=Image.LANCZOS):
"""
Resize image according to size.
image: a Pillow image instance
size: a list of two integers [width, height]
"""
img_format = image.format
img = image.copy()
img_size = img.size
ratio = max(size[0] / img_size[0], si... | [
"def",
"resize_cover",
"(",
"image",
",",
"size",
",",
"resample",
"=",
"Image",
".",
"LANCZOS",
")",
":",
"img_format",
"=",
"image",
".",
"format",
"img",
"=",
"image",
".",
"copy",
"(",
")",
"img_size",
"=",
"img",
".",
"size",
"ratio",
"=",
"max"... | Resize image according to size.
image: a Pillow image instance
size: a list of two integers [width, height] | [
"Resize",
"image",
"according",
"to",
"size",
".",
"image",
":",
"a",
"Pillow",
"image",
"instance",
"size",
":",
"a",
"list",
"of",
"two",
"integers",
"[",
"width",
"height",
"]"
] | python | test |
bxlab/bx-python | lib/bx_extras/pyparsing.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L1019-L1052 | def parseString( self, instring, parseAll=False ):
"""Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
If you want the grammar to require that the entire input string be
su... | [
"def",
"parseString",
"(",
"self",
",",
"instring",
",",
"parseAll",
"=",
"False",
")",
":",
"ParserElement",
".",
"resetCache",
"(",
")",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"#~ self.saveAsList = True",
"for",
... | Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
If you want the grammar to require that the entire input string be
successfully parsed, then set parseAll to True (equivalent to en... | [
"Execute",
"the",
"parse",
"expression",
"with",
"the",
"given",
"string",
".",
"This",
"is",
"the",
"main",
"interface",
"to",
"the",
"client",
"code",
"once",
"the",
"complete",
"expression",
"has",
"been",
"built",
"."
] | python | train |
alaudet/hcsr04sensor | recipes/imperial_distance.py | https://github.com/alaudet/hcsr04sensor/blob/74caf5c825e3f700c9daa9985542c061ae04b002/recipes/imperial_distance.py#L6-L31 | def main():
'''Calculate the distance of an object in inches using a HCSR04 sensor
and a Raspberry Pi'''
trig_pin = 17
echo_pin = 27
# Default values
# unit = 'metric'
# temperature = 20
# round_to = 1
# Create a distance reading with the hcsr04 sensor module
# and overide ... | [
"def",
"main",
"(",
")",
":",
"trig_pin",
"=",
"17",
"echo_pin",
"=",
"27",
"# Default values",
"# unit = 'metric'",
"# temperature = 20",
"# round_to = 1",
"# Create a distance reading with the hcsr04 sensor module",
"# and overide the default values for temp, unit and rounding)",
... | Calculate the distance of an object in inches using a HCSR04 sensor
and a Raspberry Pi | [
"Calculate",
"the",
"distance",
"of",
"an",
"object",
"in",
"inches",
"using",
"a",
"HCSR04",
"sensor",
"and",
"a",
"Raspberry",
"Pi"
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/audit.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/audit.py#L290-L306 | def post_process_response_headers(self, dct):
"""
Rewrite X-<>-Id header into audit logs.
"""
if not self.response_headers:
return
for key, value in self.response_headers.items():
parts = key.split("-")
if len(parts) != 3:
cont... | [
"def",
"post_process_response_headers",
"(",
"self",
",",
"dct",
")",
":",
"if",
"not",
"self",
".",
"response_headers",
":",
"return",
"for",
"key",
",",
"value",
"in",
"self",
".",
"response_headers",
".",
"items",
"(",
")",
":",
"parts",
"=",
"key",
"... | Rewrite X-<>-Id header into audit logs. | [
"Rewrite",
"X",
"-",
"<",
">",
"-",
"Id",
"header",
"into",
"audit",
"logs",
"."
] | python | train |
gwastro/pycbc | pycbc/inference/sampler/base_mcmc.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/sampler/base_mcmc.py#L828-L874 | def compute_acl(cls, filename, start_index=None, end_index=None,
min_nsamples=10):
"""Computes the autocorrleation length for all model params in the
given file.
Parameter values are averaged over all walkers at each iteration.
The ACL is then calculated over the ave... | [
"def",
"compute_acl",
"(",
"cls",
",",
"filename",
",",
"start_index",
"=",
"None",
",",
"end_index",
"=",
"None",
",",
"min_nsamples",
"=",
"10",
")",
":",
"acls",
"=",
"{",
"}",
"with",
"cls",
".",
"_io",
"(",
"filename",
",",
"'r'",
")",
"as",
"... | Computes the autocorrleation length for all model params in the
given file.
Parameter values are averaged over all walkers at each iteration.
The ACL is then calculated over the averaged chain. If an ACL cannot
be calculated because there are not enough samples, it will be set
t... | [
"Computes",
"the",
"autocorrleation",
"length",
"for",
"all",
"model",
"params",
"in",
"the",
"given",
"file",
"."
] | python | train |
jilljenn/tryalgo | tryalgo/graph.py | https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/graph.py#L155-L173 | def tree_adj_to_prec(graph, root=0):
"""Transforms a tree given as adjacency list into predecessor table form.
if graph is not a tree: will return a DFS spanning tree
:param graph: directed graph in listlist or listdict format
:returns: tree in predecessor table representation
:complexity: linear
... | [
"def",
"tree_adj_to_prec",
"(",
"graph",
",",
"root",
"=",
"0",
")",
":",
"prec",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"graph",
")",
"prec",
"[",
"root",
"]",
"=",
"root",
"# mark to visit root only once",
"to_visit",
"=",
"[",
"root",
"]",
"while",... | Transforms a tree given as adjacency list into predecessor table form.
if graph is not a tree: will return a DFS spanning tree
:param graph: directed graph in listlist or listdict format
:returns: tree in predecessor table representation
:complexity: linear | [
"Transforms",
"a",
"tree",
"given",
"as",
"adjacency",
"list",
"into",
"predecessor",
"table",
"form",
".",
"if",
"graph",
"is",
"not",
"a",
"tree",
":",
"will",
"return",
"a",
"DFS",
"spanning",
"tree"
] | python | train |
StackStorm/pybind | pybind/slxos/v17r_2_00/keychain/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_2_00/keychain/__init__.py#L94-L120 | def _set_name_of_keychain(self, v, load=False):
"""
Setter method for name_of_keychain, mapped from YANG variable /keychain/name_of_keychain (string)
If this variable is read-only (config: false) in the
source YANG file, then _set_name_of_keychain is considered as a private
method. Backends looking ... | [
"def",
"_set_name_of_keychain",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"parent",
"=",
"getattr",
"(",
"self",
",",
"\"_parent\"",
",",
"None",
")",
"if",
"parent",
"is",
"not",
"None",
"and",
"load",
"is",
"False",
":",
"raise",
... | Setter method for name_of_keychain, mapped from YANG variable /keychain/name_of_keychain (string)
If this variable is read-only (config: false) in the
source YANG file, then _set_name_of_keychain is considered as a private
method. Backends looking to populate this variable should
do so via calling thisO... | [
"Setter",
"method",
"for",
"name_of_keychain",
"mapped",
"from",
"YANG",
"variable",
"/",
"keychain",
"/",
"name_of_keychain",
"(",
"string",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
... | python | train |
saltstack/salt | salt/platform/win.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/platform/win.py#L1062-L1115 | def enumerate_tokens(sid=None, session_id=None, privs=None):
'''
Enumerate tokens from any existing processes that can be accessed.
Optionally filter by sid.
'''
for p in psutil.process_iter():
if p.pid == 0:
continue
try:
ph = win32api.OpenProcess(win32con.PR... | [
"def",
"enumerate_tokens",
"(",
"sid",
"=",
"None",
",",
"session_id",
"=",
"None",
",",
"privs",
"=",
"None",
")",
":",
"for",
"p",
"in",
"psutil",
".",
"process_iter",
"(",
")",
":",
"if",
"p",
".",
"pid",
"==",
"0",
":",
"continue",
"try",
":",
... | Enumerate tokens from any existing processes that can be accessed.
Optionally filter by sid. | [
"Enumerate",
"tokens",
"from",
"any",
"existing",
"processes",
"that",
"can",
"be",
"accessed",
".",
"Optionally",
"filter",
"by",
"sid",
"."
] | python | train |
openpermissions/koi | koi/keygen.py | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/keygen.py#L92-L104 | def gen_cert_request(filepath, keyfile, config, silent=False):
"""
generate certificate request
:param filepath: file path to the certificate request
:param keyfile: file path to the private key
:param silent: whether to suppress output
"""
message = 'generate ssl certificate request'
cm... | [
"def",
"gen_cert_request",
"(",
"filepath",
",",
"keyfile",
",",
"config",
",",
"silent",
"=",
"False",
")",
":",
"message",
"=",
"'generate ssl certificate request'",
"cmd",
"=",
"(",
"'openssl req -new -key {} -out {} -subj \"{}\"'",
"' -extensions v3_req -config {}'",
... | generate certificate request
:param filepath: file path to the certificate request
:param keyfile: file path to the private key
:param silent: whether to suppress output | [
"generate",
"certificate",
"request",
":",
"param",
"filepath",
":",
"file",
"path",
"to",
"the",
"certificate",
"request",
":",
"param",
"keyfile",
":",
"file",
"path",
"to",
"the",
"private",
"key",
":",
"param",
"silent",
":",
"whether",
"to",
"suppress",... | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L9688-L9707 | def sensor_offsets_encode(self, mag_ofs_x, mag_ofs_y, mag_ofs_z, mag_declination, raw_press, raw_temp, gyro_cal_x, gyro_cal_y, gyro_cal_z, accel_cal_x, accel_cal_y, accel_cal_z):
'''
Offsets and calibrations values for hardware sensors. This makes it
easier to debug the c... | [
"def",
"sensor_offsets_encode",
"(",
"self",
",",
"mag_ofs_x",
",",
"mag_ofs_y",
",",
"mag_ofs_z",
",",
"mag_declination",
",",
"raw_press",
",",
"raw_temp",
",",
"gyro_cal_x",
",",
"gyro_cal_y",
",",
"gyro_cal_z",
",",
"accel_cal_x",
",",
"accel_cal_y",
",",
"a... | Offsets and calibrations values for hardware sensors. This makes it
easier to debug the calibration process.
mag_ofs_x : magnetometer X offset (int16_t)
mag_ofs_y : magnetometer Y offset (int16_t)
mag_ofs_z ... | [
"Offsets",
"and",
"calibrations",
"values",
"for",
"hardware",
"sensors",
".",
"This",
"makes",
"it",
"easier",
"to",
"debug",
"the",
"calibration",
"process",
"."
] | python | train |
ejeschke/ginga | ginga/mockw/ImageViewMock.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/mockw/ImageViewMock.py#L75-L89 | def render_image(self, rgbobj, dst_x, dst_y):
"""Render the image represented by (rgbobj) at dst_x, dst_y
in the offscreen pixmap.
"""
self.logger.debug("redraw pixmap=%s" % (self.pixmap))
if self.pixmap is None:
return
self.logger.debug("drawing to pixmap")
... | [
"def",
"render_image",
"(",
"self",
",",
"rgbobj",
",",
"dst_x",
",",
"dst_y",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"redraw pixmap=%s\"",
"%",
"(",
"self",
".",
"pixmap",
")",
")",
"if",
"self",
".",
"pixmap",
"is",
"None",
":",
"ret... | Render the image represented by (rgbobj) at dst_x, dst_y
in the offscreen pixmap. | [
"Render",
"the",
"image",
"represented",
"by",
"(",
"rgbobj",
")",
"at",
"dst_x",
"dst_y",
"in",
"the",
"offscreen",
"pixmap",
"."
] | python | train |
androguard/androguard | androguard/core/bytecodes/dvm.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L3345-L3353 | def get_methods(self):
"""
Return direct and virtual methods
:rtype: a list of :class:`EncodedMethod` objects
"""
return [x
for x in self.direct_methods] + [x
for x in self.virtual_methods] | [
"def",
"get_methods",
"(",
"self",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"direct_methods",
"]",
"+",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"virtual_methods",
"]"
] | Return direct and virtual methods
:rtype: a list of :class:`EncodedMethod` objects | [
"Return",
"direct",
"and",
"virtual",
"methods"
] | python | train |
mlperf/training | reinforcement/tensorflow/minigo/oneoffs/oneoff_utils.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/oneoffs/oneoff_utils.py#L34-L41 | def parse_sgf_to_examples(sgf_path):
"""Return supervised examples from positions
NOTE: last move is not played because no p.next_move after.
"""
return zip(*[(p.position, p.next_move, p.result)
for p in sgf_wrapper.replay_sgf_file(sgf_path)]) | [
"def",
"parse_sgf_to_examples",
"(",
"sgf_path",
")",
":",
"return",
"zip",
"(",
"*",
"[",
"(",
"p",
".",
"position",
",",
"p",
".",
"next_move",
",",
"p",
".",
"result",
")",
"for",
"p",
"in",
"sgf_wrapper",
".",
"replay_sgf_file",
"(",
"sgf_path",
")... | Return supervised examples from positions
NOTE: last move is not played because no p.next_move after. | [
"Return",
"supervised",
"examples",
"from",
"positions"
] | python | train |
equinor/segyio | python/segyio/trace.py | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/trace.py#L253-L266 | def raw(self):
"""
An eager version of Trace
Returns
-------
raw : RawTrace
"""
return RawTrace(self.filehandle,
self.dtype,
len(self),
self.shape,
self.readonly,
... | [
"def",
"raw",
"(",
"self",
")",
":",
"return",
"RawTrace",
"(",
"self",
".",
"filehandle",
",",
"self",
".",
"dtype",
",",
"len",
"(",
"self",
")",
",",
"self",
".",
"shape",
",",
"self",
".",
"readonly",
",",
")"
] | An eager version of Trace
Returns
-------
raw : RawTrace | [
"An",
"eager",
"version",
"of",
"Trace"
] | python | train |
4degrees/riffle | source/riffle/icon_factory.py | https://github.com/4degrees/riffle/blob/e5a0d908df8c93ff1ee7abdda8875fd1667df53d/source/riffle/icon_factory.py#L25-L54 | def icon(self, specification):
'''Return appropriate icon for *specification*.
*specification* should be either:
* An instance of :py:class:`riffle.model.Item`
* One of the defined icon types (:py:class:`IconType`)
'''
if isinstance(specification, riffle.model.... | [
"def",
"icon",
"(",
"self",
",",
"specification",
")",
":",
"if",
"isinstance",
"(",
"specification",
",",
"riffle",
".",
"model",
".",
"Item",
")",
":",
"specification",
"=",
"self",
".",
"type",
"(",
"specification",
")",
"icon",
"=",
"None",
"if",
"... | Return appropriate icon for *specification*.
*specification* should be either:
* An instance of :py:class:`riffle.model.Item`
* One of the defined icon types (:py:class:`IconType`) | [
"Return",
"appropriate",
"icon",
"for",
"*",
"specification",
"*",
"."
] | python | test |
librosa/librosa | librosa/core/time_frequency.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L1014-L1067 | def times_like(X, sr=22050, hop_length=512, n_fft=None, axis=-1):
"""Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X... | [
"def",
"times_like",
"(",
"X",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"n_fft",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"samples",
"=",
"samples_like",
"(",
"X",
",",
"hop_length",
"=",
"hop_length",
",",
"n_fft",
"=... | Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X represents the number of frames.
sr : number > 0 [scalar]
a... | [
"Return",
"an",
"array",
"of",
"time",
"values",
"to",
"match",
"the",
"time",
"axis",
"from",
"a",
"feature",
"matrix",
"."
] | python | test |
feliphebueno/Rinzler | rinzler/core/route_mapping.py | https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L72-L82 | def __set_route(self, type_route, route):
"""
Sets the given type_route and route to the route mapping
:rtype: object
"""
if type_route in self.__routes:
if not self.verify_route_already_bound(type_route, route):
self.__routes[type_route].append(route)... | [
"def",
"__set_route",
"(",
"self",
",",
"type_route",
",",
"route",
")",
":",
"if",
"type_route",
"in",
"self",
".",
"__routes",
":",
"if",
"not",
"self",
".",
"verify_route_already_bound",
"(",
"type_route",
",",
"route",
")",
":",
"self",
".",
"__routes"... | Sets the given type_route and route to the route mapping
:rtype: object | [
"Sets",
"the",
"given",
"type_route",
"and",
"route",
"to",
"the",
"route",
"mapping",
":",
"rtype",
":",
"object"
] | python | train |
kislyuk/aegea | aegea/packages/github3/pulls.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/pulls.py#L414-L427 | def reply(self, body):
"""Reply to this review comment with a new review comment.
:param str body: The text of the comment.
:returns: The created review comment.
:rtype: :class:`~github3.pulls.ReviewComment`
"""
url = self._build_url('comments', base_url=self.pull_reques... | [
"def",
"reply",
"(",
"self",
",",
"body",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'comments'",
",",
"base_url",
"=",
"self",
".",
"pull_request_url",
")",
"index",
"=",
"self",
".",
"_api",
".",
"rfind",
"(",
"'/'",
")",
"+",
"1",
"i... | Reply to this review comment with a new review comment.
:param str body: The text of the comment.
:returns: The created review comment.
:rtype: :class:`~github3.pulls.ReviewComment` | [
"Reply",
"to",
"this",
"review",
"comment",
"with",
"a",
"new",
"review",
"comment",
"."
] | python | train |
IvanMalison/okcupyd | okcupyd/util/__init__.py | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/util/__init__.py#L54-L62 | def bust_self(self, obj):
"""Remove the value that is being stored on `obj` for this
:class:`.cached_property`
object.
:param obj: The instance on which to bust the cache.
"""
if self.func.__name__ in obj.__dict__:
delattr(obj, self.func.__name__) | [
"def",
"bust_self",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"func",
".",
"__name__",
"in",
"obj",
".",
"__dict__",
":",
"delattr",
"(",
"obj",
",",
"self",
".",
"func",
".",
"__name__",
")"
] | Remove the value that is being stored on `obj` for this
:class:`.cached_property`
object.
:param obj: The instance on which to bust the cache. | [
"Remove",
"the",
"value",
"that",
"is",
"being",
"stored",
"on",
"obj",
"for",
"this",
":",
"class",
":",
".",
"cached_property",
"object",
"."
] | python | train |
crossbario/txaio | txaio/__init__.py | https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/__init__.py#L130-L140 | def _use_framework(module):
"""
Internal helper, to set this modules methods to a specified
framework helper-methods.
"""
import txaio
for method_name in __all__:
if method_name in ['use_twisted', 'use_asyncio']:
continue
setattr(txaio, method_name,
ge... | [
"def",
"_use_framework",
"(",
"module",
")",
":",
"import",
"txaio",
"for",
"method_name",
"in",
"__all__",
":",
"if",
"method_name",
"in",
"[",
"'use_twisted'",
",",
"'use_asyncio'",
"]",
":",
"continue",
"setattr",
"(",
"txaio",
",",
"method_name",
",",
"g... | Internal helper, to set this modules methods to a specified
framework helper-methods. | [
"Internal",
"helper",
"to",
"set",
"this",
"modules",
"methods",
"to",
"a",
"specified",
"framework",
"helper",
"-",
"methods",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.