tf.experimental.numpy.issubdtype
Stay organized with collections
Save and categorize content based on your preferences.
Returns True if first argument is a typecode lower/equal in type hierarchy.
tf.experimental.numpy.issubdtype(
arg1, arg2
)
This is like the builtin :func:issubclass
, but for dtype
\ s.
Parameters
arg1, arg2 : dtype_like
dtype
or object coercible to one
Returns
out : bool
See Also
:ref:arrays.scalars
: Overview of the numpy type hierarchy.
issubsctype, issubclass_
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.string_)
True
np.issubdtype('i4', np.signedinteger)
True
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.experimental.numpy.issubdtype\n\n\u003cbr /\u003e\n\nReturns True if first argument is a typecode lower/equal in type hierarchy. \n\n tf.experimental.numpy.issubdtype(\n arg1, arg2\n )\n\nThis is like the builtin :func:`issubclass`, but for `dtype`\\\\ s.\n\nParameters\n----------\n\narg1, arg2 : dtype_like\n`dtype` or object coercible to one\n\nReturns\n-------\n\nout : bool\n\nSee Also\n--------\n\n:ref:`arrays.scalars` : Overview of the numpy type hierarchy.\nissubsctype, issubclass_\n\nExamples\n--------\n\n`issubdtype` can be used to check the type of arrays: \n\n ints = np.array([1, 2, 3], dtype=np.int32)\n np.issubdtype(ints.dtype, np.integer)\n True\n np.issubdtype(ints.dtype, np.floating)\n False\n\n floats = np.array([1, 2, 3], dtype=np.float32)\n np.issubdtype(floats.dtype, np.integer)\n False\n np.issubdtype(floats.dtype, np.floating)\n True\n\nSimilar types of different sizes are not subdtypes of each other: \n\n np.issubdtype(np.float64, np.float32)\n False\n np.issubdtype(np.float32, np.float64)\n False\n\nbut both are subtypes of `floating`: \n\n np.issubdtype(np.float64, np.floating)\n True\n np.issubdtype(np.float32, np.floating)\n True\n\nFor convenience, dtype-like objects are allowed too: \n\n np.issubdtype('S1', np.string_)\n True\n np.issubdtype('i4', np.signedinteger)\n True"]]