pyvista.core._validation.validate.validate_dimensionality#
- validate_dimensionality(
- dimensionality: Literal[0, 1, 2, 3, '0D', '1D', '2D', '3D'] | pyvista.ArrayLike,
- /,
- *,
- reshape: bool = True,
- **kwargs,
Validate a dimensionality.
By default, the dimensionality is checked to ensure it:
is scalar or is an array which can be reshaped as a scalar
is an integer in the inclusive range
[0, 3]
or is a valid alias among
'0D'
,'1D'
,'2D'
, or'3D'
- Parameters:
- dimensionality
Literal
[0, 1, 2, 3, ‘0D’, ‘1D’, ‘2D’, ‘3D’] |ArrayLike
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()
.
- dimensionality
- Returns:
int
Validated dimensionality.
Examples
Validate a dimensionality.
>>> from pyvista import _validation >>> _validation.validate_dimensionality('1D') 1
1D arrays are automatically reshaped.
>>> _validation.validate_dimensionality([3]) 3