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

Robert Kern robert.kern at gmail.com
Thu Apr 25 15:40:59 EDT 2013


On Thu, Apr 25, 2013 at 8:21 PM, Andrew Giessel
<andrew_giessel at hms.harvard.edu> wrote:
> I respect this opinion.  However (and maybe this is legacy), while reading
> through the numeric.py source file, I was surprised at how short many of the
> functions are, generally.  Functions like ones() and zeros() are pretty
> simple wrappers which call empty() and then copy over values.

Many of these are short, but they do tend to do at least two things
that someone would otherwise have to do. This really isn't the case
for iteraxis() and rollaxis(). One can use rollaxis() pretty much
everywhere you would use iteraxis(), but not vice-versa.

> FWIW, I had used numpy for over two years before realizing that the default
> behavior of iterating on a numpy array was to return slices over the first
> axis (although, this makes sense because it makes a 1d array like a list),
> and I think it is generally left out of any tutorials or guides.

Then let's add it.

--
Robert Kern



More information about the NumPy-Discussion mailing list