pyvista.core._validation.check.check_subdtype#
- check_subdtype(
- input_obj: npt.DTypeLike | _ArrayLikeOrScalar[NumberType],
- /,
- base_dtype: npt.DTypeLike | tuple[npt.DTypeLike, ...] | list[npt.DTypeLike],
- *,
- name: str = 'Input',
Check if an input’s data-type is a subtype of another data-type(s).
- Parameters:
- input_obj
float
|ArrayLike
[float
] |numpy.typing.DTypeLike
dtype
object (or object coercible to one) or an array-like object. If array-like, the dtype of the array is used.- base_dtype
numpy.typing.DTypeLike
|Sequence
[numpy.typing.DTypeLike
] dtype
-like object or a sequence ofdtype
-like objects. Theinput_obj
must be a subtype of this value. If a sequence,input_obj
must be a subtype of at least one of the specified dtypes.- name
str
, default: “Input” Variable name to use in the error messages if any are raised.
- input_obj
- Raises:
TypeError
If
input_obj
is not a subtype ofbase_dtype
.
See also
Examples
Check if
float
is a subtype ofnp.floating
.>>> import numpy as np >>> from pyvista import _validation >>> _validation.check_subdtype(float, np.floating)
Check from multiple allowable dtypes.
>>> _validation.check_subdtype(int, [np.integer, np.floating])
Check an array’s dtype.
>>> array = np.array([1, 2, 3], dtype='uint8') >>> _validation.check_subdtype(array, np.integer)