[SciPy-user] TypeError: can't convert complex to float; use abs(z)

Stéfan van der Walt stefan at sun.ac.za
Thu Apr 3 08:05:13 EDT 2008


On 03/04/2008, lorenzo bolla <lbolla at gmail.com> wrote:
> 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()

And yet:

In [3]: x = np.zeros((2,1))

In [4]: x
Out[4]:
array([[ 0.],
       [ 0.]])

In [5]: y = np.array([[1.5]])

In [6]: x[0,0] = y

In [7]: x
Out[7]:
array([[ 1.5],
       [ 0. ]])

Looks like a bug to me?

Cheers
Stéfan



More information about the SciPy-User mailing list