[Numpy-discussion] Float view of complex array
Jens Jørgen Mortensen
jensj at fysik.dtu.dk
Mon Jan 26 03:24:06 EST 2015
Hi!
I have a view of a 2-d complex array that I would like to view as a 2-d
float array. This works OK:
>>> np.ones((2, 4), complex).view(float)
array([[ 1., 0., 1., 0., 1., 0., 1., 0.],
[ 1., 0., 1., 0., 1., 0., 1., 0.]])
but this doesn't:
>>> np.ones((2, 4), complex)[:, :2].view(float)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: new type not compatible with array.
>>> np.__version__
'1.9.0'
and I don't understand why. When looking at the memory layout, I think
it should be possible.
Jens Jørgen
More information about the NumPy-Discussion
mailing list