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 |
|---|---|---|---|---|---|---|---|---|
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L430-L449 | def setFileTime(
self, fileName, creationTime, lastAccessTime, lastWriteTime, dokanFileInfo
):
"""Set time values for a file.
:param fileName: name of file to set time values for
:type fileName: ctypes.c_wchar_p
:param creationTime: creation time of file
:type creati... | [
"def",
"setFileTime",
"(",
"self",
",",
"fileName",
",",
"creationTime",
",",
"lastAccessTime",
",",
"lastWriteTime",
",",
"dokanFileInfo",
")",
":",
"return",
"self",
".",
"operations",
"(",
"'setFileTime'",
",",
"fileName",
")"
] | Set time values for a file.
:param fileName: name of file to set time values for
:type fileName: ctypes.c_wchar_p
:param creationTime: creation time of file
:type creationTime: ctypes.POINTER(ctypes.wintypes.FILETIME)
:param lastAccessTime: last access time of file
:type... | [
"Set",
"time",
"values",
"for",
"a",
"file",
"."
] | python | train |
doconix/django-mako-plus | django_mako_plus/tags.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/tags.py#L14-L33 | def django_include(context, template_name, **kwargs):
'''
Mako tag to include a Django template withing the current DMP (Mako) template.
Since this is a Django template, it is search for using the Django search
algorithm (instead of the DMP app-based concept).
See https://docs.djangoproject.com/en/2... | [
"def",
"django_include",
"(",
"context",
",",
"template_name",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"djengine",
"=",
"engines",
"[",
"'django'",
"]",
"except",
"KeyError",
"as",
"e",
":",
"raise",
"TemplateDoesNotExist",
"(",
"\"Django template engin... | Mako tag to include a Django template withing the current DMP (Mako) template.
Since this is a Django template, it is search for using the Django search
algorithm (instead of the DMP app-based concept).
See https://docs.djangoproject.com/en/2.1/topics/templates/.
The current context is sent to the incl... | [
"Mako",
"tag",
"to",
"include",
"a",
"Django",
"template",
"withing",
"the",
"current",
"DMP",
"(",
"Mako",
")",
"template",
".",
"Since",
"this",
"is",
"a",
"Django",
"template",
"it",
"is",
"search",
"for",
"using",
"the",
"Django",
"search",
"algorithm"... | python | train |
erikrose/nose-progressive | noseprogressive/runner.py | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/runner.py#L16-L27 | def _makeResult(self):
"""Return a Result that doesn't print dots.
Nose's ResultProxy will wrap it, and other plugins can still print
stuff---but without smashing into our progress bar, care of
ProgressivePlugin's stderr/out wrapping.
"""
return ProgressiveResult(self._... | [
"def",
"_makeResult",
"(",
"self",
")",
":",
"return",
"ProgressiveResult",
"(",
"self",
".",
"_cwd",
",",
"self",
".",
"_totalTests",
",",
"self",
".",
"stream",
",",
"config",
"=",
"self",
".",
"config",
")"
] | Return a Result that doesn't print dots.
Nose's ResultProxy will wrap it, and other plugins can still print
stuff---but without smashing into our progress bar, care of
ProgressivePlugin's stderr/out wrapping. | [
"Return",
"a",
"Result",
"that",
"doesn",
"t",
"print",
"dots",
"."
] | python | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/css.py | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/css.py#L159-L169 | def findStylesForEach(self, element, attrNames, default=NotImplemented):
"""Attempts to find the style setting for attrName in the CSSRulesets.
Note: This method does not attempt to resolve rules that return
"inherited", "default", or values that have units (including "%").
This is left... | [
"def",
"findStylesForEach",
"(",
"self",
",",
"element",
",",
"attrNames",
",",
"default",
"=",
"NotImplemented",
")",
":",
"rules",
"=",
"self",
".",
"findCSSRulesForEach",
"(",
"element",
",",
"attrNames",
")",
"return",
"[",
"(",
"attrName",
",",
"self",
... | Attempts to find the style setting for attrName in the CSSRulesets.
Note: This method does not attempt to resolve rules that return
"inherited", "default", or values that have units (including "%").
This is left up to the client app to re-query the CSS in order to
implement these semant... | [
"Attempts",
"to",
"find",
"the",
"style",
"setting",
"for",
"attrName",
"in",
"the",
"CSSRulesets",
"."
] | python | train |
mwouts/jupytext | jupytext/magics.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L46-L55 | def comment_magic(source, language='python', global_escape_flag=True):
"""Escape Jupyter magics with '# '"""
parser = StringParser(language)
next_is_magic = False
for pos, line in enumerate(source):
if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)):
... | [
"def",
"comment_magic",
"(",
"source",
",",
"language",
"=",
"'python'",
",",
"global_escape_flag",
"=",
"True",
")",
":",
"parser",
"=",
"StringParser",
"(",
"language",
")",
"next_is_magic",
"=",
"False",
"for",
"pos",
",",
"line",
"in",
"enumerate",
"(",
... | Escape Jupyter magics with '# | [
"Escape",
"Jupyter",
"magics",
"with",
"#"
] | python | train |
Cognexa/cxflow | cxflow/main_loop.py | https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/main_loop.py#L182-L188 | def train_by_stream(self, stream: StreamWrapper) -> None:
"""
Train the model with the given stream.
:param stream: stream to train with
"""
self._run_epoch(stream=stream, train=True) | [
"def",
"train_by_stream",
"(",
"self",
",",
"stream",
":",
"StreamWrapper",
")",
"->",
"None",
":",
"self",
".",
"_run_epoch",
"(",
"stream",
"=",
"stream",
",",
"train",
"=",
"True",
")"
] | Train the model with the given stream.
:param stream: stream to train with | [
"Train",
"the",
"model",
"with",
"the",
"given",
"stream",
"."
] | python | train |
econ-ark/HARK | HARK/ConsumptionSaving/ConsIndShockModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsIndShockModel.py#L1183-L1244 | def solveConsIndShock(solution_next,IncomeDstn,LivPrb,DiscFac,CRRA,Rfree,PermGroFac,
BoroCnstArt,aXtraGrid,vFuncBool,CubicBool):
'''
Solves a single period consumption-saving problem with CRRA utility and risky
income (subject to permanent and transitory shocks). Can generat... | [
"def",
"solveConsIndShock",
"(",
"solution_next",
",",
"IncomeDstn",
",",
"LivPrb",
",",
"DiscFac",
",",
"CRRA",
",",
"Rfree",
",",
"PermGroFac",
",",
"BoroCnstArt",
",",
"aXtraGrid",
",",
"vFuncBool",
",",
"CubicBool",
")",
":",
"# Use the basic solver if user do... | Solves a single period consumption-saving problem with CRRA utility and risky
income (subject to permanent and transitory shocks). Can generate a value
function if requested; consumption function can be linear or cubic splines.
Parameters
----------
solution_next : ConsumerSolution
The sol... | [
"Solves",
"a",
"single",
"period",
"consumption",
"-",
"saving",
"problem",
"with",
"CRRA",
"utility",
"and",
"risky",
"income",
"(",
"subject",
"to",
"permanent",
"and",
"transitory",
"shocks",
")",
".",
"Can",
"generate",
"a",
"value",
"function",
"if",
"r... | python | train |
spyder-ide/spyder | spyder/plugins/editor/extensions/docstring.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/extensions/docstring.py#L479-L524 | def parse_return_elements(return_vals_group, return_element_name,
return_element_type, placeholder):
"""Return the appropriate text for a group of return elements."""
all_eq = (return_vals_group.count(return_vals_group[0])
== len(return_vals_group))
... | [
"def",
"parse_return_elements",
"(",
"return_vals_group",
",",
"return_element_name",
",",
"return_element_type",
",",
"placeholder",
")",
":",
"all_eq",
"=",
"(",
"return_vals_group",
".",
"count",
"(",
"return_vals_group",
"[",
"0",
"]",
")",
"==",
"len",
"(",
... | Return the appropriate text for a group of return elements. | [
"Return",
"the",
"appropriate",
"text",
"for",
"a",
"group",
"of",
"return",
"elements",
"."
] | python | train |
ssalentin/plip | plip/modules/report.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L37-L73 | def construct_xml_tree(self):
"""Construct the basic XML tree"""
report = et.Element('report')
plipversion = et.SubElement(report, 'plipversion')
plipversion.text = __version__
date_of_creation = et.SubElement(report, 'date_of_creation')
date_of_creation.text = time.strft... | [
"def",
"construct_xml_tree",
"(",
"self",
")",
":",
"report",
"=",
"et",
".",
"Element",
"(",
"'report'",
")",
"plipversion",
"=",
"et",
".",
"SubElement",
"(",
"report",
",",
"'plipversion'",
")",
"plipversion",
".",
"text",
"=",
"__version__",
"date_of_cre... | Construct the basic XML tree | [
"Construct",
"the",
"basic",
"XML",
"tree"
] | python | train |
dvdotsenko/jsonrpc.py | jsonrpcparts/serializers.py | https://github.com/dvdotsenko/jsonrpc.py/blob/19673edd77a9518ac5655bd407f6b93ffbb2cafc/jsonrpcparts/serializers.py#L136-L153 | def assemble_notification_request(method, params=tuple()):
"""serialize a JSON-RPC-Notification
:Parameters: see dumps_request
:Returns: | {"method": "...", "params": ..., "id": null}
| "method", "params" and "id" are always in this order.
:Raises: see dumps_req... | [
"def",
"assemble_notification_request",
"(",
"method",
",",
"params",
"=",
"tuple",
"(",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"method",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"TypeError",
"(",
"'\"method\" must be a string (or unico... | serialize a JSON-RPC-Notification
:Parameters: see dumps_request
:Returns: | {"method": "...", "params": ..., "id": null}
| "method", "params" and "id" are always in this order.
:Raises: see dumps_request | [
"serialize",
"a",
"JSON",
"-",
"RPC",
"-",
"Notification"
] | python | train |
secdev/scapy | scapy/layers/sixlowpan.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L707-L716 | def _getTrafficClassAndFlowLabel(self):
"""Page 6, draft feb 2011 """
if self.tf == 0x0:
return (self.tc_ecn << 6) + self.tc_dscp, self.flowlabel
elif self.tf == 0x1:
return (self.tc_ecn << 6), self.flowlabel
elif self.tf == 0x2:
return (self.tc_ecn <<... | [
"def",
"_getTrafficClassAndFlowLabel",
"(",
"self",
")",
":",
"if",
"self",
".",
"tf",
"==",
"0x0",
":",
"return",
"(",
"self",
".",
"tc_ecn",
"<<",
"6",
")",
"+",
"self",
".",
"tc_dscp",
",",
"self",
".",
"flowlabel",
"elif",
"self",
".",
"tf",
"=="... | Page 6, draft feb 2011 | [
"Page",
"6",
"draft",
"feb",
"2011"
] | python | train |
django-cumulus/django-cumulus | cumulus/management/commands/syncfiles.py | https://github.com/django-cumulus/django-cumulus/blob/64feb07b857af28f226be4899e875c29405e261d/cumulus/management/commands/syncfiles.py#L154-L175 | def match_local(self, prefix, includes, excludes):
"""
Filters os.walk() with include and exclude patterns.
See: http://stackoverflow.com/a/5141829/93559
"""
includes_pattern = r"|".join([fnmatch.translate(x) for x in includes])
excludes_pattern = r"|".join([fnmatch.trans... | [
"def",
"match_local",
"(",
"self",
",",
"prefix",
",",
"includes",
",",
"excludes",
")",
":",
"includes_pattern",
"=",
"r\"|\"",
".",
"join",
"(",
"[",
"fnmatch",
".",
"translate",
"(",
"x",
")",
"for",
"x",
"in",
"includes",
"]",
")",
"excludes_pattern"... | Filters os.walk() with include and exclude patterns.
See: http://stackoverflow.com/a/5141829/93559 | [
"Filters",
"os",
".",
"walk",
"()",
"with",
"include",
"and",
"exclude",
"patterns",
".",
"See",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"5141829",
"/",
"93559"
] | python | train |
pinax/pinax-blog | pinax/blog/parsers/creole_parser.py | https://github.com/pinax/pinax-blog/blob/be1d64946381b47d197b258a488d5de56aacccce/pinax/blog/parsers/creole_parser.py#L142-L145 | def emit_node(self, node):
"""Emit a single node."""
emit = getattr(self, "%s_emit" % node.kind, self.default_emit)
return emit(node) | [
"def",
"emit_node",
"(",
"self",
",",
"node",
")",
":",
"emit",
"=",
"getattr",
"(",
"self",
",",
"\"%s_emit\"",
"%",
"node",
".",
"kind",
",",
"self",
".",
"default_emit",
")",
"return",
"emit",
"(",
"node",
")"
] | Emit a single node. | [
"Emit",
"a",
"single",
"node",
"."
] | python | train |
contains-io/rcli | rcli/usage.py | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L310-L333 | def _get_definitions(source):
# type: (str) -> Tuple[Dict[str, str], int]
"""Extract a dictionary of arguments and definitions.
Args:
source: The source for a section of a usage string that contains
definitions.
Returns:
A two-tuple containing a dictionary of all arguments ... | [
"def",
"_get_definitions",
"(",
"source",
")",
":",
"# type: (str) -> Tuple[Dict[str, str], int]",
"max_len",
"=",
"0",
"descs",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"# type: Dict[str, str]",
"lines",
"=",
"(",
"s",
".",
"strip",
"(",
")",
"for",
"s... | Extract a dictionary of arguments and definitions.
Args:
source: The source for a section of a usage string that contains
definitions.
Returns:
A two-tuple containing a dictionary of all arguments and definitions as
well as the length of the longest argument. | [
"Extract",
"a",
"dictionary",
"of",
"arguments",
"and",
"definitions",
"."
] | python | train |
pantsbuild/pants | src/python/pants/auth/cookies.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/auth/cookies.py#L39-L51 | def get_cookie_jar(self):
"""Returns our cookie jar."""
cookie_file = self._get_cookie_file()
cookie_jar = LWPCookieJar(cookie_file)
if os.path.exists(cookie_file):
cookie_jar.load()
else:
safe_mkdir_for(cookie_file)
# Save an empty cookie jar so we can change the file perms on it ... | [
"def",
"get_cookie_jar",
"(",
"self",
")",
":",
"cookie_file",
"=",
"self",
".",
"_get_cookie_file",
"(",
")",
"cookie_jar",
"=",
"LWPCookieJar",
"(",
"cookie_file",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cookie_file",
")",
":",
"cookie_jar",
"... | Returns our cookie jar. | [
"Returns",
"our",
"cookie",
"jar",
"."
] | python | train |
sprockets/sprockets.mixins.metrics | sprockets/mixins/metrics/statsd.py | https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L19-L32 | def record_timing(self, duration, *path):
"""Record a timing.
This method records a timing to the application's namespace
followed by a calculated path. Each element of `path` is
converted to a string and normalized before joining the
elements by periods. The normalization pro... | [
"def",
"record_timing",
"(",
"self",
",",
"duration",
",",
"*",
"path",
")",
":",
"self",
".",
"application",
".",
"statsd",
".",
"send",
"(",
"path",
",",
"duration",
"*",
"1000.0",
",",
"'ms'",
")"
] | Record a timing.
This method records a timing to the application's namespace
followed by a calculated path. Each element of `path` is
converted to a string and normalized before joining the
elements by periods. The normalization process is little
more than replacing periods wi... | [
"Record",
"a",
"timing",
"."
] | python | train |
petebachant/PXL | pxl/io.py | https://github.com/petebachant/PXL/blob/d7d06cb74422e1ac0154741351fbecea080cfcc0/pxl/io.py#L48-L55 | def savecsv(filename, datadict, mode="w"):
"""Save a dictionary of data to CSV."""
if mode == "a" :
header = False
else:
header = True
with open(filename, mode) as f:
_pd.DataFrame(datadict).to_csv(f, index=False, header=header) | [
"def",
"savecsv",
"(",
"filename",
",",
"datadict",
",",
"mode",
"=",
"\"w\"",
")",
":",
"if",
"mode",
"==",
"\"a\"",
":",
"header",
"=",
"False",
"else",
":",
"header",
"=",
"True",
"with",
"open",
"(",
"filename",
",",
"mode",
")",
"as",
"f",
":"... | Save a dictionary of data to CSV. | [
"Save",
"a",
"dictionary",
"of",
"data",
"to",
"CSV",
"."
] | python | train |
dmwm/DBS | Server/Python/src/dbs/dao/Oracle/FileBuffer/DeleteFiles.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/dao/Oracle/FileBuffer/DeleteFiles.py#L20-L27 | def execute(self, conn, logical_file_name={}, transaction=False):
"""
simple execute
"""
if not conn:
dbsExceptionHandler("dbsException-db-conn-failed", "Oracle/FileBuffer/DeleteFiles. Expects db connection from upper layer.")
self.dbi.processData(self.sql, logical_file_name, conn... | [
"def",
"execute",
"(",
"self",
",",
"conn",
",",
"logical_file_name",
"=",
"{",
"}",
",",
"transaction",
"=",
"False",
")",
":",
"if",
"not",
"conn",
":",
"dbsExceptionHandler",
"(",
"\"dbsException-db-conn-failed\"",
",",
"\"Oracle/FileBuffer/DeleteFiles. Expects d... | simple execute | [
"simple",
"execute"
] | python | train |
quantopian/zipline | zipline/data/benchmarks.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/benchmarks.py#L19-L42 | def get_benchmark_returns(symbol):
"""
Get a Series of benchmark returns from IEX associated with `symbol`.
Default is `SPY`.
Parameters
----------
symbol : str
Benchmark symbol for which we're getting the returns.
The data is provided by IEX (https://iextrading.com/), and we can
... | [
"def",
"get_benchmark_returns",
"(",
"symbol",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"'https://api.iextrading.com/1.0/stock/{}/chart/5y'",
".",
"format",
"(",
"symbol",
")",
")",
"data",
"=",
"r",
".",
"json",
"(",
")",
"df",
"=",
"pd",
".",
"Da... | Get a Series of benchmark returns from IEX associated with `symbol`.
Default is `SPY`.
Parameters
----------
symbol : str
Benchmark symbol for which we're getting the returns.
The data is provided by IEX (https://iextrading.com/), and we can
get up to 5 years worth of data. | [
"Get",
"a",
"Series",
"of",
"benchmark",
"returns",
"from",
"IEX",
"associated",
"with",
"symbol",
".",
"Default",
"is",
"SPY",
"."
] | python | train |
wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/__init__.py | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1183-L1219 | def series_capacitance(self, channel, resistor_index=None):
'''
Parameters
----------
channel : int
Analog channel index.
resistor_index : int, optional
Series resistor channel index.
If :data:`resistor_index` is not specified, the resistor-in... | [
"def",
"series_capacitance",
"(",
"self",
",",
"channel",
",",
"resistor_index",
"=",
"None",
")",
":",
"if",
"resistor_index",
"is",
"None",
":",
"resistor_index",
"=",
"self",
".",
"series_resistor_index",
"(",
"channel",
")",
"value",
"=",
"self",
".",
"_... | Parameters
----------
channel : int
Analog channel index.
resistor_index : int, optional
Series resistor channel index.
If :data:`resistor_index` is not specified, the resistor-index from
the current context _(i.e., the result of
:attr... | [
"Parameters",
"----------",
"channel",
":",
"int",
"Analog",
"channel",
"index",
".",
"resistor_index",
":",
"int",
"optional",
"Series",
"resistor",
"channel",
"index",
"."
] | python | train |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/signandverify.py | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L122-L182 | def checksigformat(a,invalidatehighS=False):
'''
Checks input to see if it's a correctly formatted DER Bitcoin
signature in hex string format.
Returns True/False. If it excepts, there's a different problem
unrelated to the signature...
This does NOT valid the signature in any way, it ONLY che... | [
"def",
"checksigformat",
"(",
"a",
",",
"invalidatehighS",
"=",
"False",
")",
":",
"try",
":",
"a",
"=",
"hexstrlify",
"(",
"unhexlify",
"(",
"a",
")",
")",
"except",
":",
"return",
"False",
"try",
":",
"rlen",
"=",
"2",
"*",
"int",
"(",
"a",
"[",
... | Checks input to see if it's a correctly formatted DER Bitcoin
signature in hex string format.
Returns True/False. If it excepts, there's a different problem
unrelated to the signature...
This does NOT valid the signature in any way, it ONLY checks that
it is formatted properly.
If invalidate... | [
"Checks",
"input",
"to",
"see",
"if",
"it",
"s",
"a",
"correctly",
"formatted",
"DER",
"Bitcoin",
"signature",
"in",
"hex",
"string",
"format",
"."
] | python | train |
fabioz/PyDev.Debugger | third_party/pep8/lib2to3/lib2to3/pytree.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pytree.py#L400-L404 | def clone(self):
"""Return a cloned (deep) copy of self."""
return Leaf(self.type, self.value,
(self.prefix, (self.lineno, self.column)),
fixers_applied=self.fixers_applied) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"Leaf",
"(",
"self",
".",
"type",
",",
"self",
".",
"value",
",",
"(",
"self",
".",
"prefix",
",",
"(",
"self",
".",
"lineno",
",",
"self",
".",
"column",
")",
")",
",",
"fixers_applied",
"=",
"sel... | Return a cloned (deep) copy of self. | [
"Return",
"a",
"cloned",
"(",
"deep",
")",
"copy",
"of",
"self",
"."
] | python | train |
swharden/SWHLab | swhlab/indexing/indexing.py | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/indexing/indexing.py#L133-L146 | def analyzeAll(self):
"""analyze every unanalyzed ABF in the folder."""
searchableData=str(self.files2)
self.log.debug("considering analysis for %d ABFs",len(self.IDs))
for ID in self.IDs:
if not ID+"_" in searchableData:
self.log.debug("%s needs analysis",ID)... | [
"def",
"analyzeAll",
"(",
"self",
")",
":",
"searchableData",
"=",
"str",
"(",
"self",
".",
"files2",
")",
"self",
".",
"log",
".",
"debug",
"(",
"\"considering analysis for %d ABFs\"",
",",
"len",
"(",
"self",
".",
"IDs",
")",
")",
"for",
"ID",
"in",
... | analyze every unanalyzed ABF in the folder. | [
"analyze",
"every",
"unanalyzed",
"ABF",
"in",
"the",
"folder",
"."
] | python | valid |
gwpy/gwpy | gwpy/signal/filter_design.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/signal/filter_design.py#L632-L669 | def concatenate_zpks(*zpks):
"""Concatenate a list of zero-pole-gain (ZPK) filters
Parameters
----------
*zpks
one or more zero-pole-gain format, each one should be a 3-`tuple`
containing an array of zeros, an array of poles, and a gain `float`
Returns
-------
zeros : `nump... | [
"def",
"concatenate_zpks",
"(",
"*",
"zpks",
")",
":",
"zeros",
",",
"poles",
",",
"gains",
"=",
"zip",
"(",
"*",
"zpks",
")",
"return",
"(",
"numpy",
".",
"concatenate",
"(",
"zeros",
")",
",",
"numpy",
".",
"concatenate",
"(",
"poles",
")",
",",
... | Concatenate a list of zero-pole-gain (ZPK) filters
Parameters
----------
*zpks
one or more zero-pole-gain format, each one should be a 3-`tuple`
containing an array of zeros, an array of poles, and a gain `float`
Returns
-------
zeros : `numpy.ndarray`
the concatenated ... | [
"Concatenate",
"a",
"list",
"of",
"zero",
"-",
"pole",
"-",
"gain",
"(",
"ZPK",
")",
"filters"
] | python | train |
PeerAssets/pypeerassets | pypeerassets/protocol.py | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L309-L328 | def metainfo_to_protobuf(self) -> bytes:
'''encode card_transfer info to protobuf'''
card = cardtransferproto()
card.version = self.version
card.amount.extend(self.amount)
card.number_of_decimals = self.number_of_decimals
if self.asset_specific_data:
if not i... | [
"def",
"metainfo_to_protobuf",
"(",
"self",
")",
"->",
"bytes",
":",
"card",
"=",
"cardtransferproto",
"(",
")",
"card",
".",
"version",
"=",
"self",
".",
"version",
"card",
".",
"amount",
".",
"extend",
"(",
"self",
".",
"amount",
")",
"card",
".",
"n... | encode card_transfer info to protobuf | [
"encode",
"card_transfer",
"info",
"to",
"protobuf"
] | python | train |
tcalmant/ipopo | pelix/misc/mqtt_client.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/mqtt_client.py#L399-L413 | def __on_message(self, client, userdata, msg):
# pylint: disable=W0613
"""
A message has been received from a server
:param client: Client that received the message
:param userdata: User data (unused)
:param msg: A MQTTMessage bean
"""
# Notify the caller... | [
"def",
"__on_message",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"msg",
")",
":",
"# pylint: disable=W0613",
"# Notify the caller, if any",
"if",
"self",
".",
"on_message",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"on_message",
"(",
"self",
... | A message has been received from a server
:param client: Client that received the message
:param userdata: User data (unused)
:param msg: A MQTTMessage bean | [
"A",
"message",
"has",
"been",
"received",
"from",
"a",
"server"
] | python | train |
xmikos/reparser | reparser.py | https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L84-L91 | def build_regex(self, tokens):
"""Build compound regex from list of tokens"""
patterns = []
for token in tokens:
patterns.append(token.pattern_start)
if token.pattern_end:
patterns.append(token.pattern_end)
return re.compile('|'.join(patterns), re.... | [
"def",
"build_regex",
"(",
"self",
",",
"tokens",
")",
":",
"patterns",
"=",
"[",
"]",
"for",
"token",
"in",
"tokens",
":",
"patterns",
".",
"append",
"(",
"token",
".",
"pattern_start",
")",
"if",
"token",
".",
"pattern_end",
":",
"patterns",
".",
"ap... | Build compound regex from list of tokens | [
"Build",
"compound",
"regex",
"from",
"list",
"of",
"tokens"
] | python | train |
GNS3/gns3-server | gns3server/utils/asyncio/embed_shell.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/embed_shell.py#L300-L335 | def create_stdin_shell(shell, loop=None):
"""
Run a shell application with a stdin frontend
:param application: An EmbedShell instance
:param loop: The event loop
:returns: Telnet server
"""
@asyncio.coroutine
def feed_stdin(loop, reader, shell):
history = InMemoryHistory()
... | [
"def",
"create_stdin_shell",
"(",
"shell",
",",
"loop",
"=",
"None",
")",
":",
"@",
"asyncio",
".",
"coroutine",
"def",
"feed_stdin",
"(",
"loop",
",",
"reader",
",",
"shell",
")",
":",
"history",
"=",
"InMemoryHistory",
"(",
")",
"completer",
"=",
"Word... | Run a shell application with a stdin frontend
:param application: An EmbedShell instance
:param loop: The event loop
:returns: Telnet server | [
"Run",
"a",
"shell",
"application",
"with",
"a",
"stdin",
"frontend"
] | python | train |
awslabs/sockeye | sockeye/utils.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/utils.py#L342-L363 | def smart_open(filename: str, mode: str = "rt", ftype: str = "auto", errors: str = 'replace'):
"""
Returns a file descriptor for filename with UTF-8 encoding.
If mode is "rt", file is opened read-only.
If ftype is "auto", uses gzip iff filename endswith .gz.
If ftype is {"gzip","gz"}, uses gzip.
... | [
"def",
"smart_open",
"(",
"filename",
":",
"str",
",",
"mode",
":",
"str",
"=",
"\"rt\"",
",",
"ftype",
":",
"str",
"=",
"\"auto\"",
",",
"errors",
":",
"str",
"=",
"'replace'",
")",
":",
"if",
"ftype",
"in",
"(",
"'gzip'",
",",
"'gz'",
")",
"or",
... | Returns a file descriptor for filename with UTF-8 encoding.
If mode is "rt", file is opened read-only.
If ftype is "auto", uses gzip iff filename endswith .gz.
If ftype is {"gzip","gz"}, uses gzip.
If ftype is "auto" and read mode requested, uses gzip iff is_gzip_file(filename).
Note: encoding erro... | [
"Returns",
"a",
"file",
"descriptor",
"for",
"filename",
"with",
"UTF",
"-",
"8",
"encoding",
".",
"If",
"mode",
"is",
"rt",
"file",
"is",
"opened",
"read",
"-",
"only",
".",
"If",
"ftype",
"is",
"auto",
"uses",
"gzip",
"iff",
"filename",
"endswith",
"... | python | train |
OSSOS/MOP | src/ossos/core/ossos/util.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/util.py#L112-L125 | def close(self):
"""
Closes the stream.
"""
self.flush()
try:
if self.stream is not None:
self.stream.flush()
_name = self.stream.name
self.stream.close()
self.client.copy(_name, self.filename)
ex... | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"flush",
"(",
")",
"try",
":",
"if",
"self",
".",
"stream",
"is",
"not",
"None",
":",
"self",
".",
"stream",
".",
"flush",
"(",
")",
"_name",
"=",
"self",
".",
"stream",
".",
"name",
"self",
"... | Closes the stream. | [
"Closes",
"the",
"stream",
"."
] | python | train |
jslang/responsys | responsys/client.py | https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/client.py#L369-L382 | def merge_table_records(self, table, record_data, match_column_names):
""" Responsys.mergeTableRecords call
Accepts:
InteractObject table
RecordData record_data
list match_column_names
Returns a MergeResult
"""
table = table.get_soap_object(s... | [
"def",
"merge_table_records",
"(",
"self",
",",
"table",
",",
"record_data",
",",
"match_column_names",
")",
":",
"table",
"=",
"table",
".",
"get_soap_object",
"(",
"self",
".",
"client",
")",
"record_data",
"=",
"record_data",
".",
"get_soap_object",
"(",
"s... | Responsys.mergeTableRecords call
Accepts:
InteractObject table
RecordData record_data
list match_column_names
Returns a MergeResult | [
"Responsys",
".",
"mergeTableRecords",
"call"
] | python | train |
jobovy/galpy | galpy/orbit/FullOrbit.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/FullOrbit.py#L381-L447 | def fit(self,vxvv,vxvv_err=None,pot=None,radec=False,lb=False,
customsky=False,lb_to_customsky=None,pmllpmbb_to_customsky=None,
tintJ=10,ntintJ=1000,integrate_method='dopr54_c',
disp=False,
**kwargs):
"""
NAME:
fit
PURPOSE:
fi... | [
"def",
"fit",
"(",
"self",
",",
"vxvv",
",",
"vxvv_err",
"=",
"None",
",",
"pot",
"=",
"None",
",",
"radec",
"=",
"False",
",",
"lb",
"=",
"False",
",",
"customsky",
"=",
"False",
",",
"lb_to_customsky",
"=",
"None",
",",
"pmllpmbb_to_customsky",
"=",
... | NAME:
fit
PURPOSE:
fit an Orbit to data using the current orbit as the initial
condition
INPUT:
vxvv - [:,6] array of positions and velocities along the orbit [cannot be Quantities]
vxvv_err= [:,6] array of errors on positions and velocities along ... | [
"NAME",
":",
"fit",
"PURPOSE",
":",
"fit",
"an",
"Orbit",
"to",
"data",
"using",
"the",
"current",
"orbit",
"as",
"the",
"initial",
"condition",
"INPUT",
":",
"vxvv",
"-",
"[",
":",
"6",
"]",
"array",
"of",
"positions",
"and",
"velocities",
"along",
"t... | python | train |
BreakingBytes/simkit | simkit/core/simulations.py | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/simulations.py#L329-L338 | def index_iterator(self):
"""
Generator that resumes from same index, or restarts from sent index.
"""
idx = 0 # index
while idx < self.number_intervals:
new_idx = yield idx
idx += 1
if new_idx:
idx = new_idx - 1 | [
"def",
"index_iterator",
"(",
"self",
")",
":",
"idx",
"=",
"0",
"# index",
"while",
"idx",
"<",
"self",
".",
"number_intervals",
":",
"new_idx",
"=",
"yield",
"idx",
"idx",
"+=",
"1",
"if",
"new_idx",
":",
"idx",
"=",
"new_idx",
"-",
"1"
] | Generator that resumes from same index, or restarts from sent index. | [
"Generator",
"that",
"resumes",
"from",
"same",
"index",
"or",
"restarts",
"from",
"sent",
"index",
"."
] | python | train |
eventbrite/pysoa | pysoa/client/client.py | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L701-L800 | def call_jobs_parallel_future(
self,
jobs,
expansions=None,
raise_job_errors=True,
raise_action_errors=True,
catch_transport_errors=False,
timeout=None,
**kwargs
):
"""
This method is identical in signature and behavior to `call_jobs_pa... | [
"def",
"call_jobs_parallel_future",
"(",
"self",
",",
"jobs",
",",
"expansions",
"=",
"None",
",",
"raise_job_errors",
"=",
"True",
",",
"raise_action_errors",
"=",
"True",
",",
"catch_transport_errors",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"*",
"*"... | This method is identical in signature and behavior to `call_jobs_parallel`, except that it sends the requests
and then immediately returns a `FutureResponse` instead of blocking waiting on all responses and returning
a `list` of `JobResponses`. Just call `result(timeout=None)` on the future response to ... | [
"This",
"method",
"is",
"identical",
"in",
"signature",
"and",
"behavior",
"to",
"call_jobs_parallel",
"except",
"that",
"it",
"sends",
"the",
"requests",
"and",
"then",
"immediately",
"returns",
"a",
"FutureResponse",
"instead",
"of",
"blocking",
"waiting",
"on",... | python | train |
moonso/loqusdb | loqusdb/plugins/mongo/variant.py | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L159-L196 | def delete_variant(self, variant):
"""Delete observation in database
This means that we take down the observations variable with one.
If 'observations' == 1 we remove the variant. If variant was homozygote
we decrease 'homozygote' with one.
Also remove the family from array 'fam... | [
"def",
"delete_variant",
"(",
"self",
",",
"variant",
")",
":",
"mongo_variant",
"=",
"self",
".",
"get_variant",
"(",
"variant",
")",
"if",
"mongo_variant",
":",
"if",
"mongo_variant",
"[",
"'observations'",
"]",
"==",
"1",
":",
"LOG",
".",
"debug",
"(",
... | Delete observation in database
This means that we take down the observations variable with one.
If 'observations' == 1 we remove the variant. If variant was homozygote
we decrease 'homozygote' with one.
Also remove the family from array 'families'.
Args:
variant (di... | [
"Delete",
"observation",
"in",
"database"
] | python | train |
senaite/senaite.core | bika/lims/content/bikasetup.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/bikasetup.py#L937-L945 | def getRejectionReasonsItems(self):
"""Return the list of predefined rejection reasons
"""
reasons = self.getRejectionReasons()
if not reasons:
return []
reasons = reasons[0]
keys = filter(lambda key: key != "checkbox", reasons.keys())
return map(lambd... | [
"def",
"getRejectionReasonsItems",
"(",
"self",
")",
":",
"reasons",
"=",
"self",
".",
"getRejectionReasons",
"(",
")",
"if",
"not",
"reasons",
":",
"return",
"[",
"]",
"reasons",
"=",
"reasons",
"[",
"0",
"]",
"keys",
"=",
"filter",
"(",
"lambda",
"key"... | Return the list of predefined rejection reasons | [
"Return",
"the",
"list",
"of",
"predefined",
"rejection",
"reasons"
] | python | train |
dw/mitogen | mitogen/parent.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/parent.py#L193-L203 | def get_default_remote_name():
"""
Return the default name appearing in argv[0] of remote machines.
"""
s = u'%s@%s:%d'
s %= (getpass.getuser(), socket.gethostname(), os.getpid())
# In mixed UNIX/Windows environments, the username may contain slashes.
return s.translate({
ord(u'\\'):... | [
"def",
"get_default_remote_name",
"(",
")",
":",
"s",
"=",
"u'%s@%s:%d'",
"s",
"%=",
"(",
"getpass",
".",
"getuser",
"(",
")",
",",
"socket",
".",
"gethostname",
"(",
")",
",",
"os",
".",
"getpid",
"(",
")",
")",
"# In mixed UNIX/Windows environments, the us... | Return the default name appearing in argv[0] of remote machines. | [
"Return",
"the",
"default",
"name",
"appearing",
"in",
"argv",
"[",
"0",
"]",
"of",
"remote",
"machines",
"."
] | python | train |
eqcorrscan/EQcorrscan | eqcorrscan/utils/plotting.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/plotting.py#L2264-L2290 | def _plotting_decimation(trace, max_len=10e5, decimation_step=4):
"""
Decimate data until required length reached.
:type trace: obspy.core.stream.Trace
:param trace: Trace to decimate
type max_len: int
:param max_len: Maximum length in samples
:type decimation_step: int
:param decimatio... | [
"def",
"_plotting_decimation",
"(",
"trace",
",",
"max_len",
"=",
"10e5",
",",
"decimation_step",
"=",
"4",
")",
":",
"trace_len",
"=",
"trace",
".",
"stats",
".",
"npts",
"while",
"trace_len",
">",
"max_len",
":",
"trace",
".",
"decimate",
"(",
"decimatio... | Decimate data until required length reached.
:type trace: obspy.core.stream.Trace
:param trace: Trace to decimate
type max_len: int
:param max_len: Maximum length in samples
:type decimation_step: int
:param decimation_step: Decimation factor to use for each step.
:return: obspy.core.strea... | [
"Decimate",
"data",
"until",
"required",
"length",
"reached",
"."
] | python | train |
log2timeline/plaso | plaso/output/mediator.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/mediator.py#L92-L108 | def GetFormattedSources(self, event):
"""Retrieves the formatted sources related to the event.
Args:
event (EventObject): event.
Returns:
tuple: containing:
str: full source string or None if no event formatter was found.
str: short source string or None if no event formatter ... | [
"def",
"GetFormattedSources",
"(",
"self",
",",
"event",
")",
":",
"event_formatter",
"=",
"self",
".",
"GetEventFormatter",
"(",
"event",
")",
"if",
"not",
"event_formatter",
":",
"return",
"None",
",",
"None",
"return",
"event_formatter",
".",
"GetSources",
... | Retrieves the formatted sources related to the event.
Args:
event (EventObject): event.
Returns:
tuple: containing:
str: full source string or None if no event formatter was found.
str: short source string or None if no event formatter was found. | [
"Retrieves",
"the",
"formatted",
"sources",
"related",
"to",
"the",
"event",
"."
] | python | train |
numenta/nupic | src/nupic/data/generators/anomalyzer.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/anomalyzer.py#L66-L80 | def add(reader, writer, column, start, stop, value):
"""Adds a value over a range of rows.
Args:
reader: A FileRecordStream object with input data.
writer: A FileRecordStream object to write output data to.
column: The column of data to modify.
start: The first row in the range to modify.
end: ... | [
"def",
"add",
"(",
"reader",
",",
"writer",
",",
"column",
",",
"start",
",",
"stop",
",",
"value",
")",
":",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"reader",
")",
":",
"if",
"i",
">=",
"start",
"and",
"i",
"<=",
"stop",
":",
"row",
"[... | Adds a value over a range of rows.
Args:
reader: A FileRecordStream object with input data.
writer: A FileRecordStream object to write output data to.
column: The column of data to modify.
start: The first row in the range to modify.
end: The last row in the range to modify.
value: The value ... | [
"Adds",
"a",
"value",
"over",
"a",
"range",
"of",
"rows",
"."
] | python | valid |
shaiguitar/snowclient.py | snowclient/api.py | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/api.py#L159-L166 | def resolve_links(self, snow_record, **kparams):
"""
Get the infos from the links and return SnowRecords[].
"""
records = []
for attr, link in snow_record.links().items():
records.append(self.resolve_link(snow_record, attr, **kparams))
return records | [
"def",
"resolve_links",
"(",
"self",
",",
"snow_record",
",",
"*",
"*",
"kparams",
")",
":",
"records",
"=",
"[",
"]",
"for",
"attr",
",",
"link",
"in",
"snow_record",
".",
"links",
"(",
")",
".",
"items",
"(",
")",
":",
"records",
".",
"append",
"... | Get the infos from the links and return SnowRecords[]. | [
"Get",
"the",
"infos",
"from",
"the",
"links",
"and",
"return",
"SnowRecords",
"[]",
"."
] | python | train |
klen/muffin | muffin/manage.py | https://github.com/klen/muffin/blob/7bc891e174e08b62d1ae232b5d45f8cd8bc82112/muffin/manage.py#L250-L278 | def run():
"""CLI endpoint."""
sys.path.insert(0, os.getcwd())
logging.basicConfig(level=logging.INFO, handlers=[logging.StreamHandler()])
parser = argparse.ArgumentParser(description="Manage Application", add_help=False)
parser.add_argument('app', metavar='app',
type=str, h... | [
"def",
"run",
"(",
")",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"os",
".",
"getcwd",
"(",
")",
")",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"handlers",
"=",
"[",
"logging",
".",
"StreamHandler",... | CLI endpoint. | [
"CLI",
"endpoint",
"."
] | python | train |
ptcryan/hydrawiser | hydrawiser/core.py | https://github.com/ptcryan/hydrawiser/blob/53acafb08b5cee0f6628414044b9b9f9a0b15e50/hydrawiser/core.py#L104-L130 | def relay_info(self, relay, attribute=None):
"""
Return information about a relay.
:param relay: The relay being queried.
:type relay: int
:param attribute: The attribute being queried, or all attributes for
that relay if None is specified.
:typ... | [
"def",
"relay_info",
"(",
"self",
",",
"relay",
",",
"attribute",
"=",
"None",
")",
":",
"# Check if the relay number is valid.",
"if",
"(",
"relay",
"<",
"0",
")",
"or",
"(",
"relay",
">",
"(",
"self",
".",
"num_relays",
"-",
"1",
")",
")",
":",
"# In... | Return information about a relay.
:param relay: The relay being queried.
:type relay: int
:param attribute: The attribute being queried, or all attributes for
that relay if None is specified.
:type attribute: string or None
:returns: The attribute being... | [
"Return",
"information",
"about",
"a",
"relay",
"."
] | python | train |
saltstack/salt | salt/modules/win_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L142-L193 | def traceroute(host):
'''
Performs a traceroute to a 3rd party host
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org
'''
ret = []
cmd = ['tracert', salt.utils.network.sanitize_host(host)]
lines = __salt__['cmd.run'](cmd, python_shell=False).splitline... | [
"def",
"traceroute",
"(",
"host",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"[",
"'tracert'",
",",
"salt",
".",
"utils",
".",
"network",
".",
"sanitize_host",
"(",
"host",
")",
"]",
"lines",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
","... | Performs a traceroute to a 3rd party host
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org | [
"Performs",
"a",
"traceroute",
"to",
"a",
"3rd",
"party",
"host"
] | python | train |
LionelR/pyair | pyair/date.py | https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/date.py#L50-L67 | def profil_hebdo(df, func='mean'):
"""
Calcul du profil journalier
Paramètres:
df: DataFrame de données dont l'index est une série temporelle
(cf module xair par exemple)
func: function permettant le calcul. Soit un nom de fonction numpy ('mean', 'max', ...)
soit la fonction elle-mê... | [
"def",
"profil_hebdo",
"(",
"df",
",",
"func",
"=",
"'mean'",
")",
":",
"func",
"=",
"_get_funky",
"(",
"func",
")",
"res",
"=",
"df",
".",
"groupby",
"(",
"lambda",
"x",
":",
"x",
".",
"weekday",
")",
".",
"aggregate",
"(",
"func",
")",
"# On met ... | Calcul du profil journalier
Paramètres:
df: DataFrame de données dont l'index est une série temporelle
(cf module xair par exemple)
func: function permettant le calcul. Soit un nom de fonction numpy ('mean', 'max', ...)
soit la fonction elle-même (np.mean, np.max, ...)
Retourne:
Un ... | [
"Calcul",
"du",
"profil",
"journalier"
] | python | valid |
gwastro/pycbc-glue | pycbc_glue/ligolw/utils/segments.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/utils/segments.py#L401-L481 | def finalize(self, process_row = None):
"""
Restore the LigolwSegmentList objects to the XML tables in
preparation for output. All segments from all segment
lists are inserted into the tables in time order, but this
is NOT behaviour external applications should rely on.
This is done simply in the belief th... | [
"def",
"finalize",
"(",
"self",
",",
"process_row",
"=",
"None",
")",
":",
"if",
"process_row",
"is",
"not",
"None",
":",
"process_id",
"=",
"process_row",
".",
"process_id",
"elif",
"self",
".",
"process",
"is",
"not",
"None",
":",
"process_id",
"=",
"s... | Restore the LigolwSegmentList objects to the XML tables in
preparation for output. All segments from all segment
lists are inserted into the tables in time order, but this
is NOT behaviour external applications should rely on.
This is done simply in the belief that it might assist in
constructing well balanc... | [
"Restore",
"the",
"LigolwSegmentList",
"objects",
"to",
"the",
"XML",
"tables",
"in",
"preparation",
"for",
"output",
".",
"All",
"segments",
"from",
"all",
"segment",
"lists",
"are",
"inserted",
"into",
"the",
"tables",
"in",
"time",
"order",
"but",
"this",
... | python | train |
rhayes777/PyAutoFit | autofit/tools/pipeline.py | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L143-L167 | def run_function(self, func, data_name=None, assert_optimizer_pickle_matches=True):
"""
Run the function for each phase in the pipeline.
Parameters
----------
assert_optimizer_pickle_matches
data_name
func
A function that takes a phase and prior resul... | [
"def",
"run_function",
"(",
"self",
",",
"func",
",",
"data_name",
"=",
"None",
",",
"assert_optimizer_pickle_matches",
"=",
"True",
")",
":",
"results",
"=",
"ResultsCollection",
"(",
")",
"for",
"i",
",",
"phase",
"in",
"enumerate",
"(",
"self",
".",
"ph... | Run the function for each phase in the pipeline.
Parameters
----------
assert_optimizer_pickle_matches
data_name
func
A function that takes a phase and prior results, returning results for that phase
Returns
-------
results: ResultsCollection... | [
"Run",
"the",
"function",
"for",
"each",
"phase",
"in",
"the",
"pipeline",
"."
] | python | train |
apache/incubator-heron | heron/tools/admin/src/python/standalone.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/admin/src/python/standalone.py#L573-L592 | def wait_for_job_to_start(single_master, job):
'''
Wait for a Nomad job to start
'''
i = 0
while True:
try:
r = requests.get("http://%s:4646/v1/job/%s" % (single_master, job))
if r.status_code == 200 and r.json()["Status"] == "running":
break
else:
raise RuntimeError()
... | [
"def",
"wait_for_job_to_start",
"(",
"single_master",
",",
"job",
")",
":",
"i",
"=",
"0",
"while",
"True",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"\"http://%s:4646/v1/job/%s\"",
"%",
"(",
"single_master",
",",
"job",
")",
")",
"if",
"r"... | Wait for a Nomad job to start | [
"Wait",
"for",
"a",
"Nomad",
"job",
"to",
"start"
] | python | valid |
knowmalware/camcrypt | camcrypt/__init__.py | https://github.com/knowmalware/camcrypt/blob/40c9ebbbd33ebfbb3a564ee5768cfe7a1815f6a3/camcrypt/__init__.py#L73-L95 | def encrypt(self, plainText):
"""Encrypt an arbitrary-length block of data.
NOTE: This function formerly worked only on 16-byte blocks of `plainText`.
code that assumed this should still work fine, but can optionally be
modified to call `encrypt_block` instead.
Args:
plainText (str): data ... | [
"def",
"encrypt",
"(",
"self",
",",
"plainText",
")",
":",
"encryptedResult",
"=",
"''",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"plainText",
")",
",",
"BLOCK_SIZE",
")",
":",
"block",
"=",
"plainText",
"[",
"index",
":",
"index",
"... | Encrypt an arbitrary-length block of data.
NOTE: This function formerly worked only on 16-byte blocks of `plainText`.
code that assumed this should still work fine, but can optionally be
modified to call `encrypt_block` instead.
Args:
plainText (str): data to encrypt. If the data is not a mult... | [
"Encrypt",
"an",
"arbitrary",
"-",
"length",
"block",
"of",
"data",
"."
] | python | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1054-L1320 | def rdrecord(record_name, sampfrom=0, sampto=None, channels=None,
physical=True, pb_dir=None, m2s=True, smooth_frames=True,
ignore_skew=False, return_res=64, force_channels=True,
channel_names=None, warn_empty=False):
"""
Read a WFDB record and return the signal and record... | [
"def",
"rdrecord",
"(",
"record_name",
",",
"sampfrom",
"=",
"0",
",",
"sampto",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"physical",
"=",
"True",
",",
"pb_dir",
"=",
"None",
",",
"m2s",
"=",
"True",
",",
"smooth_frames",
"=",
"True",
",",
"ig... | Read a WFDB record and return the signal and record descriptors as
attributes in a Record or MultiRecord object.
Parameters
----------
record_name : str
The name of the WFDB record to be read, without any file
extensions. If the argument contains any path delimiter
characters, t... | [
"Read",
"a",
"WFDB",
"record",
"and",
"return",
"the",
"signal",
"and",
"record",
"descriptors",
"as",
"attributes",
"in",
"a",
"Record",
"or",
"MultiRecord",
"object",
"."
] | python | train |
VIVelev/PyDojoML | dojo/tree/utils/functions.py | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/tree/utils/functions.py#L193-L207 | def print_tree(root, space=' '):
"""Prints the Decision Tree in a pretty way.
"""
if isinstance(root, Leaf):
print(space + "Prediction: " + str(root.most_frequent))
return
print(space + str(root.question))
print(space + "--> True:")
print_tree(root.true_branch, space+' ')
... | [
"def",
"print_tree",
"(",
"root",
",",
"space",
"=",
"' '",
")",
":",
"if",
"isinstance",
"(",
"root",
",",
"Leaf",
")",
":",
"print",
"(",
"space",
"+",
"\"Prediction: \"",
"+",
"str",
"(",
"root",
".",
"most_frequent",
")",
")",
"return",
"print",
... | Prints the Decision Tree in a pretty way. | [
"Prints",
"the",
"Decision",
"Tree",
"in",
"a",
"pretty",
"way",
"."
] | python | train |
nccgroup/Scout2 | AWSScout2/services/vpc.py | https://github.com/nccgroup/Scout2/blob/5d86d46d7ed91a92000496189e9cfa6b98243937/AWSScout2/services/vpc.py#L210-L229 | def propagate_vpc_names(aws_config, current_config, path, current_path, resource_id, callback_args):
"""
Propagate VPC names in VPC-related services (info only fetched during EC2 calls)
:param aws_config:
:param current_config:
:param path:
:param current_path:
:param resource_id:
:param... | [
"def",
"propagate_vpc_names",
"(",
"aws_config",
",",
"current_config",
",",
"path",
",",
"current_path",
",",
"resource_id",
",",
"callback_args",
")",
":",
"if",
"resource_id",
"==",
"ec2_classic",
":",
"current_config",
"[",
"'name'",
"]",
"=",
"ec2_classic",
... | Propagate VPC names in VPC-related services (info only fetched during EC2 calls)
:param aws_config:
:param current_config:
:param path:
:param current_path:
:param resource_id:
:param callback_args:
:return: | [
"Propagate",
"VPC",
"names",
"in",
"VPC",
"-",
"related",
"services",
"(",
"info",
"only",
"fetched",
"during",
"EC2",
"calls",
")",
":",
"param",
"aws_config",
":",
":",
"param",
"current_config",
":",
":",
"param",
"path",
":",
":",
"param",
"current_pat... | python | train |
spotify/snakebite | snakebite/client.py | https://github.com/spotify/snakebite/blob/6a456e6100b0c1be66cc1f7f9d7f50494f369da3/snakebite/client.py#L342-L375 | def du(self, paths, include_toplevel=False, include_children=True):
'''Returns size information for paths
:param paths: Paths to du
:type paths: list
:param include_toplevel: Include the given path in the result. If the path is a file, include_toplevel is always True.
:type incl... | [
"def",
"du",
"(",
"self",
",",
"paths",
",",
"include_toplevel",
"=",
"False",
",",
"include_children",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"paths",
",",
"list",
")",
":",
"raise",
"InvalidInputException",
"(",
"\"Paths should be a list\"",
... | Returns size information for paths
:param paths: Paths to du
:type paths: list
:param include_toplevel: Include the given path in the result. If the path is a file, include_toplevel is always True.
:type include_toplevel: boolean
:param include_children: Include child nodes in t... | [
"Returns",
"size",
"information",
"for",
"paths"
] | python | train |
todddeluca/python-vagrant | vagrant/__init__.py | https://github.com/todddeluca/python-vagrant/blob/83b26f9337b1f2cb6314210923bbd189e7c9199e/vagrant/__init__.py#L496-L513 | def _parse_status(self, output):
'''
Unit testing is so much easier when Vagrant is removed from the
equation.
'''
parsed = self._parse_machine_readable_output(output)
statuses = []
# group tuples by target name
# assuming tuples are sorted by target name,... | [
"def",
"_parse_status",
"(",
"self",
",",
"output",
")",
":",
"parsed",
"=",
"self",
".",
"_parse_machine_readable_output",
"(",
"output",
")",
"statuses",
"=",
"[",
"]",
"# group tuples by target name",
"# assuming tuples are sorted by target name, this should group all",
... | Unit testing is so much easier when Vagrant is removed from the
equation. | [
"Unit",
"testing",
"is",
"so",
"much",
"easier",
"when",
"Vagrant",
"is",
"removed",
"from",
"the",
"equation",
"."
] | python | train |
praekeltfoundation/seaworthy | seaworthy/client.py | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L190-L202 | def delete(self, path=None, url_kwargs=None, **kwargs):
"""
Sends a PUT request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
O... | [
"def",
"delete",
"(",
"self",
",",
"path",
"=",
"None",
",",
"url_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_session",
".",
"delete",
"(",
"self",
".",
"_url",
"(",
"path",
",",
"url_kwargs",
")",
",",
"*",
... | Sends a PUT request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Optional arguments that ``request`` takes.
:return: response object | [
"Sends",
"a",
"PUT",
"request",
"."
] | python | train |
bioidiap/bob.bio.spear | bob/bio/spear/utils/extraction.py | https://github.com/bioidiap/bob.bio.spear/blob/9f5d13d2e52d3b0c818f4abaa07cda15f62a34cd/bob/bio/spear/utils/extraction.py#L32-L37 | def calc_mean(c0, c1=[]):
""" Calculates the mean of the data."""
if c1 != []:
return (numpy.mean(c0, 0) + numpy.mean(c1, 0)) / 2.
else:
return numpy.mean(c0, 0) | [
"def",
"calc_mean",
"(",
"c0",
",",
"c1",
"=",
"[",
"]",
")",
":",
"if",
"c1",
"!=",
"[",
"]",
":",
"return",
"(",
"numpy",
".",
"mean",
"(",
"c0",
",",
"0",
")",
"+",
"numpy",
".",
"mean",
"(",
"c1",
",",
"0",
")",
")",
"/",
"2.",
"else"... | Calculates the mean of the data. | [
"Calculates",
"the",
"mean",
"of",
"the",
"data",
"."
] | python | train |
abseil/abseil-py | absl/flags/_flagvalues.py | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L859-L879 | def _get_help_for_modules(self, modules, prefix, include_special_flags):
"""Returns the help string for a list of modules.
Private to absl.flags package.
Args:
modules: List[str], a list of modules to get the help string for.
prefix: str, a string that is prepended to each generated help line.... | [
"def",
"_get_help_for_modules",
"(",
"self",
",",
"modules",
",",
"prefix",
",",
"include_special_flags",
")",
":",
"output_lines",
"=",
"[",
"]",
"for",
"module",
"in",
"modules",
":",
"self",
".",
"_render_our_module_flags",
"(",
"module",
",",
"output_lines",... | Returns the help string for a list of modules.
Private to absl.flags package.
Args:
modules: List[str], a list of modules to get the help string for.
prefix: str, a string that is prepended to each generated help line.
include_special_flags: bool, whether to include description of
SP... | [
"Returns",
"the",
"help",
"string",
"for",
"a",
"list",
"of",
"modules",
"."
] | python | train |
python-security/pyt | pyt/core/ast_helper.py | https://github.com/python-security/pyt/blob/efc0cfb716e40e0c8df4098f1cc8cf43723cd31f/pyt/core/ast_helper.py#L52-L63 | def _get_call_names_helper(node):
"""Recursively finds all function names."""
if isinstance(node, ast.Name):
if node.id not in BLACK_LISTED_CALL_NAMES:
yield node.id
elif isinstance(node, ast.Subscript):
yield from _get_call_names_helper(node.value)
elif isinstance(node, ast.... | [
"def",
"_get_call_names_helper",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Name",
")",
":",
"if",
"node",
".",
"id",
"not",
"in",
"BLACK_LISTED_CALL_NAMES",
":",
"yield",
"node",
".",
"id",
"elif",
"isinstance",
"(",
"node... | Recursively finds all function names. | [
"Recursively",
"finds",
"all",
"function",
"names",
"."
] | python | train |
deepmind/sonnet | sonnet/examples/learn_to_execute.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/learn_to_execute.py#L932-L957 | def make_batch(self):
"""Generator function for batchifying data for learning to execute.
Yields:
tuple:
1. one-hot input tensor, representing programmatic input
2. one-hot target tensor, the vealuation result.
3. one-hot decoder target, start symbol added for sequence decoding.
... | [
"def",
"make_batch",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"reset_data_source",
"(",
")",
"obs",
"=",
"np",
".",
"reshape",
"(",
"self",
".",
"_data_source",
".",
"flat_data",
",",
"[",
"self",
".",
"batch_size",
",",
"-",
"1",
"]... | Generator function for batchifying data for learning to execute.
Yields:
tuple:
1. one-hot input tensor, representing programmatic input
2. one-hot target tensor, the vealuation result.
3. one-hot decoder target, start symbol added for sequence decoding.
4. batch size tensor c... | [
"Generator",
"function",
"for",
"batchifying",
"data",
"for",
"learning",
"to",
"execute",
"."
] | python | train |
indico/indico-plugins | importer_invenio/indico_importer_invenio/connector.py | https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L193-L211 | def _init_browser(self):
"""
Ovveride this method with the appropriate way to prepare a logged in
browser.
"""
self.browser = mechanize.Browser()
self.browser.set_handle_robots(False)
self.browser.open(self.server_url + "/youraccount/login")
self.browser.s... | [
"def",
"_init_browser",
"(",
"self",
")",
":",
"self",
".",
"browser",
"=",
"mechanize",
".",
"Browser",
"(",
")",
"self",
".",
"browser",
".",
"set_handle_robots",
"(",
"False",
")",
"self",
".",
"browser",
".",
"open",
"(",
"self",
".",
"server_url",
... | Ovveride this method with the appropriate way to prepare a logged in
browser. | [
"Ovveride",
"this",
"method",
"with",
"the",
"appropriate",
"way",
"to",
"prepare",
"a",
"logged",
"in",
"browser",
"."
] | python | train |
fastai/fastai | fastai/callbacks/hooks.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/callbacks/hooks.py#L110-L114 | def model_sizes(m:nn.Module, size:tuple=(64,64))->Tuple[Sizes,Tensor,Hooks]:
"Pass a dummy input through the model `m` to get the various sizes of activations."
with hook_outputs(m) as hooks:
x = dummy_eval(m, size)
return [o.stored.shape for o in hooks] | [
"def",
"model_sizes",
"(",
"m",
":",
"nn",
".",
"Module",
",",
"size",
":",
"tuple",
"=",
"(",
"64",
",",
"64",
")",
")",
"->",
"Tuple",
"[",
"Sizes",
",",
"Tensor",
",",
"Hooks",
"]",
":",
"with",
"hook_outputs",
"(",
"m",
")",
"as",
"hooks",
... | Pass a dummy input through the model `m` to get the various sizes of activations. | [
"Pass",
"a",
"dummy",
"input",
"through",
"the",
"model",
"m",
"to",
"get",
"the",
"various",
"sizes",
"of",
"activations",
"."
] | python | train |
Yelp/kafka-utils | kafka_utils/util/zookeeper.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/zookeeper.py#L426-L435 | def get_cluster_assignment(self):
"""Fetch the cluster layout in form of assignment from zookeeper"""
plan = self.get_cluster_plan()
assignment = {}
for elem in plan['partitions']:
assignment[
(elem['topic'], elem['partition'])
] = elem['replicas']... | [
"def",
"get_cluster_assignment",
"(",
"self",
")",
":",
"plan",
"=",
"self",
".",
"get_cluster_plan",
"(",
")",
"assignment",
"=",
"{",
"}",
"for",
"elem",
"in",
"plan",
"[",
"'partitions'",
"]",
":",
"assignment",
"[",
"(",
"elem",
"[",
"'topic'",
"]",
... | Fetch the cluster layout in form of assignment from zookeeper | [
"Fetch",
"the",
"cluster",
"layout",
"in",
"form",
"of",
"assignment",
"from",
"zookeeper"
] | python | train |
terrycain/aioboto3 | aioboto3/s3/cse.py | https://github.com/terrycain/aioboto3/blob/0fd192175461f7bb192f3ed9a872591caf8474ac/aioboto3/s3/cse.py#L330-L389 | async def get_object(self, Bucket: str, Key: str, **kwargs) -> dict:
"""
S3 GetObject. Takes same args as Boto3 documentation
Decrypts any CSE
:param Bucket: S3 Bucket
:param Key: S3 Key (filepath)
:return: returns same response as a normal S3 get_object
"""
... | [
"async",
"def",
"get_object",
"(",
"self",
",",
"Bucket",
":",
"str",
",",
"Key",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"if",
"self",
".",
"_s3_client",
"is",
"None",
":",
"await",
"self",
".",
"setup",
"(",
")",
"# Ok so if ... | S3 GetObject. Takes same args as Boto3 documentation
Decrypts any CSE
:param Bucket: S3 Bucket
:param Key: S3 Key (filepath)
:return: returns same response as a normal S3 get_object | [
"S3",
"GetObject",
".",
"Takes",
"same",
"args",
"as",
"Boto3",
"documentation"
] | python | train |
Qiskit/qiskit-terra | qiskit/extensions/standard/ubase.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/ubase.py#L33-L45 | def to_matrix(self):
"""Return a Numpy.array for the U3 gate."""
theta, phi, lam = self.params
return numpy.array(
[[
numpy.cos(theta / 2),
-numpy.exp(1j * lam) * numpy.sin(theta / 2)
],
[
numpy.exp(1j * phi) *... | [
"def",
"to_matrix",
"(",
"self",
")",
":",
"theta",
",",
"phi",
",",
"lam",
"=",
"self",
".",
"params",
"return",
"numpy",
".",
"array",
"(",
"[",
"[",
"numpy",
".",
"cos",
"(",
"theta",
"/",
"2",
")",
",",
"-",
"numpy",
".",
"exp",
"(",
"1j",
... | Return a Numpy.array for the U3 gate. | [
"Return",
"a",
"Numpy",
".",
"array",
"for",
"the",
"U3",
"gate",
"."
] | python | test |
Gandi/gandi.cli | gandi/cli/modules/iaas.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/iaas.py#L475-L493 | def scp(cls, vm_id, login, identity, local_file, remote_file):
"""Copy file to remote VM."""
cmd = ['scp']
if identity:
cmd.extend(('-i', identity,))
version, ip_addr = cls.vm_ip(vm_id)
if version == 6:
ip_addr = '[%s]' % ip_addr
cmd.extend((loca... | [
"def",
"scp",
"(",
"cls",
",",
"vm_id",
",",
"login",
",",
"identity",
",",
"local_file",
",",
"remote_file",
")",
":",
"cmd",
"=",
"[",
"'scp'",
"]",
"if",
"identity",
":",
"cmd",
".",
"extend",
"(",
"(",
"'-i'",
",",
"identity",
",",
")",
")",
... | Copy file to remote VM. | [
"Copy",
"file",
"to",
"remote",
"VM",
"."
] | python | train |
wonambi-python/wonambi | wonambi/ioeeg/micromed.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/micromed.py#L43-L65 | def return_hdr(self):
"""Return the header for further use.
Returns
-------
subj_id : str
subject identification code
start_time : datetime
start time of the dataset
s_freq : float
sampling frequency
chan_name : list of str
... | [
"def",
"return_hdr",
"(",
"self",
")",
":",
"subj_id",
"=",
"self",
".",
"_header",
"[",
"'name'",
"]",
"+",
"' '",
"+",
"self",
".",
"_header",
"[",
"'surname'",
"]",
"chan_name",
"=",
"[",
"ch",
"[",
"'chan_name'",
"]",
"for",
"ch",
"in",
"self",
... | Return the header for further use.
Returns
-------
subj_id : str
subject identification code
start_time : datetime
start time of the dataset
s_freq : float
sampling frequency
chan_name : list of str
list of all the channels... | [
"Return",
"the",
"header",
"for",
"further",
"use",
"."
] | python | train |
playpauseandstop/bootstrapper | bootstrapper.py | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L265-L267 | def iteritems(data, **kwargs):
"""Iterate over dict items."""
return iter(data.items(**kwargs)) if IS_PY3 else data.iteritems(**kwargs) | [
"def",
"iteritems",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"iter",
"(",
"data",
".",
"items",
"(",
"*",
"*",
"kwargs",
")",
")",
"if",
"IS_PY3",
"else",
"data",
".",
"iteritems",
"(",
"*",
"*",
"kwargs",
")"
] | Iterate over dict items. | [
"Iterate",
"over",
"dict",
"items",
"."
] | python | valid |
PmagPy/PmagPy | programs/pmag_gui.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/pmag_gui.py#L619-L639 | def on_btn_orientation(self, event):
"""
Create and fill wxPython grid for entering
orientation data.
"""
wait = wx.BusyInfo('Compiling required data, please wait...')
wx.SafeYield()
#dw, dh = wx.DisplaySize()
size = wx.DisplaySize()
size = (size[0... | [
"def",
"on_btn_orientation",
"(",
"self",
",",
"event",
")",
":",
"wait",
"=",
"wx",
".",
"BusyInfo",
"(",
"'Compiling required data, please wait...'",
")",
"wx",
".",
"SafeYield",
"(",
")",
"#dw, dh = wx.DisplaySize()",
"size",
"=",
"wx",
".",
"DisplaySize",
"(... | Create and fill wxPython grid for entering
orientation data. | [
"Create",
"and",
"fill",
"wxPython",
"grid",
"for",
"entering",
"orientation",
"data",
"."
] | python | train |
pymupdf/PyMuPDF | fitz/fitz.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L3030-L3037 | def _getTransformation(self):
"""_getTransformation(self) -> PyObject *"""
CheckParent(self)
val = _fitz.Page__getTransformation(self)
val = Matrix(val)
return val | [
"def",
"_getTransformation",
"(",
"self",
")",
":",
"CheckParent",
"(",
"self",
")",
"val",
"=",
"_fitz",
".",
"Page__getTransformation",
"(",
"self",
")",
"val",
"=",
"Matrix",
"(",
"val",
")",
"return",
"val"
] | _getTransformation(self) -> PyObject * | [
"_getTransformation",
"(",
"self",
")",
"-",
">",
"PyObject",
"*"
] | python | train |
PyCQA/astroid | astroid/rebuilder.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/rebuilder.py#L775-L777 | def visit_pass(self, node, parent):
"""visit a Pass node by returning a fresh instance of it"""
return nodes.Pass(node.lineno, node.col_offset, parent) | [
"def",
"visit_pass",
"(",
"self",
",",
"node",
",",
"parent",
")",
":",
"return",
"nodes",
".",
"Pass",
"(",
"node",
".",
"lineno",
",",
"node",
".",
"col_offset",
",",
"parent",
")"
] | visit a Pass node by returning a fresh instance of it | [
"visit",
"a",
"Pass",
"node",
"by",
"returning",
"a",
"fresh",
"instance",
"of",
"it"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Util.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Util.py#L1411-L1424 | def make_path_relative(path):
""" makes an absolute path name to a relative pathname.
"""
if os.path.isabs(path):
drive_s,path = os.path.splitdrive(path)
import re
if not drive_s:
path=re.compile("/*(.*)").findall(path)[0]
else:
path=path[1:]
ass... | [
"def",
"make_path_relative",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
":",
"drive_s",
",",
"path",
"=",
"os",
".",
"path",
".",
"splitdrive",
"(",
"path",
")",
"import",
"re",
"if",
"not",
"drive_s",
":",
"pat... | makes an absolute path name to a relative pathname. | [
"makes",
"an",
"absolute",
"path",
"name",
"to",
"a",
"relative",
"pathname",
"."
] | python | train |
osrg/ryu | ryu/services/protocols/bgp/operator/command.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/operator/command.py#L209-L217 | def _quick_help(self, nested=False):
""":param nested: True if help is requested directly for this command
and False when help is requested for a list of possible
completions.
"""
if nested:
return self.command_path(), None, self.help_msg
... | [
"def",
"_quick_help",
"(",
"self",
",",
"nested",
"=",
"False",
")",
":",
"if",
"nested",
":",
"return",
"self",
".",
"command_path",
"(",
")",
",",
"None",
",",
"self",
".",
"help_msg",
"else",
":",
"return",
"self",
".",
"command_path",
"(",
")",
"... | :param nested: True if help is requested directly for this command
and False when help is requested for a list of possible
completions. | [
":",
"param",
"nested",
":",
"True",
"if",
"help",
"is",
"requested",
"directly",
"for",
"this",
"command",
"and",
"False",
"when",
"help",
"is",
"requested",
"for",
"a",
"list",
"of",
"possible",
"completions",
"."
] | python | train |
chaddotson/noaa_radar | noaa_radar/radar.py | https://github.com/chaddotson/noaa_radar/blob/ebb1e8d87d4b35b8942867446deced74b22a47cc/noaa_radar/radar.py#L112-L141 | def get_composite_reflectivity(self, tower_id, background='#000000', include_legend=True, include_counties=True,
include_warnings=True, include_highways=True, include_cities=True,
include_rivers=True, include_topography=True):
"""
Get... | [
"def",
"get_composite_reflectivity",
"(",
"self",
",",
"tower_id",
",",
"background",
"=",
"'#000000'",
",",
"include_legend",
"=",
"True",
",",
"include_counties",
"=",
"True",
",",
"include_warnings",
"=",
"True",
",",
"include_highways",
"=",
"True",
",",
"in... | Get the composite reflectivity for a noaa radar site.
:param tower_id: The noaa tower id. Ex Huntsville, Al -> 'HTX'.
:type tower_id: str
:param background: The hex background color.
:type background: str
:param include_legend: True - include legend.
:type include_legend... | [
"Get",
"the",
"composite",
"reflectivity",
"for",
"a",
"noaa",
"radar",
"site",
".",
":",
"param",
"tower_id",
":",
"The",
"noaa",
"tower",
"id",
".",
"Ex",
"Huntsville",
"Al",
"-",
">",
"HTX",
".",
":",
"type",
"tower_id",
":",
"str",
":",
"param",
... | python | train |
jwhitlock/drf-cached-instances | drf_cached_instances/models.py | https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L46-L55 | def values_list(self, *args, **kwargs):
"""Return the primary keys as a list.
The only valid call is values_list('pk', flat=True)
"""
flat = kwargs.pop('flat', False)
assert flat is True
assert len(args) == 1
assert args[0] == self.model._meta.pk.name
ret... | [
"def",
"values_list",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"flat",
"=",
"kwargs",
".",
"pop",
"(",
"'flat'",
",",
"False",
")",
"assert",
"flat",
"is",
"True",
"assert",
"len",
"(",
"args",
")",
"==",
"1",
"assert",
"... | Return the primary keys as a list.
The only valid call is values_list('pk', flat=True) | [
"Return",
"the",
"primary",
"keys",
"as",
"a",
"list",
"."
] | python | train |
teitei-tk/Flask-REST-Controller | flask_rest_controller/routing.py | https://github.com/teitei-tk/Flask-REST-Controller/blob/b4386b523f3d2c6550051c95d5ba74e5ff459946/flask_rest_controller/routing.py#L16-L34 | def set_routing(app, view_data):
"""
apply the routing configuration you've described
example:
view_data = [
("/", "app.IndexController", "index"),
]
1. "/" is receive request path
2. "app.IndexController" is to process the received request controller class path... | [
"def",
"set_routing",
"(",
"app",
",",
"view_data",
")",
":",
"routing_modules",
"=",
"convert_routing_module",
"(",
"view_data",
")",
"for",
"module",
"in",
"routing_modules",
":",
"view",
"=",
"import_string",
"(",
"module",
".",
"import_path",
")",
"app",
"... | apply the routing configuration you've described
example:
view_data = [
("/", "app.IndexController", "index"),
]
1. "/" is receive request path
2. "app.IndexController" is to process the received request controller class path
3. "index" string To generate a URL ... | [
"apply",
"the",
"routing",
"configuration",
"you",
"ve",
"described"
] | python | train |
basho/riak-python-client | riak/transports/http/transport.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/transport.py#L530-L550 | def delete_search_index(self, index):
"""
Fetch the specified Solr search index for Yokozuna.
:param index: a name of a yz index
:type index: string
:rtype boolean
"""
if not self.yz_wm_index:
raise NotImplementedError("Search 2.0 administration is n... | [
"def",
"delete_search_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"not",
"self",
".",
"yz_wm_index",
":",
"raise",
"NotImplementedError",
"(",
"\"Search 2.0 administration is not \"",
"\"supported for this version\"",
")",
"url",
"=",
"self",
".",
"search_index... | Fetch the specified Solr search index for Yokozuna.
:param index: a name of a yz index
:type index: string
:rtype boolean | [
"Fetch",
"the",
"specified",
"Solr",
"search",
"index",
"for",
"Yokozuna",
"."
] | python | train |
oasis-open/cti-stix-validator | stix2validator/v20/musts.py | https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/v20/musts.py#L244-L265 | def artifact_mime_type(instance):
"""Ensure the 'mime_type' property of artifact objects comes from the
Template column in the IANA media type registry.
"""
for key, obj in instance['objects'].items():
if ('type' in obj and obj['type'] == 'artifact' and 'mime_type' in obj):
if enums.... | [
"def",
"artifact_mime_type",
"(",
"instance",
")",
":",
"for",
"key",
",",
"obj",
"in",
"instance",
"[",
"'objects'",
"]",
".",
"items",
"(",
")",
":",
"if",
"(",
"'type'",
"in",
"obj",
"and",
"obj",
"[",
"'type'",
"]",
"==",
"'artifact'",
"and",
"'m... | Ensure the 'mime_type' property of artifact objects comes from the
Template column in the IANA media type registry. | [
"Ensure",
"the",
"mime_type",
"property",
"of",
"artifact",
"objects",
"comes",
"from",
"the",
"Template",
"column",
"in",
"the",
"IANA",
"media",
"type",
"registry",
"."
] | python | train |
QuantEcon/QuantEcon.py | quantecon/random/utilities.py | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L173-L212 | def draw(cdf, size=None):
"""
Generate a random sample according to the cumulative distribution
given by `cdf`. Jit-complied by Numba in nopython mode.
Parameters
----------
cdf : array_like(float, ndim=1)
Array containing the cumulative distribution.
size : scalar(int), optional(d... | [
"def",
"draw",
"(",
"cdf",
",",
"size",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"types",
".",
"Integer",
")",
":",
"def",
"draw_impl",
"(",
"cdf",
",",
"size",
")",
":",
"rs",
"=",
"np",
".",
"random",
".",
"random_sample",
"... | Generate a random sample according to the cumulative distribution
given by `cdf`. Jit-complied by Numba in nopython mode.
Parameters
----------
cdf : array_like(float, ndim=1)
Array containing the cumulative distribution.
size : scalar(int), optional(default=None)
Size of the sampl... | [
"Generate",
"a",
"random",
"sample",
"according",
"to",
"the",
"cumulative",
"distribution",
"given",
"by",
"cdf",
".",
"Jit",
"-",
"complied",
"by",
"Numba",
"in",
"nopython",
"mode",
"."
] | python | train |
numenta/nupic | src/nupic/encoders/coordinate.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/coordinate.py#L179-L189 | def _bitForCoordinate(cls, coordinate, n):
"""
Maps the coordinate to a bit in the SDR.
@param coordinate (numpy.array) Coordinate
@param n (int) The number of available bits in the SDR
@return (int) The index to a bit in the SDR
"""
seed = cls._hashCoordinate(coordinate)
rng = Random(s... | [
"def",
"_bitForCoordinate",
"(",
"cls",
",",
"coordinate",
",",
"n",
")",
":",
"seed",
"=",
"cls",
".",
"_hashCoordinate",
"(",
"coordinate",
")",
"rng",
"=",
"Random",
"(",
"seed",
")",
"return",
"rng",
".",
"getUInt32",
"(",
"n",
")"
] | Maps the coordinate to a bit in the SDR.
@param coordinate (numpy.array) Coordinate
@param n (int) The number of available bits in the SDR
@return (int) The index to a bit in the SDR | [
"Maps",
"the",
"coordinate",
"to",
"a",
"bit",
"in",
"the",
"SDR",
"."
] | python | valid |
saltstack/salt | salt/modules/freebsdpkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdpkg.py#L138-L184 | def _match(names):
'''
Since pkg_delete requires the full "pkgname-version" string, this function
will attempt to match the package name with its version. Returns a list of
partial matches and package names that match the "pkgname-version" string
required by pkg_delete, and a list of errors encounte... | [
"def",
"_match",
"(",
"names",
")",
":",
"pkgs",
"=",
"list_pkgs",
"(",
"versions_as_list",
"=",
"True",
")",
"errors",
"=",
"[",
"]",
"# Look for full matches",
"full_pkg_strings",
"=",
"[",
"]",
"out",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
... | Since pkg_delete requires the full "pkgname-version" string, this function
will attempt to match the package name with its version. Returns a list of
partial matches and package names that match the "pkgname-version" string
required by pkg_delete, and a list of errors encountered. | [
"Since",
"pkg_delete",
"requires",
"the",
"full",
"pkgname",
"-",
"version",
"string",
"this",
"function",
"will",
"attempt",
"to",
"match",
"the",
"package",
"name",
"with",
"its",
"version",
".",
"Returns",
"a",
"list",
"of",
"partial",
"matches",
"and",
"... | python | train |
exa-analytics/exa | exa/core/container.py | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L433-L444 | def _rel(self, copy=False):
"""
Get descriptive kwargs of the container (e.g. name, description, meta).
"""
rel = {}
for key, obj in vars(self).items():
if not isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)) and not key.startswith('_'):... | [
"def",
"_rel",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"rel",
"=",
"{",
"}",
"for",
"key",
",",
"obj",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"(",
"pd",
".",
"Series"... | Get descriptive kwargs of the container (e.g. name, description, meta). | [
"Get",
"descriptive",
"kwargs",
"of",
"the",
"container",
"(",
"e",
".",
"g",
".",
"name",
"description",
"meta",
")",
"."
] | python | train |
inasafe/inasafe | safe/utilities/gis.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/gis.py#L288-L302 | def is_polygon_layer(layer):
"""Check if a QGIS layer is vector and its geometries are polygons.
:param layer: A vector layer.
:type layer: QgsVectorLayer, QgsMapLayer
:returns: True if the layer contains polygons, otherwise False.
:rtype: bool
"""
try:
return (layer.type() == Qgs... | [
"def",
"is_polygon_layer",
"(",
"layer",
")",
":",
"try",
":",
"return",
"(",
"layer",
".",
"type",
"(",
")",
"==",
"QgsMapLayer",
".",
"VectorLayer",
")",
"and",
"(",
"layer",
".",
"geometryType",
"(",
")",
"==",
"QgsWkbTypes",
".",
"PolygonGeometry",
"... | Check if a QGIS layer is vector and its geometries are polygons.
:param layer: A vector layer.
:type layer: QgsVectorLayer, QgsMapLayer
:returns: True if the layer contains polygons, otherwise False.
:rtype: bool | [
"Check",
"if",
"a",
"QGIS",
"layer",
"is",
"vector",
"and",
"its",
"geometries",
"are",
"polygons",
"."
] | python | train |
pvlib/pvlib-python | pvlib/tools.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/tools.py#L262-L356 | def _array_newton(func, x0, fprime, args, tol, maxiter, fprime2,
converged=False):
"""
A vectorized version of Newton, Halley, and secant methods for arrays. Do
not use this method directly. This method is called from :func:`newton`
when ``np.isscalar(x0)`` is true. For docstring, see ... | [
"def",
"_array_newton",
"(",
"func",
",",
"x0",
",",
"fprime",
",",
"args",
",",
"tol",
",",
"maxiter",
",",
"fprime2",
",",
"converged",
"=",
"False",
")",
":",
"try",
":",
"p",
"=",
"np",
".",
"asarray",
"(",
"x0",
",",
"dtype",
"=",
"float",
"... | A vectorized version of Newton, Halley, and secant methods for arrays. Do
not use this method directly. This method is called from :func:`newton`
when ``np.isscalar(x0)`` is true. For docstring, see :func:`newton`. | [
"A",
"vectorized",
"version",
"of",
"Newton",
"Halley",
"and",
"secant",
"methods",
"for",
"arrays",
".",
"Do",
"not",
"use",
"this",
"method",
"directly",
".",
"This",
"method",
"is",
"called",
"from",
":",
"func",
":",
"newton",
"when",
"np",
".",
"iss... | python | train |
chrisspen/dtree | dtree.py | https://github.com/chrisspen/dtree/blob/9e9c9992b22ad9a7e296af7e6837666b05db43ef/dtree.py#L1331-L1342 | def out_of_bag_mae(self):
"""
Returns the mean absolute error for predictions on the out-of-bag
samples.
"""
if not self._out_of_bag_mae_clean:
try:
self._out_of_bag_mae = self.test(self.out_of_bag_samples)
self._out_of_bag_mae_clean = ... | [
"def",
"out_of_bag_mae",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_out_of_bag_mae_clean",
":",
"try",
":",
"self",
".",
"_out_of_bag_mae",
"=",
"self",
".",
"test",
"(",
"self",
".",
"out_of_bag_samples",
")",
"self",
".",
"_out_of_bag_mae_clean",
"... | Returns the mean absolute error for predictions on the out-of-bag
samples. | [
"Returns",
"the",
"mean",
"absolute",
"error",
"for",
"predictions",
"on",
"the",
"out",
"-",
"of",
"-",
"bag",
"samples",
"."
] | python | train |
UncleRus/regnupg | regnupg.py | https://github.com/UncleRus/regnupg/blob/c1acb5d459107c70e45967ec554831a5f2cd1aaf/regnupg.py#L845-L860 | def key_exists(self, key, secret=False):
'''
Check is given key exists.
:param key: Key ID
:param secret: Check secret key
:rtype: bool
'''
if len(key) < 8:
return False
key = key.upper()
res = self.list_keys(secret)
for finger... | [
"def",
"key_exists",
"(",
"self",
",",
"key",
",",
"secret",
"=",
"False",
")",
":",
"if",
"len",
"(",
"key",
")",
"<",
"8",
":",
"return",
"False",
"key",
"=",
"key",
".",
"upper",
"(",
")",
"res",
"=",
"self",
".",
"list_keys",
"(",
"secret",
... | Check is given key exists.
:param key: Key ID
:param secret: Check secret key
:rtype: bool | [
"Check",
"is",
"given",
"key",
"exists",
"."
] | python | train |
litl/backoff | backoff/_wait_gen.py | https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_wait_gen.py#L6-L23 | def expo(base=2, factor=1, max_value=None):
"""Generator for exponential decay.
Args:
base: The mathematical base of the exponentiation operation
factor: Factor to multiply the exponentation by.
max_value: The maximum value to yield. Once the value in the
true exponential s... | [
"def",
"expo",
"(",
"base",
"=",
"2",
",",
"factor",
"=",
"1",
",",
"max_value",
"=",
"None",
")",
":",
"n",
"=",
"0",
"while",
"True",
":",
"a",
"=",
"factor",
"*",
"base",
"**",
"n",
"if",
"max_value",
"is",
"None",
"or",
"a",
"<",
"max_value... | Generator for exponential decay.
Args:
base: The mathematical base of the exponentiation operation
factor: Factor to multiply the exponentation by.
max_value: The maximum value to yield. Once the value in the
true exponential sequence exceeds this, the value
of max... | [
"Generator",
"for",
"exponential",
"decay",
"."
] | python | train |
Kozea/cairocffi | cairocffi/fonts.py | https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/fonts.py#L40-L58 | def _from_pointer(pointer, incref):
"""Wrap an existing :c:type:`cairo_font_face_t *` cdata pointer.
:type incref: bool
:param incref:
Whether increase the :ref:`reference count <refcounting>` now.
:return:
A new instance of :class:`FontFace` or one of its sub-cl... | [
"def",
"_from_pointer",
"(",
"pointer",
",",
"incref",
")",
":",
"if",
"pointer",
"==",
"ffi",
".",
"NULL",
":",
"raise",
"ValueError",
"(",
"'Null pointer'",
")",
"if",
"incref",
":",
"cairo",
".",
"cairo_font_face_reference",
"(",
"pointer",
")",
"self",
... | Wrap an existing :c:type:`cairo_font_face_t *` cdata pointer.
:type incref: bool
:param incref:
Whether increase the :ref:`reference count <refcounting>` now.
:return:
A new instance of :class:`FontFace` or one of its sub-classes,
depending on the face’s type... | [
"Wrap",
"an",
"existing",
":",
"c",
":",
"type",
":",
"cairo_font_face_t",
"*",
"cdata",
"pointer",
"."
] | python | train |
nabetama/slacky | slacky/rest/rest.py | https://github.com/nabetama/slacky/blob/dde62ce49af9b8f581729c36d2ac790310b570e4/slacky/rest/rest.py#L163-L171 | def mark(self, channel_name, ts):
""" https://api.slack.com/methods/channels.mark
"""
channel_id = self.get_channel_id(channel_name)
self.params.update({
'channel': channel_id,
'ts': ts,
})
return FromUrl('https://slack.com/api/channels.... | [
"def",
"mark",
"(",
"self",
",",
"channel_name",
",",
"ts",
")",
":",
"channel_id",
"=",
"self",
".",
"get_channel_id",
"(",
"channel_name",
")",
"self",
".",
"params",
".",
"update",
"(",
"{",
"'channel'",
":",
"channel_id",
",",
"'ts'",
":",
"ts",
",... | https://api.slack.com/methods/channels.mark | [
"https",
":",
"//",
"api",
".",
"slack",
".",
"com",
"/",
"methods",
"/",
"channels",
".",
"mark"
] | python | train |
ninuxorg/nodeshot | nodeshot/interop/sync/models/node_external.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/models/node_external.py#L48-L60 | def delete_external_nodes(sender, **kwargs):
""" sync by deleting nodes from external layers when needed """
node = kwargs['instance']
if node.layer.is_external is False or not hasattr(node.layer, 'external') or node.layer.external.synchronizer_path is None:
return False
if hasattr(node, 'exte... | [
"def",
"delete_external_nodes",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"node",
"=",
"kwargs",
"[",
"'instance'",
"]",
"if",
"node",
".",
"layer",
".",
"is_external",
"is",
"False",
"or",
"not",
"hasattr",
"(",
"node",
".",
"layer",
",",
"'ex... | sync by deleting nodes from external layers when needed | [
"sync",
"by",
"deleting",
"nodes",
"from",
"external",
"layers",
"when",
"needed"
] | python | train |
aliyun/aliyun-odps-python-sdk | odps/ml/metrics/classification.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/ml/metrics/classification.py#L533-L569 | def lift_chart(df, col_true=None, col_pred=None, col_scores=None, pos_label=1):
r"""
Compute life value, true positive rate (TPR) and threshold from predicted DataFrame.
Note that this method will trigger the defined flow to execute.
:param df: predicted data frame
:type df: DataFrame
:param p... | [
"def",
"lift_chart",
"(",
"df",
",",
"col_true",
"=",
"None",
",",
"col_pred",
"=",
"None",
",",
"col_scores",
"=",
"None",
",",
"pos_label",
"=",
"1",
")",
":",
"if",
"not",
"col_pred",
":",
"col_pred",
"=",
"get_field_name_by_role",
"(",
"df",
",",
"... | r"""
Compute life value, true positive rate (TPR) and threshold from predicted DataFrame.
Note that this method will trigger the defined flow to execute.
:param df: predicted data frame
:type df: DataFrame
:param pos_label: positive label
:type pos_label: str
:param col_true: true column
... | [
"r",
"Compute",
"life",
"value",
"true",
"positive",
"rate",
"(",
"TPR",
")",
"and",
"threshold",
"from",
"predicted",
"DataFrame",
"."
] | python | train |
cltk/cltk | cltk/tokenize/sentence.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/tokenize/sentence.py#L96-L105 | def tokenize(self, text: str, model: object = None):
"""
Method for tokenizing sentences with regular expressions.
:rtype: list
:param text: text to be tokenized into sentences
:type text: str
"""
sentences = re.split(self.pattern, text)
return sentences | [
"def",
"tokenize",
"(",
"self",
",",
"text",
":",
"str",
",",
"model",
":",
"object",
"=",
"None",
")",
":",
"sentences",
"=",
"re",
".",
"split",
"(",
"self",
".",
"pattern",
",",
"text",
")",
"return",
"sentences"
] | Method for tokenizing sentences with regular expressions.
:rtype: list
:param text: text to be tokenized into sentences
:type text: str | [
"Method",
"for",
"tokenizing",
"sentences",
"with",
"regular",
"expressions",
"."
] | python | train |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L4702-L4712 | def libvlc_media_list_item_at_index(p_ml, i_pos):
'''List media instance in media list at a position
The L{libvlc_media_list_lock} should be held upon entering this function.
@param p_ml: a media list instance.
@param i_pos: position in array where to insert.
@return: media instance at position i_po... | [
"def",
"libvlc_media_list_item_at_index",
"(",
"p_ml",
",",
"i_pos",
")",
":",
"f",
"=",
"_Cfunctions",
".",
"get",
"(",
"'libvlc_media_list_item_at_index'",
",",
"None",
")",
"or",
"_Cfunction",
"(",
"'libvlc_media_list_item_at_index'",
",",
"(",
"(",
"1",
",",
... | List media instance in media list at a position
The L{libvlc_media_list_lock} should be held upon entering this function.
@param p_ml: a media list instance.
@param i_pos: position in array where to insert.
@return: media instance at position i_pos, or NULL if not found. In case of success, L{libvlc_med... | [
"List",
"media",
"instance",
"in",
"media",
"list",
"at",
"a",
"position",
"The",
"L",
"{",
"libvlc_media_list_lock",
"}",
"should",
"be",
"held",
"upon",
"entering",
"this",
"function",
"."
] | python | train |
phdata/sdc-api-tool | sdctool/api.py | https://github.com/phdata/sdc-api-tool/blob/8c86cfa89773ad411226264293d5b574194045de/sdctool/api.py#L86-L103 | def pipeline_status(url, pipeline_id, auth, verify_ssl):
"""Retrieve the current status for a pipeline.
Args:
url (str): the host url in the form 'http://host:port/'.
pipeline_id (str): the ID of of the exported pipeline.
auth (tuple): a tuple of username, and password... | [
"def",
"pipeline_status",
"(",
"url",
",",
"pipeline_id",
",",
"auth",
",",
"verify_ssl",
")",
":",
"status_result",
"=",
"requests",
".",
"get",
"(",
"url",
"+",
"'/'",
"+",
"pipeline_id",
"+",
"'/status'",
",",
"headers",
"=",
"X_REQ_BY",
",",
"auth",
... | Retrieve the current status for a pipeline.
Args:
url (str): the host url in the form 'http://host:port/'.
pipeline_id (str): the ID of of the exported pipeline.
auth (tuple): a tuple of username, and password.
verify_ssl (bool): whether to verify ssl certificate... | [
"Retrieve",
"the",
"current",
"status",
"for",
"a",
"pipeline",
"."
] | python | train |
uber/rides-python-sdk | uber_rides/auth.py | https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L194-L202 | def _generate_state_token(self, length=32):
"""Generate CSRF State Token.
CSRF State Tokens are passed as a parameter in the authorization
URL and are checked when receiving responses from the Uber Auth
server to prevent request forgery.
"""
choices = ascii_letters + dig... | [
"def",
"_generate_state_token",
"(",
"self",
",",
"length",
"=",
"32",
")",
":",
"choices",
"=",
"ascii_letters",
"+",
"digits",
"return",
"''",
".",
"join",
"(",
"SystemRandom",
"(",
")",
".",
"choice",
"(",
"choices",
")",
"for",
"_",
"in",
"range",
... | Generate CSRF State Token.
CSRF State Tokens are passed as a parameter in the authorization
URL and are checked when receiving responses from the Uber Auth
server to prevent request forgery. | [
"Generate",
"CSRF",
"State",
"Token",
"."
] | python | train |
cuihantao/andes | andes/routines/pflow.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L290-L323 | def post(self):
"""
Post processing for solved systems.
Store load, generation data on buses.
Store reactive power generation on PVs and slack generators.
Calculate series flows and area flows.
Returns
-------
None
"""
if not self.solved:... | [
"def",
"post",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"solved",
":",
"return",
"system",
"=",
"self",
".",
"system",
"exec",
"(",
"system",
".",
"call",
".",
"pfload",
")",
"system",
".",
"Bus",
".",
"Pl",
"=",
"system",
".",
"dae",
"."... | Post processing for solved systems.
Store load, generation data on buses.
Store reactive power generation on PVs and slack generators.
Calculate series flows and area flows.
Returns
-------
None | [
"Post",
"processing",
"for",
"solved",
"systems",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/data_generators/wikisum/wikisum.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wikisum/wikisum.py#L348-L379 | def rank_reference_paragraphs(wiki_title, references_content, normalize=True):
"""Rank and return reference paragraphs by tf-idf score on title tokens."""
normalized_title = _normalize_text(wiki_title)
title_tokens = _tokens_to_score(
set(tokenizer.encode(text_encoder.native_to_unicode(normalized_title))))
... | [
"def",
"rank_reference_paragraphs",
"(",
"wiki_title",
",",
"references_content",
",",
"normalize",
"=",
"True",
")",
":",
"normalized_title",
"=",
"_normalize_text",
"(",
"wiki_title",
")",
"title_tokens",
"=",
"_tokens_to_score",
"(",
"set",
"(",
"tokenizer",
".",... | Rank and return reference paragraphs by tf-idf score on title tokens. | [
"Rank",
"and",
"return",
"reference",
"paragraphs",
"by",
"tf",
"-",
"idf",
"score",
"on",
"title",
"tokens",
"."
] | python | train |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L17-L65 | def get_parsed_context(pipeline, context_in_string):
"""Execute get_parsed_context handler if specified.
Dynamically load the module specified by the context_parser key in pipeline
dict and execute the get_parsed_context function on that module.
Args:
pipeline: dict. Pipeline object.
c... | [
"def",
"get_parsed_context",
"(",
"pipeline",
",",
"context_in_string",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"if",
"'context_parser'",
"in",
"pipeline",
":",
"parser_module_name",
"=",
"pipeline",
"[",
"'context_parser'",
"]",
"logger",
".",... | Execute get_parsed_context handler if specified.
Dynamically load the module specified by the context_parser key in pipeline
dict and execute the get_parsed_context function on that module.
Args:
pipeline: dict. Pipeline object.
context_in_string: string. Argument string used to initialize... | [
"Execute",
"get_parsed_context",
"handler",
"if",
"specified",
"."
] | python | train |
ihmeuw/vivarium | src/vivarium/config_tree.py | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L397-L414 | def _load(self, f, layer=None, source=None):
"""Load data from a yaml formatted file.
Parameters
----------
f : str or file like object
If f is a string then it is interpreted as a path to the file to load
If it is a file like object then data is read directly fr... | [
"def",
"_load",
"(",
"self",
",",
"f",
",",
"layer",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"f",
",",
"'read'",
")",
":",
"self",
".",
"_loads",
"(",
"f",
".",
"read",
"(",
")",
",",
"layer",
"=",
"layer",
",... | Load data from a yaml formatted file.
Parameters
----------
f : str or file like object
If f is a string then it is interpreted as a path to the file to load
If it is a file like object then data is read directly from it.
layer : str
layer to load dat... | [
"Load",
"data",
"from",
"a",
"yaml",
"formatted",
"file",
"."
] | python | train |
trailofbits/manticore | manticore/core/executor.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/executor.py#L347-L405 | def fork(self, state, expression, policy='ALL', setstate=None):
"""
Fork state on expression concretizations.
Using policy build a list of solutions for expression.
For the state on each solution setting the new state with setstate
For example if expression is a Bool it may have... | [
"def",
"fork",
"(",
"self",
",",
"state",
",",
"expression",
",",
"policy",
"=",
"'ALL'",
",",
"setstate",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"expression",
",",
"Expression",
")",
"if",
"setstate",
"is",
"None",
":",
"setstate",
"=",
"... | Fork state on expression concretizations.
Using policy build a list of solutions for expression.
For the state on each solution setting the new state with setstate
For example if expression is a Bool it may have 2 solutions. True or False.
Parent
... | [
"Fork",
"state",
"on",
"expression",
"concretizations",
".",
"Using",
"policy",
"build",
"a",
"list",
"of",
"solutions",
"for",
"expression",
".",
"For",
"the",
"state",
"on",
"each",
"solution",
"setting",
"the",
"new",
"state",
"with",
"setstate"
] | python | valid |
a1ezzz/wasp-general | wasp_general/config.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L66-L83 | def merge_section(self, config, section_to, section_from=None):
""" Load configuration section from other configuration. If specified section doesn't exist in current
configuration, then it will be added automatically.
:param config: source configuration
:param section_to: destination section name
:param sec... | [
"def",
"merge_section",
"(",
"self",
",",
"config",
",",
"section_to",
",",
"section_from",
"=",
"None",
")",
":",
"section_from",
"=",
"section_from",
"if",
"section_from",
"is",
"not",
"None",
"else",
"section_to",
"if",
"section_from",
"not",
"in",
"config"... | Load configuration section from other configuration. If specified section doesn't exist in current
configuration, then it will be added automatically.
:param config: source configuration
:param section_to: destination section name
:param section_from: source section name (if it is None, then section_to is used... | [
"Load",
"configuration",
"section",
"from",
"other",
"configuration",
".",
"If",
"specified",
"section",
"doesn",
"t",
"exist",
"in",
"current",
"configuration",
"then",
"it",
"will",
"be",
"added",
"automatically",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.