[Numpy-discussion] Negative indexing.

Nathan Faggian nathan.faggian at gmail.com
Mon Jan 16 19:23:24 EST 2012


Hi,

I am sorry for the late reply.

Benjamin has hit the nail on the head. I guess I am seeing numpy
"fancy indexing" as equivalent to integer based coordinate sampling
and trying to compare numpy's fancy indexing to something like
map_coordinates in scipy.

I have never used np.ravel_multi_index() and will have a look at this now.

-N


On 17 January 2012 08:42, Benjamin Root <ben.root at ou.edu> wrote:
> On Mon, Jan 16, 2012 at 3:30 PM, Benjamin Root <ben.root at ou.edu> wrote:
>>
>>
>>
>> On Mon, Jan 16, 2012 at 3:24 PM, Charles R Harris
>> <charlesr.harris at gmail.com> wrote:
>>>
>>>
>>>
>>> On Sat, Jan 14, 2012 at 4:53 PM, Nathan Faggian
>>> <nathan.faggian at gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am finding it less than useful to have the negative index wrapping on
>>>> nd-arrays. Here is a short example:
>>>>
>>>> import numpy as np
>>>> a = np.zeros((3, 3))
>>>> a[:,2] = 1000
>>>> print a[0,-1]
>>>> print a[0,-1]
>>>> print a[-1,-1]
>>>>
>>>> In all cases 1000 is printed out.
>>>>
>>>
>>> Looks right to me, the whole last column is 1000. What exactly do you
>>> want to do and what is the problem?
>>>
>>> <snip>
>>>
>>> Chuck
>>>
>>
>> I would imagine that it is some sort of image processing use-case, where
>> sometimes you want the data to reflect at the boundaries, or be constant, or
>> have some other value used for access outside the domain.  So, for reflect,
>> I would guess that he would have wanted 0.0 for the first two and 1000 for
>> the last one.
>>
>> Ben Root
>>
>
> Errr, I mean 0.0 for the last one.  I can't think today.
>
> Ben Root
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list