[Numpy-discussion] question about ufuncs
Sun Feb 1 18:39:04 CST 2009
On Sun, Feb 1, 2009 at 7:33 PM, Pierre GM <firstname.lastname@example.org> wrote:
> On Feb 1, 2009, at 6:32 PM, Darren Dale wrote:
> > Is there an analog to __array_wrap__ for preprocessing arrays on
> > their way *into* a ufunc? For example, it would be nice if one could
> > do something like:
> > numpy.sin([1,2,3]*arcseconds)
> > where we have the opportunity to inspect the context, convert the
> > Quantity to units of radians, and then actually call the ufunc. Is
> > this possible, or does one have to reimplement such functions?
> Just an idea: look at the code for numpy.ma ufuncs (in numpy.ma.core).
> By defining a few classes for unary, binary and domained functions,
> you could probably do what you want, without having to recode all the
> functions by hand.
> Another idea would be to define some specific __mul__ or __rmul__
> rules for your units, so that the list would be transformed into a
I have pretty good implementations of the arithmetic operators, so
([1,2,3]*m)*([4,5,6]*J) already works. numpy.multiply and numpy.sqrt needed
help with array_wrap. I'll study your stuff in ma, thanks for the pointer.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion