[Numpy-discussion] making two 2D real arrays into one complex array

mark markbak@gmail....
Tue Apr 10 14:57:00 CDT 2007

Hello List -

Any reason why the following doesn't work?

>>> x,y = meshgrid(linspace(-1,1,10),linspace(-1,1,10))
>>> z = complex(x,y)
Traceback (most recent call last):
  File "<pyshell#225>", line 1, in ?
    z = complex(x,y)
TypeError: only length-1 arrays can be converted to Python scalars

I know I can make an empty complex z array with the size of x, then
set z.real equal to x and z.imag equal to y. But is there any reason
why the above shouldn't work? It would be easy to implement in numpy,
wouldn't it? If so, I would *really* like it.

Thanks for your help,


More information about the Numpy-discussion mailing list