pyvista.core._validation.validate.validate_arrayNx3#

validate_arrayNx3(arr, /, *, reshape=True, **kwargs)[source]#

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:
arrarray_like

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_arrayN

Similar function for one-dimensional arrays.

validate_array

Generic array validation function.

Examples

Validate an Nx3 array.

>>> from pyvista import _validation
>>> _validation.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.

>>> _validation.validate_arrayNx3([1, 2, 3])
array([[1, 2, 3]])

Add additional constraints.

>>> _validation.validate_arrayNx3(
...     ((1, 2, 3), (4, 5, 6)), must_be_in_range=[0, 10]
... )
array([[1, 2, 3],
       [4, 5, 6]])