[Numpy-discussion] Numeric.put bug
Travis Oliphant
oliphant.travis at ieee.org
Fri Oct 5 13:18:04 CDT 2001
On Friday 05 October 2001 11:10 am, you wrote:
> Has anyone yet noted this?
>
> The following code works in python1.5.2 (Numeric.__version__ == '11').
> However, in python2.0 (with Numeric.__version__ == '17.1.1') and
> python2.1 (with Numeric.__version__ == '20.0.0'), it doesn't work
> correctly.
> coords[3][3] is mis-assigned. It happens at least on SGI and Sun. I've
> not
> seen anything in the change lists for 20.1 or 20.2 about such a bug.
>
I'm not sure why this worked in Numeric version 11, but it appears you are
using the put function incorrectly. The documentation might need to be fixed
to emphasize that the index list is interpreted as a one-dimensional index
into a flattened representation of the array. The put function does the
equivalent of the operation:
a.flat[n] = v.flat[n]
In other words, if a is a 2-d array, then the index list does NOT represent
indices into the rows of the array. It represents indicies into the
flattened array.
In your example, the function is working correctly. It is placing a 12 into
the 3 position in the array (i.e. row 0 column 3) and placing a 13 into the
15th position in the array (i.e. row 3 column 3).
Like I said, I'm not sure why this worked in Numeric 11 --- it shouldn't have.
-Travis
More information about the Numpy-discussion
mailing list