[Numpy-discussion] getting the equivalent complex dtype from a real or int array
sebastian at sipsolutions.net
Tue Oct 29 14:01:05 EDT 2013
On Tue, 2013-10-29 at 16:47 +0000, Henry Gomersall wrote:
> Is there a way to extract the size of array that would be created by
> doing 1j*array?
There is np.result_type. It does the handling of scalars as normal,
dtypes will be handled like arrays (scalars are allowed to lose
> The problem I'm having is in creating an empty array to fill with
> complex values without knowing a priori what the input data type is.
> For example, I have a real or int array `a`.
> I want to create an array `b` which can hold values from 1j*a in such a
> way that I don't need to compute those explicitly (because I only need
> parts of the array say), without upcasting (or indeed downcasting) the
> So if `a` was dtype 'float32`, `b` would be of dtype `complex64`. If `a`
> was `int64`, `b` would be of dtype `complex128` etc.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion