[Numpy-discussion] ix_ and boolean indices

Pau Gargallo pau.gargallo at gmail.com
Fri Jul 7 10:51:04 CDT 2006


On 7/7/06, Martin Wiechert <martin.wiechert at gmx.de> wrote:
> Hi all,
>
> for me
>
> M [ix_(I, J)]
>
> does not work if I, J are boolean arrays. Is this intended or a bug/missing
> feature?
>
> And is there a way (other than I = where (I) [0] etc.) to make it work?
>
> Thanks,
> Martin

it is a recent feature.
It works for me on version '0.9.9.2660'

pau

>>> import numpy
>>> numpy.__version__
'0.9.9.2660'
>>> a = numpy.rand(3,4)
>>> a
array([[ 0.24347161,  0.25636386,  0.64373189,  0.82730095],
       [ 0.02062571,  0.12244009,  0.60053928,  0.10624435],
       [ 0.75472591,  0.00614411,  0.75388955,  0.40481918]])
>>> I = a[:,0]<0.5
>>> J = a[0,:]<0.5
>>> a[numpy.ix_(I,J)]
array([[ 0.24347161,  0.25636386],
       [ 0.02062571,  0.12244009]])




More information about the Numpy-discussion mailing list