[Numpy-discussion] Nasty bug using pre-initialized arrays

Stuart Brorson sdb@cloud9....
Fri Jan 4 15:37:39 CST 2008


On Fri, 4 Jan 2008, Stuart Brorson wrote:

>> I just discovered this today.  It looks like a bug to me.  Please
>> flame me mercilessly if I am wrong!  :-)

FWIW, here's what Matlab does:

>> A = rand(1, 4) + rand(1, 4)*i

A =

   Columns 1 through 3

    0.7833 + 0.7942i   0.6808 + 0.0592i   0.4611 + 0.6029i

   Column 4

    0.5678 + 0.0503i

>> B = zeros(1, 4)

B =

      0     0     0     0

>> for idx=1:4; B(idx) = A(idx); end
>> B

B =

   Columns 1 through 3

    0.7833 + 0.7942i   0.6808 + 0.0592i   0.4611 + 0.6029i

   Column 4

    0.5678 + 0.0503i


I realize NumPy != Matlab, but I'd wager that most users would think
that this is the natural behavior......


Stuart Brorson
Interactive Supercomputing, inc.
135 Beaver Street | Waltham | MA | 02452 | USA
http://www.interactivesupercomputing.com/



More information about the Numpy-discussion mailing list