mlx.core.issubdtype#
- issubdtype(: mlx.core.Dtype, : mlx.core.Dtype) bool #
- issubdtype(: mlx.core.Dtype, : mlx.core.DtypeCategory) bool
- issubdtype(: mlx.core.DtypeCategory, : mlx.core.Dtype) bool
- issubdtype(: mlx.core.DtypeCategory, : mlx.core.DtypeCategory) bool
Check if a
Dtype
orDtypeCategory
is a subtype of another.>>> ints = mx.array([1, 2, 3], dtype=mx.int32) >>> mx.issubdtype(ints.dtype, mx.integer) True >>> mx.issubdtype(ints.dtype, mx.floating) False
>>> floats = mx.array([1, 2, 3], dtype=mx.float32) >>> mx.issubdtype(floats.dtype, mx.integer) False >>> mx.issubdtype(floats.dtype, mx.floating) True
Similar types of different sizes are not subdtypes of each other:
>>> mx.issubdtype(mx.float64, mx.float32) False >>> mx.issubdtype(mx.float32, mx.float64) False
but both are subtypes of floating:
>>> mx.issubdtype(mx.float64, mx.floating) True >>> mx.issubdtype(mx.float32, mx.floating) True
For convenience, dtype-like objects are allowed too:
>>> mx.issubdtype(mx.float32, mx.inexact) True >>> mx.issubdtype(mx.signedinteger, mx.floating) False