Returns True if first argument is a typecode lower/equal in type hierarchy.
This is like the builtin issubclass
, but for dtype
s.
dtype
or object coercible to one
See also
Overview of the numpy type hierarchy.
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) True >>> np.issubdtype(ints.dtype, np.floating) False
>>> floats = np.array([1, 2, 3], dtype=np.float32) >>> np.issubdtype(floats.dtype, np.integer) False >>> np.issubdtype(floats.dtype, np.floating) True
Similar types of different sizes are not subdtypes of each other:
>>> np.issubdtype(np.float64, np.float32) False >>> np.issubdtype(np.float32, np.float64) False
but both are subtypes of floating
:
>>> np.issubdtype(np.float64, np.floating) True >>> np.issubdtype(np.float32, np.floating) True
For convenience, dtype-like objects are allowed too:
>>> np.issubdtype('S1', np.bytes_) True >>> np.issubdtype('i4', np.signedinteger) True
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4