[Numpy-discussion] PEP: named axis

Darren Dale dsdale24@gmail....
Fri Feb 6 07:48:47 CST 2009


On Fri, Feb 6, 2009 at 4:22 AM, Stéfan van der Walt <stefan@sun.ac.za>wrote:

> Hi Robert
>
> 2009/2/6 Robert Kern <robert.kern@gmail.com>:
> >> This could be implemented but would require adding information to the
> >> NumPy array.
> >
> > More than that, though. Every function and method that takes an axis
> > or reduces an axis will need to be rewritten. For that reason, I'm -1
> > on the proposal.
>
> Are you -1 on the array dictionary, or on using it to do axis mapping?
>  I would imagine that Gael would be happier even if he had to do
>
> axis = x.meta.axis['Lateral']
> some_func(x, axis)
>
> > I'm of the opinion that it should never guess. We have no idea what
> > semantics are being placed on the dict. Even in the case where all of
> > the inputs have the same dict, the operation may easily invalidate the
> > metadata. For example, a reduction on one of these axis-decorated
> > arrays would make the axis labels incorrect.
>
> That's a good point.  So what would be a sane way of propagating
> meta-data?  If we don't want to make any assumptions, it becomes the
> user's responsibility to do it manually.
>

In which case they end up writing a subclass to propagate only that portion
of the dict that they were using.

I'll add another example where a subclass would be needed to propagate the
metadata: physical quantities. I have a package (nearly ready to submit to
this list for request for comment) that uses a dict subclass to describe the
dimensionality of a quantity, like {m:1, s:-1}. I don't think this metadata
dictionary would be useful for quantities since two arrays may have the same
dimensionality but the propagated dimensionality would be {m:1, s:-1} for
addition, {m:2, s:-2} for multiplication, {} for division.

Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090206/e6ef4708/attachment.html 


More information about the Numpy-discussion mailing list