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 |
|---|---|---|---|---|---|---|---|---|
python-diamond/Diamond | src/collectors/postgres/postgres.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/postgres/postgres.py#L74-L126 | def collect(self):
"""
Do pre-flight checks, get list of db names, collect metrics, publish
"""
if psycopg2 is None:
self.log.error('Unable to import module psycopg2')
return {}
# Get list of databases
dbs = self._get_db_names()
if len(dbs... | [
"def",
"collect",
"(",
"self",
")",
":",
"if",
"psycopg2",
"is",
"None",
":",
"self",
".",
"log",
".",
"error",
"(",
"'Unable to import module psycopg2'",
")",
"return",
"{",
"}",
"# Get list of databases",
"dbs",
"=",
"self",
".",
"_get_db_names",
"(",
")",... | Do pre-flight checks, get list of db names, collect metrics, publish | [
"Do",
"pre",
"-",
"flight",
"checks",
"get",
"list",
"of",
"db",
"names",
"collect",
"metrics",
"publish"
] | python | train |
flyte/upnpclient | upnpclient/soap.py | https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/soap.py#L62-L72 | def _remove_extraneous_xml_declarations(xml_str):
"""
Sometimes devices return XML with more than one XML declaration in, such as when returning
their own XML config files. This removes the extra ones and preserves the first one.
"""
xml_declaration = ''
if xml_str.starts... | [
"def",
"_remove_extraneous_xml_declarations",
"(",
"xml_str",
")",
":",
"xml_declaration",
"=",
"''",
"if",
"xml_str",
".",
"startswith",
"(",
"'<?xml'",
")",
":",
"xml_declaration",
",",
"xml_str",
"=",
"xml_str",
".",
"split",
"(",
"'?>'",
",",
"maxsplit",
"... | Sometimes devices return XML with more than one XML declaration in, such as when returning
their own XML config files. This removes the extra ones and preserves the first one. | [
"Sometimes",
"devices",
"return",
"XML",
"with",
"more",
"than",
"one",
"XML",
"declaration",
"in",
"such",
"as",
"when",
"returning",
"their",
"own",
"XML",
"config",
"files",
".",
"This",
"removes",
"the",
"extra",
"ones",
"and",
"preserves",
"the",
"first... | python | train |
jplusplus/statscraper | statscraper/scrapers/work_injury_scraper.py | https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/scrapers/work_injury_scraper.py#L135-L154 | def _fetch_itemslist(self, item):
""" We define two collection:
- Number of work injuries ("Arbetsolycka")
- Number of workrelated diseases ("Arbetssjukdom")
Each contains four datasets:
- Per municipality and year
- Per county and year
- Per municipality and mont... | [
"def",
"_fetch_itemslist",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
".",
"is_root",
":",
"for",
"c",
"in",
"[",
"\"Arbetsolycka\"",
",",
"\"Arbetssjukdom\"",
"]",
":",
"yield",
"Collection",
"(",
"c",
",",
"blob",
"=",
"(",
"c",
",",
"None",
... | We define two collection:
- Number of work injuries ("Arbetsolycka")
- Number of workrelated diseases ("Arbetssjukdom")
Each contains four datasets:
- Per municipality and year
- Per county and year
- Per municipality and month
- Per municipality and year | [
"We",
"define",
"two",
"collection",
":",
"-",
"Number",
"of",
"work",
"injuries",
"(",
"Arbetsolycka",
")",
"-",
"Number",
"of",
"workrelated",
"diseases",
"(",
"Arbetssjukdom",
")",
"Each",
"contains",
"four",
"datasets",
":",
"-",
"Per",
"municipality",
"... | python | train |
offu/WeRoBot | werobot/pay.py | https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/pay.py#L168-L204 | def pay_order_query(self, out_trade_no):
"""
查询订单状态
一般用于无法确定 订单状态时候补偿
:param out_trade_no: 本地订单号
:return: 订单信息dict
"""
package = {
'partner': self.pay_partner_id,
'out_trade_no': out_trade_no,
}
_package = package.items()... | [
"def",
"pay_order_query",
"(",
"self",
",",
"out_trade_no",
")",
":",
"package",
"=",
"{",
"'partner'",
":",
"self",
".",
"pay_partner_id",
",",
"'out_trade_no'",
":",
"out_trade_no",
",",
"}",
"_package",
"=",
"package",
".",
"items",
"(",
")",
"_package",
... | 查询订单状态
一般用于无法确定 订单状态时候补偿
:param out_trade_no: 本地订单号
:return: 订单信息dict | [
"查询订单状态",
"一般用于无法确定",
"订单状态时候补偿"
] | python | train |
PyThaiNLP/pythainlp | pythainlp/ulmfit/__init__.py | https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/ulmfit/__init__.py#L42-L52 | def _get_path(fname: str) -> str:
"""
:meth: download get path of file from pythainlp-corpus
:param str fname: file name
:return: path to downloaded file
"""
path = get_corpus_path(fname)
if not path:
download(fname)
path = get_corpus_path(fname)
return path | [
"def",
"_get_path",
"(",
"fname",
":",
"str",
")",
"->",
"str",
":",
"path",
"=",
"get_corpus_path",
"(",
"fname",
")",
"if",
"not",
"path",
":",
"download",
"(",
"fname",
")",
"path",
"=",
"get_corpus_path",
"(",
"fname",
")",
"return",
"path"
] | :meth: download get path of file from pythainlp-corpus
:param str fname: file name
:return: path to downloaded file | [
":",
"meth",
":",
"download",
"get",
"path",
"of",
"file",
"from",
"pythainlp",
"-",
"corpus",
":",
"param",
"str",
"fname",
":",
"file",
"name",
":",
"return",
":",
"path",
"to",
"downloaded",
"file"
] | python | train |
aleju/imgaug | imgaug/augmentables/polys.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/polys.py#L1024-L1045 | def on(self, image):
"""
Project polygons from one image to a new one.
Parameters
----------
image : ndarray or tuple of int
New image onto which the polygons are to be projected.
May also simply be that new image's shape tuple.
Returns
-... | [
"def",
"on",
"(",
"self",
",",
"image",
")",
":",
"shape",
"=",
"normalize_shape",
"(",
"image",
")",
"if",
"shape",
"[",
"0",
":",
"2",
"]",
"==",
"self",
".",
"shape",
"[",
"0",
":",
"2",
"]",
":",
"return",
"self",
".",
"deepcopy",
"(",
")",... | Project polygons from one image to a new one.
Parameters
----------
image : ndarray or tuple of int
New image onto which the polygons are to be projected.
May also simply be that new image's shape tuple.
Returns
-------
imgaug.PolygonsOnImage
... | [
"Project",
"polygons",
"from",
"one",
"image",
"to",
"a",
"new",
"one",
"."
] | python | valid |
BD2KGenomics/protect | src/protect/mutation_calling/muse.py | https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/muse.py#L63-L101 | def run_muse(job, tumor_bam, normal_bam, univ_options, muse_options):
"""
Spawn a MuSE job for each chromosome on the DNA bams.
:param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq
:param dict normal_bam: Dict of bam and bai for normal DNA-Seq
:param dict univ_options: Dict of universal opt... | [
"def",
"run_muse",
"(",
"job",
",",
"tumor_bam",
",",
"normal_bam",
",",
"univ_options",
",",
"muse_options",
")",
":",
"# Get a list of chromosomes to handle",
"if",
"muse_options",
"[",
"'chromosomes'",
"]",
":",
"chromosomes",
"=",
"muse_options",
"[",
"'chromoso... | Spawn a MuSE job for each chromosome on the DNA bams.
:param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq
:param dict normal_bam: Dict of bam and bai for normal DNA-Seq
:param dict univ_options: Dict of universal options used by almost all tools
:param dict muse_options: Options specific to Mu... | [
"Spawn",
"a",
"MuSE",
"job",
"for",
"each",
"chromosome",
"on",
"the",
"DNA",
"bams",
"."
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L5100-L5117 | def ServiceWorker_stopWorker(self, versionId):
"""
Function path: ServiceWorker.stopWorker
Domain: ServiceWorker
Method name: stopWorker
Parameters:
Required arguments:
'versionId' (type: string) -> No description
No return value.
"""
assert isinstance(versionId, (str,)
), "Argu... | [
"def",
"ServiceWorker_stopWorker",
"(",
"self",
",",
"versionId",
")",
":",
"assert",
"isinstance",
"(",
"versionId",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'versionId' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"versionId",
")",
... | Function path: ServiceWorker.stopWorker
Domain: ServiceWorker
Method name: stopWorker
Parameters:
Required arguments:
'versionId' (type: string) -> No description
No return value. | [
"Function",
"path",
":",
"ServiceWorker",
".",
"stopWorker",
"Domain",
":",
"ServiceWorker",
"Method",
"name",
":",
"stopWorker",
"Parameters",
":",
"Required",
"arguments",
":",
"versionId",
"(",
"type",
":",
"string",
")",
"-",
">",
"No",
"description",
"No"... | python | train |
openstack/horizon | openstack_auth/views.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L284-L353 | def switch_keystone_provider(request, keystone_provider=None,
redirect_field_name=auth.REDIRECT_FIELD_NAME):
"""Switches the user's keystone provider using K2K Federation
If keystone_provider is given then we switch the user to
the keystone provider using K2K federation. Otherw... | [
"def",
"switch_keystone_provider",
"(",
"request",
",",
"keystone_provider",
"=",
"None",
",",
"redirect_field_name",
"=",
"auth",
".",
"REDIRECT_FIELD_NAME",
")",
":",
"base_token",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'k2k_base_unscoped_token'",
",",
... | Switches the user's keystone provider using K2K Federation
If keystone_provider is given then we switch the user to
the keystone provider using K2K federation. Otherwise if keystone_provider
is None then we switch the user back to the Identity Provider Keystone
which a non federated token auth will be ... | [
"Switches",
"the",
"user",
"s",
"keystone",
"provider",
"using",
"K2K",
"Federation"
] | python | train |
teepark/junction | junction/hub.py | https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/hub.py#L149-L180 | def publish(self, service, routing_id, method, args=None, kwargs=None,
broadcast=False, udp=False):
'''Send a 1-way message
:param service: the service name (the routing top level)
:type service: anything hash-able
:param int routing_id:
the id used for routing w... | [
"def",
"publish",
"(",
"self",
",",
"service",
",",
"routing_id",
",",
"method",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"broadcast",
"=",
"False",
",",
"udp",
"=",
"False",
")",
":",
"if",
"udp",
":",
"func",
"=",
"self",
".",
... | Send a 1-way message
:param service: the service name (the routing top level)
:type service: anything hash-able
:param int routing_id:
the id used for routing within the registered handlers of the
service
:param string method: the method name to call
:par... | [
"Send",
"a",
"1",
"-",
"way",
"message"
] | python | train |
jeffknupp/sandman | sandman/sandman.py | https://github.com/jeffknupp/sandman/blob/253ea4d15cbccd9f0016d66fedd7478614cc0b2f/sandman/sandman.py#L88-L103 | def _single_resource_json_response(resource, depth=0):
"""Return the JSON representation of *resource*.
:param resource: :class:`sandman.model.Model` to render
:type resource: :class:`sandman.model.Model`
:rtype: :class:`flask.Response`
"""
links = resource.links()
response = jsonify(**res... | [
"def",
"_single_resource_json_response",
"(",
"resource",
",",
"depth",
"=",
"0",
")",
":",
"links",
"=",
"resource",
".",
"links",
"(",
")",
"response",
"=",
"jsonify",
"(",
"*",
"*",
"resource",
".",
"as_dict",
"(",
"depth",
")",
")",
"response",
".",
... | Return the JSON representation of *resource*.
:param resource: :class:`sandman.model.Model` to render
:type resource: :class:`sandman.model.Model`
:rtype: :class:`flask.Response` | [
"Return",
"the",
"JSON",
"representation",
"of",
"*",
"resource",
"*",
"."
] | python | train |
biocore/burrito-fillings | bfillings/usearch.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/usearch.py#L1153-L1476 | def usearch_qf(
fasta_filepath,
refseqs_fp=None,
output_dir=None,
percent_id=0.97,
percent_id_err=0.97,
minsize=4,
abundance_skew=2.0,
db_filepath=None,
rev=False,
label_prefix="",
label_suffix="",
retain_label_as_comment=False,
count_start=0,
perc_id_blast=0.97,
... | [
"def",
"usearch_qf",
"(",
"fasta_filepath",
",",
"refseqs_fp",
"=",
"None",
",",
"output_dir",
"=",
"None",
",",
"percent_id",
"=",
"0.97",
",",
"percent_id_err",
"=",
"0.97",
",",
"minsize",
"=",
"4",
",",
"abundance_skew",
"=",
"2.0",
",",
"db_filepath",
... | Main convenience wrapper for using usearch to filter/cluster seqs
The complete 'usearch_qf' process is a multistep process with many calls
to usearch with various parameters. It is likely to change from the
original implementation. A lot.
fasta_filepath = fasta filepath to filtering/clustering (e.g.... | [
"Main",
"convenience",
"wrapper",
"for",
"using",
"usearch",
"to",
"filter",
"/",
"cluster",
"seqs"
] | python | train |
gesellkammer/sndfileio | sndfileio/sndfileio.py | https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/sndfileio.py#L298-L322 | def asmono(samples:np.ndarray, channel:Union[int, str]=0) -> np.ndarray:
"""
convert samples to mono if they are not mono already.
The returned array will always have the shape (numframes,)
channel: the channel number to use, or 'mix' to mix-down
all channels
"""
if numchannels(sa... | [
"def",
"asmono",
"(",
"samples",
":",
"np",
".",
"ndarray",
",",
"channel",
":",
"Union",
"[",
"int",
",",
"str",
"]",
"=",
"0",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"numchannels",
"(",
"samples",
")",
"==",
"1",
":",
"# it could be [1,2,3,4,.... | convert samples to mono if they are not mono already.
The returned array will always have the shape (numframes,)
channel: the channel number to use, or 'mix' to mix-down
all channels | [
"convert",
"samples",
"to",
"mono",
"if",
"they",
"are",
"not",
"mono",
"already",
"."
] | python | train |
udragon/pybrctl | pybrctl/pybrctl.py | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L145-L150 | def _runshell(cmd, exception):
""" Run a shell command. if fails, raise a proper exception. """
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.wait() != 0:
raise BridgeException(exception)
return p | [
"def",
"_runshell",
"(",
"cmd",
",",
"exception",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"if",
"p",
".",
"wait",
"(",
")",
"!=",... | Run a shell command. if fails, raise a proper exception. | [
"Run",
"a",
"shell",
"command",
".",
"if",
"fails",
"raise",
"a",
"proper",
"exception",
"."
] | python | train |
RedFantom/ttkwidgets | ttkwidgets/color/colorpicker.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/color/colorpicker.py#L394-L408 | def _change_sel_color(self, event):
"""Respond to motion of the color selection cross."""
(r, g, b), (h, s, v), color = self.square.get()
self.red.set(r)
self.green.set(g)
self.blue.set(b)
self.saturation.set(s)
self.value.set(v)
self.hexa.delete(0, "end")... | [
"def",
"_change_sel_color",
"(",
"self",
",",
"event",
")",
":",
"(",
"r",
",",
"g",
",",
"b",
")",
",",
"(",
"h",
",",
"s",
",",
"v",
")",
",",
"color",
"=",
"self",
".",
"square",
".",
"get",
"(",
")",
"self",
".",
"red",
".",
"set",
"(",... | Respond to motion of the color selection cross. | [
"Respond",
"to",
"motion",
"of",
"the",
"color",
"selection",
"cross",
"."
] | python | train |
etingof/pyasn1 | pyasn1/type/univ.py | https://github.com/etingof/pyasn1/blob/25cf116ef8d11bb0e08454c0f3635c9f4002c2d6/pyasn1/type/univ.py#L1867-L1897 | def isValue(self):
"""Indicate that |ASN.1| object represents ASN.1 value.
If *isValue* is `False` then this object represents just ASN.1 schema.
If *isValue* is `True` then, in addition to its ASN.1 schema features,
this object can also be used like a Python built-in object (e.g. `int... | [
"def",
"isValue",
"(",
"self",
")",
":",
"for",
"componentValue",
"in",
"self",
".",
"_componentValues",
":",
"if",
"componentValue",
"is",
"noValue",
"or",
"not",
"componentValue",
".",
"isValue",
":",
"return",
"False",
"return",
"True"
] | Indicate that |ASN.1| object represents ASN.1 value.
If *isValue* is `False` then this object represents just ASN.1 schema.
If *isValue* is `True` then, in addition to its ASN.1 schema features,
this object can also be used like a Python built-in object (e.g. `int`,
`str`, `dict` etc.)... | [
"Indicate",
"that",
"|ASN",
".",
"1|",
"object",
"represents",
"ASN",
".",
"1",
"value",
"."
] | python | train |
nilp0inter/cpe | cpe/cpelang2_3.py | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L145-L166 | def _unbind(cls, boundname):
"""
Unbinds a bound form to a WFN.
:param string boundname: CPE name
:returns: WFN object associated with boundname.
:rtype: CPE2_3_WFN
"""
try:
fs = CPE2_3_FS(boundname)
except:
# CPE name is not form... | [
"def",
"_unbind",
"(",
"cls",
",",
"boundname",
")",
":",
"try",
":",
"fs",
"=",
"CPE2_3_FS",
"(",
"boundname",
")",
"except",
":",
"# CPE name is not formatted string",
"try",
":",
"uri",
"=",
"CPE2_3_URI",
"(",
"boundname",
")",
"except",
":",
"# CPE name ... | Unbinds a bound form to a WFN.
:param string boundname: CPE name
:returns: WFN object associated with boundname.
:rtype: CPE2_3_WFN | [
"Unbinds",
"a",
"bound",
"form",
"to",
"a",
"WFN",
"."
] | python | train |
mar10/wsgidav | wsgidav/samples/mysql_dav_provider.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/samples/mysql_dav_provider.py#L295-L302 | def set_property_value(self, name, value, dry_run=False):
"""Set or remove property value.
See DAVResource.set_property_value()
"""
raise DAVError(
HTTP_FORBIDDEN, err_condition=PRECONDITION_CODE_ProtectedProperty
) | [
"def",
"set_property_value",
"(",
"self",
",",
"name",
",",
"value",
",",
"dry_run",
"=",
"False",
")",
":",
"raise",
"DAVError",
"(",
"HTTP_FORBIDDEN",
",",
"err_condition",
"=",
"PRECONDITION_CODE_ProtectedProperty",
")"
] | Set or remove property value.
See DAVResource.set_property_value() | [
"Set",
"or",
"remove",
"property",
"value",
"."
] | python | valid |
Kronuz/pyScss | scss/compiler.py | https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/compiler.py#L1295-L1314 | def create_css(self, rules):
"""
Generate the final CSS string
"""
style = rules[0].legacy_compiler_options.get(
'style', self.compiler.output_style)
debug_info = self.compiler.generate_source_map
if style == 'legacy':
sc, sp, tb, nst, srnl, nl, r... | [
"def",
"create_css",
"(",
"self",
",",
"rules",
")",
":",
"style",
"=",
"rules",
"[",
"0",
"]",
".",
"legacy_compiler_options",
".",
"get",
"(",
"'style'",
",",
"self",
".",
"compiler",
".",
"output_style",
")",
"debug_info",
"=",
"self",
".",
"compiler"... | Generate the final CSS string | [
"Generate",
"the",
"final",
"CSS",
"string"
] | python | train |
AmesCornish/buttersink | buttersink/BestDiffs.py | https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/BestDiffs.py#L155-L270 | def _analyzeDontMeasure(self, chunkSize, willMeasureLater, *sinks):
""" Figure out the best diffs to use to reach all our required volumes. """
nodes = [None]
height = 1
def sortKey(node):
if node is None:
return None
return (node.intermediate, s... | [
"def",
"_analyzeDontMeasure",
"(",
"self",
",",
"chunkSize",
",",
"willMeasureLater",
",",
"*",
"sinks",
")",
":",
"nodes",
"=",
"[",
"None",
"]",
"height",
"=",
"1",
"def",
"sortKey",
"(",
"node",
")",
":",
"if",
"node",
"is",
"None",
":",
"return",
... | Figure out the best diffs to use to reach all our required volumes. | [
"Figure",
"out",
"the",
"best",
"diffs",
"to",
"use",
"to",
"reach",
"all",
"our",
"required",
"volumes",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/message.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/message.py#L407-L430 | def update(collection_name, upsert, multi,
spec, doc, safe, last_error_args, check_keys, opts):
"""Get an **update** message.
"""
options = 0
if upsert:
options += 1
if multi:
options += 2
data = _ZERO_32
data += bson._make_c_string(collection_name)
data += st... | [
"def",
"update",
"(",
"collection_name",
",",
"upsert",
",",
"multi",
",",
"spec",
",",
"doc",
",",
"safe",
",",
"last_error_args",
",",
"check_keys",
",",
"opts",
")",
":",
"options",
"=",
"0",
"if",
"upsert",
":",
"options",
"+=",
"1",
"if",
"multi",... | Get an **update** message. | [
"Get",
"an",
"**",
"update",
"**",
"message",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L1143-L1155 | def vcenter_credentials_password(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch")
id_key = ET.SubElement(vcenter, "id")
id_key.text = kwargs.pop('id')
... | [
"def",
"vcenter_credentials_password",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"vcenter",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"vcenter\"",
",",
"xmlns",
"=",
"\"urn:brocad... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
paylogic/pip-accel | pip_accel/req.py | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/req.py#L125-L136 | def last_modified(self):
"""
The last modified time of the requirement's source distribution archive(s) (a number).
The value of this property is based on the :attr:`related_archives`
property. If no related archives are found the current time is
reported. In the balance between... | [
"def",
"last_modified",
"(",
"self",
")",
":",
"mtimes",
"=",
"list",
"(",
"map",
"(",
"os",
".",
"path",
".",
"getmtime",
",",
"self",
".",
"related_archives",
")",
")",
"return",
"max",
"(",
"mtimes",
")",
"if",
"mtimes",
"else",
"time",
".",
"time... | The last modified time of the requirement's source distribution archive(s) (a number).
The value of this property is based on the :attr:`related_archives`
property. If no related archives are found the current time is
reported. In the balance between not invalidating cached binary
distr... | [
"The",
"last",
"modified",
"time",
"of",
"the",
"requirement",
"s",
"source",
"distribution",
"archive",
"(",
"s",
")",
"(",
"a",
"number",
")",
"."
] | python | train |
garnaat/kappa | kappa/context.py | https://github.com/garnaat/kappa/blob/46709b6b790fead13294c2c18ffa5d63ea5133c7/kappa/context.py#L157-L178 | def set_logger(self, logger_name, level=logging.INFO):
"""
Convenience function to quickly configure full debug output
to go to the console.
"""
log = logging.getLogger(logger_name)
log.setLevel(level)
ch = logging.StreamHandler(None)
ch.setLevel(level)
... | [
"def",
"set_logger",
"(",
"self",
",",
"logger_name",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"logger_name",
")",
"log",
".",
"setLevel",
"(",
"level",
")",
"ch",
"=",
"logging",
".",
"StreamHa... | Convenience function to quickly configure full debug output
to go to the console. | [
"Convenience",
"function",
"to",
"quickly",
"configure",
"full",
"debug",
"output",
"to",
"go",
"to",
"the",
"console",
"."
] | python | train |
jtwhite79/pyemu | pyemu/prototypes/da.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/prototypes/da.py#L162-L179 | def forecast(self,parensemble=None):
"""for the enkf formulation, this simply moves the ensemble forward by running the model
once for each realization"""
if parensemble is None:
parensemble = self.parensemble
self.logger.log("evaluating ensemble")
failed_runs, obsens... | [
"def",
"forecast",
"(",
"self",
",",
"parensemble",
"=",
"None",
")",
":",
"if",
"parensemble",
"is",
"None",
":",
"parensemble",
"=",
"self",
".",
"parensemble",
"self",
".",
"logger",
".",
"log",
"(",
"\"evaluating ensemble\"",
")",
"failed_runs",
",",
"... | for the enkf formulation, this simply moves the ensemble forward by running the model
once for each realization | [
"for",
"the",
"enkf",
"formulation",
"this",
"simply",
"moves",
"the",
"ensemble",
"forward",
"by",
"running",
"the",
"model",
"once",
"for",
"each",
"realization"
] | python | train |
tensorflow/cleverhans | examples/nips17_adversarial_competition/eval_infra/code/worker.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/eval_infra/code/worker.py#L462-L489 | def run(self, input_dir, output_file_path):
"""Runs defense inside Docker.
Args:
input_dir: directory with input (adversarial images).
output_file_path: path of the output file.
Returns:
how long it took to run submission in seconds
"""
logging.info('Running defense %s', self.sub... | [
"def",
"run",
"(",
"self",
",",
"input_dir",
",",
"output_file_path",
")",
":",
"logging",
".",
"info",
"(",
"'Running defense %s'",
",",
"self",
".",
"submission_id",
")",
"tmp_run_dir",
"=",
"self",
".",
"temp_copy_extracted_submission",
"(",
")",
"output_dir"... | Runs defense inside Docker.
Args:
input_dir: directory with input (adversarial images).
output_file_path: path of the output file.
Returns:
how long it took to run submission in seconds | [
"Runs",
"defense",
"inside",
"Docker",
"."
] | python | train |
kapot65/python-df-parser | dfparser/rsh_parser.py | https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/rsh_parser.py#L170-L272 | def serialize_to_rsb(params: dict) -> bytes:
"""Сериализация JSON хедера rsb.
@params -- параметры в формате JSON (dfparser.def_values.DEF_RSH_PARAMS)
@return -- бинарный хедер (2048 bytes)
"""
header = bytearray(np.zeros(2048, np.byte).tostring())
if "text_header_size" in params:
hea... | [
"def",
"serialize_to_rsb",
"(",
"params",
":",
"dict",
")",
"->",
"bytes",
":",
"header",
"=",
"bytearray",
"(",
"np",
".",
"zeros",
"(",
"2048",
",",
"np",
".",
"byte",
")",
".",
"tostring",
"(",
")",
")",
"if",
"\"text_header_size\"",
"in",
"params",... | Сериализация JSON хедера rsb.
@params -- параметры в формате JSON (dfparser.def_values.DEF_RSH_PARAMS)
@return -- бинарный хедер (2048 bytes) | [
"Сериализация",
"JSON",
"хедера",
"rsb",
"."
] | python | train |
Robpol86/libnl | libnl/linux_private/netlink.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/linux_private/netlink.py#L71-L73 | def nl_family(self, value):
"""Family setter."""
self.bytearray[self._get_slicers(0)] = bytearray(c_uint(value or 0)) | [
"def",
"nl_family",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"bytearray",
"[",
"self",
".",
"_get_slicers",
"(",
"0",
")",
"]",
"=",
"bytearray",
"(",
"c_uint",
"(",
"value",
"or",
"0",
")",
")"
] | Family setter. | [
"Family",
"setter",
"."
] | python | train |
alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/skill_builder.py | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill_builder.py#L138-L180 | def exception_handler(self, can_handle_func):
# type: (Callable[[Input, Exception], bool]) -> Callable
"""Decorator that can be used to add exception handlers easily
to the builder.
The can_handle_func has to be a Callable instance, which takes
two parameters and no varargs or k... | [
"def",
"exception_handler",
"(",
"self",
",",
"can_handle_func",
")",
":",
"# type: (Callable[[Input, Exception], bool]) -> Callable",
"def",
"wrapper",
"(",
"handle_func",
")",
":",
"if",
"not",
"callable",
"(",
"can_handle_func",
")",
"or",
"not",
"callable",
"(",
... | Decorator that can be used to add exception handlers easily
to the builder.
The can_handle_func has to be a Callable instance, which takes
two parameters and no varargs or kwargs. This is because of the
ExceptionHandler class signature restrictions. The returned
wrapper function... | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"add",
"exception",
"handlers",
"easily",
"to",
"the",
"builder",
"."
] | python | train |
RRZE-HPC/kerncraft | kerncraft/kernel.py | https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L637-L643 | def print_variables_info(self, output_file=sys.stdout):
"""Print variables information in human readble format."""
table = (' name | type size \n' +
'---------+-------------------------\n')
for name, var_info in list(self.variables.items()):
table +=... | [
"def",
"print_variables_info",
"(",
"self",
",",
"output_file",
"=",
"sys",
".",
"stdout",
")",
":",
"table",
"=",
"(",
"' name | type size \\n'",
"+",
"'---------+-------------------------\\n'",
")",
"for",
"name",
",",
"var_info",
"in",
"list",
"(... | Print variables information in human readble format. | [
"Print",
"variables",
"information",
"in",
"human",
"readble",
"format",
"."
] | python | test |
pyrogram/pyrogram | pyrogram/client/client.py | https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/client.py#L1388-L1519 | def save_file(self,
path: str,
file_id: int = None,
file_part: int = 0,
progress: callable = None,
progress_args: tuple = ()):
"""Use this method to upload a file onto Telegram servers, without actually sending the message... | [
"def",
"save_file",
"(",
"self",
",",
"path",
":",
"str",
",",
"file_id",
":",
"int",
"=",
"None",
",",
"file_part",
":",
"int",
"=",
"0",
",",
"progress",
":",
"callable",
"=",
"None",
",",
"progress_args",
":",
"tuple",
"=",
"(",
")",
")",
":",
... | Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use meth... | [
"Use",
"this",
"method",
"to",
"upload",
"a",
"file",
"onto",
"Telegram",
"servers",
"without",
"actually",
"sending",
"the",
"message",
"to",
"anyone",
"."
] | python | train |
diffeo/rejester | rejester/_registry.py | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_registry.py#L104-L129 | def _acquire_lock(self, identifier, atime=30, ltime=5):
'''Acquire a lock for a given identifier.
If the lock cannot be obtained immediately, keep trying at random
intervals, up to 3 seconds, until `atime` has passed. Once the
lock has been obtained, continue to hold it for `ltime`.
... | [
"def",
"_acquire_lock",
"(",
"self",
",",
"identifier",
",",
"atime",
"=",
"30",
",",
"ltime",
"=",
"5",
")",
":",
"conn",
"=",
"redis",
".",
"Redis",
"(",
"connection_pool",
"=",
"self",
".",
"pool",
")",
"end",
"=",
"time",
".",
"time",
"(",
")",... | Acquire a lock for a given identifier.
If the lock cannot be obtained immediately, keep trying at random
intervals, up to 3 seconds, until `atime` has passed. Once the
lock has been obtained, continue to hold it for `ltime`.
:param str identifier: lock token to write
:param in... | [
"Acquire",
"a",
"lock",
"for",
"a",
"given",
"identifier",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/electronic_structure/cohp.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/cohp.py#L599-L716 | def from_file(cls, fmt, filename=None,
structure_file=None, are_coops=False):
"""
Creates a CompleteCohp object from an output file of a COHP
calculation. Valid formats are either LMTO (for the Stuttgart
LMTO-ASA code) or LOBSTER (for the LOBSTER code).
Args:
... | [
"def",
"from_file",
"(",
"cls",
",",
"fmt",
",",
"filename",
"=",
"None",
",",
"structure_file",
"=",
"None",
",",
"are_coops",
"=",
"False",
")",
":",
"fmt",
"=",
"fmt",
".",
"upper",
"(",
")",
"if",
"fmt",
"==",
"\"LMTO\"",
":",
"# LMTO COOPs and orb... | Creates a CompleteCohp object from an output file of a COHP
calculation. Valid formats are either LMTO (for the Stuttgart
LMTO-ASA code) or LOBSTER (for the LOBSTER code).
Args:
cohp_file: Name of the COHP output file. Defaults to COPL
for LMTO and COHPCAR.lobster/CO... | [
"Creates",
"a",
"CompleteCohp",
"object",
"from",
"an",
"output",
"file",
"of",
"a",
"COHP",
"calculation",
".",
"Valid",
"formats",
"are",
"either",
"LMTO",
"(",
"for",
"the",
"Stuttgart",
"LMTO",
"-",
"ASA",
"code",
")",
"or",
"LOBSTER",
"(",
"for",
"t... | python | train |
pypa/pipenv | pipenv/vendor/urllib3/util/request.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/request.py#L95-L118 | def rewind_body(body, body_pos):
"""
Attempt to rewind body to a certain position.
Primarily used for request redirects and retries.
:param body:
File-like object that supports seek.
:param int pos:
Position to seek to in file.
"""
body_seek = getattr(body, 'seek', None)
... | [
"def",
"rewind_body",
"(",
"body",
",",
"body_pos",
")",
":",
"body_seek",
"=",
"getattr",
"(",
"body",
",",
"'seek'",
",",
"None",
")",
"if",
"body_seek",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"body_pos",
",",
"integer_types",
")",
":",
"try",
... | Attempt to rewind body to a certain position.
Primarily used for request redirects and retries.
:param body:
File-like object that supports seek.
:param int pos:
Position to seek to in file. | [
"Attempt",
"to",
"rewind",
"body",
"to",
"a",
"certain",
"position",
".",
"Primarily",
"used",
"for",
"request",
"redirects",
"and",
"retries",
"."
] | python | train |
jroyal/pyIDS | pyIDS/ids.py | https://github.com/jroyal/pyIDS/blob/3c2d3ff4bdc7bfe116dfd02152dadd26f92f74b5/pyIDS/ids.py#L82-L92 | def get_work_item_by_id(self, wi_id):
'''
Retrieves a single work item based off of the supplied ID
:param wi_id: The work item ID number
:return: Workitem or None
'''
work_items = self.get_work_items(id=wi_id)
if work_items is not None:
return work_i... | [
"def",
"get_work_item_by_id",
"(",
"self",
",",
"wi_id",
")",
":",
"work_items",
"=",
"self",
".",
"get_work_items",
"(",
"id",
"=",
"wi_id",
")",
"if",
"work_items",
"is",
"not",
"None",
":",
"return",
"work_items",
"[",
"0",
"]",
"return",
"None"
] | Retrieves a single work item based off of the supplied ID
:param wi_id: The work item ID number
:return: Workitem or None | [
"Retrieves",
"a",
"single",
"work",
"item",
"based",
"off",
"of",
"the",
"supplied",
"ID"
] | python | train |
apache/incubator-heron | heron/statemgrs/src/python/config.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/statemgrs/src/python/config.py#L45-L50 | def validate_state_locations(self):
"""
Names of all state locations must be unique.
"""
names = map(lambda loc: loc["name"], self.locations)
assert len(names) == len(set(names)), "Names of state locations must be unique" | [
"def",
"validate_state_locations",
"(",
"self",
")",
":",
"names",
"=",
"map",
"(",
"lambda",
"loc",
":",
"loc",
"[",
"\"name\"",
"]",
",",
"self",
".",
"locations",
")",
"assert",
"len",
"(",
"names",
")",
"==",
"len",
"(",
"set",
"(",
"names",
")",... | Names of all state locations must be unique. | [
"Names",
"of",
"all",
"state",
"locations",
"must",
"be",
"unique",
"."
] | python | valid |
edeposit/edeposit.amqp | edeposit/amqp/amqpdaemon.py | https://github.com/edeposit/edeposit.amqp/blob/7804b52028b90ab96302d54bc2430f88dc2ebf64/edeposit/amqp/amqpdaemon.py#L163-L182 | def get_sendback(self, uuid, key):
"""
Return function for sending progress messages back to original caller.
Args:
uuid (str): UUID of the received message.
key (str): Routing key.
Returns:
fn reference: Reference to function which takes only one da... | [
"def",
"get_sendback",
"(",
"self",
",",
"uuid",
",",
"key",
")",
":",
"def",
"send_back_callback",
"(",
"data",
")",
":",
"self",
".",
"sendResponse",
"(",
"serializers",
".",
"serialize",
"(",
"data",
")",
",",
"uuid",
",",
"key",
")",
"return",
"sen... | Return function for sending progress messages back to original caller.
Args:
uuid (str): UUID of the received message.
key (str): Routing key.
Returns:
fn reference: Reference to function which takes only one data \
argument. | [
"Return",
"function",
"for",
"sending",
"progress",
"messages",
"back",
"to",
"original",
"caller",
"."
] | python | train |
erdewit/ib_insync | ib_insync/ib.py | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L208-L228 | def connect(
self, host: str = '127.0.0.1', port: int = 7497,
clientId: int = 1, timeout: float = 2):
"""
Connect to a running TWS or IB gateway application.
After the connection is made the client is fully synchronized
and ready to serve requests.
This m... | [
"def",
"connect",
"(",
"self",
",",
"host",
":",
"str",
"=",
"'127.0.0.1'",
",",
"port",
":",
"int",
"=",
"7497",
",",
"clientId",
":",
"int",
"=",
"1",
",",
"timeout",
":",
"float",
"=",
"2",
")",
":",
"return",
"self",
".",
"_run",
"(",
"self",... | Connect to a running TWS or IB gateway application.
After the connection is made the client is fully synchronized
and ready to serve requests.
This method is blocking.
Args:
host: Host name or IP address.
port: Port number.
clientId: ID number to use... | [
"Connect",
"to",
"a",
"running",
"TWS",
"or",
"IB",
"gateway",
"application",
".",
"After",
"the",
"connection",
"is",
"made",
"the",
"client",
"is",
"fully",
"synchronized",
"and",
"ready",
"to",
"serve",
"requests",
"."
] | python | train |
tjvr/kurt | kurt/__init__.py | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2358-L2371 | def save(self, path):
"""Save the sound to a wave file at the given path.
Uses :attr:`Waveform.save`, but if the path ends in a folder instead of
a file, the filename is based on the project's :attr:`name`.
:returns: Path to the saved file.
"""
(folder, filename) = os.... | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"if",
"not",
"filename",
":",
"filename",
"=",
"_clean_filename",
"(",
"self",
".",
"name",
")",
"path",... | Save the sound to a wave file at the given path.
Uses :attr:`Waveform.save`, but if the path ends in a folder instead of
a file, the filename is based on the project's :attr:`name`.
:returns: Path to the saved file. | [
"Save",
"the",
"sound",
"to",
"a",
"wave",
"file",
"at",
"the",
"given",
"path",
"."
] | python | train |
UMIACS/qav | qav/validators.py | https://github.com/UMIACS/qav/blob/f92108855f9fcbe3ccea5fc6f683bd90a6e18e1b/qav/validators.py#L369-L383 | def validate(self, value):
"""
Return True if the choice is an integer; False otherwise.
If the value was cast successfully to an int, set the choice that will
make its way into the answers dict to the cast int value, not the
string representation.
"""
try:
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"int_value",
"=",
"int",
"(",
"value",
")",
"self",
".",
"_choice",
"=",
"int_value",
"return",
"True",
"except",
"ValueError",
":",
"self",
".",
"error_message",
"=",
"'%s is not a valid ... | Return True if the choice is an integer; False otherwise.
If the value was cast successfully to an int, set the choice that will
make its way into the answers dict to the cast int value, not the
string representation. | [
"Return",
"True",
"if",
"the",
"choice",
"is",
"an",
"integer",
";",
"False",
"otherwise",
"."
] | python | train |
lepture/flask-oauthlib | flask_oauthlib/provider/oauth1.py | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L486-L518 | def require_oauth(self, *realms, **kwargs):
"""Protect resource with specified scopes."""
def wrapper(f):
@wraps(f)
def decorated(*args, **kwargs):
for func in self._before_request_funcs:
func()
if hasattr(request, 'oauth') and... | [
"def",
"require_oauth",
"(",
"self",
",",
"*",
"realms",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func... | Protect resource with specified scopes. | [
"Protect",
"resource",
"with",
"specified",
"scopes",
"."
] | python | test |
Azure/azure-cli-extensions | src/alias/azext_alias/custom.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/alias/azext_alias/custom.py#L80-L97 | def list_alias():
"""
List all registered aliases.
Returns:
An array of dictionary containing the alias and the command that it points to.
"""
alias_table = get_alias_table()
output = []
for alias in alias_table.sections():
if alias_table.has_option(alias, 'command'):
... | [
"def",
"list_alias",
"(",
")",
":",
"alias_table",
"=",
"get_alias_table",
"(",
")",
"output",
"=",
"[",
"]",
"for",
"alias",
"in",
"alias_table",
".",
"sections",
"(",
")",
":",
"if",
"alias_table",
".",
"has_option",
"(",
"alias",
",",
"'command'",
")"... | List all registered aliases.
Returns:
An array of dictionary containing the alias and the command that it points to. | [
"List",
"all",
"registered",
"aliases",
"."
] | python | train |
INM-6/hybridLFPy | hybridLFPy/postproc.py | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/hybridLFPy/postproc.py#L233-L255 | def calc_lfp_layer(self):
"""
Calculate the LFP from concatenated subpopulations residing in a
certain layer, e.g all L4E pops are summed, according to the `mapping_Yy`
attribute of the `hybridLFPy.Population` objects.
"""
LFPdict = {}
lastY = None
for Y,... | [
"def",
"calc_lfp_layer",
"(",
"self",
")",
":",
"LFPdict",
"=",
"{",
"}",
"lastY",
"=",
"None",
"for",
"Y",
",",
"y",
"in",
"self",
".",
"mapping_Yy",
":",
"if",
"lastY",
"!=",
"Y",
":",
"try",
":",
"LFPdict",
".",
"update",
"(",
"{",
"Y",
":",
... | Calculate the LFP from concatenated subpopulations residing in a
certain layer, e.g all L4E pops are summed, according to the `mapping_Yy`
attribute of the `hybridLFPy.Population` objects. | [
"Calculate",
"the",
"LFP",
"from",
"concatenated",
"subpopulations",
"residing",
"in",
"a",
"certain",
"layer",
"e",
".",
"g",
"all",
"L4E",
"pops",
"are",
"summed",
"according",
"to",
"the",
"mapping_Yy",
"attribute",
"of",
"the",
"hybridLFPy",
".",
"Populati... | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/external_ca/models/create_certificate_issuer_config.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/external_ca/models/create_certificate_issuer_config.py#L91-L106 | def reference(self, reference):
"""
Sets the reference of this CreateCertificateIssuerConfig.
The certificate name, as created in the factory, to which the certificate issuer configuration applies. The following names are reserved and cannot be configured: LwM2M, BOOTSTRAP.
:param refe... | [
"def",
"reference",
"(",
"self",
",",
"reference",
")",
":",
"if",
"reference",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `reference`, must not be `None`\"",
")",
"if",
"reference",
"is",
"not",
"None",
"and",
"len",
"(",
"reference",
"... | Sets the reference of this CreateCertificateIssuerConfig.
The certificate name, as created in the factory, to which the certificate issuer configuration applies. The following names are reserved and cannot be configured: LwM2M, BOOTSTRAP.
:param reference: The reference of this CreateCertificateIssuer... | [
"Sets",
"the",
"reference",
"of",
"this",
"CreateCertificateIssuerConfig",
".",
"The",
"certificate",
"name",
"as",
"created",
"in",
"the",
"factory",
"to",
"which",
"the",
"certificate",
"issuer",
"configuration",
"applies",
".",
"The",
"following",
"names",
"are... | python | train |
mitsei/dlkit | dlkit/json_/cataloging/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/objects.py#L206-L221 | def get_parent_catalog_nodes(self):
"""Gets the parents of this catalog.
return: (osid.cataloging.CatalogNodeList) - the parents of the
``id``
*compliance: mandatory -- This method must be implemented.*
"""
parent_catalog_nodes = []
for node in self._my_... | [
"def",
"get_parent_catalog_nodes",
"(",
"self",
")",
":",
"parent_catalog_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"_my_map",
"[",
"'parentNodes'",
"]",
":",
"parent_catalog_nodes",
".",
"append",
"(",
"CatalogNode",
"(",
"node",
".",
"_my_map"... | Gets the parents of this catalog.
return: (osid.cataloging.CatalogNodeList) - the parents of the
``id``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"parents",
"of",
"this",
"catalog",
"."
] | python | train |
erikrose/more-itertools | more_itertools/more.py | https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L1035-L1053 | def split_at(iterable, pred):
"""Yield lists of items from *iterable*, where each list is delimited by
an item where callable *pred* returns ``True``. The lists do not include
the delimiting items.
>>> list(split_at('abcdcba', lambda x: x == 'b'))
[['a'], ['c', 'd', 'c'], ['a']]
>>... | [
"def",
"split_at",
"(",
"iterable",
",",
"pred",
")",
":",
"buf",
"=",
"[",
"]",
"for",
"item",
"in",
"iterable",
":",
"if",
"pred",
"(",
"item",
")",
":",
"yield",
"buf",
"buf",
"=",
"[",
"]",
"else",
":",
"buf",
".",
"append",
"(",
"item",
")... | Yield lists of items from *iterable*, where each list is delimited by
an item where callable *pred* returns ``True``. The lists do not include
the delimiting items.
>>> list(split_at('abcdcba', lambda x: x == 'b'))
[['a'], ['c', 'd', 'c'], ['a']]
>>> list(split_at(range(10), lambda n: ... | [
"Yield",
"lists",
"of",
"items",
"from",
"*",
"iterable",
"*",
"where",
"each",
"list",
"is",
"delimited",
"by",
"an",
"item",
"where",
"callable",
"*",
"pred",
"*",
"returns",
"True",
".",
"The",
"lists",
"do",
"not",
"include",
"the",
"delimiting",
"it... | python | train |
chimera0/accel-brain-code | Automatic-Summarization/pysummarization/vectorizabletoken/encoder_decoder.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Automatic-Summarization/pysummarization/vectorizabletoken/encoder_decoder.py#L54-L67 | def vectorize(self, token_list):
'''
Tokenize token list.
Args:
token_list: The list of tokens..
Returns:
[vector of token, vector of token, vector of token, ...]
'''
sentence_list = [token_list]
test_observed... | [
"def",
"vectorize",
"(",
"self",
",",
"token_list",
")",
":",
"sentence_list",
"=",
"[",
"token_list",
"]",
"test_observed_arr",
"=",
"self",
".",
"__setup_dataset",
"(",
"sentence_list",
",",
"self",
".",
"__token_master_list",
")",
"pred_arr",
"=",
"self",
"... | Tokenize token list.
Args:
token_list: The list of tokens..
Returns:
[vector of token, vector of token, vector of token, ...] | [
"Tokenize",
"token",
"list",
".",
"Args",
":",
"token_list",
":",
"The",
"list",
"of",
"tokens",
"..",
"Returns",
":",
"[",
"vector",
"of",
"token",
"vector",
"of",
"token",
"vector",
"of",
"token",
"...",
"]"
] | python | train |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L2166-L2188 | def alias_log(self, log_id, alias_id):
"""Adds an ``Id`` to a ``Log`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Log`` is determined by the provider.
The new ``Id`` performs as an alias to the primary ``Id``. If
the alias is a pointer to another log, it is re... | [
"def",
"alias_log",
"(",
"self",
",",
"log_id",
",",
"alias_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinLookupSession.alias_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session... | Adds an ``Id`` to a ``Log`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Log`` is determined by the provider.
The new ``Id`` performs as an alias to the primary ``Id``. If
the alias is a pointer to another log, it is reassigned to the
given log ``Id``.
... | [
"Adds",
"an",
"Id",
"to",
"a",
"Log",
"for",
"the",
"purpose",
"of",
"creating",
"compatibility",
"."
] | python | train |
bachiraoun/pyrep | OldRepository.py | https://github.com/bachiraoun/pyrep/blob/0449bf2fad3e3e8dda855d4686a8869efeefd433/OldRepository.py#L564-L583 | def walk_files_relative_path(self, relativePath=""):
"""
Walk the repository and yield all found files relative path joined with file name.
:parameters:
#. relativePath (str): The relative path from which start the walk.
"""
def walk_files(directory, relativePath):
... | [
"def",
"walk_files_relative_path",
"(",
"self",
",",
"relativePath",
"=",
"\"\"",
")",
":",
"def",
"walk_files",
"(",
"directory",
",",
"relativePath",
")",
":",
"directories",
"=",
"dict",
".",
"__getitem__",
"(",
"directory",
",",
"'directories'",
")",
"file... | Walk the repository and yield all found files relative path joined with file name.
:parameters:
#. relativePath (str): The relative path from which start the walk. | [
"Walk",
"the",
"repository",
"and",
"yield",
"all",
"found",
"files",
"relative",
"path",
"joined",
"with",
"file",
"name",
"."
] | python | valid |
hadrianl/huobi | huobitrade/service.py | https://github.com/hadrianl/huobi/blob/bbfa2036703ee84a76d5d8e9f89c25fc8a55f2c7/huobitrade/service.py#L451-L472 | def send_margin_order(self, acc_id, amount, symbol, _type, price=0, _async=False):
"""
创建并执行借贷订单
:param amount:
:param symbol:
:param _type: 可选值 {buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖}
:param price:
:return:
"""
params = {... | [
"def",
"send_margin_order",
"(",
"self",
",",
"acc_id",
",",
"amount",
",",
"symbol",
",",
"_type",
",",
"price",
"=",
"0",
",",
"_async",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'account-id'",
":",
"acc_id",
",",
"'amount'",
":",
"amount",
",",
... | 创建并执行借贷订单
:param amount:
:param symbol:
:param _type: 可选值 {buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖}
:param price:
:return: | [
"创建并执行借贷订单",
":",
"param",
"amount",
":",
":",
"param",
"symbol",
":",
":",
"param",
"_type",
":",
"可选值",
"{",
"buy",
"-",
"market:市价买",
"sell",
"-",
"market:市价卖",
"buy",
"-",
"limit:限价买",
"sell",
"-",
"limit:限价卖",
"}",
":",
"param",
"price",
":",
":",... | python | train |
fermiPy/fermipy | fermipy/jobs/chain.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/chain.py#L48-L53 | def main(cls):
"""Hook to run this `Chain` from the command line """
chain = cls.create()
args = chain._run_argparser(sys.argv[1:])
chain._run_chain(sys.stdout, args.dry_run)
chain._finalize(args.dry_run) | [
"def",
"main",
"(",
"cls",
")",
":",
"chain",
"=",
"cls",
".",
"create",
"(",
")",
"args",
"=",
"chain",
".",
"_run_argparser",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"chain",
".",
"_run_chain",
"(",
"sys",
".",
"stdout",
",",
"args",
... | Hook to run this `Chain` from the command line | [
"Hook",
"to",
"run",
"this",
"Chain",
"from",
"the",
"command",
"line"
] | python | train |
ssherar/hook | hook/model.py | https://github.com/ssherar/hook/blob/54160df554d8b2ed65d762168e5808487e873ed9/hook/model.py#L76-L91 | def from_yaml(cls, defaults, **kwargs):
"""Creates a new instance of a rule by merging two dictionaries.
This allows for independant configuration files to be merged
into the defaults."""
# TODO: I hate myself for this. Fix it later mmkay?
if "token" not in defaults:
... | [
"def",
"from_yaml",
"(",
"cls",
",",
"defaults",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: I hate myself for this. Fix it later mmkay?",
"if",
"\"token\"",
"not",
"in",
"defaults",
":",
"kwargs",
"[",
"\"token\"",
"]",
"=",
"None",
"defaults",
"=",
"copy",
"... | Creates a new instance of a rule by merging two dictionaries.
This allows for independant configuration files to be merged
into the defaults. | [
"Creates",
"a",
"new",
"instance",
"of",
"a",
"rule",
"by",
"merging",
"two",
"dictionaries",
"."
] | python | test |
gwastro/pycbc-glue | pycbc_glue/markup.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/markup.py#L396-L423 | def _argsdicts( args, mydict ):
"""A utility generator that pads argument list and dictionary values, will only be called with len( args ) = 0, 1."""
if len( args ) == 0:
args = None,
elif len( args ) == 1:
args = _totuple( args[0] )
else:
raise Exception( "We should have n... | [
"def",
"_argsdicts",
"(",
"args",
",",
"mydict",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"args",
"=",
"None",
",",
"elif",
"len",
"(",
"args",
")",
"==",
"1",
":",
"args",
"=",
"_totuple",
"(",
"args",
"[",
"0",
"]",
")",
"el... | A utility generator that pads argument list and dictionary values, will only be called with len( args ) = 0, 1. | [
"A",
"utility",
"generator",
"that",
"pads",
"argument",
"list",
"and",
"dictionary",
"values",
"will",
"only",
"be",
"called",
"with",
"len",
"(",
"args",
")",
"=",
"0",
"1",
"."
] | python | train |
foliant-docs/foliantcontrib.mkdocs | foliant/backends/mkdocs.py | https://github.com/foliant-docs/foliantcontrib.mkdocs/blob/5f71a47139ab1cb630f1b61d4cef1c0657001272/foliant/backends/mkdocs.py#L77-L106 | def _get_page_with_optional_heading(self, page_file_path: str) -> str or Dict:
'''Get the content of first heading of source Markdown file, if the file
contains any headings. Return a data element of ``pages`` section
of ``mkdocs.yml`` file.
:param page_file_path: path to source Markdow... | [
"def",
"_get_page_with_optional_heading",
"(",
"self",
",",
"page_file_path",
":",
"str",
")",
"->",
"str",
"or",
"Dict",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"f'Looking for the first heading in {page_file_path}'",
")",
"if",
"page_file_path",
".",
"endswi... | Get the content of first heading of source Markdown file, if the file
contains any headings. Return a data element of ``pages`` section
of ``mkdocs.yml`` file.
:param page_file_path: path to source Markdown file
:returns: Unchanged file path or a dictionary: content of first heading, f... | [
"Get",
"the",
"content",
"of",
"first",
"heading",
"of",
"source",
"Markdown",
"file",
"if",
"the",
"file",
"contains",
"any",
"headings",
".",
"Return",
"a",
"data",
"element",
"of",
"pages",
"section",
"of",
"mkdocs",
".",
"yml",
"file",
"."
] | python | train |
glamp/bashplotlib | bashplotlib/utils/helpers.py | https://github.com/glamp/bashplotlib/blob/f7533172c4dc912b5accae42edd5c0f655d7468f/bashplotlib/utils/helpers.py#L67-L76 | def abbreviate(labels, rfill=' '):
"""
Abbreviate labels without introducing ambiguities.
"""
max_len = max(len(l) for l in labels)
for i in range(1, max_len):
abbrev = [l[:i].ljust(i, rfill) for l in labels]
if len(abbrev) == len(set(abbrev)):
break
return abbrev | [
"def",
"abbreviate",
"(",
"labels",
",",
"rfill",
"=",
"' '",
")",
":",
"max_len",
"=",
"max",
"(",
"len",
"(",
"l",
")",
"for",
"l",
"in",
"labels",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"max_len",
")",
":",
"abbrev",
"=",
"[",
"l",
... | Abbreviate labels without introducing ambiguities. | [
"Abbreviate",
"labels",
"without",
"introducing",
"ambiguities",
"."
] | python | train |
calmjs/calmjs | src/calmjs/base.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L448-L455 | def get_records_for_package(self, package_name):
"""
Get all records identified by package.
"""
result = []
result.extend(self.package_module_map.get(package_name))
return result | [
"def",
"get_records_for_package",
"(",
"self",
",",
"package_name",
")",
":",
"result",
"=",
"[",
"]",
"result",
".",
"extend",
"(",
"self",
".",
"package_module_map",
".",
"get",
"(",
"package_name",
")",
")",
"return",
"result"
] | Get all records identified by package. | [
"Get",
"all",
"records",
"identified",
"by",
"package",
"."
] | python | train |
michaelpb/omnic | omnic/cli/commands.py | https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/cli/commands.py#L110-L122 | async def _precache(url, to_type, force=False):
'''
Helper function used by precache and precache-named which does the
actual precaching
'''
if force:
cli.print('%s: force clearing' % url)
_clear_cache(url)
cli.print('%s: precaching "%s"' % (url, to_type))
with autodrain_work... | [
"async",
"def",
"_precache",
"(",
"url",
",",
"to_type",
",",
"force",
"=",
"False",
")",
":",
"if",
"force",
":",
"cli",
".",
"print",
"(",
"'%s: force clearing'",
"%",
"url",
")",
"_clear_cache",
"(",
"url",
")",
"cli",
".",
"print",
"(",
"'%s: preca... | Helper function used by precache and precache-named which does the
actual precaching | [
"Helper",
"function",
"used",
"by",
"precache",
"and",
"precache",
"-",
"named",
"which",
"does",
"the",
"actual",
"precaching"
] | python | train |
ultrabug/py3status | py3status/module.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/module.py#L232-L244 | def force_update(self):
"""
Forces an update of the module.
"""
if self.disabled or self.terminated or not self.enabled:
return
# clear cached_until for each method to allow update
for meth in self.methods:
self.methods[meth]["cached_until"] = time... | [
"def",
"force_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"disabled",
"or",
"self",
".",
"terminated",
"or",
"not",
"self",
".",
"enabled",
":",
"return",
"# clear cached_until for each method to allow update",
"for",
"meth",
"in",
"self",
".",
"methods",... | Forces an update of the module. | [
"Forces",
"an",
"update",
"of",
"the",
"module",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/utils/data.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/data.py#L101-L104 | def chop(seq, size):
"""Chop a sequence into chunks of the given size."""
chunk = lambda i: seq[i:i+size]
return map(chunk,xrange(0,len(seq),size)) | [
"def",
"chop",
"(",
"seq",
",",
"size",
")",
":",
"chunk",
"=",
"lambda",
"i",
":",
"seq",
"[",
"i",
":",
"i",
"+",
"size",
"]",
"return",
"map",
"(",
"chunk",
",",
"xrange",
"(",
"0",
",",
"len",
"(",
"seq",
")",
",",
"size",
")",
")"
] | Chop a sequence into chunks of the given size. | [
"Chop",
"a",
"sequence",
"into",
"chunks",
"of",
"the",
"given",
"size",
"."
] | python | test |
wummel/patool | patoolib/util.py | https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/util.py#L430-L441 | def set_mode (filename, flags):
"""Set mode flags for given filename if not already set."""
try:
mode = os.lstat(filename).st_mode
except OSError:
# ignore
return
if not (mode & flags):
try:
os.chmod(filename, flags | mode)
except OSError as msg:
... | [
"def",
"set_mode",
"(",
"filename",
",",
"flags",
")",
":",
"try",
":",
"mode",
"=",
"os",
".",
"lstat",
"(",
"filename",
")",
".",
"st_mode",
"except",
"OSError",
":",
"# ignore",
"return",
"if",
"not",
"(",
"mode",
"&",
"flags",
")",
":",
"try",
... | Set mode flags for given filename if not already set. | [
"Set",
"mode",
"flags",
"for",
"given",
"filename",
"if",
"not",
"already",
"set",
"."
] | python | train |
lemieuxl/pyplink | pyplink/pyplink.py | https://github.com/lemieuxl/pyplink/blob/31d47c86f589064bda98206314a2d0b20e7fd2f0/pyplink/pyplink.py#L198-L202 | def _read_current_marker(self):
"""Reads the current marker and returns its genotypes."""
return self._geno_values[
np.frombuffer(self._bed.read(self._nb_bytes), dtype=np.uint8)
].flatten(order="C")[:self._nb_samples] | [
"def",
"_read_current_marker",
"(",
"self",
")",
":",
"return",
"self",
".",
"_geno_values",
"[",
"np",
".",
"frombuffer",
"(",
"self",
".",
"_bed",
".",
"read",
"(",
"self",
".",
"_nb_bytes",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"]",
"."... | Reads the current marker and returns its genotypes. | [
"Reads",
"the",
"current",
"marker",
"and",
"returns",
"its",
"genotypes",
"."
] | python | train |
codeinn/vcs | vcs/backends/base.py | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L755-L770 | def add(self, *filenodes):
"""
Marks given ``FileNode`` objects as *to be committed*.
:raises ``NodeAlreadyExistsError``: if node with same path exists at
latest changeset
:raises ``NodeAlreadyAddedError``: if node with same path is already
marked as *added*
... | [
"def",
"add",
"(",
"self",
",",
"*",
"filenodes",
")",
":",
"# Check if not already marked as *added* first",
"for",
"node",
"in",
"filenodes",
":",
"if",
"node",
".",
"path",
"in",
"(",
"n",
".",
"path",
"for",
"n",
"in",
"self",
".",
"added",
")",
":",... | Marks given ``FileNode`` objects as *to be committed*.
:raises ``NodeAlreadyExistsError``: if node with same path exists at
latest changeset
:raises ``NodeAlreadyAddedError``: if node with same path is already
marked as *added* | [
"Marks",
"given",
"FileNode",
"objects",
"as",
"*",
"to",
"be",
"committed",
"*",
"."
] | python | train |
tensorflow/cleverhans | cleverhans/attacks/spsa.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks/spsa.py#L613-L758 | def projected_optimization(loss_fn,
input_image,
label,
epsilon,
num_steps,
clip_min=None,
clip_max=None,
optimizer=TensorAdam(),
... | [
"def",
"projected_optimization",
"(",
"loss_fn",
",",
"input_image",
",",
"label",
",",
"epsilon",
",",
"num_steps",
",",
"clip_min",
"=",
"None",
",",
"clip_max",
"=",
"None",
",",
"optimizer",
"=",
"TensorAdam",
"(",
")",
",",
"project_perturbation",
"=",
... | Generic projected optimization, generalized to work with approximate
gradients. Used for e.g. the SPSA attack.
Args:
:param loss_fn: A callable which takes `input_image` and `label` as
arguments, and returns a batch of loss values. Same
interface as TensorOptimizer.
... | [
"Generic",
"projected",
"optimization",
"generalized",
"to",
"work",
"with",
"approximate",
"gradients",
".",
"Used",
"for",
"e",
".",
"g",
".",
"the",
"SPSA",
"attack",
"."
] | python | train |
orbingol/NURBS-Python | geomdl/utilities.py | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/utilities.py#L192-L216 | def evaluate_bounding_box(ctrlpts):
""" Computes the minimum bounding box of the point set.
The (minimum) bounding box is the smallest enclosure in which all the input points lie.
:param ctrlpts: points
:type ctrlpts: list, tuple
:return: bounding box in the format [min, max]
:rtype: tuple
... | [
"def",
"evaluate_bounding_box",
"(",
"ctrlpts",
")",
":",
"# Estimate dimension from the first element of the control points",
"dimension",
"=",
"len",
"(",
"ctrlpts",
"[",
"0",
"]",
")",
"# Evaluate bounding box",
"bbmin",
"=",
"[",
"float",
"(",
"'inf'",
")",
"for",... | Computes the minimum bounding box of the point set.
The (minimum) bounding box is the smallest enclosure in which all the input points lie.
:param ctrlpts: points
:type ctrlpts: list, tuple
:return: bounding box in the format [min, max]
:rtype: tuple | [
"Computes",
"the",
"minimum",
"bounding",
"box",
"of",
"the",
"point",
"set",
"."
] | python | train |
OpenGeoVis/espatools | espatools/read.py | https://github.com/OpenGeoVis/espatools/blob/5c04daae0f035c7efcb4096bb85a26c6959ac9ea/espatools/read.py#L82-L134 | def GenerateBand(self, band, meta_only=False, cast=False):
"""Genreate a Band object given band metadata
Args:
band (dict): dictionary containing metadata for a given band
Return:
Band : the loaded Band onject"""
# Read the band data and add it to dictionary
... | [
"def",
"GenerateBand",
"(",
"self",
",",
"band",
",",
"meta_only",
"=",
"False",
",",
"cast",
"=",
"False",
")",
":",
"# Read the band data and add it to dictionary",
"if",
"not",
"meta_only",
":",
"fname",
"=",
"band",
".",
"get",
"(",
"'file_name'",
")",
"... | Genreate a Band object given band metadata
Args:
band (dict): dictionary containing metadata for a given band
Return:
Band : the loaded Band onject | [
"Genreate",
"a",
"Band",
"object",
"given",
"band",
"metadata"
] | python | train |
joshspeagle/dynesty | dynesty/utils.py | https://github.com/joshspeagle/dynesty/blob/9e482aafeb5cf84bedb896fa6f07a761d917983e/dynesty/utils.py#L704-L846 | def unravel_run(res, save_proposals=True, print_progress=True):
"""
Unravels a run with `K` live points into `K` "strands" (a nested sampling
run with only 1 live point). **WARNING: the anciliary quantities provided
with each unraveled "strand" are only valid if the point was initialized
from the pr... | [
"def",
"unravel_run",
"(",
"res",
",",
"save_proposals",
"=",
"True",
",",
"print_progress",
"=",
"True",
")",
":",
"idxs",
"=",
"res",
".",
"samples_id",
"# label for each live/dead point",
"# Check if we added in the last set of dead points.",
"added_live",
"=",
"True... | Unravels a run with `K` live points into `K` "strands" (a nested sampling
run with only 1 live point). **WARNING: the anciliary quantities provided
with each unraveled "strand" are only valid if the point was initialized
from the prior.**
Parameters
----------
res : :class:`~dynesty.results.Res... | [
"Unravels",
"a",
"run",
"with",
"K",
"live",
"points",
"into",
"K",
"strands",
"(",
"a",
"nested",
"sampling",
"run",
"with",
"only",
"1",
"live",
"point",
")",
".",
"**",
"WARNING",
":",
"the",
"anciliary",
"quantities",
"provided",
"with",
"each",
"unr... | python | train |
bmweiner/skillful | skillful/interface.py | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/interface.py#L399-L419 | def set_card_standard(self, title, text, smallImageUrl=None,
largeImageUrl=None):
"""Set response card as standard type.
title, text, and image cannot exceed 8,000 characters.
Args:
title: str. Title of Simple or Standard type card.
text: str. ... | [
"def",
"set_card_standard",
"(",
"self",
",",
"title",
",",
"text",
",",
"smallImageUrl",
"=",
"None",
",",
"largeImageUrl",
"=",
"None",
")",
":",
"self",
".",
"response",
".",
"card",
".",
"type",
"=",
"'Standard'",
"self",
".",
"response",
".",
"card"... | Set response card as standard type.
title, text, and image cannot exceed 8,000 characters.
Args:
title: str. Title of Simple or Standard type card.
text: str. Content of Standard type card.
smallImageUrl: str. URL of small image. Cannot exceed 2,000
... | [
"Set",
"response",
"card",
"as",
"standard",
"type",
"."
] | python | train |
MechanicalSoup/MechanicalSoup | mechanicalsoup/form.py | https://github.com/MechanicalSoup/MechanicalSoup/blob/027a270febf5bcda6a75db60ea9838d631370f4b/mechanicalsoup/form.py#L190-L231 | def set_select(self, data):
"""Set the *selected*-attribute of the first option element
specified by ``data`` (i.e. select an option from a dropdown).
:param data: Dict of ``{name: value, ...}``.
Find the select element whose *name*-attribute is ``name``.
Then select fro... | [
"def",
"set_select",
"(",
"self",
",",
"data",
")",
":",
"for",
"(",
"name",
",",
"value",
")",
"in",
"data",
".",
"items",
"(",
")",
":",
"select",
"=",
"self",
".",
"form",
".",
"find",
"(",
"\"select\"",
",",
"{",
"\"name\"",
":",
"name",
"}",... | Set the *selected*-attribute of the first option element
specified by ``data`` (i.e. select an option from a dropdown).
:param data: Dict of ``{name: value, ...}``.
Find the select element whose *name*-attribute is ``name``.
Then select from among its children the option element... | [
"Set",
"the",
"*",
"selected",
"*",
"-",
"attribute",
"of",
"the",
"first",
"option",
"element",
"specified",
"by",
"data",
"(",
"i",
".",
"e",
".",
"select",
"an",
"option",
"from",
"a",
"dropdown",
")",
"."
] | python | train |
Visgean/urljects | urljects/routemap.py | https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/routemap.py#L43-L58 | def include(self, location, namespace=None, app_name=None):
"""
Return an object suitable for url_patterns.
:param location: root URL for all URLs from this router
:param namespace: passed to url()
:param app_name: passed to url()
"""
sorted_entries = sorted(self... | [
"def",
"include",
"(",
"self",
",",
"location",
",",
"namespace",
"=",
"None",
",",
"app_name",
"=",
"None",
")",
":",
"sorted_entries",
"=",
"sorted",
"(",
"self",
".",
"routes",
",",
"key",
"=",
"operator",
".",
"itemgetter",
"(",
"0",
")",
",",
"r... | Return an object suitable for url_patterns.
:param location: root URL for all URLs from this router
:param namespace: passed to url()
:param app_name: passed to url() | [
"Return",
"an",
"object",
"suitable",
"for",
"url_patterns",
"."
] | python | train |
biocore/burrito-fillings | bfillings/mothur.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/mothur.py#L348-L366 | def _input_as_lines(self, data):
"""Write sequence of lines to temp file, return filename
data: a sequence to be written to a file, each element of the
sequence will compose a line in the file
* Note: '\n' will be stripped off the end of each sequence
element before wri... | [
"def",
"_input_as_lines",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_input_filename",
"=",
"self",
".",
"getTmpFilename",
"(",
"self",
".",
"WorkingDir",
",",
"suffix",
"=",
"'.fasta'",
")",
"with",
"open",
"(",
"self",
".",
"_input_filename",
",",... | Write sequence of lines to temp file, return filename
data: a sequence to be written to a file, each element of the
sequence will compose a line in the file
* Note: '\n' will be stripped off the end of each sequence
element before writing to a file in order to avoid
... | [
"Write",
"sequence",
"of",
"lines",
"to",
"temp",
"file",
"return",
"filename"
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10053-L10075 | def local_position_ned_cov_send(self, time_boot_ms, time_utc, estimator_type, x, y, z, vx, vy, vz, ax, ay, az, covariance, force_mavlink1=False):
'''
The filtered local position (e.g. fused computer vision and
accelerometers). Coordinate frame is right-handed,
... | [
"def",
"local_position_ned_cov_send",
"(",
"self",
",",
"time_boot_ms",
",",
"time_utc",
",",
"estimator_type",
",",
"x",
",",
"y",
",",
"z",
",",
"vx",
",",
"vy",
",",
"vz",
",",
"ax",
",",
"ay",
",",
"az",
",",
"covariance",
",",
"force_mavlink1",
"=... | The filtered local position (e.g. fused computer vision and
accelerometers). Coordinate frame is right-handed,
Z-axis down (aeronautical frame, NED / north-east-down
convention)
time_boot_ms : Timestamp (milliseconds since system boot). 0 for... | [
"The",
"filtered",
"local",
"position",
"(",
"e",
".",
"g",
".",
"fused",
"computer",
"vision",
"and",
"accelerometers",
")",
".",
"Coordinate",
"frame",
"is",
"right",
"-",
"handed",
"Z",
"-",
"axis",
"down",
"(",
"aeronautical",
"frame",
"NED",
"/",
"n... | python | train |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L110-L142 | def open_required(func):
"""Decorator to specify that the J-Link DLL must be opened, and a
J-Link connection must be established.
Args:
func (function): function being decorated
Returns:
The wrapper function.
"""
@functools.wraps(func)
def wr... | [
"def",
"open_required",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wrapper function to check that the given ``JLink`` has been\n ope... | Decorator to specify that the J-Link DLL must be opened, and a
J-Link connection must be established.
Args:
func (function): function being decorated
Returns:
The wrapper function. | [
"Decorator",
"to",
"specify",
"that",
"the",
"J",
"-",
"Link",
"DLL",
"must",
"be",
"opened",
"and",
"a",
"J",
"-",
"Link",
"connection",
"must",
"be",
"established",
"."
] | python | train |
totalgood/nlpia | src/nlpia/anki.py | https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/anki.py#L33-L46 | def get_anki_phrases_english(limit=None):
""" Return all the English phrases in the Anki translation flashcards
>>> len(get_anki_phrases_english(limit=100)) > 700
True
"""
texts = set()
for lang in ANKI_LANGUAGES:
df = get_data(lang)
phrases = df.eng.str.strip().values
... | [
"def",
"get_anki_phrases_english",
"(",
"limit",
"=",
"None",
")",
":",
"texts",
"=",
"set",
"(",
")",
"for",
"lang",
"in",
"ANKI_LANGUAGES",
":",
"df",
"=",
"get_data",
"(",
"lang",
")",
"phrases",
"=",
"df",
".",
"eng",
".",
"str",
".",
"strip",
"(... | Return all the English phrases in the Anki translation flashcards
>>> len(get_anki_phrases_english(limit=100)) > 700
True | [
"Return",
"all",
"the",
"English",
"phrases",
"in",
"the",
"Anki",
"translation",
"flashcards"
] | python | train |
scikit-hep/probfit | probfit/oneshot.py | https://github.com/scikit-hep/probfit/blob/de3593798ea3877dd2785062bed6877dd9058a02/probfit/oneshot.py#L11-L30 | def fit_uml(f, data, quiet=False, print_level=0, *arg, **kwd):
"""
perform unbinned likelihood fit
:param f: pdf
:param data: data
:param quiet: if not quite draw latest fit on fail fit
:param printlevel: minuit printlevel
:return:
"""
uml = UnbinnedLH(f, data)
minuit = Minuit(um... | [
"def",
"fit_uml",
"(",
"f",
",",
"data",
",",
"quiet",
"=",
"False",
",",
"print_level",
"=",
"0",
",",
"*",
"arg",
",",
"*",
"*",
"kwd",
")",
":",
"uml",
"=",
"UnbinnedLH",
"(",
"f",
",",
"data",
")",
"minuit",
"=",
"Minuit",
"(",
"uml",
",",
... | perform unbinned likelihood fit
:param f: pdf
:param data: data
:param quiet: if not quite draw latest fit on fail fit
:param printlevel: minuit printlevel
:return: | [
"perform",
"unbinned",
"likelihood",
"fit",
":",
"param",
"f",
":",
"pdf",
":",
"param",
"data",
":",
"data",
":",
"param",
"quiet",
":",
"if",
"not",
"quite",
"draw",
"latest",
"fit",
"on",
"fail",
"fit",
":",
"param",
"printlevel",
":",
"minuit",
"pr... | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L5573-L5592 | def getmsg(option, lenout=_default_len_out):
"""
Retrieve the current short error message,
the explanation of the short error message, or the
long error message.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getmsg_c.html
:param option: Indicates type of error message.
:type opti... | [
"def",
"getmsg",
"(",
"option",
",",
"lenout",
"=",
"_default_len_out",
")",
":",
"option",
"=",
"stypes",
".",
"stringToCharP",
"(",
"option",
")",
"lenout",
"=",
"ctypes",
".",
"c_int",
"(",
"lenout",
")",
"msg",
"=",
"stypes",
".",
"stringToCharP",
"(... | Retrieve the current short error message,
the explanation of the short error message, or the
long error message.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getmsg_c.html
:param option: Indicates type of error message.
:type option: str
:param lenout: Available space in the output ... | [
"Retrieve",
"the",
"current",
"short",
"error",
"message",
"the",
"explanation",
"of",
"the",
"short",
"error",
"message",
"or",
"the",
"long",
"error",
"message",
"."
] | python | train |
davidfokkema/artist | artist/utils.py | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/utils.py#L86-L98 | def save_data(data, suffix='', dirname=None):
"""Save a dataset using caller's name.
:param data: a list or numpy array containing the data
:param suffix: optional suffix to add to name
:param dirname: optional directory name
"""
if type(data) == list:
data = np.array(data).T
name... | [
"def",
"save_data",
"(",
"data",
",",
"suffix",
"=",
"''",
",",
"dirname",
"=",
"None",
")",
":",
"if",
"type",
"(",
"data",
")",
"==",
"list",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
")",
".",
"T",
"name",
"=",
"create_graph_name",
"(... | Save a dataset using caller's name.
:param data: a list or numpy array containing the data
:param suffix: optional suffix to add to name
:param dirname: optional directory name | [
"Save",
"a",
"dataset",
"using",
"caller",
"s",
"name",
"."
] | python | train |
zetaops/pyoko | pyoko/manage.py | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L934-L947 | def _format_links_fields(self, links):
"""
Format the fields containing links into 4-tuples printable by _print_fields().
"""
fields = list()
for link in links:
linked_model = link['mdl'](super_context)
null = self._marker_true if link['null'] is True else... | [
"def",
"_format_links_fields",
"(",
"self",
",",
"links",
")",
":",
"fields",
"=",
"list",
"(",
")",
"for",
"link",
"in",
"links",
":",
"linked_model",
"=",
"link",
"[",
"'mdl'",
"]",
"(",
"super_context",
")",
"null",
"=",
"self",
".",
"_marker_true",
... | Format the fields containing links into 4-tuples printable by _print_fields(). | [
"Format",
"the",
"fields",
"containing",
"links",
"into",
"4",
"-",
"tuples",
"printable",
"by",
"_print_fields",
"()",
"."
] | python | train |
saltstack/salt | salt/modules/bcache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bcache.py#L128-L155 | def detach(dev=None):
'''
Detach a backing device(s) from a cache set
If no dev is given, all backing devices will be attached.
Detaching a backing device will flush it's write cache.
This should leave the underlying device in a consistent state, but might take a while.
CLI example:
.. co... | [
"def",
"detach",
"(",
"dev",
"=",
"None",
")",
":",
"if",
"dev",
"is",
"None",
":",
"res",
"=",
"{",
"}",
"for",
"dev",
",",
"data",
"in",
"status",
"(",
"alldevs",
"=",
"True",
")",
".",
"items",
"(",
")",
":",
"if",
"'cache'",
"in",
"data",
... | Detach a backing device(s) from a cache set
If no dev is given, all backing devices will be attached.
Detaching a backing device will flush it's write cache.
This should leave the underlying device in a consistent state, but might take a while.
CLI example:
.. code-block:: bash
salt '*' ... | [
"Detach",
"a",
"backing",
"device",
"(",
"s",
")",
"from",
"a",
"cache",
"set",
"If",
"no",
"dev",
"is",
"given",
"all",
"backing",
"devices",
"will",
"be",
"attached",
"."
] | python | train |
hatemile/hatemile-for-python | hatemile/implementation/navig.py | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/navig.py#L291-L314 | def _is_valid_heading(self):
"""
Check that the headings of page are sintatic correct.
:return: True if the headings of page are sintatic correct or False if
not.
:rtype: bool
"""
elements = self.parser.find('h1,h2,h3,h4,h5,h6').list_results()
l... | [
"def",
"_is_valid_heading",
"(",
"self",
")",
":",
"elements",
"=",
"self",
".",
"parser",
".",
"find",
"(",
"'h1,h2,h3,h4,h5,h6'",
")",
".",
"list_results",
"(",
")",
"last_level",
"=",
"0",
"count_main_heading",
"=",
"0",
"self",
".",
"validate_heading",
"... | Check that the headings of page are sintatic correct.
:return: True if the headings of page are sintatic correct or False if
not.
:rtype: bool | [
"Check",
"that",
"the",
"headings",
"of",
"page",
"are",
"sintatic",
"correct",
"."
] | python | train |
ishikota/PyPokerEngine | pypokerengine/players.py | https://github.com/ishikota/PyPokerEngine/blob/a52a048a15da276005eca4acae96fb6eeb4dc034/pypokerengine/players.py#L45-L48 | def respond_to_ask(self, message):
"""Called from Dealer when ask message received from RoundManager"""
valid_actions, hole_card, round_state = self.__parse_ask_message(message)
return self.declare_action(valid_actions, hole_card, round_state) | [
"def",
"respond_to_ask",
"(",
"self",
",",
"message",
")",
":",
"valid_actions",
",",
"hole_card",
",",
"round_state",
"=",
"self",
".",
"__parse_ask_message",
"(",
"message",
")",
"return",
"self",
".",
"declare_action",
"(",
"valid_actions",
",",
"hole_card",
... | Called from Dealer when ask message received from RoundManager | [
"Called",
"from",
"Dealer",
"when",
"ask",
"message",
"received",
"from",
"RoundManager"
] | python | train |
jterrace/pyssim | ssim/utils.py | https://github.com/jterrace/pyssim/blob/ff9bd90c3eb7525013ad46babf66b7cc78391e89/ssim/utils.py#L31-L47 | def to_grayscale(img):
"""Convert PIL image to numpy grayscale array and numpy alpha array.
Args:
img (PIL.Image): PIL Image object.
Returns:
(gray, alpha): both numpy arrays.
"""
gray = numpy.asarray(ImageOps.grayscale(img)).astype(numpy.float)
imbands = img.getbands()
alpha ... | [
"def",
"to_grayscale",
"(",
"img",
")",
":",
"gray",
"=",
"numpy",
".",
"asarray",
"(",
"ImageOps",
".",
"grayscale",
"(",
"img",
")",
")",
".",
"astype",
"(",
"numpy",
".",
"float",
")",
"imbands",
"=",
"img",
".",
"getbands",
"(",
")",
"alpha",
"... | Convert PIL image to numpy grayscale array and numpy alpha array.
Args:
img (PIL.Image): PIL Image object.
Returns:
(gray, alpha): both numpy arrays. | [
"Convert",
"PIL",
"image",
"to",
"numpy",
"grayscale",
"array",
"and",
"numpy",
"alpha",
"array",
"."
] | python | test |
StagPython/StagPy | stagpy/stagyyparsers.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L259-L386 | def fields(fieldfile, only_header=False, only_istep=False):
"""Extract fields data.
Args:
fieldfile (:class:`pathlib.Path`): path of the binary field file.
only_header (bool): when True (and :data:`only_istep` is False), only
:data:`header` is returned.
only_istep (bool): wh... | [
"def",
"fields",
"(",
"fieldfile",
",",
"only_header",
"=",
"False",
",",
"only_istep",
"=",
"False",
")",
":",
"# something to skip header?",
"if",
"not",
"fieldfile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
"header",
"=",
"{",
"}",
"with",
"fiel... | Extract fields data.
Args:
fieldfile (:class:`pathlib.Path`): path of the binary field file.
only_header (bool): when True (and :data:`only_istep` is False), only
:data:`header` is returned.
only_istep (bool): when True, only :data:`istep` is returned.
Returns:
depe... | [
"Extract",
"fields",
"data",
"."
] | python | train |
robin900/gspread-dataframe | gspread_dataframe.py | https://github.com/robin900/gspread-dataframe/blob/b64fef7ec196bfed69362aa35c593f448830a735/gspread_dataframe.py#L118-L135 | def get_as_dataframe(worksheet,
evaluate_formulas=False,
**options):
"""
Returns the worksheet contents as a DataFrame.
:param worksheet: the worksheet.
:param evaluate_formulas: if True, get the value of a cell after
formula evaluation; otherwise g... | [
"def",
"get_as_dataframe",
"(",
"worksheet",
",",
"evaluate_formulas",
"=",
"False",
",",
"*",
"*",
"options",
")",
":",
"all_values",
"=",
"_get_all_values",
"(",
"worksheet",
",",
"evaluate_formulas",
")",
"return",
"TextParser",
"(",
"all_values",
",",
"*",
... | Returns the worksheet contents as a DataFrame.
:param worksheet: the worksheet.
:param evaluate_formulas: if True, get the value of a cell after
formula evaluation; otherwise get the formula itself if present.
Defaults to False.
:param \*\*options: all the options for pandas.io.pars... | [
"Returns",
"the",
"worksheet",
"contents",
"as",
"a",
"DataFrame",
"."
] | python | train |
google/grumpy | third_party/stdlib/quopri.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L21-L33 | def needsquoting(c, quotetabs, header):
"""Decide whether a particular character needs to be quoted.
The 'quotetabs' flag indicates whether embedded tabs and spaces should be
quoted. Note that line-ending tabs and spaces are always encoded, as per
RFC 1521.
"""
if c in ' \t':
return qu... | [
"def",
"needsquoting",
"(",
"c",
",",
"quotetabs",
",",
"header",
")",
":",
"if",
"c",
"in",
"' \\t'",
":",
"return",
"quotetabs",
"# if header, we have to escape _ because _ is used to escape space",
"if",
"c",
"==",
"'_'",
":",
"return",
"header",
"return",
"c",... | Decide whether a particular character needs to be quoted.
The 'quotetabs' flag indicates whether embedded tabs and spaces should be
quoted. Note that line-ending tabs and spaces are always encoded, as per
RFC 1521. | [
"Decide",
"whether",
"a",
"particular",
"character",
"needs",
"to",
"be",
"quoted",
"."
] | python | valid |
Autodesk/aomi | aomi/helpers.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L140-L155 | def mount_for_path(path, client):
"""Returns the mountpoint for this path"""
backend_data = client.list_secret_backends()['data']
backends = [mnt for mnt in backend_data.keys()]
path_bits = path.split('/')
if len(path_bits) == 1:
vault_path = "%s/" % path
if vault_path in backends:
... | [
"def",
"mount_for_path",
"(",
"path",
",",
"client",
")",
":",
"backend_data",
"=",
"client",
".",
"list_secret_backends",
"(",
")",
"[",
"'data'",
"]",
"backends",
"=",
"[",
"mnt",
"for",
"mnt",
"in",
"backend_data",
".",
"keys",
"(",
")",
"]",
"path_bi... | Returns the mountpoint for this path | [
"Returns",
"the",
"mountpoint",
"for",
"this",
"path"
] | python | train |
BlackEarth/bxml | bxml/xt.py | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xt.py#L45-L51 | def get_match(self, elem):
"""for the given elem, return the @match function that will be applied"""
for m in self.matches:
if (m.expression is not None and eval(m.expression)==True) \
or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
... | [
"def",
"get_match",
"(",
"self",
",",
"elem",
")",
":",
"for",
"m",
"in",
"self",
".",
"matches",
":",
"if",
"(",
"m",
".",
"expression",
"is",
"not",
"None",
"and",
"eval",
"(",
"m",
".",
"expression",
")",
"==",
"True",
")",
"or",
"(",
"m",
"... | for the given elem, return the @match function that will be applied | [
"for",
"the",
"given",
"elem",
"return",
"the"
] | python | train |
pkkid/python-plexapi | plexapi/media.py | https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/media.py#L177-L188 | def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.codec = data.attrib.get('codec')
self.codecID = data.attrib.get('codecID')
self.id = cast(int, data.attrib.get('id'))
self.index = cast(int, data.attrib.get('index', '-... | [
"def",
"_loadData",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"codec",
"=",
"data",
".",
"attrib",
".",
"get",
"(",
"'codec'",
")",
"self",
".",
"codecID",
"=",
"data",
".",
"attrib",
".",
"get",
"(",
"'c... | Load attribute values from Plex XML response. | [
"Load",
"attribute",
"values",
"from",
"Plex",
"XML",
"response",
"."
] | python | train |
aboSamoor/polyglot | polyglot/base.py | https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/base.py#L108-L132 | def iter_delimiter(self, byte_size=8192):
""" Generalization of the default iter file delimited by '\n'.
Note:
The newline string can be arbitrarily long; it need not be restricted to a
single character. You can also set the read size and control whether or not
the newline string is left on th... | [
"def",
"iter_delimiter",
"(",
"self",
",",
"byte_size",
"=",
"8192",
")",
":",
"partial",
"=",
"u''",
"while",
"True",
":",
"read_chars",
"=",
"self",
".",
"read",
"(",
"byte_size",
")",
"if",
"not",
"read_chars",
":",
"break",
"partial",
"+=",
"read_cha... | Generalization of the default iter file delimited by '\n'.
Note:
The newline string can be arbitrarily long; it need not be restricted to a
single character. You can also set the read size and control whether or not
the newline string is left on the end of the iterated lines. Setting
newlin... | [
"Generalization",
"of",
"the",
"default",
"iter",
"file",
"delimited",
"by",
"\\",
"n",
".",
"Note",
":",
"The",
"newline",
"string",
"can",
"be",
"arbitrarily",
"long",
";",
"it",
"need",
"not",
"be",
"restricted",
"to",
"a",
"single",
"character",
".",
... | python | train |
dls-controls/pymalcolm | malcolm/core/concurrency.py | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/concurrency.py#L61-L67 | def get(self, timeout=None):
# type: (float) -> T
"""Return the result or raise the error the function has produced"""
self.wait(timeout)
if isinstance(self._result, Exception):
raise self._result
return self._result | [
"def",
"get",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# type: (float) -> T",
"self",
".",
"wait",
"(",
"timeout",
")",
"if",
"isinstance",
"(",
"self",
".",
"_result",
",",
"Exception",
")",
":",
"raise",
"self",
".",
"_result",
"return",
... | Return the result or raise the error the function has produced | [
"Return",
"the",
"result",
"or",
"raise",
"the",
"error",
"the",
"function",
"has",
"produced"
] | python | train |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L111-L123 | def read(self, identifier, path):
""" Retrieve and parse a text given an identifier
:param identifier: Identifier of the text
:type identifier: str
:param path: Path of the text
:type path: str
:return: Parsed Text
:rtype: CapitainsCtsText
"""
wit... | [
"def",
"read",
"(",
"self",
",",
"identifier",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"o",
"=",
"self",
".",
"classes",
"[",
"\"text\"",
"]",
"(",
"urn",
"=",
"identifier",
",",
"resource",
"=",
"self",
".",
"xml... | Retrieve and parse a text given an identifier
:param identifier: Identifier of the text
:type identifier: str
:param path: Path of the text
:type path: str
:return: Parsed Text
:rtype: CapitainsCtsText | [
"Retrieve",
"and",
"parse",
"a",
"text",
"given",
"an",
"identifier"
] | python | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L139-L157 | def _rdtxt_gos(self, ret, go_file):
"""Read GO IDs from a file."""
if not os.path.exists(go_file):
raise RuntimeError("CAN NOT READ: {FILE}\n".format(FILE=go_file))
goids = set()
go2color = {}
with open(go_file) as ifstrm:
for line in ifstrm:
... | [
"def",
"_rdtxt_gos",
"(",
"self",
",",
"ret",
",",
"go_file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"go_file",
")",
":",
"raise",
"RuntimeError",
"(",
"\"CAN NOT READ: {FILE}\\n\"",
".",
"format",
"(",
"FILE",
"=",
"go_file",
")",... | Read GO IDs from a file. | [
"Read",
"GO",
"IDs",
"from",
"a",
"file",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/view.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/view.py#L59-L115 | def get_port_at_point(self, vpos, distance=10, exclude=None, exclude_port_fun=None):
"""
Find item with port closest to specified position.
List of items to be ignored can be specified with `exclude`
parameter.
Tuple is returned
- found item
- closest, connecta... | [
"def",
"get_port_at_point",
"(",
"self",
",",
"vpos",
",",
"distance",
"=",
"10",
",",
"exclude",
"=",
"None",
",",
"exclude_port_fun",
"=",
"None",
")",
":",
"# Method had to be inherited, as the base method has a bug:",
"# It misses the statement max_dist = d",
"v2i",
... | Find item with port closest to specified position.
List of items to be ignored can be specified with `exclude`
parameter.
Tuple is returned
- found item
- closest, connectable port
- closest point on found port (in view coordinates)
:Parameters:
vpos
... | [
"Find",
"item",
"with",
"port",
"closest",
"to",
"specified",
"position",
"."
] | python | train |
aio-libs/aioredis | aioredis/commands/cluster.py | https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/cluster.py#L74-L78 | def cluster_reset(self, *, hard=False):
"""Reset a Redis Cluster node."""
reset = hard and b'HARD' or b'SOFT'
fut = self.execute(b'CLUSTER', b'RESET', reset)
return wait_ok(fut) | [
"def",
"cluster_reset",
"(",
"self",
",",
"*",
",",
"hard",
"=",
"False",
")",
":",
"reset",
"=",
"hard",
"and",
"b'HARD'",
"or",
"b'SOFT'",
"fut",
"=",
"self",
".",
"execute",
"(",
"b'CLUSTER'",
",",
"b'RESET'",
",",
"reset",
")",
"return",
"wait_ok",... | Reset a Redis Cluster node. | [
"Reset",
"a",
"Redis",
"Cluster",
"node",
"."
] | python | train |
Samreay/ChainConsumer | chainconsumer/chainconsumer.py | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/chainconsumer.py#L783-L816 | def divide_chain(self, chain=0):
"""
Returns a ChainConsumer instance containing all the walks of a given chain
as individual chains themselves.
This method might be useful if, for example, your chain was made using
MCMC with 4 walkers. To check the sampling of all 4 walkers agr... | [
"def",
"divide_chain",
"(",
"self",
",",
"chain",
"=",
"0",
")",
":",
"indexes",
"=",
"self",
".",
"_get_chain",
"(",
"chain",
")",
"con",
"=",
"ChainConsumer",
"(",
")",
"for",
"index",
"in",
"indexes",
":",
"chain",
"=",
"self",
".",
"chains",
"[",... | Returns a ChainConsumer instance containing all the walks of a given chain
as individual chains themselves.
This method might be useful if, for example, your chain was made using
MCMC with 4 walkers. To check the sampling of all 4 walkers agree, you could
call this to get a ChainConsume... | [
"Returns",
"a",
"ChainConsumer",
"instance",
"containing",
"all",
"the",
"walks",
"of",
"a",
"given",
"chain",
"as",
"individual",
"chains",
"themselves",
"."
] | python | train |
ming060/robotframework-uiautomatorlibrary | uiautomatorlibrary/Mobile.py | https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L288-L294 | def swipe_top(self, steps=10, *args, **selectors):
"""
Swipe the UI object with *selectors* from center to top
See `Swipe Left` for more details.
"""
self.device(**selectors).swipe.up(steps=steps) | [
"def",
"swipe_top",
"(",
"self",
",",
"steps",
"=",
"10",
",",
"*",
"args",
",",
"*",
"*",
"selectors",
")",
":",
"self",
".",
"device",
"(",
"*",
"*",
"selectors",
")",
".",
"swipe",
".",
"up",
"(",
"steps",
"=",
"steps",
")"
] | Swipe the UI object with *selectors* from center to top
See `Swipe Left` for more details. | [
"Swipe",
"the",
"UI",
"object",
"with",
"*",
"selectors",
"*",
"from",
"center",
"to",
"top"
] | python | train |
scanny/python-pptx | pptx/oxml/table.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/table.py#L479-L482 | def dimensions(self):
"""(row_count, col_count) pair describing size of range."""
_, _, width, height = self._extents
return height, width | [
"def",
"dimensions",
"(",
"self",
")",
":",
"_",
",",
"_",
",",
"width",
",",
"height",
"=",
"self",
".",
"_extents",
"return",
"height",
",",
"width"
] | (row_count, col_count) pair describing size of range. | [
"(",
"row_count",
"col_count",
")",
"pair",
"describing",
"size",
"of",
"range",
"."
] | python | train |
twisted/mantissa | xmantissa/website.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/website.py#L194-L223 | def _produceIt(self, segments, thunk):
"""
Underlying implmeentation of L{PrefixURLMixin.produceResource} and
L{PrefixURLMixin.sessionlessProduceResource}.
@param segments: the URL segments to dispatch.
@param thunk: a 0-argument callable which returns an L{IResource}
p... | [
"def",
"_produceIt",
"(",
"self",
",",
"segments",
",",
"thunk",
")",
":",
"if",
"not",
"self",
".",
"prefixURL",
":",
"needle",
"=",
"(",
")",
"else",
":",
"needle",
"=",
"tuple",
"(",
"self",
".",
"prefixURL",
".",
"split",
"(",
"'/'",
")",
")",
... | Underlying implmeentation of L{PrefixURLMixin.produceResource} and
L{PrefixURLMixin.sessionlessProduceResource}.
@param segments: the URL segments to dispatch.
@param thunk: a 0-argument callable which returns an L{IResource}
provider, or None.
@return: a 2-tuple of C{(resourc... | [
"Underlying",
"implmeentation",
"of",
"L",
"{",
"PrefixURLMixin",
".",
"produceResource",
"}",
"and",
"L",
"{",
"PrefixURLMixin",
".",
"sessionlessProduceResource",
"}",
"."
] | python | train |
yamins81/tabular | tabular/fast.py | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L308-L354 | def recarrayisin(X,Y,weak=True):
"""
Indices of elements in a numpy record array (or ndarray with structured
dtype) that appear in another.
Fast routine for determining indices of elements in numpy record array `X`
that appear in numpy record array `Y`, returning a boolean array `Z` such
tha... | [
"def",
"recarrayisin",
"(",
"X",
",",
"Y",
",",
"weak",
"=",
"True",
")",
":",
"if",
"(",
"weak",
"and",
"set",
"(",
"X",
".",
"dtype",
".",
"names",
")",
"!=",
"set",
"(",
"Y",
".",
"dtype",
".",
"names",
")",
")",
"or",
"(",
"not",
"weak",
... | Indices of elements in a numpy record array (or ndarray with structured
dtype) that appear in another.
Fast routine for determining indices of elements in numpy record array `X`
that appear in numpy record array `Y`, returning a boolean array `Z` such
that::
Z[i] = X[i] in Y
Record... | [
"Indices",
"of",
"elements",
"in",
"a",
"numpy",
"record",
"array",
"(",
"or",
"ndarray",
"with",
"structured",
"dtype",
")",
"that",
"appear",
"in",
"another",
"."
] | python | train |
JoelBender/bacpypes | py25/bacpypes/bsllservice.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/bsllservice.py#L1006-L1039 | def process_npdu(self, npdu):
"""encode NPDUs from the service access point and send them downstream."""
if _debug: RouterToRouterService._debug("process_npdu %r", npdu)
# encode the npdu as if it was about to be delivered to the network
pdu = PDU()
npdu.encode(pdu)
if _... | [
"def",
"process_npdu",
"(",
"self",
",",
"npdu",
")",
":",
"if",
"_debug",
":",
"RouterToRouterService",
".",
"_debug",
"(",
"\"process_npdu %r\"",
",",
"npdu",
")",
"# encode the npdu as if it was about to be delivered to the network",
"pdu",
"=",
"PDU",
"(",
")",
... | encode NPDUs from the service access point and send them downstream. | [
"encode",
"NPDUs",
"from",
"the",
"service",
"access",
"point",
"and",
"send",
"them",
"downstream",
"."
] | python | train |
klmitch/turnstile | turnstile/limits.py | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/limits.py#L464-L472 | def dehydrate(self):
"""Return a dict representing this bucket."""
# Only concerned about very specific attributes
result = {}
for attr in self.attrs:
result[attr] = getattr(self, attr)
return result | [
"def",
"dehydrate",
"(",
"self",
")",
":",
"# Only concerned about very specific attributes",
"result",
"=",
"{",
"}",
"for",
"attr",
"in",
"self",
".",
"attrs",
":",
"result",
"[",
"attr",
"]",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"return",
"res... | Return a dict representing this bucket. | [
"Return",
"a",
"dict",
"representing",
"this",
"bucket",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.