diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-11 21:39:04 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-11 21:39:04 +0000 |
commit | a345bd21446141f16f70b8f84c7b42b257b0dcff (patch) | |
tree | 187c250e1e127f14d0ef373af3047cca82602e75 /numpy/lib/function_base.py | |
parent | 107a45f793e249bc87e9bd328fa7d62519a5b4e9 (diff) | |
download | numpy-a345bd21446141f16f70b8f84c7b42b257b0dcff.tar.gz |
Fix .choose docstring and allow more functions to be 'vectorized'
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 17 |
1 files changed, 11 insertions, 6 deletions
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: |