Question about indexing arrays with boolean arrays

Michael Sorich michael.sorich at gmail.com
Wed Oct 18 19:33:06 CDT 2006


On 10/18/06, Daniel Arbuckle <djarb at highenergymagic.org> wrote:
> Why does a[b1, b2] not mean the same thing as a[b1][:, b2], when "a"
> is an array and "b1" and "b2" are appropriately sized arrays of
> booleans?

>From my previous experience with R I am used to a[b1, b2] being
equivalent to a[b1][:, b2], so this is a little strange to me as well.
In numpy I think you need to use the function ix_ to get the cross
product.

e.g. a[ix_(b1,b2)] is equivalent to a[b1][:, b2]

a[b1,b2] raises an error about a type mismatch. I have no idea what
this syntax is supposed to do in numpy.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list