[SciPy-user] TypeError: can't convert complex to float; use abs(z)
段丞博
lilyphysik at gmail.com
Thu Apr 3 21:06:45 EDT 2008
Yes,I notice that gij returns a 2d array,if it returns a complex
number instead of an array,the
result should be right.I reexamine the function "gij",and found
the error. I should use an
integer to specify the dimension of the new array. In
"reshape",the argument called "newshape" should
be tuple or integer,the function will return a 1D array if an
integer is specified.
>> your function gij returns a 2d array (a matrix) with just 1 element.
>> you cannot assign to the element b[0,0], the value of the matrix c, but you
>> can assign it the value of the _only_ element of c, i.e. c.item().
>>
>> your last line become:
>> b[0,0] = c.item()
>>
>
> Correct. However, it's still a weird error message that may be
> indicative of incorrect code somewhere in numpy.
>
>
More information about the SciPy-User
mailing list