[Numpy-discussion] Vectorize and ufunc attribute

Bradley M. Froehle brad.froehle@gmail....
Tue Mar 12 09:59:53 CDT 2013


T J:

You may want to look into `numpy.frompyfunc` (
http://docs.scipy.org/doc/numpy/reference/generated/numpy.frompyfunc.html).

-Brad


On Tue, Mar 12, 2013 at 12:40 AM, T J <tjhnson@gmail.com> wrote:

> Prior to 1.7, I had working compatibility code such as the following:
>
>
> if has_good_functions:
>     # http://projects.scipy.org/numpy/ticket/1096
>     from numpy import logaddexp, logaddexp2
> else:
>     logaddexp = vectorize(_logaddexp, otypes=[numpy.float64])
>     logaddexp2 = vectorize(_logaddexp2, otypes=[numpy.float64])
>
>     # Run these at least once so that .ufunc.reduce exists
>     logaddexp([1.,2.,3.],[1.,2.,3.])
>     logaddexp2([1.,2.,3.],[1.,2.,3.])
>
>     # And then make reduce available at the top level
>     logaddexp.reduce = logaddexp.ufunc.reduce
>     logaddexp2.reduce = logaddexp2.ufunc.reduce
>
>
> The point was that I wanted to treat the output of vectorize as a hacky
> drop-in replacement for a ufunc.  In 1.7, I discovered that vectorize had
> changed (https://github.com/numpy/numpy/pull/290), and now there is no
> longer a ufunc attribute at all.
>
> Should this be added back in?  Besides hackish drop-in replacements, I see
> value in to being able to call reduce, accumulate, etc (when possible) on
> the output of vectorize().
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130312/30eb19ce/attachment.html 


More information about the NumPy-Discussion mailing list