[Numpy-discussion] Raveling, reshape order keyword unnecessarily confuses index and memory ordering

Sebastian Berg sebastian at sipsolutions.net
Fri Apr 5 05:20:45 EDT 2013


On Thu, 2013-04-04 at 14:20 -0700, Matthew Brett wrote:
> Hi,
> On Tue, Apr 2, 2013 at 4:32 AM, Nathaniel Smith <njs at pobox.com> wrote:
> <snip>
> > Maybe we should go through and rename "order" to something more descriptive
> > in each case, so we'd have
> >   a.reshape(..., index_order="C")
> >   a.copy(memory_order="F")
> > etc.?
> I'd like to propose this instead:
> a.reshape(..., order="C")
> a.copy(layout="F")

I actually like this, makes the point clearer that it has to do with
memory layout and implies contiguity, plus it is short and from the
numpy perspective copy, etc. are the ones that add additional info to
"order" and not reshape (because IMO memory order is something new users
should not worry about at first). A and K orders will still have their
quirks with np.array and copy=True/False, but for many functions they
are esoteric anyway.

It will be one hell of a deprecation though, but I am +0.5 for adding an
alias for now (maybe someone knows an even better name?), but I think
that in this case, it probably really is better to wait with actual
deprecation warnings for a few versions, since it touches a *lot* of
code. Plus I think at the point of starting deprecation warnings (and
best earlier) numpy should provide an automatic fixer script...

The only counter point that remains for me is the difficulty of
deprecation, since I think the new name idea is very clean. And this is
unfortunately even more invasive then the index_order proposal.

Fun point at the end: ndarray.tostring takes an order argument, which is
correct as "order" but has a lot in common with "layout" :). (that is
not an issue IMO, but for me it is a reason to prefer the layout
proposal over the index_order one).



> This fits well with the terms we've been using during the discussion.
> It reduces the changes to only one of the two meanings.
> Thinking about it, I feel that this would have been considerably
> clearer to me as I learned numpy.
> Cheers,
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list