[Numpy-discussion] Raveling, reshape order keyword unnecessarily confuses index and memory ordering
Sat Mar 30 18:28:49 CDT 2013
On Sat, 2013-03-30 at 12:45 -0700, Matthew Brett wrote:
> On Sat, Mar 30, 2013 at 11:55 AM, Sebastian Berg
> <firstname.lastname@example.org> wrote:
> > On Fri, 2013-03-29 at 19:08 -0700, Matthew Brett wrote:
> >> Hi,
> >> We were teaching today, and found ourselves getting very confused
> >> about ravel and shape in numpy.
> >> What do y'all think?
> > Personally I think it is clear enough and that "Z" and "N" would confuse
> > me just as much (though I am used to the other names). Also "Z" and "N"
> > would seem more like aliases, which would also make sense in the memory
> > order context.
> > If anything, I would prefer renaming the arguments iteration_order and
> > memory_order, but it seems overdoing it...
> I am not sure what you mean - at the moment there is one argument
> called 'order' that can refer to iteration order or memory order. Are
> you proposing two arguments?
Yes that is what I meant. The reason that it is not convincing to me is
that if I write `np.reshape(arr, ..., order='Z')`, I may be tempted to
also write `np.copy(arr, order='Z')`. I don't see anything against
allowing 'Z' as a more memorable 'C' (I also used to forget which was
which), but I don't really see enforcing a different _value_ on the same
named argument making it clearer.
Renaming the argument itself would seem more sensible to me right now,
but I cannot think of a decent name, so I would prefer trying to clarify
the documentation if necessary.
> > Maybe the documentation could just be checked if it is always clear
> > though. I.e. maybe it does not use "iteration" or "memory" order
> > consistently (though I somewhat feel it is usually clear that it must be
> > iteration order, since no numpy function cares about the input memory
> > order as they will just do a copy if necessary).
> Do you really mean this? Numpy is full of 'order=' flags that refer to memory.
I somewhat imagined there were more iteration order flags and I
basically count empty/ones/.../copy as basically one "array creation"
> NumPy-Discussion mailing list
More information about the NumPy-Discussion