[Numpy-discussion] Rationale for atleast_3d
Sebastian Haase
haase at msg.ucsf.edu
Fri Sep 22 16:50:04 CDT 2006
On Friday 22 September 2006 12:57, Travis Oliphant wrote:
> Bill Baxter wrote:
> >26 weeks, 4 days, 2 hours and 9 minutes ago, Zdeněk Hurák asked why
> >atleast_3d acts the way it does:
> >http://article.gmane.org/gmane.comp.python.numeric.general/4382/match=atle
> >ast+3d
> >
> >He doesn't seem to have gotten any answers. And now I'm wondering the
> >same thing. Anyone have any idea?
>
> This function came from scipy and was written by somebody at Enthought.
> I was hoping they would respond. The behavior of atleast_3d does make
> sense in the context of atleast_2d and thinking of 3-d arrays as
> "stacks" of 2-d arrays where the stacks are in the last dimension.
>
> atleast_2d converts 1-d arrays to 1xN arrays
>
> atleast_3d converts 1-d arrays to 1xNx1 arrays so that they can be
> "stacked" in the last dimension. I agree that this isn't consistent
> with the general notion of "pre-pending" 1's to increase the
> dimensionality of the array.
>
> However, array(a, copy=False, ndmin=3) will always produce arrays with
> a 1 at the begining. So at_least3d is convenient if you like to think
> of 3-d arrays of stacks of 2-d arrays where the last axis is the
> "stacking" dimension.
>
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.
Is there a general consensus on how one should look at this ? Or are there
multiple incompatible view -- maybe coming from different fields -- ?
-Sebastian
More information about the Numpy-discussion
mailing list