complex_dtype¶
-
odl.util.utility.
complex_dtype
(dtype, default=None)[source]¶ Return complex counterpart of
dtype
if existing, elsedefault
.- Parameters
- dtype :
Real or complex floating point data type. It can be given in any way the
numpy.dtype
constructor understands.- default :
Object to be returned if no complex counterpart is found for
dtype
, except forNone
, in which case an error is raised.
- Returns
- complex_dtype
numpy.dtype
The complex counterpart of
dtype
.
- complex_dtype
- Raises
- ValueError
if there is no complex counterpart to the given data type and
default == None
.
Examples
Convert scalar dtypes:
>>> complex_dtype(float) dtype('complex128') >>> complex_dtype('float32') dtype('complex64') >>> complex_dtype(complex) dtype('complex128')
Dtypes with shape are also supported:
>>> complex_dtype(np.dtype((float, (3,)))) dtype(('<c16', (3,))) >>> complex_dtype(('float32', (3,))) dtype(('<c8', (3,)))