From a345bd21446141f16f70b8f84c7b42b257b0dcff Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Tue, 11 Jul 2006 21:39:04 +0000 Subject: Fix .choose docstring and allow more functions to be 'vectorized' --- numpy/lib/function_base.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'numpy/lib') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 9969834a8..3143c8846 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -617,11 +617,15 @@ class vectorize(object): """ def __init__(self, pyfunc, otypes='', doc=None): - nin, ndefault = _get_nargs(pyfunc) self.thefunc = pyfunc self.ufunc = None - self.nin = nin - self.nin_wo_defaults = nin - ndefault + nin, ndefault = _get_nargs(pyfunc) + if nin == 0 and ndefault == 0: + self.nin = None + self.nin_wo_defaults = None + else: + self.nin = nin + self.nin_wo_defaults = nin - ndefault self.nout = None if doc is None: self.__doc__ = pyfunc.__doc__ @@ -640,9 +644,10 @@ class vectorize(object): # get number of outputs and output types by calling # the function on the first entries of args nargs = len(args) - if (nargs > self.nin) or (nargs < self.nin_wo_defaults): - raise ValueError, "mismatch between python function inputs"\ - " and received arguments" + if self.nin: + if (nargs > self.nin) or (nargs < self.nin_wo_defaults): + raise ValueError, "mismatch between python function inputs"\ + " and received arguments" if self.nout is None or self.otypes == '': newargs = [] for arg in args: -- cgit v1.2.1