[Numpy-discussion] Selecting columns of a matrix

Travis Oliphant oliphant.travis at ieee.org
Thu Jun 22 01:58:52 EDT 2006

Simon Burton wrote:
> On Wed, 21 Jun 2006 10:50:26 -0600
> Travis Oliphant <oliphant.travis at ieee.org> wrote:
>> So, in SVN NumPy, you will be able to do
>> a[:,V>0]
>> a[V>0,:] 
>> The V>0 will be replaced with integer arrays as if nonzero(V>0) had been 
>> called.
> OK.
> But just for the record, we should note how to
> do the operation that this used to do, eg.
>>>> a=numpy.array([1,2])
>>>> a[[numpy.bool_(1)]]
> array([2]
This behavior hasn't changed...

All that's changed is that what used to raise an error (boolean arrays 
in a tuple) now works in the same way that boolean arrays worked before.
> So, with the new implementation, is it possible to cast
> the bool array to an integer type without incurring a copy overhead ?

I'm not sure what you mean.  What copy overhead?   There is still 
copying going on.  The way it's been implemented, the boolean arrays get 
replaced with integer index arrays under the hood so it is really nearly 
identical to replacing the boolean array with nonzero(<boolean>).
> And finally, is someone keeping track of the performance
> of array getitem ? It seems that as travis overloads it more and
> more it might then slow down in some cases.
Actually, I'm very concientious of the overhead of getitem in code that 
I add.  I just today found a memory leak in code that was added that I 
did not review carefully that was also slowing down all accesses of 
arrays > 1d that resulted in array scalars.  I added an optimization 
that should speed that up.

But, it would be great if others could watch the speed changes for basic 
> I must admit my vision is blurring and head is spining as numpy 
> goes through these growing pains
The 1.0 beta release is coming shortly.   I would like to see the first 
beta by the first of July.   The final 1.0 release won't occur, though, 
until after SciPy 2006.

Thanks for your patience.   We've been doing a lot of house-cleaning 
lately to separate the "old but compatible" interface from the "new."   
This has resulted in some confusion, to be sure.   Please don't hesitate 
to voice your concerns.


More information about the NumPy-Discussion mailing list