pyvista.core._validation.validate.validate_number#
- validate_number(num: float, /, *, reshape: bool = True, **kwargs)[source]#
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:
- num
float
Number to validate.
- reshapebool, default:
True
If
True
, 1D arrays with 1 element are considered valid input and are reshaped to be 0-dimensional.- **kwargs
dict
,optional
Additional keyword arguments passed to
validate_array()
.
- num
- Returns:
See also
validate_array
Generic array validation function.
Examples
Validate a number.
>>> from pyvista import _validation >>> _validation.validate_number(1) 1
1D arrays are automatically reshaped.
>>> _validation.validate_number([42.0]) 42.0
Additional checks can be added as needed.
>>> _validation.validate_number( ... 10, must_be_in_range=[0, 10], must_be_integer=True ... ) 10