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 dropin 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 dropin replacements, I see value in to being able to call reduce, accumulate, etc (when possible) on the output of vectorize().
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 dropin 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 dropin replacements, I see value in to being able to call reduce, accumulate, etc (when possible) on the output of vectorize().
NumPyDiscussion mailing list NumPyDiscussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpydiscussion
On Tue, Mar 12, 2013 at 9:59 AM, Bradley M. Froehle brad.froehle@gmail.comwrote:
T J:
You may want to look into `numpy.frompyfunc` ( http://docs.scipy.org/doc/numpy/reference/generated/numpy.frompyfunc.html ).
Yeah that's better, but it doesn't respect the output type of the function. Be nice if this supported the otypes keyword.
participants (2)

Bradley M. Froehle

T J