[Numpy-discussion] ix_ with matrix input

Keith Goodman kwgoodman@gmail....
Sat May 10 12:50:23 CDT 2008


Would it break a numpy design principle to allow ix_ to take 1xn and
nx1 matrices as input?

Here's the use case I had in mind:

>> import numpy.matlib as mp
>> x = mp.asmatrix(mp.arange(9).reshape(3,3))
>> ridx = x.sum(1) > 3
>> cidx = x.sum(0) > 9
>> x[mp.ix_(ridx, cidx)]
---------------------------------------------------------------------------
ValueError: Cross index must be 1 dimensional

Workaround (convert to arrays):

>> ridx = x.A.sum(1) > 3
>> cidx = x.A.sum(0) > 9
>> x[mp.ix_(ridx, cidx)]


More information about the Numpy-discussion mailing list