<br><br><div class="gmail_quote">On Sun, May 8, 2011 at 3:15 PM, Paul Anton Letnes <span dir="ltr"><<a href="mailto:paul.anton.letnes@gmail.com">paul.anton.letnes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
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.<br>

<br>
% python testcrash.py                                                                                                                                          [14:13:27 on 11-05-08]<br>
<type 'numpy.ndarray'> [ 12.+0.1j]<br>
<type 'numpy.ndarray'> [ 1.+0.1j]<br>
complex128<br>
Traceback (most recent call last):<br>
  File "testcrash.py", line 11, in <module><br>
    A[0] = A[0] + (eps1 - eps2)<br>
TypeError: can't convert complex to float<br>
<br>
 % cat testcrash.py<br>
#!/usr/bin/env python<br>
<br>
import numpy<br>
<br>
A = numpy.zeros(10, dtype=numpy.complex128)<br>
eps1 = numpy.complex128([12.0 + 0.1j])<br>
eps2 = numpy.complex128([1.0 + 0.1j])<br></blockquote><div><br>It's the brackets, numpy.complex128([1.0 + 0.1j]) is a 1d array, not a scalar. The error message is less than helpful though.<br><br><snip><br><br>
Chuck<br></div><br></div>