Validate scalar parameters type and value.
The scalar parameter to validate.
The name of the parameter to be printed in error messages.
Acceptable data types for the parameter.
The minimum valid value the parameter can take. If None (default) it is implied that the parameter does not have a lower bound.
The maximum valid value the parameter can take. If None (default) it is implied that the parameter does not have an upper bound.
Whether the interval defined by min_val
and max_val
should include the boundaries. Possible choices are:
"left"
: only min_val
is included in the valid interval. It is equivalent to the interval [ min_val, max_val )
.
"right"
: only max_val
is included in the valid interval. It is equivalent to the interval ( min_val, max_val ]
.
"both"
: min_val
and max_val
are included in the valid interval. It is equivalent to the interval [ min_val, max_val ]
.
"neither"
: neither min_val
nor max_val
are included in the valid interval. It is equivalent to the interval ( min_val, max_val )
.
The validated number.
If the parameter’s type does not match the desired type.
If the parameter’s value violates the given bounds. If min_val
, max_val
and include_boundaries
are inconsistent.
Examples
>>> from sklearn.utils.validation import check_scalar >>> check_scalar(10, "x", int, min_val=1, max_val=20) 10
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4