def complextofloat(dtype):
""" convert dtype from complex to corresponding real dtype """
dtype = dtype.type if isinstance(dtype, np.dtype) else dtype
if not issubclass(dtype, np.complexfloating):
outdtype = dtype
elif dtype == np.complex64:
outdtype = np.float32
elif dtype == np.complex128:
outdtype = np.float64
else:
raise TypeError("input dtype " + str(dtype) +
" cannot be translated to floating")
return np.dtype(outdtype)
评论列表
文章目录