[Numpy-discussion] A proposed change to rollaxis() behavior for negative 'start' values

Ryan May rmay31@gmail....
Thu Sep 23 10:37:50 CDT 2010


On Thu, Sep 23, 2010 at 10:32 AM, Anne Archibald
<aarchiba@physics.mcgill.ca> wrote:
> Just a quick correction: len(a) gives a.shape[0], while what you want
> is actually len(a.shape). So:
>
> In [1]: a = np.zeros((2,3,4,5,6))
>
> In [2]: len(a)
> Out[2]: 2
>
> In [8]: np.rollaxis(a,0,len(a.shape)).shape
> Out[8]: (3, 4, 5, 6, 2)
>
> So it behaves just like insert. But "len(a.shape)" is rather
> cumbersome, especially if you haven't given a a name yet:

It's available as a.ndim

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


More information about the NumPy-Discussion mailing list