[NumPy-Tickets] [NumPy] #1732: Set complex128 array with a complex64 element fails
NumPy Trac
numpy-tickets@scipy....
Tue Feb 1 13:12:42 CST 2011
#1732: Set complex128 array with a complex64 element fails
--------------------------------------+-------------------------------------
Reporter: SevenThunders | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.core | Version: 1.5.0
Keywords: complex array assignment |
--------------------------------------+-------------------------------------
Observe the following code snippet:
{{{
import numpy as np
z = np.empty((2),dtype=np.complex128)
z[0] = np.complex64(1.+1.j)
z[1] = np.complex64(1.+1.j)
print z
[ 1.+0.j 1.+0.j]
}}}
Numpy fails to make an obvious conversion from complex64 floats to
complex128. The imaginary parts are lost, which can lead to surprising
and difficult to find bugs. Now if the intention is for this conversion
to be explicit, then the assignment should have generated an exception,
not the bizarre behavior of only keeping the real part.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1732>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list