sidpy.hdf.dtype_utils.is_complex_dtype

sidpy.hdf.dtype_utils.is_complex_dtype(dtype)[source]

Checks if the provided dtype is a complex dtype

Parameters:

dtype (object) – Object that is a class:h5py.Datatype, or numpy.dtype object

Returns:

is_complex – True if the dtype was a complex dtype. Else returns False

Return type:

bool

Examples

>>> import numpy as np
>>> import sidpy
>>> for dtype in [np.float32, np.float16, np.uint8, np.int16, bool]:
>>>     print('Is {} a complex dtype?: {}'.format(dtype, (sidpy.dtype_utils.is_complex_dtype(dtype))))
Is <class 'numpy.float32'> a complex dtype?: False
Is <class 'numpy.float16'> a complex dtype?: False
Is <class 'numpy.uint8'> a complex dtype?: False
Is <class 'numpy.int16'> a complex dtype?: False
Is <class 'bool'> a complex dtype?: False
>>> struct_dtype = np.dtype({'names': ['r', 'g', 'b'],
>>>                         'formats': [np.float32, np.uint16, np.float64]})
Is [('r', '<f4'), ('g', '<u2'), ('b', '<f8')] a complex dtype?: False
>>> for dtype in [complex, np.complex64, np.complex128, np.complex256]:
>>>     print('Is {} a complex dtype?: {}'.format(dtype, (sidpy.dtype_utils.is_complex_dtype(dtype))))
Is <class 'complex'> a complex dtype?: True
Is <class 'numpy.complex64'> a complex dtype?: True
Is <class 'numpy.complex128'> a complex dtype?: True
Is <class 'numpy.complex256'> a complex dtype?: False