[Numpy-discussion] Vectorize and ufunc attribute
T J
tjhnson at gmail.com
Tue Mar 12 03:40:14 EDT 2013
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().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130312/46ca6078/attachment.html>
More information about the NumPy-Discussion
mailing list