[Numpy-discussion] bug in numpy.ndarray?
Paul Anton Letnes
paul.anton.letnes at gmail.com
Sun May 8 17:15:31 EDT 2011
Hi,
it seems that I have found a bug in numpy.ndarray. numpy 1.5.1, python 2.7.1 from macports on mac os x 10.6.7. I got the same error on Fedora 14 with numpy 1.4.1 and python 2.7. Appending a [0] to the last line solves the problem.
% python testcrash.py [14:13:27 on 11-05-08]
<type 'numpy.ndarray'> [ 12.+0.1j]
<type 'numpy.ndarray'> [ 1.+0.1j]
complex128
Traceback (most recent call last):
File "testcrash.py", line 11, in <module>
A[0] = A[0] + (eps1 - eps2)
TypeError: can't convert complex to float
% cat testcrash.py
#!/usr/bin/env python
import numpy
A = numpy.zeros(10, dtype=numpy.complex128)
eps1 = numpy.complex128([12.0 + 0.1j])
eps2 = numpy.complex128([1.0 + 0.1j])
print type(eps1), eps1
print type(eps2), eps2
print A.dtype
A[0] = A[0] + (eps1 - eps2)
More information about the NumPy-Discussion
mailing list