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

Pierre GM pgmdevlist@gmail....
Tue Apr 10 15:03:47 CDT 2007


On Tuesday 10 April 2007 15:57:00 mark wrote:
> 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)

Because complex is a python function that doesn't work well w/ ndarrays. 
int/float/bool would give the same result.

Please try:
z = x + 1j *y


More information about the Numpy-discussion mailing list