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
Examples#
Download Python source code | Download Jupyter notebook
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
See Also#
validate_arrayGeneric array validation function.