Skip to main content

pyvista-validation

Validate and standardize array-like input.

These are the input validation functions developed for PyVista, extracted into a standalone package so any project can use them. NumPy is the only required dependency: PyVista is not needed, and VTK and SciPy are optional.

The functions are useful when writing Python methods that accept flexible array-like input, wrapping VTK, or anywhere you want one standard representation out of many possible inputs.

Warning — The API of this package is unstable and likely to change between minor versions (for example 0.1.0 to 0.2.0). Pin the exact version you depend on, for example pyvista-validation==0.1.0.

Installation

pip install pyvista-validation

VTK and SciPy are only needed to validate their own object types, so they ship as extras:

pip install pyvista-validation[vtk]    # accept vtkMatrix3x3, vtkMatrix4x4, vtkTransform
pip install pyvista-validation[scipy]  # accept scipy.spatial.transform.Rotation
pip install pyvista-validation[all]    # both

Neither is imported unless you actually pass one of their objects in.

The wheels carry a C extension that runs the checks; the package works the same without it, from the source distribution or with PYVISTA_VALIDATION_ACCELERATE=false in the environment.

Two families of function

A check function:

  • Performs a simple validation on a single input variable.
  • Raises an error if the check fails due to invalid input.
  • Does not modify its input, and returns it unchanged, typed as what the check established, so a check can be used inline.

A validate function:

  • Uses check functions to check the type and/or value of input arguments.
  • Applies optional constraints -- for example input or output must have a specific length, shape, type, data-type, etc.
  • Accepts many different input types or values and standardizes the output as a single representation with known properties.

Usage

validate functions return a standard representation:

>>> import numpy as np
>>> from pyvista_validation import validate_array3
>>> from pyvista_validation import validate_arrayNx3
>>> from pyvista_validation import validate_data_range

>>> validate_array3([1, 2, 3])
array([1, 2, 3])

>>> validate_arrayNx3([[1, 2, 3], [4, 5, 6]])
array([[1, 2, 3],
       [4, 5, 6]])

>>> validate_data_range([0, 1])
(0, 1)

A 3x3 input to validate_transform4x4 is padded into a 4x4 matrix:

>>> from pyvista_validation import validate_transform4x4

>>> validate_transform4x4(np.eye(3))
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

validate_array is the general-purpose entry point that the others build on, and takes the constraints as keyword arguments:

>>> from pyvista_validation import validate_array

>>> validate_array(
...     [1, 2, 3], must_have_shape=(3,), must_be_in_range=[0, 5], dtype_out=float
... )
array([1., 2., 3.])

check functions return their input unchanged and raise on failure:

>>> from pyvista_validation import check_range
>>> from pyvista_validation import check_subdtype

>>> check_range([1, 5], rng=[0, 3])
Traceback (most recent call last):
    ...
ValueError: Array values must all be less than or equal to 3.

>>> check_subdtype(np.array([1.0]), np.integer)
Traceback (most recent call last):
    ...
TypeError: Input has incorrect dtype of 'float64'. The dtype must be a subtype of <class 'numpy.integer'>.

Error messages name the offending value and the constraint it violated:

>>> validate_array3([1, 2])
Traceback (most recent call last):
    ...
ValueError: Array has shape (2,) which is not allowed. Shape must be one of [(3,), (1, 3), (3, 1)].

Pass name= to any function to control how the input is described in that message.

Common use cases

To validate Use
A 3-element vector validate_array3
An Nx3 point or vector array validate_arrayNx3
Point or cell IDs validate_arrayN_unsigned
A transformation matrix validate_transform4x4
A rotation matrix validate_rotation

API reference

validate functions

Function Description
validate_array Check and validate a numeric array meets specific requirements.
validate_array3 Validate a numeric 1D array with 3 elements.
validate_arrayN Validate a numeric 1D array.
validate_arrayN_unsigned Validate a numeric 1D array of non-negative (unsigned) integers.
validate_arrayNx3 Validate an array is numeric and has shape Nx3.
validate_axes Validate 3D axes vectors.
validate_data_range Validate a data range.
validate_dimensionality Validate a dimensionality.
validate_number Validate a real, finite number.
validate_rotation Validate a rotation as a 3x3 matrix.
validate_transform3x3 Validate transform-like input as a 3x3 ndarray.
validate_transform4x4 Validate transform-like input as a 4x4 ndarray.

check functions

Function Description
check_contains Check if an item is in a container.
check_finite Check if an array has finite values, that is, no NaN or Inf values.
check_greater_than Check if an array's elements are all greater than some value.
check_instance Check if an object is an instance of the given type or types.
check_integer Check if an array has integer or integer-like float values.
check_iterable Check if an object is an instance of Iterable.
check_iterable_items Check if an iterable's items all have a specified type.
check_length Check if the length of an array meets specific requirements.
check_less_than Check if an array's elements are all less than some value.
check_ndim Check if an array has the specified number of dimensions.
check_nonnegative Check if an array's elements are all nonnegative.
check_number Check if an object is an instance of Number.
check_range Check if an array's values are all within a specific range.
check_real Check if an array has real numbers (float or integer type).
check_sequence Check if an object is an instance of Sequence.
check_shape Check if an array has the specified shape.
check_sorted Check if an array's values are sorted.
check_string Check if an object is an instance of str.
check_subdtype Check if an input's data-type is a subtype of another data-type or data-types.
check_type Check if an object is one of the given type or types.

Every function has a full docstring with parameters and examples.

Relationship to PyVista

This code began as pyvista.core._validation and keeps its full commit history here. PyVista is a downstream consumer, and CI installs this checkout into PyVista and runs PyVista's own core test suite against it on every change.

One PyVista-specific helper, _validate_color_sequence, was not moved: it is built on pyvista.plotting's Color class and stays with PyVista.

License

MIT

Metadata

Release files for pyvista-validation 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvista-validation 0.5.3
File Size Uploaded
pyvista_validation-0.5.3.tar.gz 561.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyvista-validation 0.5.3
File
pyvista_validation-0.5.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pyvista_validation-0.5.3-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details
pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
pyvista_validation-0.5.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
pyvista_validation-0.5.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
pyvista_validation-0.5.3-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
pyvista_validation-0.5.3-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 2.0 MB

Release files / pyvista_validation-0.5.3.tar.gz

Download URL pyvista_validation-0.5.3.tar.gz
Size 561.0 kB
Tags Source
SHA-256 checksum
How to use checksums
aeb1037cfe19c9027d2463183739d90ddc34983a40f9c75b730c3467c61f3437
BLAKE2b-256 checksum
How to use checksums
5c552b7ad94d59fc851fa733030ccd1b187f629ec5e6b5fe17a80f78b4c2b205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-win_amd64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-win_amd64.whl
Size 76.7 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fd118552d7f7f1eb9ff5d85585d399b73c98f0acb4018ab89aeb57d94e03bd32
BLAKE2b-256 checksum
How to use checksums
b473f3b6c810609a91c9434ebfa1fe9139b1a92c5e2af7b2b702693dbae0bd4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-win32.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-win32.whl
Size 70.8 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
ddfe8e07b4d11713ea08069b69b06ccf72895eaac0c55aa6969c0923a6fd3687
BLAKE2b-256 checksum
How to use checksums
e6028208a17ee93ed6dfe152df64afebb92059930047ce5d82e26a8749e0cc97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl
Size 262.4 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
abda5d3d6e6ae82d97014e4557cd208945d55fbc0019b4418bea929a4dfc0f4d
BLAKE2b-256 checksum
How to use checksums
b6d7eea82d43a96efc33ba38c65b0777649b8c80ba45103b5cc87387f6c15b22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl
Size 294.4 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2f719a1cc0279f0fb063f52467f63c503f18973b43e3c9cdb86d5f9367173199
BLAKE2b-256 checksum
How to use checksums
47d2fa7c0cf7746f466f657f8d24627281a4942cb0d51a33c48d5bcd40eae3c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 264.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
08895724c508d28a5c294141267aead47801867eb148cadd0a12a1c74b2009d6
BLAKE2b-256 checksum
How to use checksums
488a68101449cf6caf5bdf3ad5d58fc8a232f2edf03ec8800562e10f1199b7a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 296.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
1c8ccc5ba102f46078bdab8402b36a98435f5346cc9d9858ff350e85ff049c62
BLAKE2b-256 checksum
How to use checksums
b65ff309befb464abde5609befd71a7c11d888f8407d91b393e1830ffd90b39c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-macosx_11_0_arm64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-macosx_11_0_arm64.whl
Size 89.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
22e5fb34f4e513c762f4689cb7f1458cfe3a83f7f3671d57c011b6e46e81f458
BLAKE2b-256 checksum
How to use checksums
08fc1b9c01e4bf676ae1e80cc3db278f22af14cbcc0b97ca6f64805ce862a37c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / pyvista_validation-0.5.3-cp310-abi3-macosx_10_9_x86_64.whl

Download URL pyvista_validation-0.5.3-cp310-abi3-macosx_10_9_x86_64.whl
Size 85.8 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
0159610693aec89487c1f3aa1d7d68113a23063a218f19cda64654e1d3926dc3
BLAKE2b-256 checksum
How to use checksums
d79d2f16dc332aea7f65b4243da3622fa41ea5826d355d1c76d4e8d6ca8f797c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.4

9 release files

This release

0.5.3 This release

9 release files

0.5.2

9 release files

0.5.1

9 release files

0.5.0

9 release files

0.4.0

9 release files

0.3.0

9 release files

0.2.3

9 release files

0.2.2

9 release files

0.2.1

9 release files

0.2.0

9 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page