pyvista_validation.validate.validate_arrayNx3#
- pyvista_validation.validate.validate_arrayNx3(arr: VectorLike[float] | MatrixLike[float], /, *, reshape: bool = True, **kwargs)#
Validate an array is numeric and has shape Nx3.
The array is checked to ensure its input values:
have shape
(N, 3)or can be reshaped to(N, 3)are numeric
The returned array is formatted so that its values:
have shape
(N, 3).
- Parameters:
- arrVectorLike[float] | MatrixLike[float]
Array to validate.
- reshapebool, default: True
If
True, 1D arrays with 3 elements are considered valid input and are reshaped to(1, 3)to ensure the output is two-dimensional.- **kwargsdict, optional
Additional keyword arguments passed to
validate_array().
- Returns:
- np.ndarray
Validated array with shape
(N, 3).
See also
validate_arrayNSimilar function for one-dimensional arrays.
validate_arrayGeneric array validation function.
Examples
Validate an Nx3 array.
>>> from pyvista_validation import validate_arrayNx3 >>> validate_arrayNx3(((1, 2, 3), (4, 5, 6))) array([[1, 2, 3], [4, 5, 6]])
One-dimensional 3-element arrays are automatically reshaped to 2D.
>>> validate_arrayNx3([1, 2, 3]) array([[1, 2, 3]])
Add additional constraints.
>>> validate_arrayNx3(((1, 2, 3), (4, 5, 6)), must_be_in_range=[0, 10]) array([[1, 2, 3], [4, 5, 6]])