Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Checker.error_count
(self)
Count of all errors found
Count of all errors found
def error_count(self) -> int: """Count of all errors found""" return sum(len(e) for e in self.errors.values())
[ "def", "error_count", "(", "self", ")", "->", "int", ":", "return", "sum", "(", "len", "(", "e", ")", "for", "e", "in", "self", ".", "errors", ".", "values", "(", ")", ")" ]
[ 28, 4 ]
[ 30, 56 ]
python
en
['en', 'en', 'en']
True
Checker.failed
(self)
Dictionary of errors per check
Dictionary of errors per check
def failed(self) -> dict: """Dictionary of errors per check""" return dict((k, (len(v))) for k, v in self.errors.items())
[ "def", "failed", "(", "self", ")", "->", "dict", ":", "return", "dict", "(", "(", "k", ",", "(", "len", "(", "v", ")", ")", ")", "for", "k", ",", "v", "in", "self", ".", "errors", ".", "items", "(", ")", ")" ]
[ 33, 4 ]
[ 35, 66 ]
python
en
['en', 'en', 'it']
True
Checker.fix
(self)
Flag to determine whether the checker should attempt to fix found problems
Flag to determine whether the checker should attempt to fix found problems
def fix(self) -> bool: """Flag to determine whether the checker should attempt to fix found problems""" return self.args.fix
[ "def", "fix", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "args", ".", "fix" ]
[ 38, 4 ]
[ 40, 28 ]
python
en
['en', 'en', 'en']
True
Checker.has_failed
(self)
Shows whether there are any failures
Shows whether there are any failures
def has_failed(self) -> bool: """Shows whether there are any failures""" # add logic for warn/error return bool(self.failed or self.warned)
[ "def", "has_failed", "(", "self", ")", "->", "bool", ":", "# add logic for warn/error", "return", "bool", "(", "self", ".", "failed", "or", "self", ".", "warned", ")" ]
[ 43, 4 ]
[ 46, 47 ]
python
en
['en', 'en', 'en']
True
Checker.path
(self)
The "path" - usually Envoy src dir. This is used for finding configs for the tooling and should be a dir
The "path" - usually Envoy src dir. This is used for finding configs for the tooling and should be a dir
def path(self) -> str: """The "path" - usually Envoy src dir. This is used for finding configs for the tooling and should be a dir""" try: path = self.args.path or self.args.paths[0] except IndexError: raise self.parser.error( "Missing path: `path` must be...
[ "def", "path", "(", "self", ")", "->", "str", ":", "try", ":", "path", "=", "self", ".", "args", ".", "path", "or", "self", ".", "args", ".", "paths", "[", "0", "]", "except", "IndexError", ":", "raise", "self", ".", "parser", ".", "error", "(", ...
[ 49, 4 ]
[ 60, 19 ]
python
en
['en', 'en', 'en']
True
Checker.paths
(self)
List of paths to apply checks to
List of paths to apply checks to
def paths(self) -> list: """List of paths to apply checks to""" return self.args.paths or [self.path]
[ "def", "paths", "(", "self", ")", "->", "list", ":", "return", "self", ".", "args", ".", "paths", "or", "[", "self", ".", "path", "]" ]
[ 63, 4 ]
[ 65, 45 ]
python
en
['en', 'en', 'en']
True
Checker.show_summary
(self)
Show a summary at the end or not
Show a summary at the end or not
def show_summary(self) -> bool: """Show a summary at the end or not""" return bool(self.args.summary or self.error_count or self.warning_count)
[ "def", "show_summary", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "args", ".", "summary", "or", "self", ".", "error_count", "or", "self", ".", "warning_count", ")" ]
[ 68, 4 ]
[ 70, 80 ]
python
en
['en', 'en', 'en']
True
Checker.status
(self)
Dictionary showing current success/warnings/errors
Dictionary showing current success/warnings/errors
def status(self) -> dict: """Dictionary showing current success/warnings/errors""" return dict( success=self.success_count, errors=self.error_count, warnings=self.warning_count, failed=self.failed, warned=self.warned, succeeded=self...
[ "def", "status", "(", "self", ")", "->", "dict", ":", "return", "dict", "(", "success", "=", "self", ".", "success_count", ",", "errors", "=", "self", ".", "error_count", ",", "warnings", "=", "self", ".", "warning_count", ",", "failed", "=", "self", "...
[ 73, 4 ]
[ 81, 37 ]
python
en
['en', 'en', 'en']
True
Checker.succeeded
(self)
Dictionary of successful checks grouped by check type
Dictionary of successful checks grouped by check type
def succeeded(self) -> dict: """Dictionary of successful checks grouped by check type""" return dict((k, (len(v))) for k, v in self.success.items())
[ "def", "succeeded", "(", "self", ")", "->", "dict", ":", "return", "dict", "(", "(", "k", ",", "(", "len", "(", "v", ")", ")", ")", "for", "k", ",", "v", "in", "self", ".", "success", ".", "items", "(", ")", ")" ]
[ 84, 4 ]
[ 86, 67 ]
python
en
['en', 'en', 'en']
True
Checker.success_count
(self)
Current count of successful checks
Current count of successful checks
def success_count(self) -> int: """Current count of successful checks""" return sum(len(e) for e in self.success.values())
[ "def", "success_count", "(", "self", ")", "->", "int", ":", "return", "sum", "(", "len", "(", "e", ")", "for", "e", "in", "self", ".", "success", ".", "values", "(", ")", ")" ]
[ 89, 4 ]
[ 91, 57 ]
python
en
['en', 'en', 'en']
True
Checker.summary
(self)
Instance of the checker's summary class
Instance of the checker's summary class
def summary(self) -> "CheckerSummary": """Instance of the checker's summary class""" return self.summary_class(self)
[ "def", "summary", "(", "self", ")", "->", "\"CheckerSummary\"", ":", "return", "self", ".", "summary_class", "(", "self", ")" ]
[ 94, 4 ]
[ 96, 39 ]
python
en
['en', 'en', 'en']
True
Checker.summary_class
(self)
Checker's summary class
Checker's summary class
def summary_class(self) -> Type["CheckerSummary"]: """Checker's summary class""" return CheckerSummary
[ "def", "summary_class", "(", "self", ")", "->", "Type", "[", "\"CheckerSummary\"", "]", ":", "return", "CheckerSummary" ]
[ 99, 4 ]
[ 101, 29 ]
python
en
['en', 'mg', 'en']
True
Checker.warned
(self)
Dictionary of warned checks grouped by check type
Dictionary of warned checks grouped by check type
def warned(self) -> dict: """Dictionary of warned checks grouped by check type""" return dict((k, (len(v))) for k, v in self.warnings.items())
[ "def", "warned", "(", "self", ")", "->", "dict", ":", "return", "dict", "(", "(", "k", ",", "(", "len", "(", "v", ")", ")", ")", "for", "k", ",", "v", "in", "self", ".", "warnings", ".", "items", "(", ")", ")" ]
[ 104, 4 ]
[ 106, 68 ]
python
en
['en', 'en', 'en']
True
Checker.warning_count
(self)
Current count of warned checks
Current count of warned checks
def warning_count(self) -> int: """Current count of warned checks""" return sum(len(e) for e in self.warnings.values())
[ "def", "warning_count", "(", "self", ")", "->", "int", ":", "return", "sum", "(", "len", "(", "e", ")", "for", "e", "in", "self", ".", "warnings", ".", "values", "(", ")", ")" ]
[ 109, 4 ]
[ 111, 58 ]
python
en
['en', 'en', 'en']
True
Checker.add_arguments
(self, parser: argparse.ArgumentParser)
Add arguments to the arg parser
Add arguments to the arg parser
def add_arguments(self, parser: argparse.ArgumentParser) -> None: """Add arguments to the arg parser""" parser.add_argument( "--fix", action="store_true", default=False, help="Attempt to fix in place") parser.add_argument( "--diff", action="store_true", ...
[ "def", "add_arguments", "(", "self", ",", "parser", ":", "argparse", ".", "ArgumentParser", ")", "->", "None", ":", "parser", ".", "add_argument", "(", "\"--fix\"", ",", "action", "=", "\"store_true\"", ",", "default", "=", "False", ",", "help", "=", "\"At...
[ 113, 4 ]
[ 167, 9 ]
python
en
['en', 'en', 'en']
True
Checker.error
(self, name: str, errors: list, log: bool = True)
Record (and log) errors for a check type
Record (and log) errors for a check type
def error(self, name: str, errors: list, log: bool = True) -> int: """Record (and log) errors for a check type""" self.errors[name] = self.errors.get(name, []) self.errors[name].extend(errors) if log: self.log.error("\n".join(errors)) return 1
[ "def", "error", "(", "self", ",", "name", ":", "str", ",", "errors", ":", "list", ",", "log", ":", "bool", "=", "True", ")", "->", "int", ":", "self", ".", "errors", "[", "name", "]", "=", "self", ".", "errors", ".", "get", "(", "name", ",", ...
[ 169, 4 ]
[ 175, 16 ]
python
en
['en', 'en', 'en']
True
Checker.get_checks
(self)
Get list of checks for this checker class filtered according to user args
Get list of checks for this checker class filtered according to user args
def get_checks(self) -> Sequence[str]: """Get list of checks for this checker class filtered according to user args""" return ( self.checks if not self.args.check else [check for check in self.args.check if check in self.checks])
[ "def", "get_checks", "(", "self", ")", "->", "Sequence", "[", "str", "]", ":", "return", "(", "self", ".", "checks", "if", "not", "self", ".", "args", ".", "check", "else", "[", "check", "for", "check", "in", "self", ".", "args", ".", "check", "if"...
[ 177, 4 ]
[ 181, 73 ]
python
en
['en', 'en', 'en']
True
Checker.on_check_run
(self, check: str)
Callback hook called after each check run
Callback hook called after each check run
def on_check_run(self, check: str) -> None: """Callback hook called after each check run""" pass
[ "def", "on_check_run", "(", "self", ",", "check", ":", "str", ")", "->", "None", ":", "pass" ]
[ 183, 4 ]
[ 185, 12 ]
python
en
['en', 'en', 'en']
True
Checker.on_checks_begin
(self)
Callback hook called before all checks
Callback hook called before all checks
def on_checks_begin(self) -> None: """Callback hook called before all checks""" pass
[ "def", "on_checks_begin", "(", "self", ")", "->", "None", ":", "pass" ]
[ 187, 4 ]
[ 189, 12 ]
python
en
['en', 'ig', 'en']
True
Checker.on_checks_complete
(self)
Callback hook called after all checks have run, and returning the final outcome of a checks_run
Callback hook called after all checks have run, and returning the final outcome of a checks_run
def on_checks_complete(self) -> int: """Callback hook called after all checks have run, and returning the final outcome of a checks_run""" if self.show_summary: self.summary.print_summary() return 1 if self.has_failed else 0
[ "def", "on_checks_complete", "(", "self", ")", "->", "int", ":", "if", "self", ".", "show_summary", ":", "self", ".", "summary", ".", "print_summary", "(", ")", "return", "1", "if", "self", ".", "has_failed", "else", "0" ]
[ 191, 4 ]
[ 195, 42 ]
python
en
['en', 'en', 'en']
True
Checker.run
(self)
Run all configured checks and return the sum of their error counts
Run all configured checks and return the sum of their error counts
def run(self) -> int: """Run all configured checks and return the sum of their error counts""" checks = self.get_checks() self.on_checks_begin() for check in checks: self.log.info(f"[CHECKS:{self.name}] {check}") getattr(self, f"check_{check}")() self....
[ "def", "run", "(", "self", ")", "->", "int", ":", "checks", "=", "self", ".", "get_checks", "(", ")", "self", ".", "on_checks_begin", "(", ")", "for", "check", "in", "checks", ":", "self", ".", "log", ".", "info", "(", "f\"[CHECKS:{self.name}] {check}\""...
[ 197, 4 ]
[ 205, 40 ]
python
en
['en', 'en', 'en']
True
Checker.succeed
(self, name: str, success: list, log: bool = True)
Record (and log) success for a check type
Record (and log) success for a check type
def succeed(self, name: str, success: list, log: bool = True) -> None: """Record (and log) success for a check type""" self.success[name] = self.success.get(name, []) self.success[name].extend(success) if log: self.log.info("\n".join(success))
[ "def", "succeed", "(", "self", ",", "name", ":", "str", ",", "success", ":", "list", ",", "log", ":", "bool", "=", "True", ")", "->", "None", ":", "self", ".", "success", "[", "name", "]", "=", "self", ".", "success", ".", "get", "(", "name", "...
[ 207, 4 ]
[ 213, 45 ]
python
en
['en', 'en', 'en']
True
Checker.warn
(self, name: str, warnings: list, log: bool = True)
Record (and log) warnings for a check type
Record (and log) warnings for a check type
def warn(self, name: str, warnings: list, log: bool = True) -> None: """Record (and log) warnings for a check type""" self.warnings[name] = self.warnings.get(name, []) self.warnings[name].extend(warnings) if log: self.log.warning("\n".join(warnings))
[ "def", "warn", "(", "self", ",", "name", ":", "str", ",", "warnings", ":", "list", ",", "log", ":", "bool", "=", "True", ")", "->", "None", ":", "self", ".", "warnings", "[", "name", "]", "=", "self", ".", "warnings", ".", "get", "(", "name", "...
[ 215, 4 ]
[ 221, 49 ]
python
en
['en', 'en', 'en']
True
CheckerSummary.max_errors
(self)
Maximum errors to display in summary
Maximum errors to display in summary
def max_errors(self) -> int: """Maximum errors to display in summary""" return self.checker.args.summary_errors
[ "def", "max_errors", "(", "self", ")", "->", "int", ":", "return", "self", ".", "checker", ".", "args", ".", "summary_errors" ]
[ 238, 4 ]
[ 240, 47 ]
python
en
['en', 'la', 'en']
True
CheckerSummary.max_warnings
(self)
Maximum warnings to display in summary
Maximum warnings to display in summary
def max_warnings(self) -> int: """Maximum warnings to display in summary""" return self.checker.args.summary_warnings
[ "def", "max_warnings", "(", "self", ")", "->", "int", ":", "return", "self", ".", "checker", ".", "args", ".", "summary_warnings" ]
[ 243, 4 ]
[ 245, 49 ]
python
en
['en', 'so', 'en']
True
CheckerSummary.print_status
(self)
Print summary status to stderr
Print summary status to stderr
def print_status(self) -> None: """Print summary status to stderr""" self.checker.log.warning( "\n".join(self._section(f"[SUMMARY:{self.checker.name}] {self.checker.status}")))
[ "def", "print_status", "(", "self", ")", "->", "None", ":", "self", ".", "checker", ".", "log", ".", "warning", "(", "\"\\n\"", ".", "join", "(", "self", ".", "_section", "(", "f\"[SUMMARY:{self.checker.name}] {self.checker.status}\"", ")", ")", ")" ]
[ 260, 4 ]
[ 263, 93 ]
python
en
['en', 'fi', 'hi']
False
CheckerSummary.print_summary
(self)
Write summary to stderr
Write summary to stderr
def print_summary(self) -> None: """Write summary to stderr""" self.print_failed("warnings") self.print_failed("errors") self.print_status()
[ "def", "print_summary", "(", "self", ")", "->", "None", ":", "self", ".", "print_failed", "(", "\"warnings\"", ")", "self", ".", "print_failed", "(", "\"errors\"", ")", "self", ".", "print_status", "(", ")" ]
[ 265, 4 ]
[ 269, 27 ]
python
en
['en', 'ky', 'en']
True
CheckerSummary._section
(self, message: str, lines: list = None)
Print a summary section
Print a summary section
def _section(self, message: str, lines: list = None) -> list: """Print a summary section""" section = ["", "-" * 80, "", f"{message}"] if lines: section += lines return section
[ "def", "_section", "(", "self", ",", "message", ":", "str", ",", "lines", ":", "list", "=", "None", ")", "->", "list", ":", "section", "=", "[", "\"\"", ",", "\"-\"", "*", "80", ",", "\"\"", ",", "f\"{message}\"", "]", "if", "lines", ":", "section"...
[ 271, 4 ]
[ 276, 22 ]
python
en
['en', 'ga', 'en']
True
test_logging_sync_dist_true_ddp
(tmpdir)
Tests to ensure that the sync_dist flag works with CPU (should just return the original value)
Tests to ensure that the sync_dist flag works with CPU (should just return the original value)
def test_logging_sync_dist_true_ddp(tmpdir): """ Tests to ensure that the sync_dist flag works with CPU (should just return the original value) """ fake_result = 1 class TestModel(BoringModel): def training_step(self, batch, batch_idx): acc = self.step(batch[0]) sel...
[ "def", "test_logging_sync_dist_true_ddp", "(", "tmpdir", ")", ":", "fake_result", "=", "1", "class", "TestModel", "(", "BoringModel", ")", ":", "def", "training_step", "(", "self", ",", "batch", ",", "batch_idx", ")", ":", "acc", "=", "self", ".", "step", ...
[ 32, 0 ]
[ 65, 55 ]
python
en
['en', 'error', 'th']
False
test__validation_step__log
(tmpdir)
Tests that validation_step can log
Tests that validation_step can log
def test__validation_step__log(tmpdir): """ Tests that validation_step can log """ class TestModel(BoringModel): def training_step(self, batch, batch_idx): acc = self.step(batch) acc = acc + batch_idx self.log('a', acc, on_step=True, on_epoch=True) ...
[ "def", "test__validation_step__log", "(", "tmpdir", ")", ":", "class", "TestModel", "(", "BoringModel", ")", ":", "def", "training_step", "(", "self", ",", "batch", ",", "batch_idx", ")", ":", "acc", "=", "self", ".", "step", "(", "batch", ")", "acc", "=...
[ 72, 0 ]
[ 132, 50 ]
python
en
['en', 'error', 'th']
False
GradInformation.grad_norm
(self, norm_type: Union[float, int, str])
Compute each parameter's gradient's norm and their overall norm. The overall norm is computed over all gradients together, as if they were concatenated into a single vector. Args: norm_type: The type of the used p-norm, cast to float if necessary. Can be ``'inf'`` f...
Compute each parameter's gradient's norm and their overall norm.
def grad_norm(self, norm_type: Union[float, int, str]) -> Dict[str, float]: """Compute each parameter's gradient's norm and their overall norm. The overall norm is computed over all gradients together, as if they were concatenated into a single vector. Args: norm_type: The ...
[ "def", "grad_norm", "(", "self", ",", "norm_type", ":", "Union", "[", "float", ",", "int", ",", "str", "]", ")", "->", "Dict", "[", "str", ",", "float", "]", ":", "norm_type", "=", "float", "(", "norm_type", ")", "norms", ",", "all_norms", "=", "{"...
[ 24, 4 ]
[ 54, 20 ]
python
en
['en', 'en', 'en']
True
fv
(rate, nper, pmt, pv, when='end')
Compute the future value. Given: * a present value, `pv` * an interest `rate` compounded once per period, of which there are * `nper` total * a (fixed) payment, `pmt`, paid either * at the beginning (`when` = {'begin', 1}) or the end (`when` = {'end', 0}) of each period ...
Compute the future value.
def fv(rate, nper, pmt, pv, when='end'): """ Compute the future value. Given: * a present value, `pv` * an interest `rate` compounded once per period, of which there are * `nper` total * a (fixed) payment, `pmt`, paid either * at the beginning (`when` = {'begin', 1}) or the ...
[ "def", "fv", "(", "rate", ",", "nper", ",", "pmt", ",", "pv", ",", "when", "=", "'end'", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "(", "rate", ",", "nper", ",", "pmt", ",", "pv", ",", "when", ")", "=", "map", "(", "np", ".", ...
[ 51, 0 ]
[ 137, 32 ]
python
en
['en', 'error', 'th']
False
pmt
(rate, nper, pv, fv=0, when='end')
Compute the payment against loan principal plus interest. Given: * a present value, `pv` (e.g., an amount borrowed) * a future value, `fv` (e.g., 0) * an interest `rate` compounded once per period, of which there are * `nper` total * and (optional) specification of whether paym...
Compute the payment against loan principal plus interest.
def pmt(rate, nper, pv, fv=0, when='end'): """ Compute the payment against loan principal plus interest. Given: * a present value, `pv` (e.g., an amount borrowed) * a future value, `fv` (e.g., 0) * an interest `rate` compounded once per period, of which there are * `nper` total ...
[ "def", "pmt", "(", "rate", ",", "nper", ",", "pv", ",", "fv", "=", "0", ",", "when", "=", "'end'", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "(", "rate", ",", "nper", ",", "pv", ",", "fv", ",", "when", ")", "=", "map", "(", ...
[ 145, 0 ]
[ 235, 33 ]
python
en
['en', 'error', 'th']
False
nper
(rate, pmt, pv, fv=0, when='end')
Compute the number of periodic payments. :class:`decimal.Decimal` type is not supported. Parameters ---------- rate : array_like Rate of interest (per period) pmt : array_like Payment pv : array_like Present value fv : array_like, optional Future value ...
Compute the number of periodic payments.
def nper(rate, pmt, pv, fv=0, when='end'): """ Compute the number of periodic payments. :class:`decimal.Decimal` type is not supported. Parameters ---------- rate : array_like Rate of interest (per period) pmt : array_like Payment pv : array_like Present value ...
[ "def", "nper", "(", "rate", ",", "pmt", ",", "pv", ",", "fv", "=", "0", ",", "when", "=", "'end'", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "(", "rate", ",", "pmt", ",", "pv", ",", "fv", ",", "when", ")", "=", "map", "(", "...
[ 243, 0 ]
[ 309, 40 ]
python
en
['en', 'error', 'th']
False
ipmt
(rate, per, nper, pv, fv=0, when='end')
Compute the interest portion of a payment. Parameters ---------- rate : scalar or array_like of shape(M, ) Rate of interest as decimal (not per cent) per period per : scalar or array_like of shape(M, ) Interest paid against the loan changes during the life or the loan. The ...
Compute the interest portion of a payment.
def ipmt(rate, per, nper, pv, fv=0, when='end'): """ Compute the interest portion of a payment. Parameters ---------- rate : scalar or array_like of shape(M, ) Rate of interest as decimal (not per cent) per period per : scalar or array_like of shape(M, ) Interest paid against th...
[ "def", "ipmt", "(", "rate", ",", "per", ",", "nper", ",", "pv", ",", "fv", "=", "0", ",", "when", "=", "'end'", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "rate", ",", "per", ",", "nper", ",", "pv", ",", "fv", ",", "when", "=",...
[ 317, 0 ]
[ 410, 15 ]
python
en
['en', 'error', 'th']
False
_rbl
(rate, per, pmt, pv, when)
This function is here to simply have a different name for the 'fv' function to not interfere with the 'fv' keyword argument within the 'ipmt' function. It is the 'remaining balance on loan' which might be useful as it's own function, but is easily calculated with the 'fv' function.
This function is here to simply have a different name for the 'fv' function to not interfere with the 'fv' keyword argument within the 'ipmt' function. It is the 'remaining balance on loan' which might be useful as it's own function, but is easily calculated with the 'fv' function.
def _rbl(rate, per, pmt, pv, when): """ This function is here to simply have a different name for the 'fv' function to not interfere with the 'fv' keyword argument within the 'ipmt' function. It is the 'remaining balance on loan' which might be useful as it's own function, but is easily calculated ...
[ "def", "_rbl", "(", "rate", ",", "per", ",", "pmt", ",", "pv", ",", "when", ")", ":", "return", "fv", "(", "rate", ",", "(", "per", "-", "1", ")", ",", "pmt", ",", "pv", ",", "when", ")" ]
[ 413, 0 ]
[ 420, 45 ]
python
en
['en', 'error', 'th']
False
ppmt
(rate, per, nper, pv, fv=0, when='end')
Compute the payment against loan principal. Parameters ---------- rate : array_like Rate of interest (per period) per : array_like, int Amount paid against the loan changes. The `per` is the period of interest. nper : array_like Number of compounding periods ...
Compute the payment against loan principal.
def ppmt(rate, per, nper, pv, fv=0, when='end'): """ Compute the payment against loan principal. Parameters ---------- rate : array_like Rate of interest (per period) per : array_like, int Amount paid against the loan changes. The `per` is the period of interest. np...
[ "def", "ppmt", "(", "rate", ",", "per", ",", "nper", ",", "pv", ",", "fv", "=", "0", ",", "when", "=", "'end'", ")", ":", "total", "=", "pmt", "(", "rate", ",", "nper", ",", "pv", ",", "fv", ",", "when", ")", "return", "total", "-", "ipmt", ...
[ 428, 0 ]
[ 454, 54 ]
python
en
['en', 'error', 'th']
False
pv
(rate, nper, pmt, fv=0, when='end')
Compute the present value. Given: * a future value, `fv` * an interest `rate` compounded once per period, of which there are * `nper` total * a (fixed) payment, `pmt`, paid either * at the beginning (`when` = {'begin', 1}) or the end (`when` = {'end', 0}) of each period ...
Compute the present value.
def pv(rate, nper, pmt, fv=0, when='end'): """ Compute the present value. Given: * a future value, `fv` * an interest `rate` compounded once per period, of which there are * `nper` total * a (fixed) payment, `pmt`, paid either * at the beginning (`when` = {'begin', 1}) or th...
[ "def", "pv", "(", "rate", ",", "nper", ",", "pmt", ",", "fv", "=", "0", ",", "when", "=", "'end'", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "(", "rate", ",", "nper", ",", "pmt", ",", "fv", ",", "when", ")", "=", "map", "(", ...
[ 462, 0 ]
[ 552, 32 ]
python
en
['en', 'error', 'th']
False
rate
(nper, pmt, pv, fv, when='end', guess=None, tol=None, maxiter=100)
Compute the rate of interest per period. Parameters ---------- nper : array_like Number of compounding periods pmt : array_like Payment pv : array_like Present value fv : array_like Future value when : {{'begin', 1}, {'end', 0}}, {string, int}, optional ...
Compute the rate of interest per period.
def rate(nper, pmt, pv, fv, when='end', guess=None, tol=None, maxiter=100): """ Compute the rate of interest per period. Parameters ---------- nper : array_like Number of compounding periods pmt : array_like Payment pv : array_like Present value fv : array_like ...
[ "def", "rate", "(", "nper", ",", "pmt", ",", "pv", ",", "fv", ",", "when", "=", "'end'", ",", "guess", "=", "None", ",", "tol", "=", "None", ",", "maxiter", "=", "100", ")", ":", "when", "=", "_convert_when", "(", "when", ")", "default_type", "="...
[ 580, 0 ]
[ 649, 17 ]
python
en
['en', 'error', 'th']
False
irr
(values)
Return the Internal Rate of Return (IRR). This is the "average" periodically compounded rate of return that gives a net present value of 0.0; for a more complete explanation, see Notes below. :class:`decimal.Decimal` type is not supported. Parameters ---------- values : array_like, s...
Return the Internal Rate of Return (IRR).
def irr(values): """ Return the Internal Rate of Return (IRR). This is the "average" periodically compounded rate of return that gives a net present value of 0.0; for a more complete explanation, see Notes below. :class:`decimal.Decimal` type is not supported. Parameters ---------- ...
[ "def", "irr", "(", "values", ")", ":", "# `np.roots` call is why this function does not support Decimal type.", "#", "# Ultimately Decimal support needs to be added to np.roots, which has", "# greater implications on the entire linear algebra module and how it does", "# eigenvalue computations."...
[ 657, 0 ]
[ 734, 15 ]
python
en
['en', 'error', 'th']
False
npv
(rate, values)
Returns the NPV (Net Present Value) of a cash flow series. Parameters ---------- rate : scalar The discount rate. values : array_like, shape(M, ) The values of the time series of cash flows. The (fixed) time interval between cash flow "events" must be the same as that for ...
Returns the NPV (Net Present Value) of a cash flow series.
def npv(rate, values): """ Returns the NPV (Net Present Value) of a cash flow series. Parameters ---------- rate : scalar The discount rate. values : array_like, shape(M, ) The values of the time series of cash flows. The (fixed) time interval between cash flow "events"...
[ "def", "npv", "(", "rate", ",", "values", ")", ":", "values", "=", "np", ".", "asarray", "(", "values", ")", "return", "(", "values", "/", "(", "1", "+", "rate", ")", "**", "np", ".", "arange", "(", "0", ",", "len", "(", "values", ")", ")", "...
[ 742, 0 ]
[ 785, 69 ]
python
en
['en', 'error', 'th']
False
mirr
(values, finance_rate, reinvest_rate)
Modified internal rate of return. Parameters ---------- values : array_like Cash flows (must contain at least one positive and one negative value) or nan is returned. The first value is considered a sunk cost at time zero. finance_rate : scalar Interest rate paid o...
Modified internal rate of return.
def mirr(values, finance_rate, reinvest_rate): """ Modified internal rate of return. Parameters ---------- values : array_like Cash flows (must contain at least one positive and one negative value) or nan is returned. The first value is considered a sunk cost at time zero. ...
[ "def", "mirr", "(", "values", ",", "finance_rate", ",", "reinvest_rate", ")", ":", "values", "=", "np", ".", "asarray", "(", "values", ")", "n", "=", "values", ".", "size", "# Without this explicit cast the 1/(n - 1) computation below", "# becomes a float, which cause...
[ 793, 0 ]
[ 829, 61 ]
python
en
['en', 'error', 'th']
False
SortGenerator.random
(size, dtype)
Returns a randomly-shuffled array.
Returns a randomly-shuffled array.
def random(size, dtype): """ Returns a randomly-shuffled array. """ arr = np.arange(size, dtype=dtype) np.random.shuffle(arr) return arr
[ "def", "random", "(", "size", ",", "dtype", ")", ":", "arr", "=", "np", ".", "arange", "(", "size", ",", "dtype", "=", "dtype", ")", "np", ".", "random", ".", "shuffle", "(", "arr", ")", "return", "arr" ]
[ 117, 4 ]
[ 123, 18 ]
python
en
['en', 'error', 'th']
False
SortGenerator.ordered
(size, dtype)
Returns an ordered array.
Returns an ordered array.
def ordered(size, dtype): """ Returns an ordered array. """ return np.arange(size, dtype=dtype)
[ "def", "ordered", "(", "size", ",", "dtype", ")", ":", "return", "np", ".", "arange", "(", "size", ",", "dtype", "=", "dtype", ")" ]
[ 127, 4 ]
[ 131, 43 ]
python
en
['en', 'error', 'th']
False
SortGenerator.reversed
(size, dtype)
Returns an array that's in descending order.
Returns an array that's in descending order.
def reversed(size, dtype): """ Returns an array that's in descending order. """ return np.arange(size-1, -1, -1, dtype=dtype)
[ "def", "reversed", "(", "size", ",", "dtype", ")", ":", "return", "np", ".", "arange", "(", "size", "-", "1", ",", "-", "1", ",", "-", "1", ",", "dtype", "=", "dtype", ")" ]
[ 135, 4 ]
[ 139, 53 ]
python
en
['en', 'error', 'th']
False
SortGenerator.uniform
(size, dtype)
Returns an array that has the same value everywhere.
Returns an array that has the same value everywhere.
def uniform(size, dtype): """ Returns an array that has the same value everywhere. """ return np.ones(size, dtype=dtype)
[ "def", "uniform", "(", "size", ",", "dtype", ")", ":", "return", "np", ".", "ones", "(", "size", ",", "dtype", "=", "dtype", ")" ]
[ 143, 4 ]
[ 147, 41 ]
python
en
['en', 'error', 'th']
False
SortGenerator.swapped_pair
(size, dtype, swap_frac)
Returns an ordered array, but one that has ``swap_frac * size`` pairs swapped.
Returns an ordered array, but one that has ``swap_frac * size`` pairs swapped.
def swapped_pair(size, dtype, swap_frac): """ Returns an ordered array, but one that has ``swap_frac * size`` pairs swapped. """ a = np.arange(size, dtype=dtype) for _ in range(int(size * swap_frac)): x, y = np.random.randint(0, size, 2) a[x], a[y]...
[ "def", "swapped_pair", "(", "size", ",", "dtype", ",", "swap_frac", ")", ":", "a", "=", "np", ".", "arange", "(", "size", ",", "dtype", "=", "dtype", ")", "for", "_", "in", "range", "(", "int", "(", "size", "*", "swap_frac", ")", ")", ":", "x", ...
[ 151, 4 ]
[ 160, 16 ]
python
en
['en', 'error', 'th']
False
SortGenerator.sorted_block
(size, dtype, block_size)
Returns an array with blocks that are all sorted.
Returns an array with blocks that are all sorted.
def sorted_block(size, dtype, block_size): """ Returns an array with blocks that are all sorted. """ a = np.arange(size, dtype=dtype) b = [] if size < block_size: return a block_num = size // block_size for i in range(block_num): b....
[ "def", "sorted_block", "(", "size", ",", "dtype", ",", "block_size", ")", ":", "a", "=", "np", ".", "arange", "(", "size", ",", "dtype", "=", "dtype", ")", "b", "=", "[", "]", "if", "size", "<", "block_size", ":", "return", "a", "block_num", "=", ...
[ 164, 4 ]
[ 175, 26 ]
python
en
['en', 'error', 'th']
False
SortGenerator.random_unsorted_area
(cls, size, dtype, frac, area_size=None)
This type of array has random unsorted areas such that they compose the fraction ``frac`` of the original array.
This type of array has random unsorted areas such that they compose the fraction ``frac`` of the original array.
def random_unsorted_area(cls, size, dtype, frac, area_size=None): """ This type of array has random unsorted areas such that they compose the fraction ``frac`` of the original array. """ if area_size is None: area_size = cls.AREA_SIZE area_num = int(size * fr...
[ "def", "random_unsorted_area", "(", "cls", ",", "size", ",", "dtype", ",", "frac", ",", "area_size", "=", "None", ")", ":", "if", "area_size", "is", "None", ":", "area_size", "=", "cls", ".", "AREA_SIZE", "area_num", "=", "int", "(", "size", "*", "frac...
[ 179, 4 ]
[ 193, 16 ]
python
en
['en', 'error', 'th']
False
SortGenerator.random_bubble
(cls, size, dtype, bubble_num, bubble_size=None)
This type of array has ``bubble_num`` random unsorted areas.
This type of array has ``bubble_num`` random unsorted areas.
def random_bubble(cls, size, dtype, bubble_num, bubble_size=None): """ This type of array has ``bubble_num`` random unsorted areas. """ if bubble_size is None: bubble_size = cls.BUBBLE_SIZE frac = bubble_size * bubble_num / size return cls.random_unsorted_are...
[ "def", "random_bubble", "(", "cls", ",", "size", ",", "dtype", ",", "bubble_num", ",", "bubble_size", "=", "None", ")", ":", "if", "bubble_size", "is", "None", ":", "bubble_size", "=", "cls", ".", "BUBBLE_SIZE", "frac", "=", "bubble_size", "*", "bubble_num...
[ 197, 4 ]
[ 205, 71 ]
python
en
['en', 'error', 'th']
False
test_skip_on_fast_dev_run_tuner
(tmpdir, tuner_alg)
Test that tuner algorithms are skipped if fast dev run is enabled
Test that tuner algorithms are skipped if fast dev run is enabled
def test_skip_on_fast_dev_run_tuner(tmpdir, tuner_alg): """ Test that tuner algorithms are skipped if fast dev run is enabled """ model = BoringModel() model.lr = 0.1 # avoid no-lr-found exception trainer = Trainer( default_root_dir=tmpdir, max_epochs=2, auto_scale_batch_size=T...
[ "def", "test_skip_on_fast_dev_run_tuner", "(", "tmpdir", ",", "tuner_alg", ")", ":", "model", "=", "BoringModel", "(", ")", "model", ".", "lr", "=", "0.1", "# avoid no-lr-found exception", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "...
[ 14, 0 ]
[ 28, 27 ]
python
en
['en', 'en', 'en']
True
test_callbacks_and_logger_not_called_with_fastdevrun
(tmpdir, fast_dev_run)
Test that ModelCheckpoint, EarlyStopping and Logger are turned off with fast_dev_run
Test that ModelCheckpoint, EarlyStopping and Logger are turned off with fast_dev_run
def test_callbacks_and_logger_not_called_with_fastdevrun(tmpdir, fast_dev_run): """ Test that ModelCheckpoint, EarlyStopping and Logger are turned off with fast_dev_run """ class FastDevRunModel(BoringModel): def __init__(self): super().__init__() self.training_step_cal...
[ "def", "test_callbacks_and_logger_not_called_with_fastdevrun", "(", "tmpdir", ",", "fast_dev_run", ")", ":", "class", "FastDevRunModel", "(", "BoringModel", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self",...
[ 33, 0 ]
[ 127, 65 ]
python
en
['en', 'error', 'th']
False
get_root_logger
(log_file=None, log_level=logging.INFO)
Use `get_logger` method in mmcv to get the root logger. The logger will be initialized if it has not been initialized. By default a StreamHandler will be added. If `log_file` is specified, a FileHandler will also be added. The name of the root logger is the top-level package name, e.g., "mmpose". ...
Use `get_logger` method in mmcv to get the root logger.
def get_root_logger(log_file=None, log_level=logging.INFO): """Use `get_logger` method in mmcv to get the root logger. The logger will be initialized if it has not been initialized. By default a StreamHandler will be added. If `log_file` is specified, a FileHandler will also be added. The name of the r...
[ "def", "get_root_logger", "(", "log_file", "=", "None", ",", "log_level", "=", "logging", ".", "INFO", ")", ":", "return", "get_logger", "(", "__name__", ".", "split", "(", "'.'", ")", "[", "0", "]", ",", "log_file", ",", "log_level", ")" ]
[ 5, 0 ]
[ 23, 66 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.calibrate
(self, tun_cap=None)
Calibrate the lightning sensor - this takes up to half a second and is blocking. The value of tun_cap should be between 0 and 15, and is used to set the internal tuning capacitors (0-120pF in steps of 8pF)
Calibrate the lightning sensor - this takes up to half a second and is blocking.
def calibrate(self, tun_cap=None): """Calibrate the lightning sensor - this takes up to half a second and is blocking. The value of tun_cap should be between 0 and 15, and is used to set the internal tuning capacitors (0-120pF in steps of 8pF) """ time.sleep(0.08) ...
[ "def", "calibrate", "(", "self", ",", "tun_cap", "=", "None", ")", ":", "time", ".", "sleep", "(", "0.08", ")", "self", ".", "read_data", "(", ")", "if", "tun_cap", "is", "not", "None", ":", "if", "tun_cap", "<", "0x10", "and", "tun_cap", ">", "-",...
[ 12, 4 ]
[ 33, 25 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.reset
(self)
Reset all registers to their default power on values
Reset all registers to their default power on values
def reset(self): """Reset all registers to their default power on values """ self.set_byte(0x3C, 0x96)
[ "def", "reset", "(", "self", ")", ":", "self", ".", "set_byte", "(", "0x3C", ",", "0x96", ")" ]
[ 35, 4 ]
[ 38, 33 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_interrupt
(self)
Get the value of the interrupt register 0x01 - Too much noise 0x04 - Disturber 0x08 - Lightning
Get the value of the interrupt register
def get_interrupt(self): """Get the value of the interrupt register 0x01 - Too much noise 0x04 - Disturber 0x08 - Lightning """ self.read_data() return self.registers[0x03] & 0x0F
[ "def", "get_interrupt", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "return", "self", ".", "registers", "[", "0x03", "]", "&", "0x0F" ]
[ 40, 4 ]
[ 48, 42 ]
python
en
['en', 'da', 'en']
True
RPi_AS3935.get_distance
(self)
Get the estimated distance of the most recent lightning event
Get the estimated distance of the most recent lightning event
def get_distance(self): """Get the estimated distance of the most recent lightning event """ self.read_data() if self.registers[0x07] & 0x3F == 0x3F: return False else: return self.registers[0x07] & 0x3F
[ "def", "get_distance", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "if", "self", ".", "registers", "[", "0x07", "]", "&", "0x3F", "==", "0x3F", ":", "return", "False", "else", ":", "return", "self", ".", "registers", "[", "0x07", "]", ...
[ 50, 4 ]
[ 57, 46 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_energy
(self)
Get the calculated energy of the most recent lightning event
Get the calculated energy of the most recent lightning event
def get_energy(self): """Get the calculated energy of the most recent lightning event """ self.read_data() return ((self.registers[0x06] & 0x1F) << 16) | (self.registers[0x05] << 8) | self.registers[0x04]
[ "def", "get_energy", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "return", "(", "(", "self", ".", "registers", "[", "0x06", "]", "&", "0x1F", ")", "<<", "16", ")", "|", "(", "self", ".", "registers", "[", "0x05", "]", "<<", "8", ...
[ 59, 4 ]
[ 63, 105 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_noise_floor
(self)
Get the noise floor value. Actual voltage levels used in the sensor are located in Table 16 of the data sheet.
Get the noise floor value.
def get_noise_floor(self): """Get the noise floor value. Actual voltage levels used in the sensor are located in Table 16 of the data sheet. """ self.read_data() return (self.registers[0x01] & 0x70) >> 4
[ "def", "get_noise_floor", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "return", "(", "self", ".", "registers", "[", "0x01", "]", "&", "0x70", ")", ">>", "4" ]
[ 65, 4 ]
[ 72, 49 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_noise_floor
(self, noisefloor)
Set the noise floor value. Actual voltage levels used in the sensor are located in Table 16 of the data sheet.
Set the noise floor value.
def set_noise_floor(self, noisefloor): """Set the noise floor value. Actual voltage levels used in the sensor are located in Table 16 of the data sheet. """ self.read_data() noisefloor = (noisefloor & 0x07) << 4 write_data = (self.registers[0x01] & 0x8F) + noisef...
[ "def", "set_noise_floor", "(", "self", ",", "noisefloor", ")", ":", "self", ".", "read_data", "(", ")", "noisefloor", "=", "(", "noisefloor", "&", "0x07", ")", "<<", "4", "write_data", "=", "(", "self", ".", "registers", "[", "0x01", "]", "&", "0x8F", ...
[ 74, 4 ]
[ 83, 39 ]
python
en
['en', 'fr', 'en']
True
RPi_AS3935.lower_noise_floor
(self, min_noise=0)
Lower the noise floor by one step. min_noise is the minimum step that the noise_floor should be lowered to.
Lower the noise floor by one step.
def lower_noise_floor(self, min_noise=0): """Lower the noise floor by one step. min_noise is the minimum step that the noise_floor should be lowered to. """ floor = self.get_noise_floor() if floor > min_noise: floor = floor - 1 self.set_noise_floo...
[ "def", "lower_noise_floor", "(", "self", ",", "min_noise", "=", "0", ")", ":", "floor", "=", "self", ".", "get_noise_floor", "(", ")", "if", "floor", ">", "min_noise", ":", "floor", "=", "floor", "-", "1", "self", ".", "set_noise_floor", "(", "floor", ...
[ 85, 4 ]
[ 95, 20 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.raise_noise_floor
(self, max_noise=7)
Raise the noise floor by one step max_noise is the maximum step that the noise_floor should be raised to.
Raise the noise floor by one step
def raise_noise_floor(self, max_noise=7): """Raise the noise floor by one step max_noise is the maximum step that the noise_floor should be raised to. """ floor = self.get_noise_floor() if floor < max_noise: floor = floor + 1 self.set_noise_floor(...
[ "def", "raise_noise_floor", "(", "self", ",", "max_noise", "=", "7", ")", ":", "floor", "=", "self", ".", "get_noise_floor", "(", ")", "if", "floor", "<", "max_noise", ":", "floor", "=", "floor", "+", "1", "self", ".", "set_noise_floor", "(", "floor", ...
[ 97, 4 ]
[ 107, 20 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_min_strikes
(self)
Get the number of lightning detections required before an interrupt is raised.
Get the number of lightning detections required before an interrupt is raised.
def get_min_strikes(self): """Get the number of lightning detections required before an interrupt is raised. """ self.read_data() value = (self.registers[0x02] >> 4) & 0x03 if value == 0: return 1 elif value == 1: return 5 elif valu...
[ "def", "get_min_strikes", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "value", "=", "(", "self", ".", "registers", "[", "0x02", "]", ">>", "4", ")", "&", "0x03", "if", "value", "==", "0", ":", "return", "1", "elif", "value", "==", ...
[ 109, 4 ]
[ 122, 21 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_min_strikes
(self, minstrikes)
Set the number of lightning detections required before an interrupt is raised. Valid values are 1, 5, 9, and 16, any other raises an exception.
Set the number of lightning detections required before an interrupt is raised.
def set_min_strikes(self, minstrikes): """Set the number of lightning detections required before an interrupt is raised. Valid values are 1, 5, 9, and 16, any other raises an exception. """ if minstrikes == 1: minstrikes = 0 elif minstrikes == 5: ...
[ "def", "set_min_strikes", "(", "self", ",", "minstrikes", ")", ":", "if", "minstrikes", "==", "1", ":", "minstrikes", "=", "0", "elif", "minstrikes", "==", "5", ":", "minstrikes", "=", "1", "elif", "minstrikes", "==", "9", ":", "minstrikes", "=", "2", ...
[ 124, 4 ]
[ 144, 39 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_indoors
(self)
Determine whether or not the sensor is configured for indoor use or not. Returns True if configured to be indoors, otherwise False.
Determine whether or not the sensor is configured for indoor use or not.
def get_indoors(self): """Determine whether or not the sensor is configured for indoor use or not. Returns True if configured to be indoors, otherwise False. """ self.read_data() if self.registers[0x00] & 0x20 == 0x20: return True else: re...
[ "def", "get_indoors", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "if", "self", ".", "registers", "[", "0x00", "]", "&", "0x20", "==", "0x20", ":", "return", "True", "else", ":", "return", "False" ]
[ 146, 4 ]
[ 156, 24 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_indoors
(self, indoors)
Set whether or not the sensor should use an indoor configuration.
Set whether or not the sensor should use an indoor configuration.
def set_indoors(self, indoors): """Set whether or not the sensor should use an indoor configuration. """ self.read_data() if indoors: write_value = (self.registers[0x00] & 0xC1) | 0x24 else: write_value = (self.registers[0x00] & 0xC1) | 0x1C self.s...
[ "def", "set_indoors", "(", "self", ",", "indoors", ")", ":", "self", ".", "read_data", "(", ")", "if", "indoors", ":", "write_value", "=", "(", "self", ".", "registers", "[", "0x00", "]", "&", "0xC1", ")", "|", "0x24", "else", ":", "write_value", "="...
[ 158, 4 ]
[ 166, 40 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_mask_disturber
(self, mask_dist)
Set whether or not disturbers should be masked (no interrupts for what the sensor determines are man-made events)
Set whether or not disturbers should be masked (no interrupts for what the sensor determines are man-made events)
def set_mask_disturber(self, mask_dist): """Set whether or not disturbers should be masked (no interrupts for what the sensor determines are man-made events) """ self.read_data() if mask_dist: write_value = self.registers[0x03] | 0x20 else: write_v...
[ "def", "set_mask_disturber", "(", "self", ",", "mask_dist", ")", ":", "self", ".", "read_data", "(", ")", "if", "mask_dist", ":", "write_value", "=", "self", ".", "registers", "[", "0x03", "]", "|", "0x20", "else", ":", "write_value", "=", "self", ".", ...
[ 168, 4 ]
[ 177, 40 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_mask_disturber
(self)
Get whether or not disturbers are masked or not. Returns True if interrupts are masked, false otherwise
Get whether or not disturbers are masked or not.
def get_mask_disturber(self): """Get whether or not disturbers are masked or not. Returns True if interrupts are masked, false otherwise """ self.read_data() if self.registers[0x03] & 0x20 == 0x20: return True else: return False
[ "def", "get_mask_disturber", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "if", "self", ".", "registers", "[", "0x03", "]", "&", "0x20", "==", "0x20", ":", "return", "True", "else", ":", "return", "False" ]
[ 179, 4 ]
[ 188, 24 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_disp_lco
(self, display_lco)
Have the internal LC oscillator signal displayed on the interrupt pin for measurement. Passing display_lco=True enables the output, False disables it.
Have the internal LC oscillator signal displayed on the interrupt pin for measurement.
def set_disp_lco(self, display_lco): """Have the internal LC oscillator signal displayed on the interrupt pin for measurement. Passing display_lco=True enables the output, False disables it. """ self.read_data() if display_lco: self.set_byte(0x08, (self.regis...
[ "def", "set_disp_lco", "(", "self", ",", "display_lco", ")", ":", "self", ".", "read_data", "(", ")", "if", "display_lco", ":", "self", ".", "set_byte", "(", "0x08", ",", "(", "self", ".", "registers", "[", "0x08", "]", "|", "0x80", ")", ")", "else",...
[ 190, 4 ]
[ 201, 25 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.get_disp_lco
(self)
Determine whether or not the internal LC oscillator is displayed on the interrupt pin. Returns True if the LC oscillator is being displayed on the interrupt pin, False otherwise
Determine whether or not the internal LC oscillator is displayed on the interrupt pin.
def get_disp_lco(self): """Determine whether or not the internal LC oscillator is displayed on the interrupt pin. Returns True if the LC oscillator is being displayed on the interrupt pin, False otherwise """ self.read_data() if self.registers[0x08] & 0x80 == 0x8...
[ "def", "get_disp_lco", "(", "self", ")", ":", "self", ".", "read_data", "(", ")", "if", "self", ".", "registers", "[", "0x08", "]", "&", "0x80", "==", "0x80", ":", "return", "True", "else", ":", "return", "False" ]
[ 203, 4 ]
[ 214, 24 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.set_byte
(self, register, value)
Write a byte to a particular address on the sensor. This method should rarely be used directly.
Write a byte to a particular address on the sensor.
def set_byte(self, register, value): """Write a byte to a particular address on the sensor. This method should rarely be used directly. """ self.i2cbus.write_byte_data(self.address, register, value)
[ "def", "set_byte", "(", "self", ",", "register", ",", "value", ")", ":", "self", ".", "i2cbus", ".", "write_byte_data", "(", "self", ".", "address", ",", "register", ",", "value", ")" ]
[ 216, 4 ]
[ 221, 66 ]
python
en
['en', 'en', 'en']
True
RPi_AS3935.read_data
(self)
Read a block of data from the sensor and store it. This doesn't read exact registers because the library used by smbus doesn't support repeated I2C starts (required to read registers directly on the sensor) This method should rarely be called directly.
Read a block of data from the sensor and store it.
def read_data(self): """ Read a block of data from the sensor and store it. This doesn't read exact registers because the library used by smbus doesn't support repeated I2C starts (required to read registers directly on the sensor) This method should rarely be called di...
[ "def", "read_data", "(", "self", ")", ":", "self", ".", "registers", "=", "self", ".", "i2cbus", ".", "read_i2c_block_data", "(", "self", ".", "address", ",", "0x00", ")" ]
[ 223, 4 ]
[ 233, 76 ]
python
en
['en', 'error', 'th']
False
build_project
(args)
Build a dev version of the project. Returns ------- site_dir site-packages directory where it was installed
Build a dev version of the project.
def build_project(args): """ Build a dev version of the project. Returns ------- site_dir site-packages directory where it was installed """ import distutils.sysconfig root_ok = [os.path.exists(os.path.join(ROOT_DIR, fn)) for fn in PROJECT_ROOT_FILES] if no...
[ "def", "build_project", "(", "args", ")", ":", "import", "distutils", ".", "sysconfig", "root_ok", "=", "[", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "ROOT_DIR", ",", "fn", ")", ")", "for", "fn", "in", "PROJECT_ROOT...
[ 308, 0 ]
[ 425, 36 ]
python
en
['en', 'error', 'th']
False
train_model
(model, dataset, cfg, distributed=False, validate=False, timestamp=None, meta=None)
Train model entry function. Args: model (nn.Module): The model to be trained. dataset (Dataset): Train dataset. cfg (dict): The config dict for training. distributed (bool): Whether to use distributed training. Default: False. validate (bool): Whether to do evalu...
Train model entry function.
def train_model(model, dataset, cfg, distributed=False, validate=False, timestamp=None, meta=None): """Train model entry function. Args: model (nn.Module): The model to be trained. dataset (Dataset):...
[ "def", "train_model", "(", "model", ",", "dataset", ",", "cfg", ",", "distributed", "=", "False", ",", "validate", "=", "False", ",", "timestamp", "=", "None", ",", "meta", "=", "None", ")", ":", "logger", "=", "get_root_logger", "(", "cfg", ".", "log_...
[ 11, 0 ]
[ 149, 60 ]
python
en
['en', 'en', 'en']
True
UseDatabase.__init__
(self, config: dict)
Add the database configuration parameters to the object. This class expects a single dictionary argument which needs to assign the appropriate values to (at least) the following keys: host - the IP address of the host running MySQL/MariaDB. user - the MySQL/MariaDB username to ...
Add the database configuration parameters to the object.
def __init__(self, config: dict): """Add the database configuration parameters to the object. This class expects a single dictionary argument which needs to assign the appropriate values to (at least) the following keys: host - the IP address of the host running MySQL/MariaDB. ...
[ "def", "__init__", "(", "self", ",", "config", ":", "dict", ")", ":", "self", ".", "configuration", "=", "config" ]
[ 48, 4 ]
[ 61, 35 ]
python
en
['en', 'en', 'en']
True
UseDatabase.__enter__
(self)
Connect to database and create a DB cursor. Return the database cursor to the context manager. Raise ConnnectionError if the database can't be found. Raise CredentialsError if the wrong username/password used.
Connect to database and create a DB cursor.
def __enter__(self) -> 'cursor': """Connect to database and create a DB cursor. Return the database cursor to the context manager. Raise ConnnectionError if the database can't be found. Raise CredentialsError if the wrong username/password used. """ try: self...
[ "def", "__enter__", "(", "self", ")", "->", "'cursor'", ":", "try", ":", "self", ".", "conn", "=", "mysql", ".", "connector", ".", "connect", "(", "*", "*", "self", ".", "configuration", ")", "self", ".", "cursor", "=", "self", ".", "conn", ".", "c...
[ 63, 4 ]
[ 77, 48 ]
python
en
['en', 'en', 'en']
True
UseDatabase.__exit__
(self, exc_type, exc_value, exc_traceback)
Destroy the cursor as well as the connection (after committing). Raise ProgrammingError as an SQLError, and re-raise anything else.
Destroy the cursor as well as the connection (after committing).
def __exit__(self, exc_type, exc_value, exc_traceback): """Destroy the cursor as well as the connection (after committing). Raise ProgrammingError as an SQLError, and re-raise anything else. """ self.conn.commit() self.cursor.close() self.conn.close() if exc_type...
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "exc_traceback", ")", ":", "self", ".", "conn", ".", "commit", "(", ")", "self", ".", "cursor", ".", "close", "(", ")", "self", ".", "conn", ".", "close", "(", ")", "if", "exc_...
[ 79, 4 ]
[ 90, 37 ]
python
en
['en', 'en', 'en']
True
slow
(t)
Label a test as 'slow'. The exact definition of a slow test is obviously both subjective and hardware-dependent, but in general any individual test that requires more than a second or two should be labeled as slow (the whole suite consists of thousands of tests, so even a second is significant). ...
Label a test as 'slow'.
def slow(t): """ Label a test as 'slow'. The exact definition of a slow test is obviously both subjective and hardware-dependent, but in general any individual test that requires more than a second or two should be labeled as slow (the whole suite consists of thousands of tests, so even a secon...
[ "def", "slow", "(", "t", ")", ":", "t", ".", "slow", "=", "True", "return", "t" ]
[ 30, 0 ]
[ 63, 12 ]
python
en
['en', 'error', 'th']
False
setastest
(tf=True)
Signals to nose that this function is or is not a test. Parameters ---------- tf : bool If True, specifies that the decorated callable is a test. If False, specifies that the decorated callable is not a test. Default is True. Notes ----- This decorator can't use th...
Signals to nose that this function is or is not a test.
def setastest(tf=True): """ Signals to nose that this function is or is not a test. Parameters ---------- tf : bool If True, specifies that the decorated callable is a test. If False, specifies that the decorated callable is not a test. Default is True. Notes ----- ...
[ "def", "setastest", "(", "tf", "=", "True", ")", ":", "def", "set_test", "(", "t", ")", ":", "t", ".", "__test__", "=", "tf", "return", "t", "return", "set_test" ]
[ 65, 0 ]
[ 96, 19 ]
python
en
['en', 'error', 'th']
False
skipif
(skip_condition, msg=None)
Make function raise SkipTest exception if a given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is actually executed. Parameters ------...
Make function raise SkipTest exception if a given condition is true.
def skipif(skip_condition, msg=None): """ Make function raise SkipTest exception if a given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is ...
[ "def", "skipif", "(", "skip_condition", ",", "msg", "=", "None", ")", ":", "def", "skip_decorator", "(", "f", ")", ":", "# Local import to avoid a hard nose dependency and only incur the", "# import time overhead at actual test-time.", "import", "nose", "# Allow for both bool...
[ 98, 0 ]
[ 172, 25 ]
python
en
['en', 'error', 'th']
False
knownfailureif
(fail_condition, msg=None)
Make function raise KnownFailureException exception if given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is actually executed. Parameters...
Make function raise KnownFailureException exception if given condition is true.
def knownfailureif(fail_condition, msg=None): """ Make function raise KnownFailureException exception if given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until...
[ "def", "knownfailureif", "(", "fail_condition", ",", "msg", "=", "None", ")", ":", "if", "msg", "is", "None", ":", "msg", "=", "'Test skipped due to known failure'", "# Allow for both boolean or callable known failure conditions.", "if", "isinstance", "(", "fail_condition...
[ 175, 0 ]
[ 227, 30 ]
python
en
['en', 'error', 'th']
False
deprecated
(conditional=True)
Filter deprecation warnings while running the test suite. This decorator can be used to filter DeprecationWarning's, to avoid printing them during the test suite run, while checking that the test actually raises a DeprecationWarning. Parameters ---------- conditional : bool or callable, o...
Filter deprecation warnings while running the test suite.
def deprecated(conditional=True): """ Filter deprecation warnings while running the test suite. This decorator can be used to filter DeprecationWarning's, to avoid printing them during the test suite run, while checking that the test actually raises a DeprecationWarning. Parameters -------...
[ "def", "deprecated", "(", "conditional", "=", "True", ")", ":", "def", "deprecate_decorator", "(", "f", ")", ":", "# Local import to avoid a hard nose dependency and only incur the", "# import time overhead at actual test-time.", "import", "nose", "def", "_deprecated_imp", "(...
[ 229, 0 ]
[ 272, 30 ]
python
en
['en', 'error', 'th']
False
parametrize
(vars, input)
Pytest compatibility class. This implements the simplest level of pytest.mark.parametrize for use in nose as an aid in making the transition to pytest. It achieves that by adding a dummy var parameter and ignoring the doc_func parameter of the base class. It does not support variable substitution b...
Pytest compatibility class. This implements the simplest level of pytest.mark.parametrize for use in nose as an aid in making the transition to pytest. It achieves that by adding a dummy var parameter and ignoring the doc_func parameter of the base class. It does not support variable substitution b...
def parametrize(vars, input): """ Pytest compatibility class. This implements the simplest level of pytest.mark.parametrize for use in nose as an aid in making the transition to pytest. It achieves that by adding a dummy var parameter and ignoring the doc_func parameter of the base class. It does no...
[ "def", "parametrize", "(", "vars", ",", "input", ")", ":", "from", ".", "parameterized", "import", "parameterized", "return", "parameterized", "(", "input", ")" ]
[ 275, 0 ]
[ 289, 31 ]
python
en
['en', 'error', 'th']
False
Loadable.dump
(self, fname: str, thin: bool = False, use_pickle: bool = True)
Dumps the object into a JSON/pickle file.
Dumps the object into a JSON/pickle file.
def dump(self, fname: str, thin: bool = False, use_pickle: bool = True) -> None: """Dumps the object into a JSON/pickle file.""" with Path(fname).open("wb") as pfile: pfile.write(self.dumps(thin, use_pickle))
[ "def", "dump", "(", "self", ",", "fname", ":", "str", ",", "thin", ":", "bool", "=", "False", ",", "use_pickle", ":", "bool", "=", "True", ")", "->", "None", ":", "with", "Path", "(", "fname", ")", ".", "open", "(", "\"wb\"", ")", "as", "pfile", ...
[ 35, 4 ]
[ 38, 53 ]
python
en
['en', 'en', 'en']
True
Loadable.dumps
(self, _thin: bool = False, use_pickle: bool = True)
Dumps the object with pickle and returns it as a bytestring
Dumps the object with pickle and returns it as a bytestring
def dumps(self, _thin: bool = False, use_pickle: bool = True) -> None: """Dumps the object with pickle and returns it as a bytestring""" # if thin: # obj = ThinObject(self) # else: # obj = self # try: if use_pickle: try: return ...
[ "def", "dumps", "(", "self", ",", "_thin", ":", "bool", "=", "False", ",", "use_pickle", ":", "bool", "=", "True", ")", "->", "None", ":", "# if thin:", "# obj = ThinObject(self)", "# else:", "# obj = self", "# try:", "if", "use_pickle", ":", "try", ...
[ 40, 4 ]
[ 54, 74 ]
python
en
['en', 'en', 'en']
True
Loadable.save
(self, fname: str)
Save the DataObject to a file depending on the filename extension.
Save the DataObject to a file depending on the filename extension.
def save(self, fname: str) -> None: """Save the DataObject to a file depending on the filename extension.""" _fname = fname compress = thin = pickl = False if fname.endswith(self._pickle_extension + ".bz2"): compress = True pickl = True elif fname.endswit...
[ "def", "save", "(", "self", ",", "fname", ":", "str", ")", "->", "None", ":", "_fname", "=", "fname", "compress", "=", "thin", "=", "pickl", "=", "False", "if", "fname", ".", "endswith", "(", "self", ".", "_pickle_extension", "+", "\".bz2\"", ")", ":...
[ 56, 4 ]
[ 91, 63 ]
python
en
['en', 'en', 'en']
True
Loadable.load
(cls, fname: str)
Returns an object retrieved from a JSON/pickle file.
Returns an object retrieved from a JSON/pickle file.
def load(cls, fname: str) -> Loadable: """Returns an object retrieved from a JSON/pickle file.""" if fname.endswith(cls._pickle_extension + ".bz2"): print("Uncompressing data...") file = bz2.BZ2File(fname, "rb") obj = pickle.load(file) print("Done.") ...
[ "def", "load", "(", "cls", ",", "fname", ":", "str", ")", "->", "Loadable", ":", "if", "fname", ".", "endswith", "(", "cls", ".", "_pickle_extension", "+", "\".bz2\"", ")", ":", "print", "(", "\"Uncompressing data...\"", ")", "file", "=", "bz2", ".", "...
[ 101, 4 ]
[ 117, 18 ]
python
en
['en', 'en', 'en']
True
DataObject.__init__
(self, source: Any)
__init__(self, source: Any)
__init__(self, source: Any)
def __init__(self, source: Any) -> None: """__init__(self, source: Any)""" parsed = self.parse(source) for k in self._data_keys: if k not in parsed: raise ValueError(f"Parse function did not give '{k}' data.") for k, value in parsed.items(): if k.s...
[ "def", "__init__", "(", "self", ",", "source", ":", "Any", ")", "->", "None", ":", "parsed", "=", "self", ".", "parse", "(", "source", ")", "for", "k", "in", "self", ".", "_data_keys", ":", "if", "k", "not", "in", "parsed", ":", "raise", "ValueErro...
[ 180, 4 ]
[ 197, 43 ]
python
en
['fr', 'en', 'en']
True
DataObject.parse
(self, source: str)
Read in data. Should set the _source attribute.
Read in data. Should set the _source attribute.
def parse(self, source: str) -> dict[str, Any]: """Read in data. Should set the _source attribute.""" raise NotImplementedError
[ "def", "parse", "(", "self", ",", "source", ":", "str", ")", "->", "dict", "[", "str", ",", "Any", "]", ":", "raise", "NotImplementedError" ]
[ 199, 4 ]
[ 201, 33 ]
python
en
['en', 'en', 'en']
True
DataObject.copy
(self)
Return a deep copy.
Return a deep copy.
def copy(self) -> DataObject: """Return a deep copy.""" return copy.deepcopy(self)
[ "def", "copy", "(", "self", ")", "->", "DataObject", ":", "return", "copy", ".", "deepcopy", "(", "self", ")" ]
[ 203, 4 ]
[ 205, 34 ]
python
ca
['es', 'ca', 'en']
False
DataObject.source
(self)
The original object from which this instance was created (e.g., filename).
The original object from which this instance was created (e.g., filename).
def source(self) -> Optional[Any]: """The original object from which this instance was created (e.g., filename).""" return self._source
[ "def", "source", "(", "self", ")", "->", "Optional", "[", "Any", "]", ":", "return", "self", ".", "_source" ]
[ 208, 4 ]
[ 210, 27 ]
python
en
['en', 'en', 'en']
True
DataObject.data
(self)
Mutable data container dictionary.
Mutable data container dictionary.
def data(self) -> dict[str, Any]: """Mutable data container dictionary.""" return self._data
[ "def", "data", "(", "self", ")", "->", "dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_data" ]
[ 213, 4 ]
[ 215, 25 ]
python
it
['it', 'en', 'it']
True
DataObject.meta
(self)
Mutable metadata dictionary.
Mutable metadata dictionary.
def meta(self) -> dict[str, Any]: """Mutable metadata dictionary.""" return self._meta
[ "def", "meta", "(", "self", ")", "->", "dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_meta" ]
[ 218, 4 ]
[ 220, 25 ]
python
it
['it', 'ky', 'it']
True
DataObject.unit
(self)
Dictionary with unit strings for meta values.
Dictionary with unit strings for meta values.
def unit(self) -> dict[str, str]: """Dictionary with unit strings for meta values.""" return self._units
[ "def", "unit", "(", "self", ")", "->", "dict", "[", "str", ",", "str", "]", ":", "return", "self", ".", "_units" ]
[ 223, 4 ]
[ 225, 26 ]
python
en
['en', 'en', 'en']
True
DataObject.get_field_string
(self, field: str, fmt: Optional[str] = None)
Get a string that contains the value and its unit.
Get a string that contains the value and its unit.
def get_field_string(self, field: str, fmt: Optional[str] = None) -> str: """Get a string that contains the value and its unit.""" if fmt is None: fmt = ".5g" value = getattr(self, field) if value == np.nan: return "NaN" if isinstance(value, Number): ...
[ "def", "get_field_string", "(", "self", ",", "field", ":", "str", ",", "fmt", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "if", "fmt", "is", "None", ":", "fmt", "=", "\".5g\"", "value", "=", "getattr", "(", "self", ",", ...
[ 227, 4 ]
[ 237, 40 ]
python
en
['en', 'en', 'en']
True
DataObject.is_compatible
(self, other: DataObject)
[summary] Parameters ---------- other : DataObject [description] Returns ------- bool [description]
[summary]
def is_compatible(self, other: DataObject) -> bool: """[summary] Parameters ---------- other : DataObject [description] Returns ------- bool [description] """ # """Check if another DataObject has data of the same dimension...
[ "def", "is_compatible", "(", "self", ",", "other", ":", "DataObject", ")", "->", "bool", ":", "# \"\"\"Check if another DataObject has data of the same dimensions.\"\"\"", "return", "isinstance", "(", "other", ",", "type", "(", "self", ")", ")" ]
[ 280, 4 ]
[ 294, 44 ]
python
en
['en', 'ky', 'en']
False
DataObject.__json_encode__
(self)
Returns dict with all information to reconstruct object from a .json file
Returns dict with all information to reconstruct object from a .json file
def __json_encode__(self) -> dict: """Returns dict with all information to reconstruct object from a .json file""" return {"source": self._source}
[ "def", "__json_encode__", "(", "self", ")", "->", "dict", ":", "return", "{", "\"source\"", ":", "self", ".", "_source", "}" ]
[ 303, 4 ]
[ 305, 39 ]
python
en
['en', 'en', 'en']
True
DataObject.__json_decode__
(self, **attrs)
Accepts attributes from .json file and initilizes new object.
Accepts attributes from .json file and initilizes new object.
def __json_decode__(self, **attrs) -> None: """Accepts attributes from .json file and initilizes new object.""" self.__init__(**attrs)
[ "def", "__json_decode__", "(", "self", ",", "*", "*", "attrs", ")", "->", "None", ":", "self", ".", "__init__", "(", "*", "*", "attrs", ")" ]
[ 307, 4 ]
[ 309, 30 ]
python
en
['en', 'en', 'en']
True
DataObjectStack._split_source
(self, source: Union[str, Iterable])
Split the source parameter of the constructor into source arguments that can be passed to single DataObjects.
Split the source parameter of the constructor into source arguments that can be passed to single DataObjects.
def _split_source(self, source: Union[str, Iterable]) -> list: """Split the source parameter of the constructor into source arguments that can be passed to single DataObjects.""" return_val = source if not isinstance(return_val, list): raise ValueError(f"Cannot create Objects...
[ "def", "_split_source", "(", "self", ",", "source", ":", "Union", "[", "str", ",", "Iterable", "]", ")", "->", "list", ":", "return_val", "=", "source", "if", "not", "isinstance", "(", "return_val", ",", "list", ")", ":", "raise", "ValueError", "(", "f...
[ 353, 4 ]
[ 359, 21 ]
python
en
['en', 'en', 'en']
True
DataObjectStack._construct
(self)
Build the stack from a list of sources.
Build the stack from a list of sources.
def _construct(self) -> None: """Build the stack from a list of sources.""" self._virtual = False sources = self._elements if not sources: raise ValueError("Empty source for DataObjectStack (wrong file path?)") self._elements = [self._single_construct(sources[0])] ...
[ "def", "_construct", "(", "self", ")", "->", "None", ":", "self", ".", "_virtual", "=", "False", "sources", "=", "self", ".", "_elements", "if", "not", "sources", ":", "raise", "ValueError", "(", "\"Empty source for DataObjectStack (wrong file path?)\"", ")", "s...
[ 361, 4 ]
[ 371, 42 ]
python
en
['en', 'en', 'en']
True