[SciPy-user] scipy sclicing

John [H2O] washakie@gmail....
Fri Oct 10 11:20:56 CDT 2008




> 
> Fortunately numpy's broadcasting can do it for you,
> repeating each array along a new axis:
> 
> X[ np.array([1,3,5])[:,np.newaxis], np.array([2,4])[np.newaxis,:] ]
> 
> 
> Anne
> 

So perhaps the approach should be:

def slize(X,i,j):
    from numpy import array, newaxis
    X = X[ array([i)[:,newaxis], array(j)[newaxis,:] ]
    return X

Seems a little easier for me to remember!

-- 
View this message in context: http://www.nabble.com/scipy-sclicing-tp19917625p19921526.html
Sent from the Scipy-User mailing list archive at Nabble.com.



More information about the SciPy-user mailing list