Re: [Numpy-discussion] Question about indexing

2008-05-30 Thread Travis E. Oliphant
Hi Raul, There are a some points that might help you with indexing: 1) a[obj] is (basically) equivalent to a.__getitem__(numpy.index_exp[obj]) 2) obj is always converted to a tuple if it isn't one already: * numpy.index_exp[0,1] == (0,1) * numpy.index_exp[(0,1)] == (0,1) * numpy.index_exp[

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Keith Goodman
On Thu, May 29, 2008 at 8:50 PM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > Is ``a[[0,1]]`` completely equivalent to ``a[[0,1],...]`` > and ``a[[0,1],:]``? They look, smell, and taste the same. But I can't read array's __getitem__ since it is in C instead of python. >> np.index_exp[[0,1]] ([0,

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Alan G Isaac
>> On Thu, 29 May 2008, Keith Goodman apparently wrote: >> a[[0,1]] >>> That one looks odd. But it is just shorthand for: >> a[[0,1],:] > On Thu, May 29, 2008 at 6:32 PM, Alan G Isaac > <[EMAIL PROTECTED]> wrote: >> Do you mean that ``a[[0,1],:]`` is a more primitive >> expression tha

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Keith Goodman
On Thu, May 29, 2008 at 6:32 PM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > On Thu, 29 May 2008, Keith Goodman apparently wrote: >> >>> a[[0,1]] >> That one looks odd. But it is just shorthand for: >> >>> a[[0,1],:] > > > Do you mean that ``a[[0,1],:]`` is a more primitive > expression than ``a[[0,1

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Alan G Isaac
On Thu, 29 May 2008, Keith Goodman apparently wrote: > >>> a[[0,1]] > That one looks odd. But it is just shorthand for: > >>> a[[0,1],:] Do you mean that ``a[[0,1],:]`` is a more primitive expression than ``a[[0,1]]``? In what sense, and does it ever matter? Is ``a[[0,1]]`` completely equiv

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Keith Goodman
On Thu, May 29, 2008 at 4:36 PM, Raul Kompass <[EMAIL PROTECTED]> wrote: > I'm new to using numpy. Today I experimented a bit with indexing > motivated by the finding that although > a[a>0.5] and a[where(a>0.5)] give the same expected result (elements of > a greater than 0.5) > a[argwhere(a>0.5)]

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Robin
On Fri, May 30, 2008 at 12:57 AM, Robin <[EMAIL PROTECTED]> wrote: > You are indexing here with a 1d list [0,1]. Since you don't provide a > column index you get rows 0 and 1. > If you do a[ [0,1] , [0,1] ] then you get element [0,0] and element [0,1]. Whoops - you get [0,0] and [1,1]. Robin

Re: [Numpy-discussion] Question about indexing

2008-05-29 Thread Robin
On Fri, May 30, 2008 at 12:36 AM, Raul Kompass <[EMAIL PROTECTED]> wrote: > I'm new to using numpy. Today I experimented a bit with indexing > motivated by the finding that although > a[a>0.5] and a[where(a>0.5)] give the same expected result (elements of > a greater than 0.5) > a[argwhere(a>0.5)]

[Numpy-discussion] Question about indexing

2008-05-29 Thread Raul Kompass
I'm new to using numpy. Today I experimented a bit with indexing motivated by the finding that although a[a>0.5] and a[where(a>0.5)] give the same expected result (elements of a greater than 0.5) a[argwhere(a>0.5)] results in something else (rows of a in different order). I tried to figure out