flopscope.

flopscope.numpy.issubdtype

fnp.issubdtype(arg1, arg2)[flopscope source][numpy source]

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

Adapted from NumPy docs np.issubdtype

Areacore
Typefree
NumPy Refnp.issubdtype
Cost
0
Flopscope Context

Return True if first argument is lower in type hierarchy.

This is like the builtin issubclass, but for dtype s.

Parameters

arg1, arg2:dtype_like

dtype or object coercible to one

Returns

out:bool

See also

Examples

issubdtype can be used to check the type of arrays:

>>> ints = flops.array([1, 2, 3], dtype=flops.int32)
>>> flops.issubdtype(ints.dtype, flops.integer)
True
>>> flops.issubdtype(ints.dtype, flops.floating)
False
>>> floats = flops.array([1, 2, 3], dtype=flops.float32)
>>> flops.issubdtype(floats.dtype, flops.integer)
False
>>> flops.issubdtype(floats.dtype, flops.floating)
True

Similar types of different sizes are not subdtypes of each other:

>>> flops.issubdtype(flops.float64, flops.float32)
False
>>> flops.issubdtype(flops.float32, flops.float64)
False

but both are subtypes of floating:

>>> flops.issubdtype(flops.float64, flops.floating)
True
>>> flops.issubdtype(flops.float32, flops.floating)
True

For convenience, dtype-like objects are allowed too:

>>> flops.issubdtype('S1', flops.bytes_)
True
>>> flops.issubdtype('i4', flops.signedinteger)
True