[Numpy-discussion] Rationale for atleast_3d

Bill Baxter wbaxter at gmail.com
Fri Sep 22 22:53:02 CDT 2006

Thanks for the explanations, folks, I thought that might be the case.

On 9/23/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
> I'm working with "stacks of 2d arrays" -- but I was always under the
> impression that -- since the last axis is the "fastest"  -- "stacks of
> <something>" should stack in the first dimension  -- not the last --so that
> the members of the stack still remain contiguous is memory.

I also don't see why you'd want to stack matrices along the last axis
in numpy.   C-style memory order is one reason not to, but printing as
well seems to favor stacking matrices along the first (0th) axis
instead of the last.

> Is there a general consensus on how one should look at this ?  Or are there
> multiple incompatible view -- maybe coming from different fields -- ?

I've beed stacking along the first axis myself.  Perhaps the original
folks who implemented atleast_3d were coming from Matlab, where
stacking is generally done along the last axis.  But everything in
Matlab is Fortran order under the hood so it makes sense there.

 Anyway, glad to know it was just the implementer's idiosyncracy
rather than some deep secret of the universe that I wasn't aware of.

I sometimes wonder what sort of overhead is induced by numpy using
primarily C-style while many of the underlying algorithms we use are
in Fortran.  I suspect f2py has to do a lot of copying to get things
in the right order for making the calls to Fortran.


More information about the Numpy-discussion mailing list