pyvista.core._validation.validate.validate_array3#
- validate_array3(
- arr: float | VectorLike[float] | MatrixLike[float],
- /,
- *,
- reshape: bool = True,
- broadcast: bool = False,
- **kwargs,
Validate a numeric 1D array with 3 elements.
The array is checked to ensure its input values:
have shape
(3,)or can be reshaped to(3,)are numeric and real
The returned array is formatted so that it has shape
(3,).- Parameters:
- arr
float|VectorLike[float] |MatrixLike[float] Array to validate.
- reshapebool, default:
True If
True, 2D vectors with shape(1, 3)are considered valid input, and are reshaped to(3,)to ensure the output is consistently one-dimensional.- broadcastbool, default:
False If
True, scalar values or 1D arrays with a single element are considered valid input and the single value is broadcast to a length 3 array.- **kwargs
dict,optional Additional keyword arguments passed to
validate_array().
- arr
- Returns:
np.ndarrayValidated 1D array with 3 elements.
See also
validate_numberSimilar function for a single number.
validate_arrayNSimilar function for one-dimensional arrays.
validate_arrayGeneric array validation function.
Examples
Validate a 1D array with three elements.
>>> from pyvista import _validation >>> _validation.validate_array3((1, 2, 3)) array([1, 2, 3])
2D 3-element arrays are automatically reshaped to be 1D.
>>> _validation.validate_array3([[1, 2, 3]]) array([1, 2, 3])
Scalar 0-dimensional values can be automatically broadcast as a 3-element 1D array.
>>> _validation.validate_array3(42.0, broadcast=True) array([42.0, 42.0, 42.0])
Add additional constraints if needed.
>>> _validation.validate_array3((1, 2, 3), must_be_nonnegative=True) array([1, 2, 3])