pyvista_validation.validate.validate_number#
- pyvista_validation.validate.validate_number(num: float, /, *, reshape: bool = True, **kwargs)#
Validate a real, finite number.
By default, the number is checked to ensure it:
is scalar or is an array which can be reshaped as a scalar
is a real number
is finite
- Parameters:
- numfloat
Number to validate.
- reshapebool, default: True
If
True, 1D arrays with 1 element are considered valid input and are reshaped to be 0-dimensional.- **kwargsdict, optional
Additional keyword arguments passed to
validate_array().
- Returns:
- outputint | float
Validated number.
See also
validate_arrayGeneric array validation function.
Examples
Validate a number.
>>> from pyvista_validation import validate_number >>> validate_number(1) 1
1D arrays are automatically reshaped.
>>> validate_number([42.0]) 42.0
Additional checks can be added as needed.
>>> validate_number(10, must_be_in_range=[0, 10], must_be_integer=True) 10