[Numpy-discussion] Proposal of new function: iteraxis()

Robert Kern robert.kern@gmail....
Fri Apr 26 04:42:35 CDT 2013


On Thu, Apr 25, 2013 at 9:04 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:

> After thinking about it, I'm in favor of this small function. Rollaxis takes
> a bit of thought and document reading to figure out how to use it, whereas
> this function covers a common use with an easy to understand API.

It seems to me that just an additional example in the rollaxis()
docstring solves that problem:

  ``rollaxis()`` can be used to iterate over a given axis of a
multidimensional array:

    >>> for x in np.rollaxis(a, 2):
    ...     print x.shape
    ...
    (3, 4, 6)
    (3, 4, 6)
    (3, 4, 6)
    (3, 4, 6)
    (3, 4, 6)

--
Robert Kern


More information about the NumPy-Discussion mailing list