[Numpy-discussion] Re: Unexpected change of array used to index another array

Robert Kern robert.kern at gmail.com
Mon Apr 10 00:02:01 CDT 2006

Charles R Harris wrote:
> On 4/8/06, *Webb Sprague* <webb.sprague at gmail.com
> <mailto:webb.sprague at gmail.com>> wrote:
>     Hi.
>     I indexed an 10 x 10(called bigM below) with another array (OFFS_TMP
>     below).  I suppose because OFFS_TMP has negative numbers, it was
>     changed to cycle around to 9 wherever there is a negative 1 (which is
>     the forward version of -1 if you are a 10 x 10 matrix).  You can
>     analogous behavior with -2 => 8, etc.  Is changing the indexing matrix
>     really the correct behavior?  The result of using the index seems to
>     be fine.  Has this story been told already and I didn't know it? 
> It's the python way:
>>>> a = [1,2,3]
>>>> a[-1]
> 3
> It gives a convenient way to index from the end of the array. But I'm
> not sure that was your question.

That's not the issue. The problem was that the index array was being modified
in-place simply by being used as an index array.

Robert Kern
robert.kern at gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list