This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / issubdtype

function

numpy:issubdtype

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/numerictypes.py :475

Signature

def   issubdtype ( arg1 arg2 )

Summary

Returns True if first argument is a typecode lower/equal in type hierarchy.

Extended Summary

This is like the builtin issubclass, but for dtypes.

Parameters

arg1, arg2 : dtype_like

dtype or object coercible to one

Returns

out : bool

Examples

`issubdtype` can be used to check the type of arrays:
ints = np.array([1, 2, 3], dtype=np.int32)
np.issubdtype(ints.dtype, np.integer)
np.issubdtype(ints.dtype, np.floating)
floats = np.array([1, 2, 3], dtype=np.float32)
np.issubdtype(floats.dtype, np.integer)
np.issubdtype(floats.dtype, np.floating)
Similar types of different sizes are not subdtypes of each other:
np.issubdtype(np.float64, np.float32)
np.issubdtype(np.float32, np.float64)
but both are subtypes of `floating`:
np.issubdtype(np.float64, np.floating)
np.issubdtype(np.float32, np.floating)
For convenience, dtype-like objects are allowed too:
np.issubdtype('S1', np.bytes_)
np.issubdtype('i4', np.signedinteger)

See also

arrays.scalars

Overview of the numpy type hierarchy.

Aliases

  • numpy.issubdtype