diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-10-07 01:35:17 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-10-07 01:35:17 +0000 |
commit | fe0b9ed21326cc779f70880152b271908769d3d4 (patch) | |
tree | 2d6373b3afe2dee0ae1f6675ac87cf9760ceb1d9 /numpy/lib/function_base.py | |
parent | 505a95a549ca32c2e81587022ab9259eb4aafe2f (diff) | |
download | numpy-fe0b9ed21326cc779f70880152b271908769d3d4.tar.gz |
Fix ticket #325
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3a8b5ffd7..84c0e5772 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -822,6 +822,12 @@ class vectorize(object): if (nargs > self.nin) or (nargs < self.nin_wo_defaults): raise ValueError, "mismatch between python function inputs"\ " and received arguments" + + if (self.lastcallargs != nargs): + self.lastcallargs = nargs + self.ufunc = None + self.nout = None + if self.nout is None or self.otypes == '': newargs = [] for arg in args: @@ -832,21 +838,20 @@ class vectorize(object): else: self.nout = 1 theout = (theout,) - if self.otypes == '': - otypes = [] - for k in range(self.nout): - otypes.append(asarray(theout[k]).dtype.char) - self.otypes = ''.join(otypes) + otypes = [] + for k in range(self.nout): + otypes.append(asarray(theout[k]).dtype.char) + self.otypes = ''.join(otypes) - if (self.ufunc is None) or (self.lastcallargs != nargs): + if (self.ufunc is None): self.ufunc = frompyfunc(self.thefunc, nargs, self.nout) - self.lastcallargs = nargs if self.nout == 1: - return array(self.ufunc(*args),copy=False).astype(self.otypes[0]) + _res = array(self.ufunc(*args),copy=False).astype(self.otypes[0]) else: - return tuple([array(x,copy=False).astype(c) \ + _res = tuple([array(x,copy=False).astype(c) \ for x, c in zip(self.ufunc(*args), self.otypes)]) + return _res def cov(m,y=None, rowvar=1, bias=0): """Estimate the covariance matrix. |