[Numpy-discussion] Keyword argument support for vectorize.
Michael McNeil Forbes
Mon Apr 9 04:53:46 CDT 2012
On 8 Apr 2012, at 12:09 PM, Ralf Gommers wrote:
> That looks like a useful enhancement. Integrating in the existing
> vectorize class should be the way to go.
Okay. I will push forward. I would also like to add support for
"freezing" (or "excluding") certain arguments from the vectorization.
Any ideas for a good argument name? (I am just using "exclude=['p']"
The use case I have is vectorizing polynomial evaluation `polyval(p,
x)`. The coefficient array `p` should not be vectorized over, only
the variable `x`, so something like:
def mypolyval(p, x):
return np.polyval(p, x)
would work like np.polyval currently behaves:
array([ 2., 5.])
(Of course, numpy already has polyval: I am actually trying to wrap
similar functions that use Theano for automatic differentiation, but
the idea is the same).
It seems like functools.partial is the appropriate tool to use here
which means I will have to deal with the
This will require overcoming the issues with how vectorize deduces the
number of parameters, but if I integrate this with the vectorize
class, then this should be easy to patch as well.
> On Sat, Apr 7, 2012 at 12:18 AM, Michael McNeil Forbes <email@example.com
> > wrote:
>> I added a simple enhancement patch to provide vectorize with simple
>> keyword argument support. (I added a new kwvectorize decorator, but
>> suspect this could/should easily be rolled into the existing
More information about the NumPy-Discussion