dtype¶
Helper functions for validation of dtype.
For literal dtypes intended for use by end-users, see numpydantic.dtype
- validate_dtype(dtype: Any, target: str | type | Any | generic) bool[source]¶
Validate a dtype against the target dtype.
If dtype or target are Any, validation passes trivially. The dtype may be Any when the dtype can’t be determined, but failure to determine dtype shouldn’t be fatal (e.g. BaseModel dtypes for empty arrays).
- Parameters:
dtype – The dtype to validate
target (
DtypeType) – The target dtype
- Returns:
Trueif valid,Falseotherwise- Return type: