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
ABCPolyBase.roots
(self)
Return the roots of the series polynomial. Compute the roots for the series. Note that the accuracy of the roots decrease the further outside the domain they lie. Returns ------- roots : ndarray Array containing the roots of the series.
Return the roots of the series polynomial.
def roots(self): """Return the roots of the series polynomial. Compute the roots for the series. Note that the accuracy of the roots decrease the further outside the domain they lie. Returns ------- roots : ndarray Array containing the roots of the series. ...
[ "def", "roots", "(", "self", ")", ":", "roots", "=", "self", ".", "_roots", "(", "self", ".", "coef", ")", "return", "pu", ".", "mapdomain", "(", "roots", ",", "self", ".", "window", ",", "self", ".", "domain", ")" ]
[ 762, 4 ]
[ 775, 60 ]
python
en
['en', 'en', 'en']
True
ABCPolyBase.linspace
(self, n=100, domain=None)
Return x, y values at equally spaced points in domain. Returns the x, y values at `n` linearly spaced points across the domain. Here y is the value of the polynomial at the points x. By default the domain is the same as that of the series instance. This method is intended mostly as a p...
Return x, y values at equally spaced points in domain.
def linspace(self, n=100, domain=None): """Return x, y values at equally spaced points in domain. Returns the x, y values at `n` linearly spaced points across the domain. Here y is the value of the polynomial at the points x. By default the domain is the same as that of the series inst...
[ "def", "linspace", "(", "self", ",", "n", "=", "100", ",", "domain", "=", "None", ")", ":", "if", "domain", "is", "None", ":", "domain", "=", "self", ".", "domain", "x", "=", "np", ".", "linspace", "(", "domain", "[", "0", "]", ",", "domain", "...
[ 777, 4 ]
[ 807, 19 ]
python
en
['en', 'en', 'en']
True
ABCPolyBase.fit
(cls, x, y, deg, domain=None, rcond=None, full=False, w=None, window=None)
Least squares fit to data. Return a series instance that is the least squares fit to the data `y` sampled at `x`. The domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning. Parameters ---------...
Least squares fit to data.
def fit(cls, x, y, deg, domain=None, rcond=None, full=False, w=None, window=None): """Least squares fit to data. Return a series instance that is the least squares fit to the data `y` sampled at `x`. The domain of the returned instance can be specified and this will often result...
[ "def", "fit", "(", "cls", ",", "x", ",", "y", ",", "deg", ",", "domain", "=", "None", ",", "rcond", "=", "None", ",", "full", "=", "False", ",", "w", "=", "None", ",", "window", "=", "None", ")", ":", "if", "domain", "is", "None", ":", "domai...
[ 810, 4 ]
[ 897, 58 ]
python
en
['en', 'en', 'en']
True
ABCPolyBase.fromroots
(cls, roots, domain=[], window=None)
Return series instance that has the specified roots. Returns a series representing the product ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a list of roots. Parameters ---------- roots : array_like List of roots. domain : {[], None, arr...
Return series instance that has the specified roots.
def fromroots(cls, roots, domain=[], window=None): """Return series instance that has the specified roots. Returns a series representing the product ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a list of roots. Parameters ---------- roots : array_l...
[ "def", "fromroots", "(", "cls", ",", "roots", ",", "domain", "=", "[", "]", ",", "window", "=", "None", ")", ":", "[", "roots", "]", "=", "pu", ".", "as_series", "(", "[", "roots", "]", ",", "trim", "=", "False", ")", "if", "domain", "is", "Non...
[ 900, 4 ]
[ 938, 54 ]
python
en
['en', 'en', 'en']
True
ABCPolyBase.identity
(cls, domain=None, window=None)
Identity function. If ``p`` is the returned series, then ``p(x) == x`` for all values of x. Parameters ---------- domain : {None, array_like}, optional If given, the array must be of the form ``[beg, end]``, where ``beg`` and ``end`` are the endpoints of...
Identity function.
def identity(cls, domain=None, window=None): """Identity function. If ``p`` is the returned series, then ``p(x) == x`` for all values of x. Parameters ---------- domain : {None, array_like}, optional If given, the array must be of the form ``[beg, end]``, wh...
[ "def", "identity", "(", "cls", ",", "domain", "=", "None", ",", "window", "=", "None", ")", ":", "if", "domain", "is", "None", ":", "domain", "=", "cls", ".", "domain", "if", "window", "is", "None", ":", "window", "=", "cls", ".", "window", "off", ...
[ 941, 4 ]
[ 971, 40 ]
python
en
['en', 'ja', 'en']
False
ABCPolyBase.basis
(cls, deg, domain=None, window=None)
Series basis polynomial of degree `deg`. Returns the series representing the basis polynomial of degree `deg`. .. versionadded:: 1.7.0 Parameters ---------- deg : int Degree of the basis polynomial for the series. Must be >= 0. domain : {None, array_like}, ...
Series basis polynomial of degree `deg`.
def basis(cls, deg, domain=None, window=None): """Series basis polynomial of degree `deg`. Returns the series representing the basis polynomial of degree `deg`. .. versionadded:: 1.7.0 Parameters ---------- deg : int Degree of the basis polynomial for the s...
[ "def", "basis", "(", "cls", ",", "deg", ",", "domain", "=", "None", ",", "window", "=", "None", ")", ":", "if", "domain", "is", "None", ":", "domain", "=", "cls", ".", "domain", "if", "window", "is", "None", ":", "window", "=", "cls", ".", "windo...
[ 974, 4 ]
[ 1010, 50 ]
python
en
['en', 'el-Latn', 'en']
True
ABCPolyBase.cast
(cls, series, domain=None, window=None)
Convert series to series of this class. The `series` is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert method. .. versionadded:: 1.7.0 Paramet...
Convert series to series of this class.
def cast(cls, series, domain=None, window=None): """Convert series to series of this class. The `series` is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert ...
[ "def", "cast", "(", "cls", ",", "series", ",", "domain", "=", "None", ",", "window", "=", "None", ")", ":", "if", "domain", "is", "None", ":", "domain", "=", "cls", ".", "domain", "if", "window", "is", "None", ":", "window", "=", "cls", ".", "win...
[ 1013, 4 ]
[ 1052, 50 ]
python
en
['en', 'en', 'en']
True
parse_flags
(line)
Parse a line from a config file containing compile flags. Parameters ---------- line : str A single line containing one or more compile flags. Returns ------- d : dict Dictionary of parsed flags, split into relevant categories. These categories are the keys of `d`:...
Parse a line from a config file containing compile flags.
def parse_flags(line): """ Parse a line from a config file containing compile flags. Parameters ---------- line : str A single line containing one or more compile flags. Returns ------- d : dict Dictionary of parsed flags, split into relevant categories. These c...
[ "def", "parse_flags", "(", "line", ")", ":", "d", "=", "{", "'include_dirs'", ":", "[", "]", ",", "'library_dirs'", ":", "[", "]", ",", "'libraries'", ":", "[", "]", ",", "'macros'", ":", "[", "]", ",", "'ignored'", ":", "[", "]", "}", "flags", "...
[ 35, 0 ]
[ 75, 12 ]
python
en
['en', 'error', 'th']
False
read_config
(pkgname, dirs=None)
Return library info for a package from its configuration file. Parameters ---------- pkgname : str Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini). dirs : sequence, optional If given, should be a sequence of...
Return library info for a package from its configuration file.
def read_config(pkgname, dirs=None): """ Return library info for a package from its configuration file. Parameters ---------- pkgname : str Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini). dirs : sequence, option...
[ "def", "read_config", "(", "pkgname", ",", "dirs", "=", "None", ")", ":", "try", ":", "return", "_CACHE", "[", "pkgname", "]", "except", "KeyError", ":", "v", "=", "_read_config_imp", "(", "pkg_to_filename", "(", "pkgname", ")", ",", "dirs", ")", "_CACHE...
[ 330, 0 ]
[ 374, 16 ]
python
en
['en', 'error', 'th']
False
LibraryInfo.sections
(self)
Return the section headers of the config file. Parameters ---------- None Returns ------- keys : list of str The list of section headers.
Return the section headers of the config file.
def sections(self): """ Return the section headers of the config file. Parameters ---------- None Returns ------- keys : list of str The list of section headers. """ return list(self._sections.keys())
[ "def", "sections", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_sections", ".", "keys", "(", ")", ")" ]
[ 118, 4 ]
[ 132, 42 ]
python
en
['en', 'error', 'th']
False
VariableSet.variables
(self)
Return the list of variable names. Parameters ---------- None Returns ------- names : list of str The names of all variables in the `VariableSet` instance.
Return the list of variable names.
def variables(self): """ Return the list of variable names. Parameters ---------- None Returns ------- names : list of str The names of all variables in the `VariableSet` instance. """ return list(self._raw_data.keys())
[ "def", "variables", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_raw_data", ".", "keys", "(", ")", ")" ]
[ 196, 4 ]
[ 210, 42 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.get_deprecated_arg_names
(cls)
Returns a list with deprecated Trainer arguments.
Returns a list with deprecated Trainer arguments.
def get_deprecated_arg_names(cls) -> List: """Returns a list with deprecated Trainer arguments.""" depr_arg_names = [] for name, val in cls.__dict__.items(): if name.startswith('DEPRECATED') and isinstance(val, (tuple, list)): depr_arg_names.extend(val) return...
[ "def", "get_deprecated_arg_names", "(", "cls", ")", "->", "List", ":", "depr_arg_names", "=", "[", "]", "for", "name", ",", "val", "in", "cls", ".", "__dict__", ".", "items", "(", ")", ":", "if", "name", ".", "startswith", "(", "'DEPRECATED'", ")", "an...
[ 201, 4 ]
[ 207, 29 ]
python
en
['en', 'en', 'en']
True
TrainerProperties.progress_bar_dict
(self)
Read-only for progress bar metrics.
Read-only for progress bar metrics.
def progress_bar_dict(self) -> dict: """ Read-only for progress bar metrics. """ ref_model = self.lightning_module ref_model = cast(LightningModule, ref_model) standard_metrics = ref_model.get_progress_bar_dict() logged_metrics = self.progress_bar_metrics duplicates = li...
[ "def", "progress_bar_dict", "(", "self", ")", "->", "dict", ":", "ref_model", "=", "self", ".", "lightning_module", "ref_model", "=", "cast", "(", "LightningModule", ",", "ref_model", ")", "standard_metrics", "=", "ref_model", ".", "get_progress_bar_dict", "(", ...
[ 240, 4 ]
[ 257, 26 ]
python
en
['en', 'no', 'en']
True
TrainerProperties.disable_validation
(self)
Check if validation is disabled during training.
Check if validation is disabled during training.
def disable_validation(self) -> bool: """ Check if validation is disabled during training. """ return not self.enable_validation
[ "def", "disable_validation", "(", "self", ")", "->", "bool", ":", "return", "not", "self", ".", "enable_validation" ]
[ 260, 4 ]
[ 262, 41 ]
python
en
['en', 'en', 'en']
True
TrainerProperties.enable_validation
(self)
Check if we should run validation during training.
Check if we should run validation during training.
def enable_validation(self) -> bool: """ Check if we should run validation during training. """ model_ref = self.lightning_module val_loop_enabled = is_overridden('validation_step', model_ref) and self.limit_val_batches > 0 return val_loop_enabled
[ "def", "enable_validation", "(", "self", ")", "->", "bool", ":", "model_ref", "=", "self", ".", "lightning_module", "val_loop_enabled", "=", "is_overridden", "(", "'validation_step'", ",", "model_ref", ")", "and", "self", ".", "limit_val_batches", ">", "0", "ret...
[ 265, 4 ]
[ 269, 31 ]
python
en
['en', 'en', 'en']
True
TrainerProperties.default_root_dir
(self)
The default location to save artifacts of loggers, checkpoints etc. It is used as a fallback if logger or checkpoint callback do not define specific save paths.
The default location to save artifacts of loggers, checkpoints etc. It is used as a fallback if logger or checkpoint callback do not define specific save paths.
def default_root_dir(self) -> str: """ The default location to save artifacts of loggers, checkpoints etc. It is used as a fallback if logger or checkpoint callback do not define specific save paths. """ if get_filesystem(self._default_root_dir).protocol == "file": re...
[ "def", "default_root_dir", "(", "self", ")", "->", "str", ":", "if", "get_filesystem", "(", "self", ".", "_default_root_dir", ")", ".", "protocol", "==", "\"file\"", ":", "return", "os", ".", "path", ".", "normpath", "(", "self", ".", "_default_root_dir", ...
[ 272, 4 ]
[ 279, 37 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.weights_save_path
(self)
The default root location to save weights (checkpoints), e.g., when the :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` does not define a file path.
The default root location to save weights (checkpoints), e.g., when the :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` does not define a file path.
def weights_save_path(self) -> str: """ The default root location to save weights (checkpoints), e.g., when the :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` does not define a file path. """ if get_filesystem(self._weights_save_path).protocol == "file": ...
[ "def", "weights_save_path", "(", "self", ")", "->", "str", ":", "if", "get_filesystem", "(", "self", ".", "_weights_save_path", ")", ".", "protocol", "==", "\"file\"", ":", "return", "os", ".", "path", ".", "normpath", "(", "self", ".", "_weights_save_path",...
[ 282, 4 ]
[ 289, 38 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.early_stopping_callback
(self)
The first :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist.
The first :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist.
def early_stopping_callback(self) -> Optional[EarlyStopping]: """ The first :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist. """ callbacks = self.early_stopping_callbacks return cal...
[ "def", "early_stopping_callback", "(", "self", ")", "->", "Optional", "[", "EarlyStopping", "]", ":", "callbacks", "=", "self", ".", "early_stopping_callbacks", "return", "callbacks", "[", "0", "]", "if", "len", "(", "callbacks", ")", ">", "0", "else", "None...
[ 292, 4 ]
[ 298, 59 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.early_stopping_callbacks
(self)
A list of all instances of :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` found in the Trainer.callbacks list.
A list of all instances of :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` found in the Trainer.callbacks list.
def early_stopping_callbacks(self) -> List[EarlyStopping]: """ A list of all instances of :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` found in the Trainer.callbacks list. """ return [c for c in self.callbacks if isinstance(c, EarlyStopping)]
[ "def", "early_stopping_callbacks", "(", "self", ")", "->", "List", "[", "EarlyStopping", "]", ":", "return", "[", "c", "for", "c", "in", "self", ".", "callbacks", "if", "isinstance", "(", "c", ",", "EarlyStopping", ")", "]" ]
[ 301, 4 ]
[ 306, 74 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.checkpoint_callback
(self)
The first :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist.
The first :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist.
def checkpoint_callback(self) -> Optional[ModelCheckpoint]: """ The first :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` callback in the Trainer.callbacks list, or ``None`` if it doesn't exist. """ callbacks = self.checkpoint_callbacks return callb...
[ "def", "checkpoint_callback", "(", "self", ")", "->", "Optional", "[", "ModelCheckpoint", "]", ":", "callbacks", "=", "self", ".", "checkpoint_callbacks", "return", "callbacks", "[", "0", "]", "if", "len", "(", "callbacks", ")", ">", "0", "else", "None" ]
[ 309, 4 ]
[ 315, 59 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.checkpoint_callbacks
(self)
A list of all instances of :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` found in the Trainer.callbacks list.
A list of all instances of :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` found in the Trainer.callbacks list.
def checkpoint_callbacks(self) -> List[ModelCheckpoint]: """ A list of all instances of :class:`~pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint` found in the Trainer.callbacks list. """ return [c for c in self.callbacks if isinstance(c, ModelCheckpoint)]
[ "def", "checkpoint_callbacks", "(", "self", ")", "->", "List", "[", "ModelCheckpoint", "]", ":", "return", "[", "c", "for", "c", "in", "self", ".", "callbacks", "if", "isinstance", "(", "c", ",", "ModelCheckpoint", ")", "]" ]
[ 318, 4 ]
[ 323, 76 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.model
(self)
The LightningModule, but possibly wrapped into DataParallel or DistributedDataParallel. To access the pure LightningModule, use :meth:`~pytorch_lightning.trainer.trainer.Trainer.lightning_module` instead.
The LightningModule, but possibly wrapped into DataParallel or DistributedDataParallel. To access the pure LightningModule, use :meth:`~pytorch_lightning.trainer.trainer.Trainer.lightning_module` instead.
def model(self) -> torch.nn.Module: """ The LightningModule, but possibly wrapped into DataParallel or DistributedDataParallel. To access the pure LightningModule, use :meth:`~pytorch_lightning.trainer.trainer.Trainer.lightning_module` instead. """ return self.accelerator...
[ "def", "model", "(", "self", ")", "->", "torch", ".", "nn", ".", "Module", ":", "return", "self", ".", "accelerator", ".", "model" ]
[ 329, 4 ]
[ 335, 37 ]
python
en
['en', 'error', 'th']
False
TrainerProperties.model
(self, model: torch.nn.Module)
Setter for the model, pass-through to accelerator and plugin where the model reference is stored. Used by the Tuner to reset the state of Trainer and Accelerator. Args: model: The LightningModule, possibly wrapped into DataParallel or DistributedDataParallel, depending ...
Setter for the model, pass-through to accelerator and plugin where the model reference is stored. Used by the Tuner to reset the state of Trainer and Accelerator.
def model(self, model: torch.nn.Module) -> None: """ Setter for the model, pass-through to accelerator and plugin where the model reference is stored. Used by the Tuner to reset the state of Trainer and Accelerator. Args: model: The LightningModule, possibly wrapped into Dat...
[ "def", "model", "(", "self", ",", "model", ":", "torch", ".", "nn", ".", "Module", ")", "->", "None", ":", "self", ".", "accelerator", ".", "model", "=", "model" ]
[ 338, 4 ]
[ 347, 38 ]
python
en
['en', 'error', 'th']
False
warn_if_output_is_none
(output: Any, method_name: str)
Warns user about which method returned None.
Warns user about which method returned None.
def warn_if_output_is_none(output: Any, method_name: str) -> None: """ Warns user about which method returned None. """ if output is None: warning_cache.warn(f'Your {method_name} returned None. Did you forget to return an output?')
[ "def", "warn_if_output_is_none", "(", "output", ":", "Any", ",", "method_name", ":", "str", ")", "->", "None", ":", "if", "output", "is", "None", ":", "warning_cache", ".", "warn", "(", "f'Your {method_name} returned None. Did you forget to return an output?'", ")" ]
[ 79, 0 ]
[ 82, 100 ]
python
en
['en', 'en', 'en']
True
_LightningModuleWrapperBase.__init__
(self, pl_module: LightningModule)
Wraps the user's LightningModule and redirects the forward call to the appropriate method, either ``training_step``, ``validation_step`` or ``test_step``. If the LightningModule is in none of the states `training`, `testing` or `validation`, the inputs will be redirected to the ...
Wraps the user's LightningModule and redirects the forward call to the appropriate method, either ``training_step``, ``validation_step`` or ``test_step``. If the LightningModule is in none of the states `training`, `testing` or `validation`, the inputs will be redirected to the ...
def __init__(self, pl_module: LightningModule): """ Wraps the user's LightningModule and redirects the forward call to the appropriate method, either ``training_step``, ``validation_step`` or ``test_step``. If the LightningModule is in none of the states `training`, `testing` or `validat...
[ "def", "__init__", "(", "self", ",", "pl_module", ":", "LightningModule", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "module", "=", "pl_module" ]
[ 29, 4 ]
[ 42, 31 ]
python
en
['en', 'error', 'th']
False
approx
(a, b, fill_value=True, rtol=1e-5, atol=1e-8)
Returns true if all components of a and b are equal to given tolerances. If fill_value is True, masked values considered equal. Otherwise, masked values are considered unequal. The relative error rtol should be positive and << 1.0 The absolute error atol comes into play for those elements of b th...
Returns true if all components of a and b are equal to given tolerances.
def approx(a, b, fill_value=True, rtol=1e-5, atol=1e-8): """ Returns true if all components of a and b are equal to given tolerances. If fill_value is True, masked values considered equal. Otherwise, masked values are considered unequal. The relative error rtol should be positive and << 1.0 The ab...
[ "def", "approx", "(", "a", ",", "b", ",", "fill_value", "=", "True", ",", "rtol", "=", "1e-5", ",", "atol", "=", "1e-8", ")", ":", "m", "=", "mask_or", "(", "getmask", "(", "a", ")", ",", "getmask", "(", "b", ")", ")", "d1", "=", "filled", "(...
[ 42, 0 ]
[ 61, 20 ]
python
en
['en', 'error', 'th']
False
almost
(a, b, decimal=6, fill_value=True)
Returns True if a and b are equal up to decimal places. If fill_value is True, masked values considered equal. Otherwise, masked values are considered unequal.
Returns True if a and b are equal up to decimal places.
def almost(a, b, decimal=6, fill_value=True): """ Returns True if a and b are equal up to decimal places. If fill_value is True, masked values considered equal. Otherwise, masked values are considered unequal. """ m = mask_or(getmask(a), getmask(b)) d1 = filled(a) d2 = filled(b) if...
[ "def", "almost", "(", "a", ",", "b", ",", "decimal", "=", "6", ",", "fill_value", "=", "True", ")", ":", "m", "=", "mask_or", "(", "getmask", "(", "a", ")", ",", "getmask", "(", "b", ")", ")", "d1", "=", "filled", "(", "a", ")", "d2", "=", ...
[ 64, 0 ]
[ 80, 20 ]
python
en
['en', 'error', 'th']
False
_assert_equal_on_sequences
(actual, desired, err_msg='')
Asserts the equality of two non-array sequences.
Asserts the equality of two non-array sequences.
def _assert_equal_on_sequences(actual, desired, err_msg=''): """ Asserts the equality of two non-array sequences. """ assert_equal(len(actual), len(desired), err_msg) for k in range(len(desired)): assert_equal(actual[k], desired[k], 'item=%r\n%s' % (k, err_msg)) return
[ "def", "_assert_equal_on_sequences", "(", "actual", ",", "desired", ",", "err_msg", "=", "''", ")", ":", "assert_equal", "(", "len", "(", "actual", ")", ",", "len", "(", "desired", ")", ",", "err_msg", ")", "for", "k", "in", "range", "(", "len", "(", ...
[ 83, 0 ]
[ 91, 10 ]
python
en
['en', 'error', 'th']
False
assert_equal_records
(a, b)
Asserts that two records are equal. Pretty crude for now.
Asserts that two records are equal.
def assert_equal_records(a, b): """ Asserts that two records are equal. Pretty crude for now. """ assert_equal(a.dtype, b.dtype) for f in a.dtype.names: (af, bf) = (operator.getitem(a, f), operator.getitem(b, f)) if not (af is masked) and not (bf is masked): assert_...
[ "def", "assert_equal_records", "(", "a", ",", "b", ")", ":", "assert_equal", "(", "a", ".", "dtype", ",", "b", ".", "dtype", ")", "for", "f", "in", "a", ".", "dtype", ".", "names", ":", "(", "af", ",", "bf", ")", "=", "(", "operator", ".", "get...
[ 94, 0 ]
[ 106, 10 ]
python
en
['en', 'error', 'th']
False
assert_equal
(actual, desired, err_msg='')
Asserts that two items are equal.
Asserts that two items are equal.
def assert_equal(actual, desired, err_msg=''): """ Asserts that two items are equal. """ # Case #1: dictionary ..... if isinstance(desired, dict): if not isinstance(actual, dict): raise AssertionError(repr(type(actual))) assert_equal(len(actual), len(desired), err_msg) ...
[ "def", "assert_equal", "(", "actual", ",", "desired", ",", "err_msg", "=", "''", ")", ":", "# Case #1: dictionary .....", "if", "isinstance", "(", "desired", ",", "dict", ")", ":", "if", "not", "isinstance", "(", "actual", ",", "dict", ")", ":", "raise", ...
[ 109, 0 ]
[ 145, 55 ]
python
en
['en', 'error', 'th']
False
fail_if_equal
(actual, desired, err_msg='',)
Raises an assertion error if two items are equal.
Raises an assertion error if two items are equal.
def fail_if_equal(actual, desired, err_msg='',): """ Raises an assertion error if two items are equal. """ if isinstance(desired, dict): if not isinstance(actual, dict): raise AssertionError(repr(type(actual))) fail_if_equal(len(actual), len(desired), err_msg) for k,...
[ "def", "fail_if_equal", "(", "actual", ",", "desired", ",", "err_msg", "=", "''", ",", ")", ":", "if", "isinstance", "(", "desired", ",", "dict", ")", ":", "if", "not", "isinstance", "(", "actual", ",", "dict", ")", ":", "raise", "AssertionError", "(",...
[ 148, 0 ]
[ 171, 33 ]
python
en
['en', 'error', 'th']
False
assert_almost_equal
(actual, desired, decimal=7, err_msg='', verbose=True)
Asserts that two items are almost equal. The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).
Asserts that two items are almost equal.
def assert_almost_equal(actual, desired, decimal=7, err_msg='', verbose=True): """ Asserts that two items are almost equal. The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal). """ if isinstance(actual, np.ndarray) or isinstance(desired, np.ndarray): return assert_array_al...
[ "def", "assert_almost_equal", "(", "actual", ",", "desired", ",", "decimal", "=", "7", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "if", "isinstance", "(", "actual", ",", "np", ".", "ndarray", ")", "or", "isinstance", "(", "desire...
[ 177, 0 ]
[ 190, 33 ]
python
en
['en', 'error', 'th']
False
assert_array_compare
(comparison, x, y, err_msg='', verbose=True, header='', fill_value=True)
Asserts that comparison between two masked arrays is satisfied. The comparison is elementwise.
Asserts that comparison between two masked arrays is satisfied.
def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', fill_value=True): """ Asserts that comparison between two masked arrays is satisfied. The comparison is elementwise. """ # Allocate a common mask and refill m = mask_or(getmask(x), getmask(...
[ "def", "assert_array_compare", "(", "comparison", ",", "x", ",", "y", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ",", "header", "=", "''", ",", "fill_value", "=", "True", ")", ":", "# Allocate a common mask and refill", "m", "=", "mask_or", "(...
[ 196, 0 ]
[ 218, 74 ]
python
en
['en', 'error', 'th']
False
assert_array_equal
(x, y, err_msg='', verbose=True)
Checks the elementwise equality of two masked arrays.
Checks the elementwise equality of two masked arrays.
def assert_array_equal(x, y, err_msg='', verbose=True): """ Checks the elementwise equality of two masked arrays. """ assert_array_compare(operator.__eq__, x, y, err_msg=err_msg, verbose=verbose, header='Arrays are not equal')
[ "def", "assert_array_equal", "(", "x", ",", "y", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "assert_array_compare", "(", "operator", ".", "__eq__", ",", "x", ",", "y", ",", "err_msg", "=", "err_msg", ",", "verbose", "=", "verbose...
[ 221, 0 ]
[ 228, 55 ]
python
en
['en', 'error', 'th']
False
fail_if_array_equal
(x, y, err_msg='', verbose=True)
Raises an assertion error if two masked arrays are not equal elementwise.
Raises an assertion error if two masked arrays are not equal elementwise.
def fail_if_array_equal(x, y, err_msg='', verbose=True): """ Raises an assertion error if two masked arrays are not equal elementwise. """ def compare(x, y): return (not np.alltrue(approx(x, y))) assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose, ...
[ "def", "fail_if_array_equal", "(", "x", ",", "y", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "def", "compare", "(", "x", ",", "y", ")", ":", "return", "(", "not", "np", ".", "alltrue", "(", "approx", "(", "x", ",", "y", "...
[ 231, 0 ]
[ 239, 55 ]
python
en
['en', 'error', 'th']
False
assert_array_approx_equal
(x, y, decimal=6, err_msg='', verbose=True)
Checks the equality of two masked arrays, up to given number odecimals. The equality is checked elementwise.
Checks the equality of two masked arrays, up to given number odecimals.
def assert_array_approx_equal(x, y, decimal=6, err_msg='', verbose=True): """ Checks the equality of two masked arrays, up to given number odecimals. The equality is checked elementwise. """ def compare(x, y): "Returns the result of the loose comparison between x and y)." return ap...
[ "def", "assert_array_approx_equal", "(", "x", ",", "y", ",", "decimal", "=", "6", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "def", "compare", "(", "x", ",", "y", ")", ":", "\"Returns the result of the loose comparison between x and y).\...
[ 242, 0 ]
[ 253, 62 ]
python
en
['en', 'error', 'th']
False
assert_array_almost_equal
(x, y, decimal=6, err_msg='', verbose=True)
Checks the equality of two masked arrays, up to given number odecimals. The equality is checked elementwise.
Checks the equality of two masked arrays, up to given number odecimals.
def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True): """ Checks the equality of two masked arrays, up to given number odecimals. The equality is checked elementwise. """ def compare(x, y): "Returns the result of the loose comparison between x and y)." return al...
[ "def", "assert_array_almost_equal", "(", "x", ",", "y", ",", "decimal", "=", "6", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "def", "compare", "(", "x", ",", "y", ")", ":", "\"Returns the result of the loose comparison between x and y).\...
[ 256, 0 ]
[ 267, 62 ]
python
en
['en', 'error', 'th']
False
assert_array_less
(x, y, err_msg='', verbose=True)
Checks that x is smaller than y elementwise.
Checks that x is smaller than y elementwise.
def assert_array_less(x, y, err_msg='', verbose=True): """ Checks that x is smaller than y elementwise. """ assert_array_compare(operator.__lt__, x, y, err_msg=err_msg, verbose=verbose, header='Arrays are not less-ordered')
[ "def", "assert_array_less", "(", "x", ",", "y", ",", "err_msg", "=", "''", ",", "verbose", "=", "True", ")", ":", "assert_array_compare", "(", "operator", ".", "__lt__", ",", "x", ",", "y", ",", "err_msg", "=", "err_msg", ",", "verbose", "=", "verbose"...
[ 270, 0 ]
[ 277, 62 ]
python
en
['en', 'error', 'th']
False
assert_mask_equal
(m1, m2, err_msg='')
Asserts the equality of two masks.
Asserts the equality of two masks.
def assert_mask_equal(m1, m2, err_msg=''): """ Asserts the equality of two masks. """ if m1 is nomask: assert_(m2 is nomask) if m2 is nomask: assert_(m1 is nomask) assert_array_equal(m1, m2, err_msg=err_msg)
[ "def", "assert_mask_equal", "(", "m1", ",", "m2", ",", "err_msg", "=", "''", ")", ":", "if", "m1", "is", "nomask", ":", "assert_", "(", "m2", "is", "nomask", ")", "if", "m2", "is", "nomask", ":", "assert_", "(", "m1", "is", "nomask", ")", "assert_a...
[ 280, 0 ]
[ 289, 47 ]
python
en
['en', 'error', 'th']
False
empty_like
(prototype, dtype=None, order=None, subok=None, shape=None)
empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new array with the same shape and type as a given array. Parameters ---------- prototype : array_like The shape and data-type of `prototype` define these same attributes of the returned array. dtype ...
empty_like(prototype, dtype=None, order='K', subok=True, shape=None)
def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): """ empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new array with the same shape and type as a given array. Parameters ---------- prototype : array_like The shape and data-type of ...
[ "def", "empty_like", "(", "prototype", ",", "dtype", "=", "None", ",", "order", "=", "None", ",", "subok", "=", "None", ",", "shape", "=", "None", ")", ":", "return", "(", "prototype", ",", ")" ]
[ 77, 0 ]
[ 141, 23 ]
python
en
['en', 'error', 'th']
False
concatenate
(arrays, axis=None, out=None)
concatenate((a1, a2, ...), axis=0, out=None) Join a sequence of arrays along an existing axis. Parameters ---------- a1, a2, ... : sequence of array_like The arrays must have the same shape, except in the dimension corresponding to `axis` (the first, by default). axis : int, o...
concatenate((a1, a2, ...), axis=0, out=None)
def concatenate(arrays, axis=None, out=None): """ concatenate((a1, a2, ...), axis=0, out=None) Join a sequence of arrays along an existing axis. Parameters ---------- a1, a2, ... : sequence of array_like The arrays must have the same shape, except in the dimension corresponding...
[ "def", "concatenate", "(", "arrays", ",", "axis", "=", "None", ",", "out", "=", "None", ")", ":", "if", "out", "is", "not", "None", ":", "# optimize for the typical case where only arrays is provided", "arrays", "=", "list", "(", "arrays", ")", "arrays", ".", ...
[ 145, 0 ]
[ 231, 17 ]
python
en
['en', 'error', 'th']
False
inner
(a, b)
inner(a, b) Inner product of two arrays. Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes. Parameters ---------- a, b : array_like If `a` and `b` are nonscalar, their last dimensions must match. ...
inner(a, b)
def inner(a, b): """ inner(a, b) Inner product of two arrays. Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes. Parameters ---------- a, b : array_like If `a` and `b` are nonscalar, their last...
[ "def", "inner", "(", "a", ",", "b", ")", ":", "return", "(", "a", ",", "b", ")" ]
[ 235, 0 ]
[ 308, 17 ]
python
en
['en', 'error', 'th']
False
where
(condition, x=None, y=None)
where(condition, [x, y]) Return elements chosen from `x` or `y` depending on `condition`. .. note:: When only `condition` is provided, this function is a shorthand for ``np.asarray(condition).nonzero()``. Using `nonzero` directly should be preferred, as it behaves correctly for su...
where(condition, [x, y])
def where(condition, x=None, y=None): """ where(condition, [x, y]) Return elements chosen from `x` or `y` depending on `condition`. .. note:: When only `condition` is provided, this function is a shorthand for ``np.asarray(condition).nonzero()``. Using `nonzero` directly should be ...
[ "def", "where", "(", "condition", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "return", "(", "condition", ",", "x", ",", "y", ")" ]
[ 312, 0 ]
[ 383, 28 ]
python
en
['en', 'error', 'th']
False
lexsort
(keys, axis=None)
lexsort(keys, axis=-1) Perform an indirect stable sort using a sequence of keys. Given multiple sorting keys, which can be interpreted as columns in a spreadsheet, lexsort returns an array of integer indices that describes the sort order by multiple columns. The last key in the sequence is used ...
lexsort(keys, axis=-1)
def lexsort(keys, axis=None): """ lexsort(keys, axis=-1) Perform an indirect stable sort using a sequence of keys. Given multiple sorting keys, which can be interpreted as columns in a spreadsheet, lexsort returns an array of integer indices that describes the sort order by multiple columns. T...
[ "def", "lexsort", "(", "keys", ",", "axis", "=", "None", ")", ":", "if", "isinstance", "(", "keys", ",", "tuple", ")", ":", "return", "keys", "else", ":", "return", "(", "keys", ",", ")" ]
[ 387, 0 ]
[ 465, 22 ]
python
en
['en', 'error', 'th']
False
can_cast
(from_, to, casting=None)
can_cast(from_, to, casting='safe') Returns True if cast between data types can occur according to the casting rule. If from is a scalar or array scalar, also returns True if the scalar value can be cast without overflow or truncation to an integer. Parameters ---------- from_ : dtyp...
can_cast(from_, to, casting='safe')
def can_cast(from_, to, casting=None): """ can_cast(from_, to, casting='safe') Returns True if cast between data types can occur according to the casting rule. If from is a scalar or array scalar, also returns True if the scalar value can be cast without overflow or truncation to an integer. ...
[ "def", "can_cast", "(", "from_", ",", "to", ",", "casting", "=", "None", ")", ":", "return", "(", "from_", ",", ")" ]
[ 469, 0 ]
[ 580, 19 ]
python
en
['en', 'error', 'th']
False
min_scalar_type
(a)
min_scalar_type(a) For scalar ``a``, returns the data type with the smallest size and smallest scalar kind which can hold its value. For non-scalar array ``a``, returns the vector's dtype unmodified. Floating point values are not demoted to integers, and complex values are not demoted to flo...
min_scalar_type(a)
def min_scalar_type(a): """ min_scalar_type(a) For scalar ``a``, returns the data type with the smallest size and smallest scalar kind which can hold its value. For non-scalar array ``a``, returns the vector's dtype unmodified. Floating point values are not demoted to integers, and comple...
[ "def", "min_scalar_type", "(", "a", ")", ":", "return", "(", "a", ",", ")" ]
[ 584, 0 ]
[ 631, 15 ]
python
en
['en', 'error', 'th']
False
result_type
(*arrays_and_dtypes)
result_type(*arrays_and_dtypes) Returns the type that results from applying the NumPy type promotion rules to the arguments. Type promotion in NumPy works similarly to the rules in languages like C++, with some slight differences. When both scalars and arrays are used, the array's type takes...
result_type(*arrays_and_dtypes)
def result_type(*arrays_and_dtypes): """ result_type(*arrays_and_dtypes) Returns the type that results from applying the NumPy type promotion rules to the arguments. Type promotion in NumPy works similarly to the rules in languages like C++, with some slight differences. When both scalars and...
[ "def", "result_type", "(", "*", "arrays_and_dtypes", ")", ":", "return", "arrays_and_dtypes" ]
[ 635, 0 ]
[ 703, 28 ]
python
en
['en', 'error', 'th']
False
dot
(a, b, out=None)
dot(a, b, out=None) Dot product of two arrays. Specifically, - If both `a` and `b` are 1-D arrays, it is inner product of vectors (without complex conjugation). - If both `a` and `b` are 2-D arrays, it is matrix multiplication, but using :func:`matmul` or ``a @ b`` is preferred. - I...
dot(a, b, out=None)
def dot(a, b, out=None): """ dot(a, b, out=None) Dot product of two arrays. Specifically, - If both `a` and `b` are 1-D arrays, it is inner product of vectors (without complex conjugation). - If both `a` and `b` are 2-D arrays, it is matrix multiplication, but using :func:`matmul` or ...
[ "def", "dot", "(", "a", ",", "b", ",", "out", "=", "None", ")", ":", "return", "(", "a", ",", "b", ",", "out", ")" ]
[ 707, 0 ]
[ 791, 22 ]
python
en
['en', 'error', 'th']
False
vdot
(a, b)
vdot(a, b) Return the dot product of two vectors. The vdot(`a`, `b`) function handles complex numbers differently than dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. Note that `vdot` handles multidi...
vdot(a, b)
def vdot(a, b): """ vdot(a, b) Return the dot product of two vectors. The vdot(`a`, `b`) function handles complex numbers differently than dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. Note that...
[ "def", "vdot", "(", "a", ",", "b", ")", ":", "return", "(", "a", ",", "b", ")" ]
[ 795, 0 ]
[ 849, 17 ]
python
en
['en', 'error', 'th']
False
bincount
(x, weights=None, minlength=None)
bincount(x, weights=None, minlength=0) Count number of occurrences of each value in array of non-negative ints. The number of bins (of size 1) is one larger than the largest value in `x`. If `minlength` is specified, there will be at least this number of bins in the output array (though it will b...
bincount(x, weights=None, minlength=0)
def bincount(x, weights=None, minlength=None): """ bincount(x, weights=None, minlength=0) Count number of occurrences of each value in array of non-negative ints. The number of bins (of size 1) is one larger than the largest value in `x`. If `minlength` is specified, there will be at least this nu...
[ "def", "bincount", "(", "x", ",", "weights", "=", "None", ",", "minlength", "=", "None", ")", ":", "return", "(", "x", ",", "weights", ")" ]
[ 853, 0 ]
[ 925, 23 ]
python
en
['en', 'error', 'th']
False
ravel_multi_index
(multi_index, dims, mode=None, order=None)
ravel_multi_index(multi_index, dims, mode='raise', order='C') Converts a tuple of index arrays into an array of flat indices, applying boundary modes to the multi-index. Parameters ---------- multi_index : tuple of array_like A tuple of integer arrays, one array for each dimension. ...
ravel_multi_index(multi_index, dims, mode='raise', order='C')
def ravel_multi_index(multi_index, dims, mode=None, order=None): """ ravel_multi_index(multi_index, dims, mode='raise', order='C') Converts a tuple of index arrays into an array of flat indices, applying boundary modes to the multi-index. Parameters ---------- multi_index : tuple of array_...
[ "def", "ravel_multi_index", "(", "multi_index", ",", "dims", ",", "mode", "=", "None", ",", "order", "=", "None", ")", ":", "return", "multi_index" ]
[ 929, 0 ]
[ 986, 22 ]
python
en
['en', 'error', 'th']
False
unravel_index
(indices, shape=None, order=None, dims=None)
unravel_index(indices, shape, order='C') Converts a flat index or array of flat indices into a tuple of coordinate arrays. Parameters ---------- indices : array_like An integer array whose elements are indices into the flattened version of an array of dimensions ``shape``. Bef...
unravel_index(indices, shape, order='C')
def unravel_index(indices, shape=None, order=None, dims=None): """ unravel_index(indices, shape, order='C') Converts a flat index or array of flat indices into a tuple of coordinate arrays. Parameters ---------- indices : array_like An integer array whose elements are indices into ...
[ "def", "unravel_index", "(", "indices", ",", "shape", "=", "None", ",", "order", "=", "None", ",", "dims", "=", "None", ")", ":", "if", "dims", "is", "not", "None", ":", "warnings", ".", "warn", "(", "\"'shape' argument should be used instead of 'dims'\"", "...
[ 990, 0 ]
[ 1039, 21 ]
python
en
['en', 'error', 'th']
False
copyto
(dst, src, casting=None, where=None)
copyto(dst, src, casting='same_kind', where=True) Copies values from one array to another, broadcasting as necessary. Raises a TypeError if the `casting` rule is violated, and if `where` is provided, it selects which elements to copy. .. versionadded:: 1.7.0 Parameters ---------- ds...
copyto(dst, src, casting='same_kind', where=True)
def copyto(dst, src, casting=None, where=None): """ copyto(dst, src, casting='same_kind', where=True) Copies values from one array to another, broadcasting as necessary. Raises a TypeError if the `casting` rule is violated, and if `where` is provided, it selects which elements to copy. .. ver...
[ "def", "copyto", "(", "dst", ",", "src", ",", "casting", "=", "None", ",", "where", "=", "None", ")", ":", "return", "(", "dst", ",", "src", ",", "where", ")" ]
[ 1043, 0 ]
[ 1074, 28 ]
python
en
['en', 'error', 'th']
False
putmask
(a, mask, values)
putmask(a, mask, values) Changes elements of an array based on conditional and input values. Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``. If `values` is not the same size as `a` and `mask` then it will repeat. This gives behavior different from ``a[mask] = values``. ...
putmask(a, mask, values)
def putmask(a, mask, values): """ putmask(a, mask, values) Changes elements of an array based on conditional and input values. Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``. If `values` is not the same size as `a` and `mask` then it will repeat. This gives behavior di...
[ "def", "putmask", "(", "a", ",", "mask", ",", "values", ")", ":", "return", "(", "a", ",", "mask", ",", "values", ")" ]
[ 1078, 0 ]
[ 1119, 28 ]
python
en
['en', 'error', 'th']
False
packbits
(a, axis=None, bitorder='big')
packbits(a, axis=None, bitorder='big') Packs the elements of a binary-valued array into bits in a uint8 array. The result is padded to full bytes by inserting zero bits at the end. Parameters ---------- a : array_like An array of integers or booleans whose elements should be packed t...
packbits(a, axis=None, bitorder='big')
def packbits(a, axis=None, bitorder='big'): """ packbits(a, axis=None, bitorder='big') Packs the elements of a binary-valued array into bits in a uint8 array. The result is padded to full bytes by inserting zero bits at the end. Parameters ---------- a : array_like An array of int...
[ "def", "packbits", "(", "a", ",", "axis", "=", "None", ",", "bitorder", "=", "'big'", ")", ":", "return", "(", "a", ",", ")" ]
[ 1123, 0 ]
[ 1177, 15 ]
python
en
['en', 'error', 'th']
False
unpackbits
(a, axis=None, count=None, bitorder='big')
unpackbits(a, axis=None, count=None, bitorder='big') Unpacks elements of a uint8 array into a binary-valued output array. Each element of `a` represents a bit-field that should be unpacked into a binary-valued output array. The shape of the output array is either 1-D (if `axis` is ``None``) or th...
unpackbits(a, axis=None, count=None, bitorder='big')
def unpackbits(a, axis=None, count=None, bitorder='big'): """ unpackbits(a, axis=None, count=None, bitorder='big') Unpacks elements of a uint8 array into a binary-valued output array. Each element of `a` represents a bit-field that should be unpacked into a binary-valued output array. The shape of...
[ "def", "unpackbits", "(", "a", ",", "axis", "=", "None", ",", "count", "=", "None", ",", "bitorder", "=", "'big'", ")", ":", "return", "(", "a", ",", ")" ]
[ 1181, 0 ]
[ 1261, 15 ]
python
en
['en', 'error', 'th']
False
shares_memory
(a, b, max_work=None)
shares_memory(a, b, max_work=None) Determine if two arrays share memory Parameters ---------- a, b : ndarray Input arrays max_work : int, optional Effort to spend on solving the overlap problem (maximum number of candidate solutions to consider). The following special ...
shares_memory(a, b, max_work=None)
def shares_memory(a, b, max_work=None): """ shares_memory(a, b, max_work=None) Determine if two arrays share memory Parameters ---------- a, b : ndarray Input arrays max_work : int, optional Effort to spend on solving the overlap problem (maximum number of candidate...
[ "def", "shares_memory", "(", "a", ",", "b", ",", "max_work", "=", "None", ")", ":", "return", "(", "a", ",", "b", ")" ]
[ 1265, 0 ]
[ 1305, 17 ]
python
en
['en', 'error', 'th']
False
may_share_memory
(a, b, max_work=None)
may_share_memory(a, b, max_work=None) Determine if two arrays might share memory A return of True does not necessarily mean that the two arrays share any element. It just means that they *might*. Only the memory bounds of a and b are checked by default. Parameters ---------- a, b :...
may_share_memory(a, b, max_work=None)
def may_share_memory(a, b, max_work=None): """ may_share_memory(a, b, max_work=None) Determine if two arrays might share memory A return of True does not necessarily mean that the two arrays share any element. It just means that they *might*. Only the memory bounds of a and b are checked by ...
[ "def", "may_share_memory", "(", "a", ",", "b", ",", "max_work", "=", "None", ")", ":", "return", "(", "a", ",", "b", ")" ]
[ 1309, 0 ]
[ 1346, 17 ]
python
en
['en', 'error', 'th']
False
is_busday
(dates, weekmask=None, holidays=None, busdaycal=None, out=None)
is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None) Calculates which of the given dates are valid days, and which are not. .. versionadded:: 1.7.0 Parameters ---------- dates : array_like of datetime64[D] The array of dates to process. weekmask : str or ...
is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None)
def is_busday(dates, weekmask=None, holidays=None, busdaycal=None, out=None): """ is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None) Calculates which of the given dates are valid days, and which are not. .. versionadded:: 1.7.0 Parameters ---------- dates : arra...
[ "def", "is_busday", "(", "dates", ",", "weekmask", "=", "None", ",", "holidays", "=", "None", ",", "busdaycal", "=", "None", ",", "out", "=", "None", ")", ":", "return", "(", "dates", ",", "weekmask", ",", "holidays", ",", "out", ")" ]
[ 1350, 0 ]
[ 1400, 43 ]
python
en
['en', 'error', 'th']
False
busday_offset
(dates, offsets, roll=None, weekmask=None, holidays=None, busdaycal=None, out=None)
busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None) First adjusts the date to fall on a valid day according to the ``roll`` rule, then applies offsets to the given dates counted in valid days. .. versionadded:: 1.7.0 Parameters -------...
busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None)
def busday_offset(dates, offsets, roll=None, weekmask=None, holidays=None, busdaycal=None, out=None): """ busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None) First adjusts the date to fall on a valid day according to the ``roll`` ru...
[ "def", "busday_offset", "(", "dates", ",", "offsets", ",", "roll", "=", "None", ",", "weekmask", "=", "None", ",", "holidays", "=", "None", ",", "busdaycal", "=", "None", ",", "out", "=", "None", ")", ":", "return", "(", "dates", ",", "offsets", ",",...
[ 1404, 0 ]
[ 1494, 52 ]
python
en
['en', 'error', 'th']
False
busday_count
(begindates, enddates, weekmask=None, holidays=None, busdaycal=None, out=None)
busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None) Counts the number of valid days between `begindates` and `enddates`, not including the day of `enddates`. If ``enddates`` specifies a date value that is earlier than the corresponding ``begindates`` date...
busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None)
def busday_count(begindates, enddates, weekmask=None, holidays=None, busdaycal=None, out=None): """ busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None) Counts the number of valid days between `begindates` and `enddates`, not including the day o...
[ "def", "busday_count", "(", "begindates", ",", "enddates", ",", "weekmask", "=", "None", ",", "holidays", "=", "None", ",", "busdaycal", "=", "None", ",", "out", "=", "None", ")", ":", "return", "(", "begindates", ",", "enddates", ",", "weekmask", ",", ...
[ 1498, 0 ]
[ 1562, 58 ]
python
en
['en', 'error', 'th']
False
datetime_as_string
(arr, unit=None, timezone=None, casting=None)
datetime_as_string(arr, unit=None, timezone='naive', casting='same_kind') Convert an array of datetimes into an array of strings. Parameters ---------- arr : array_like of datetime64 The array of UTC timestamps to format. unit : str One of None, 'auto', or a :ref:`datetime uni...
datetime_as_string(arr, unit=None, timezone='naive', casting='same_kind')
def datetime_as_string(arr, unit=None, timezone=None, casting=None): """ datetime_as_string(arr, unit=None, timezone='naive', casting='same_kind') Convert an array of datetimes into an array of strings. Parameters ---------- arr : array_like of datetime64 The array of UTC timestamps to...
[ "def", "datetime_as_string", "(", "arr", ",", "unit", "=", "None", ",", "timezone", "=", "None", ",", "casting", "=", "None", ")", ":", "return", "(", "arr", ",", ")" ]
[ 1567, 0 ]
[ 1630, 17 ]
python
en
['en', 'error', 'th']
False
linspace
(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)
Return evenly spaced numbers over a specified interval. Returns `num` evenly spaced samples, calculated over the interval [`start`, `stop`]. The endpoint of the interval can optionally be excluded. .. versionchanged:: 1.16.0 Non-scalar `start` and `stop` are now supported. Parameter...
Return evenly spaced numbers over a specified interval.
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0): """ Return evenly spaced numbers over a specified interval. Returns `num` evenly spaced samples, calculated over the interval [`start`, `stop`]. The endpoint of the interval can optionally be excluded...
[ "def", "linspace", "(", "start", ",", "stop", ",", "num", "=", "50", ",", "endpoint", "=", "True", ",", "retstep", "=", "False", ",", "dtype", "=", "None", ",", "axis", "=", "0", ")", ":", "# 2016-02-25, 1.12", "num", "=", "_index_deprecate", "(", "n...
[ 37, 0 ]
[ 178, 42 ]
python
en
['en', 'error', 'th']
False
logspace
(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0)
Return numbers spaced evenly on a log scale. In linear space, the sequence starts at ``base ** start`` (`base` to the power of `start`) and ends with ``base ** stop`` (see `endpoint` below). .. versionchanged:: 1.16.0 Non-scalar `start` and `stop` are now supported. Parameters --...
Return numbers spaced evenly on a log scale.
def logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0): """ Return numbers spaced evenly on a log scale. In linear space, the sequence starts at ``base ** start`` (`base` to the power of `start`) and ends with ``base ** stop`` (see `endpoint` below). .. ve...
[ "def", "logspace", "(", "start", ",", "stop", ",", "num", "=", "50", ",", "endpoint", "=", "True", ",", "base", "=", "10.0", ",", "dtype", "=", "None", ",", "axis", "=", "0", ")", ":", "y", "=", "linspace", "(", "start", ",", "stop", ",", "num"...
[ 187, 0 ]
[ 279, 55 ]
python
en
['en', 'error', 'th']
False
geomspace
(start, stop, num=50, endpoint=True, dtype=None, axis=0)
Return numbers spaced evenly on a log scale (a geometric progression). This is similar to `logspace`, but with endpoints specified directly. Each output sample is a constant multiple of the previous. .. versionchanged:: 1.16.0 Non-scalar `start` and `stop` are now supported. Parameters ...
Return numbers spaced evenly on a log scale (a geometric progression).
def geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0): """ Return numbers spaced evenly on a log scale (a geometric progression). This is similar to `logspace`, but with endpoints specified directly. Each output sample is a constant multiple of the previous. .. versionchanged:: 1.1...
[ "def", "geomspace", "(", "start", ",", "stop", ",", "num", "=", "50", ",", "endpoint", "=", "True", ",", "dtype", "=", "None", ",", "axis", "=", "0", ")", ":", "start", "=", "asanyarray", "(", "start", ")", "stop", "=", "asanyarray", "(", "stop", ...
[ 288, 0 ]
[ 429, 43 ]
python
en
['en', 'error', 'th']
False
add_newdoc
(place, obj, doc)
Adds documentation to obj which is in module place. If doc is a string add it to obj as a docstring If doc is a tuple, then the first element is interpreted as an attribute of obj and the second as the docstring (method, docstring) If doc is a list, then each element of the list sho...
Adds documentation to obj which is in module place.
def add_newdoc(place, obj, doc): """ Adds documentation to obj which is in module place. If doc is a string add it to obj as a docstring If doc is a tuple, then the first element is interpreted as an attribute of obj and the second as the docstring (method, docstring) If doc is a...
[ "def", "add_newdoc", "(", "place", ",", "obj", ",", "doc", ")", ":", "new", "=", "getattr", "(", "__import__", "(", "place", ",", "globals", "(", ")", ",", "{", "}", ",", "[", "obj", "]", ")", ",", "obj", ")", "if", "isinstance", "(", "doc", ",...
[ 440, 0 ]
[ 469, 64 ]
python
en
['en', 'error', 'th']
False
MergeActiveShadowTest.testadjust_reserved_range
(self)
adjust_reserved_range removes specified skip_reserved_numbers.
adjust_reserved_range removes specified skip_reserved_numbers.
def testadjust_reserved_range(self): """adjust_reserved_range removes specified skip_reserved_numbers.""" desc_pb_text = """ reserved_range { start: 41 end: 41 } reserved_range { start: 42 end: 42 } reserved_range { start: 43 end: 44 } reserved_range { start: 50 end: 51 } """ ...
[ "def", "testadjust_reserved_range", "(", "self", ")", ":", "desc_pb_text", "=", "\"\"\"\nreserved_range {\n start: 41\n end: 41\n}\nreserved_range {\n start: 42\n end: 42\n}\nreserved_range {\n start: 43\n end: 44\n}\nreserved_range {\n start: 50\n end: 51\n}\n \"\"\"", "desc", "=", ...
[ 23, 4 ]
[ 57, 62 ]
python
en
['sv', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_enum
(self)
merge_active_shadow_enum recovers shadow values.
merge_active_shadow_enum recovers shadow values.
def testmerge_active_shadow_enum(self): """merge_active_shadow_enum recovers shadow values.""" active_pb_text = """ value { number: 1 name: "foo" } value { number: 0 name: "DEPRECATED_AND_UNAVAILABLE_DO_NOT_USE" } value { number: 3 name: "bar" } reserved_name: "baz" reserved_range { start:...
[ "def", "testmerge_active_shadow_enum", "(", "self", ")", ":", "active_pb_text", "=", "\"\"\"\nvalue {\n number: 1\n name: \"foo\"\n}\nvalue {\n number: 0\n name: \"DEPRECATED_AND_UNAVAILABLE_DO_NOT_USE\"\n}\nvalue {\n number: 3\n name: \"bar\"\n}\nreserved_name: \"baz\"\nreserved_range {\n st...
[ 59, 4 ]
[ 128, 68 ]
python
en
['pt', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_message_comments
(self)
merge_active_shadow_message preserves comment field correspondence.
merge_active_shadow_message preserves comment field correspondence.
def testmerge_active_shadow_message_comments(self): """merge_active_shadow_message preserves comment field correspondence.""" active_pb_text = """ field { number: 9 name: "oneof_1_0" oneof_index: 0 } field { number: 1 name: "simple_field_0" } field { number: 0 name: "oneof_2_0" oneof_ind...
[ "def", "testmerge_active_shadow_message_comments", "(", "self", ")", ":", "active_pb_text", "=", "\"\"\"\nfield {\n number: 9\n name: \"oneof_1_0\"\n oneof_index: 0\n}\nfield {\n number: 1\n name: \"simple_field_0\"\n}\nfield {\n number: 0\n name: \"oneof_2_0\"\n oneof_index: 2\n}\nfield {\n...
[ 130, 4 ]
[ 395, 88 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_message
(self)
merge_active_shadow_message recovers shadow fields with oneofs.
merge_active_shadow_message recovers shadow fields with oneofs.
def testmerge_active_shadow_message(self): """merge_active_shadow_message recovers shadow fields with oneofs.""" active_pb_text = """ field { number: 1 name: "foo" } field { number: 0 name: "bar" oneof_index: 2 } field { number: 3 name: "baz" } field { number: 4 name: "newbie" } reserv...
[ "def", "testmerge_active_shadow_message", "(", "self", ")", ":", "active_pb_text", "=", "\"\"\"\nfield {\n number: 1\n name: \"foo\"\n}\nfield {\n number: 0\n name: \"bar\"\n oneof_index: 2\n}\nfield {\n number: 3\n name: \"baz\"\n}\nfield {\n number: 4\n name: \"newbie\"\n}\nreserved_name:...
[ 397, 4 ]
[ 519, 93 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_message_no_shadow_message
(self)
merge_active_shadow_message doesn't require a shadow message for new nested active messages.
merge_active_shadow_message doesn't require a shadow message for new nested active messages.
def testmerge_active_shadow_message_no_shadow_message(self): """merge_active_shadow_message doesn't require a shadow message for new nested active messages.""" active_proto = descriptor_pb2.DescriptorProto() shadow_proto = descriptor_pb2.DescriptorProto() active_proto.nested_type.add().n...
[ "def", "testmerge_active_shadow_message_no_shadow_message", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "active_proto", ".", "nested_type", ".", ...
[ 521, 4 ]
[ 531, 65 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_message_no_shadow_enum
(self)
merge_active_shadow_message doesn't require a shadow enum for new nested active enums.
merge_active_shadow_message doesn't require a shadow enum for new nested active enums.
def testmerge_active_shadow_message_no_shadow_enum(self): """merge_active_shadow_message doesn't require a shadow enum for new nested active enums.""" active_proto = descriptor_pb2.DescriptorProto() shadow_proto = descriptor_pb2.DescriptorProto() active_proto.enum_type.add().name = 'foo'...
[ "def", "testmerge_active_shadow_message_no_shadow_enum", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "active_proto", ".", "enum_type", ".", "ad...
[ 533, 4 ]
[ 543, 63 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_message_missing
(self)
merge_active_shadow_message recovers missing messages from shadow.
merge_active_shadow_message recovers missing messages from shadow.
def testmerge_active_shadow_message_missing(self): """merge_active_shadow_message recovers missing messages from shadow.""" active_proto = descriptor_pb2.DescriptorProto() shadow_proto = descriptor_pb2.DescriptorProto() shadow_proto.nested_type.add().name = 'foo' target_proto = d...
[ "def", "testmerge_active_shadow_message_missing", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "DescriptorProto", "(", ")", "shadow_proto", ".", "nested_type", ".", "add", ...
[ 545, 4 ]
[ 555, 65 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_file_missing
(self)
merge_active_shadow_file recovers missing messages from shadow.
merge_active_shadow_file recovers missing messages from shadow.
def testmerge_active_shadow_file_missing(self): """merge_active_shadow_file recovers missing messages from shadow.""" active_proto = descriptor_pb2.FileDescriptorProto() shadow_proto = descriptor_pb2.FileDescriptorProto() shadow_proto.message_type.add().name = 'foo' target_proto ...
[ "def", "testmerge_active_shadow_file_missing", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "shadow_proto", ".", "message_type", ".", "a...
[ 557, 4 ]
[ 564, 66 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_file_no_shadow_message
(self)
merge_active_shadow_file doesn't require a shadow message for new active messages.
merge_active_shadow_file doesn't require a shadow message for new active messages.
def testmerge_active_shadow_file_no_shadow_message(self): """merge_active_shadow_file doesn't require a shadow message for new active messages.""" active_proto = descriptor_pb2.FileDescriptorProto() shadow_proto = descriptor_pb2.FileDescriptorProto() active_proto.message_type.add().name ...
[ "def", "testmerge_active_shadow_file_no_shadow_message", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "active_proto", ".", "message_type", ...
[ 566, 4 ]
[ 573, 66 ]
python
en
['en', 'en', 'en']
True
MergeActiveShadowTest.testmerge_active_shadow_file_no_shadow_enum
(self)
merge_active_shadow_file doesn't require a shadow enum for new active enums.
merge_active_shadow_file doesn't require a shadow enum for new active enums.
def testmerge_active_shadow_file_no_shadow_enum(self): """merge_active_shadow_file doesn't require a shadow enum for new active enums.""" active_proto = descriptor_pb2.FileDescriptorProto() shadow_proto = descriptor_pb2.FileDescriptorProto() active_proto.enum_type.add().name = 'foo' ...
[ "def", "testmerge_active_shadow_file_no_shadow_enum", "(", "self", ")", ":", "active_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "shadow_proto", "=", "descriptor_pb2", ".", "FileDescriptorProto", "(", ")", "active_proto", ".", "enum_type", ".", ...
[ 575, 4 ]
[ 582, 63 ]
python
en
['en', 'en', 'en']
True
Arrayterator.__getitem__
(self, index)
Return a new arrayterator.
Return a new arrayterator.
def __getitem__(self, index): """ Return a new arrayterator. """ # Fix index, handling ellipsis and incomplete slices. if not isinstance(index, tuple): index = (index,) fixed = [] length, dims = len(index), self.ndim for slice_ in index: ...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "# Fix index, handling ellipsis and incomplete slices.", "if", "not", "isinstance", "(", "index", ",", "tuple", ")", ":", "index", "=", "(", "index", ",", ")", "fixed", "=", "[", "]", "length", ",", ...
[ 98, 4 ]
[ 128, 18 ]
python
en
['en', 'error', 'th']
False
Arrayterator.__array__
(self)
Return corresponding data.
Return corresponding data.
def __array__(self): """ Return corresponding data. """ slice_ = tuple(slice(*t) for t in zip( self.start, self.stop, self.step)) return self.var[slice_]
[ "def", "__array__", "(", "self", ")", ":", "slice_", "=", "tuple", "(", "slice", "(", "*", "t", ")", "for", "t", "in", "zip", "(", "self", ".", "start", ",", "self", ".", "stop", ",", "self", ".", "step", ")", ")", "return", "self", ".", "var",...
[ 130, 4 ]
[ 137, 31 ]
python
en
['en', 'error', 'th']
False
Arrayterator.flat
(self)
A 1-D flat iterator for Arrayterator objects. This iterator returns elements of the array to be iterated over in `Arrayterator` one by one. It is similar to `flatiter`. See Also -------- Arrayterator flatiter Examples -------- >>> a = n...
A 1-D flat iterator for Arrayterator objects.
def flat(self): """ A 1-D flat iterator for Arrayterator objects. This iterator returns elements of the array to be iterated over in `Arrayterator` one by one. It is similar to `flatiter`. See Also -------- Arrayterator flatiter Examples ...
[ "def", "flat", "(", "self", ")", ":", "for", "block", "in", "self", ":", "for", "value", "in", "block", ".", "flat", ":", "yield", "value" ]
[ 140, 4 ]
[ 166, 27 ]
python
en
['en', 'error', 'th']
False
Arrayterator.shape
(self)
The shape of the array to be iterated over. For an example, see `Arrayterator`.
The shape of the array to be iterated over.
def shape(self): """ The shape of the array to be iterated over. For an example, see `Arrayterator`. """ return tuple(((stop-start-1)//step+1) for start, stop, step in zip(self.start, self.stop, self.step))
[ "def", "shape", "(", "self", ")", ":", "return", "tuple", "(", "(", "(", "stop", "-", "start", "-", "1", ")", "//", "step", "+", "1", ")", "for", "start", ",", "stop", ",", "step", "in", "zip", "(", "self", ".", "start", ",", "self", ".", "st...
[ 169, 4 ]
[ 177, 54 ]
python
en
['en', 'error', 'th']
False
TestFromrecords.test_fromrecords_0len
(self)
Verify fromrecords works with a 0-length input
Verify fromrecords works with a 0-length input
def test_fromrecords_0len(self): """ Verify fromrecords works with a 0-length input """ dtype = [('a', float), ('b', float)] r = np.rec.fromrecords([], dtype=dtype) assert_equal(r.shape, (0,))
[ "def", "test_fromrecords_0len", "(", "self", ")", ":", "dtype", "=", "[", "(", "'a'", ",", "float", ")", ",", "(", "'b'", ",", "float", ")", "]", "r", "=", "np", ".", "rec", ".", "fromrecords", "(", "[", "]", ",", "dtype", "=", "dtype", ")", "a...
[ 36, 4 ]
[ 40, 35 ]
python
en
['en', 'en', 'en']
True
TestRecord.test_nested_fields_are_records
(self, nfields)
Test that nested structured types are treated as records too
Test that nested structured types are treated as records too
def test_nested_fields_are_records(self, nfields): """ Test that nested structured types are treated as records too """ dt = np.dtype([('a', np.uint8), ('b', np.uint8), ('c', np.uint8)][:nfields]) dt_outer = np.dtype([('inner', dt)]) data = np.zeros(3, dt_outer).view(np.recarray) ...
[ "def", "test_nested_fields_are_records", "(", "self", ",", "nfields", ")", ":", "dt", "=", "np", ".", "dtype", "(", "[", "(", "'a'", ",", "np", ".", "uint8", ")", ",", "(", "'b'", ",", "np", ".", "uint8", ")", ",", "(", "'c'", ",", "np", ".", "...
[ 460, 4 ]
[ 471, 52 ]
python
en
['en', 'en', 'en']
True
TestRecord.test_nested_dtype_padding
(self)
test that trailing padding is preserved
test that trailing padding is preserved
def test_nested_dtype_padding(self): """ test that trailing padding is preserved """ # construct a dtype with padding at the end dt = np.dtype([('a', np.uint8), ('b', np.uint8), ('c', np.uint8)]) dt_padded_end = dt[['a', 'b']] assert dt_padded_end.itemsize == dt.itemsize ...
[ "def", "test_nested_dtype_padding", "(", "self", ")", ":", "# construct a dtype with padding at the end", "dt", "=", "np", ".", "dtype", "(", "[", "(", "'a'", ",", "np", ".", "uint8", ")", ",", "(", "'b'", ",", "np", ".", "uint8", ")", ",", "(", "'c'", ...
[ 473, 4 ]
[ 486, 57 ]
python
en
['en', 'en', 'en']
True
short_path
(path, cwd=None)
Return relative or absolute path name, whichever is shortest.
Return relative or absolute path name, whichever is shortest.
def short_path(path, cwd=None): """ Return relative or absolute path name, whichever is shortest. """ if not isinstance(path, str): return path if cwd is None: cwd = os.getcwd() abspath = os.path.abspath(path) relpath = os.path.relpath(path, cwd) if len(abspath) <= len(re...
[ "def", "short_path", "(", "path", ",", "cwd", "=", "None", ")", ":", "if", "not", "isinstance", "(", "path", ",", "str", ")", ":", "return", "path", "if", "cwd", "is", "None", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "abspath", "=", "os", ...
[ 131, 0 ]
[ 143, 18 ]
python
en
['en', 'error', 'th']
False
get_all_dict
(module)
Return a copy of the __all__ dict with irrelevant items removed.
Return a copy of the __all__ dict with irrelevant items removed.
def get_all_dict(module): """Return a copy of the __all__ dict with irrelevant items removed.""" if hasattr(module, "__all__"): all_dict = copy.deepcopy(module.__all__) else: all_dict = copy.deepcopy(dir(module)) all_dict = [name for name in all_dict if not name.s...
[ "def", "get_all_dict", "(", "module", ")", ":", "if", "hasattr", "(", "module", ",", "\"__all__\"", ")", ":", "all_dict", "=", "copy", ".", "deepcopy", "(", "module", ".", "__all__", ")", "else", ":", "all_dict", "=", "copy", ".", "deepcopy", "(", "dir...
[ 184, 0 ]
[ 217, 45 ]
python
en
['en', 'en', 'en']
True
compare
(all_dict, others, names, module_name)
Return sets of objects only in __all__, refguide, or completely missing.
Return sets of objects only in __all__, refguide, or completely missing.
def compare(all_dict, others, names, module_name): """Return sets of objects only in __all__, refguide, or completely missing.""" only_all = set() for name in all_dict: if name not in names: for pat in REFGUIDE_AUTOSUMMARY_SKIPLIST: if re.match(pat, module_name + '.' + na...
[ "def", "compare", "(", "all_dict", ",", "others", ",", "names", ",", "module_name", ")", ":", "only_all", "=", "set", "(", ")", "for", "name", "in", "all_dict", ":", "if", "name", "not", "in", "names", ":", "for", "pat", "in", "REFGUIDE_AUTOSUMMARY_SKIPL...
[ 220, 0 ]
[ 243, 38 ]
python
en
['en', 'en', 'en']
True
check_rest
(module, names, dots=True)
Check reStructuredText formatting of docstrings Returns: [(name, success_flag, output), ...]
Check reStructuredText formatting of docstrings
def check_rest(module, names, dots=True): """ Check reStructuredText formatting of docstrings Returns: [(name, success_flag, output), ...] """ try: skip_types = (dict, str, unicode, float, int) except NameError: # python 3 skip_types = (dict, str, float, int) resu...
[ "def", "check_rest", "(", "module", ",", "names", ",", "dots", "=", "True", ")", ":", "try", ":", "skip_types", "=", "(", "dict", ",", "str", ",", "unicode", ",", "float", ",", "int", ")", "except", "NameError", ":", "# python 3", "skip_types", "=", ...
[ 379, 0 ]
[ 441, 18 ]
python
en
['en', 'error', 'th']
False
_run_doctests
(tests, full_name, verbose, doctest_warnings)
Run modified doctests for the set of `tests`. Returns: list of [(success_flag, output), ...]
Run modified doctests for the set of `tests`.
def _run_doctests(tests, full_name, verbose, doctest_warnings): """Run modified doctests for the set of `tests`. Returns: list of [(success_flag, output), ...] """ flags = NORMALIZE_WHITESPACE | ELLIPSIS | IGNORE_EXCEPTION_DETAIL runner = DTRunner(full_name, checker=Checker(), optionflags=flags, ...
[ "def", "_run_doctests", "(", "tests", ",", "full_name", ",", "verbose", ",", "doctest_warnings", ")", ":", "flags", "=", "NORMALIZE_WHITESPACE", "|", "ELLIPSIS", "|", "IGNORE_EXCEPTION_DETAIL", "runner", "=", "DTRunner", "(", "full_name", ",", "checker", "=", "C...
[ 616, 0 ]
[ 669, 26 ]
python
en
['en', 'en', 'en']
True
check_doctests
(module, verbose, ns=None, dots=True, doctest_warnings=False)
Check code in docstrings of the module's public symbols. Returns: list of [(item_name, success_flag, output), ...]
Check code in docstrings of the module's public symbols.
def check_doctests(module, verbose, ns=None, dots=True, doctest_warnings=False): """Check code in docstrings of the module's public symbols. Returns: list of [(item_name, success_flag, output), ...] """ if ns is None: ns = dict(DEFAULT_NAMESPACE) # Loop over non-deprecat...
[ "def", "check_doctests", "(", "module", ",", "verbose", ",", "ns", "=", "None", ",", "dots", "=", "True", ",", "doctest_warnings", "=", "False", ")", ":", "if", "ns", "is", "None", ":", "ns", "=", "dict", "(", "DEFAULT_NAMESPACE", ")", "# Loop over non-d...
[ 672, 0 ]
[ 721, 18 ]
python
en
['en', 'en', 'en']
True
check_doctests_testfile
(fname, verbose, ns=None, dots=True, doctest_warnings=False)
Check code in a text file. Mimic `check_doctests` above, differing mostly in test discovery. (which is borrowed from stdlib's doctest.testfile here, https://github.com/python-git/python/blob/master/Lib/doctest.py) Returns: list of [(item_name, success_flag, output), ...] Notes ----- We ...
Check code in a text file.
def check_doctests_testfile(fname, verbose, ns=None, dots=True, doctest_warnings=False): """Check code in a text file. Mimic `check_doctests` above, differing mostly in test discovery. (which is borrowed from stdlib's doctest.testfile here, https://github.com/python-git/python/blob/...
[ "def", "check_doctests_testfile", "(", "fname", ",", "verbose", ",", "ns", "=", "None", ",", "dots", "=", "True", ",", "doctest_warnings", "=", "False", ")", ":", "results", "=", "[", "]", "if", "ns", "is", "None", ":", "ns", "=", "dict", "(", "DEFAU...
[ 724, 0 ]
[ 809, 18 ]
python
en
['en', 'en', 'en']
True
log_request
(req: 'flask_request', res: str)
Log details of the web request and the results.
Log details of the web request and the results.
def log_request(req: 'flask_request', res: str) -> None: """Log details of the web request and the results.""" # raise Exception("Something awful just happened.") with UseDatabase(app.config['dbconfig']) as cursor: _SQL = """insert into log (phrase, letters, ip, browser_string, r...
[ "def", "log_request", "(", "req", ":", "'flask_request'", ",", "res", ":", "str", ")", "->", "None", ":", "# raise Exception(\"Something awful just happened.\")", "with", "UseDatabase", "(", "app", ".", "config", "[", "'dbconfig'", "]", ")", "as", "cursor", ":",...
[ 28, 0 ]
[ 42, 37 ]
python
en
['en', 'en', 'en']
True
do_search
()
Extract the posted data; perform the search; return results.
Extract the posted data; perform the search; return results.
def do_search() -> 'html': """Extract the posted data; perform the search; return results.""" phrase = request.form['phrase'] letters = request.form['letters'] title = 'Here are your results:' results = str(search4letters(phrase, letters)) try: log_request(request, results) except Ex...
[ "def", "do_search", "(", ")", "->", "'html'", ":", "phrase", "=", "request", ".", "form", "[", "'phrase'", "]", "letters", "=", "request", ".", "form", "[", "'letters'", "]", "title", "=", "'Here are your results:'", "results", "=", "str", "(", "search4let...
[ 46, 0 ]
[ 60, 48 ]
python
en
['en', 'en', 'en']
True
entry_page
()
Display this webapp's HTML form.
Display this webapp's HTML form.
def entry_page() -> 'html': """Display this webapp's HTML form.""" return render_template('entry.html', the_title='Welcome to search4letters on the web!')
[ "def", "entry_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters on the web!'", ")" ]
[ 65, 0 ]
[ 68, 77 ]
python
en
['en', 'en', 'en']
True
view_the_log
()
Display the contents of the log file as a HTML table.
Display the contents of the log file as a HTML table.
def view_the_log() -> 'html': """Display the contents of the log file as a HTML table.""" try: with UseDatabase(app.config['dbconfig']) as cursor: _SQL = """select phrase, letters, ip, browser_string, results from log""" cursor.execute(_SQL) conten...
[ "def", "view_the_log", "(", ")", "->", "'html'", ":", "try", ":", "with", "UseDatabase", "(", "app", ".", "config", "[", "'dbconfig'", "]", ")", "as", "cursor", ":", "_SQL", "=", "\"\"\"select phrase, letters, ip, browser_string, results\n from log\...
[ 73, 0 ]
[ 95, 18 ]
python
en
['en', 'en', 'en']
True
propagate_ids
(previous_poses, current_poses, threshold=3)
Propagate poses ids from previous frame results. Id is propagated, if there are at least `threshold` similar keypoints between pose from previous frame and current. :param previous_poses: poses from previous frame with ids :param current_poses: poses from current frame to assign ids :param threshold: m...
Propagate poses ids from previous frame results. Id is propagated, if there are at least `threshold` similar keypoints between pose from previous frame and current.
def propagate_ids(previous_poses, current_poses, threshold=3): """Propagate poses ids from previous frame results. Id is propagated, if there are at least `threshold` similar keypoints between pose from previous frame and current. :param previous_poses: poses from previous frame with ids :param current...
[ "def", "propagate_ids", "(", "previous_poses", ",", "current_poses", ",", "threshold", "=", "3", ")", ":", "current_poses_sorted_ids", "=", "list", "(", "range", "(", "len", "(", "current_poses", ")", ")", ")", "current_poses_sorted_ids", "=", "sorted", "(", "...
[ 61, 0 ]
[ 92, 114 ]
python
en
['en', 'en', 'en']
True
RuleVariableTests.test_rule_variable_decorator_internals
(self)
Make sure that the expected attributes are attached to a function by the variable decorators.
Make sure that the expected attributes are attached to a function by the variable decorators.
def test_rule_variable_decorator_internals(self): """Make sure that the expected attributes are attached to a function by the variable decorators. """ def some_test_function(self): pass wrapper = rule_variable(StringType, 'Foo Name', options=['op1', 'op2']) ...
[ "def", "test_rule_variable_decorator_internals", "(", "self", ")", ":", "def", "some_test_function", "(", "self", ")", ":", "pass", "wrapper", "=", "rule_variable", "(", "StringType", ",", "'Foo Name'", ",", "options", "=", "[", "'op1'", ",", "'op2'", "]", ")"...
[ 29, 4 ]
[ 42, 54 ]
python
en
['en', 'en', 'en']
True
scale_batch_size
( trainer, model: LightningModule, mode: str = 'power', steps_per_trial: int = 3, init_val: int = 2, max_trials: int = 25, batch_arg_name: str = 'batch_size', **fit_kwargs )
r""" Will iteratively try to find the largest batch size for a given model that does not give an out of memory (OOM) error. Args: trainer: The Trainer model: Model to fit. mode: string setting the search mode. Either `power` or `binsearch`. If mode is `power` we keep mu...
r""" Will iteratively try to find the largest batch size for a given model that does not give an out of memory (OOM) error.
def scale_batch_size( trainer, model: LightningModule, mode: str = 'power', steps_per_trial: int = 3, init_val: int = 2, max_trials: int = 25, batch_arg_name: str = 'batch_size', **fit_kwargs ): r""" Will iteratively try to find the largest batch size for a given model that d...
[ "def", "scale_batch_size", "(", "trainer", ",", "model", ":", "LightningModule", ",", "mode", ":", "str", "=", "'power'", ",", "steps_per_trial", ":", "int", "=", "3", ",", "init_val", ":", "int", "=", "2", ",", "max_trials", ":", "int", "=", "25", ","...
[ 27, 0 ]
[ 129, 19 ]
python
cy
['en', 'cy', 'hi']
False
_run_power_scaling
(trainer, model, new_size, batch_arg_name, max_trials, **fit_kwargs)
Batch scaling mode where the size is doubled at each iteration until an OOM error is encountered.
Batch scaling mode where the size is doubled at each iteration until an OOM error is encountered.
def _run_power_scaling(trainer, model, new_size, batch_arg_name, max_trials, **fit_kwargs): """ Batch scaling mode where the size is doubled at each iteration until an OOM error is encountered. """ for _ in range(max_trials): garbage_collection_cuda() trainer.global_step = 0 # reset aft...
[ "def", "_run_power_scaling", "(", "trainer", ",", "model", ",", "new_size", ",", "batch_arg_name", ",", "max_trials", ",", "*", "*", "fit_kwargs", ")", ":", "for", "_", "in", "range", "(", "max_trials", ")", ":", "garbage_collection_cuda", "(", ")", "trainer...
[ 174, 0 ]
[ 197, 19 ]
python
en
['en', 'en', 'en']
True
_run_binsearch_scaling
(trainer, model, new_size, batch_arg_name, max_trials, **fit_kwargs)
Batch scaling mode where the size is initially is doubled at each iteration until an OOM error is encountered. Hereafter, the batch size is further refined using a binary search
Batch scaling mode where the size is initially is doubled at each iteration until an OOM error is encountered. Hereafter, the batch size is further refined using a binary search
def _run_binsearch_scaling(trainer, model, new_size, batch_arg_name, max_trials, **fit_kwargs): """ Batch scaling mode where the size is initially is doubled at each iteration until an OOM error is encountered. Hereafter, the batch size is further refined using a binary search """ high = None ...
[ "def", "_run_binsearch_scaling", "(", "trainer", ",", "model", ",", "new_size", ",", "batch_arg_name", ",", "max_trials", ",", "*", "*", "fit_kwargs", ")", ":", "high", "=", "None", "count", "=", "0", "while", "True", ":", "garbage_collection_cuda", "(", ")"...
[ 200, 0 ]
[ 241, 19 ]
python
en
['en', 'en', 'en']
True
_adjust_batch_size
( trainer, batch_arg_name: str = 'batch_size', factor: float = 1.0, value: Optional[int] = None, desc: Optional[str] = None )
Helper function for adjusting the batch size. Args: trainer: instance of pytorch_lightning.Trainer batch_arg_name: name of the field where batch_size is stored. factor: value which the old batch size is multiplied by to get the new batch size value: if a value is giv...
Helper function for adjusting the batch size.
def _adjust_batch_size( trainer, batch_arg_name: str = 'batch_size', factor: float = 1.0, value: Optional[int] = None, desc: Optional[str] = None ) -> Tuple[int, bool]: """ Helper function for adjusting the batch size. Args: trainer: instance of pytorch_lightning.Trainer ba...
[ "def", "_adjust_batch_size", "(", "trainer", ",", "batch_arg_name", ":", "str", "=", "'batch_size'", ",", "factor", ":", "float", "=", "1.0", ",", "value", ":", "Optional", "[", "int", "]", "=", "None", ",", "desc", ":", "Optional", "[", "str", "]", "=...
[ 244, 0 ]
[ 281, 28 ]
python
en
['en', 'da', 'en']
True