diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/ma.py | 13 | ||||
-rw-r--r-- | numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py | 2 | ||||
-rw-r--r-- | numpy/fft/fftpack.py | 2 | ||||
-rw-r--r-- | numpy/lib/arraysetops.py | 2 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 4 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/lib/utils.py | 2 | ||||
-rw-r--r-- | numpy/linalg/linalg.py | 2 | ||||
-rw-r--r-- | numpy/numarray/functions.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/random_array.py | 2 |
10 files changed, 23 insertions, 14 deletions
diff --git a/numpy/core/ma.py b/numpy/core/ma.py index 67335019f..35f8ee120 100644 --- a/numpy/core/ma.py +++ b/numpy/core/ma.py @@ -1604,8 +1604,17 @@ def masked_array (a, mask=nomask, fill_value=None): """ return array(a, mask=mask, copy=0, fill_value=fill_value) -sum = add.reduce -product = multiply.reduce +def sum (target, axis=None, dtype=None): + if axis is None: + target = ravel(target) + axis = 0 + return add.reduce(target, axis, dtype) + +def product (target, axis=None, dtype=None): + if axis is None: + target = ravel(target) + axis = 0 + return multiply.reduce(target, axis, dtype) def average (a, axis=None, weights=None, returned = 0): """average(a, axis=None, weights=None) diff --git a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py index ab8b62f4b..e1d4a47a6 100644 --- a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py @@ -222,7 +222,7 @@ class Array: if arr1.shape != arr2.shape: return False s = arr1==arr2 - return alltrue(s.flatten(),axis=0) + return alltrue(s.flatten()) def __str__(self): return str(self.arr) diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py index ffa6ac18d..1cb24f2b7 100644 --- a/numpy/fft/fftpack.py +++ b/numpy/fft/fftpack.py @@ -200,7 +200,7 @@ def _cook_nd_args(a, s=None, axes=None, invreal=0): if axes == None: s = list(a.shape) else: - s = take(a.shape, axes,axis=0) + s = take(a.shape, axes) else: shapeless = 0 s = list(s) diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index b98517f3d..7bd666029 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -179,7 +179,7 @@ def test_unique1d_speed( plot_results = False ): dt1s.append( dt1 ) dt2s.append( dt2 ) - assert numpy.alltrue( b == c) + assert numpy.alltrue( b == c ) print nItems diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index a202f67cb..a14a3dc9f 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -540,9 +540,9 @@ def extract(condition, arr): """Return the elements of ravel(arr) where ravel(condition) is True (in 1D). - Equivalent to compress(ravel(condition), ravel(arr),0). + Equivalent to compress(ravel(condition), ravel(arr)). """ - return _nx.take(ravel(arr), nonzero(ravel(condition))[0],axis=0) + return _nx.take(ravel(arr), nonzero(ravel(condition))[0]) def place(arr, mask, vals): """Similar to putmask arr[mask] = vals but the 1D array vals has the diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 03db2570a..d44215446 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -32,7 +32,7 @@ def apply_along_axis(func1d,axis,arr,*args): if isscalar(res): outarr = zeros(outshape,asarray(res).dtype) outarr[ind] = res - Ntot = product(outshape,axis=0) + Ntot = product(outshape) k = 1 while k < Ntot: # increment the index @@ -48,7 +48,7 @@ def apply_along_axis(func1d,axis,arr,*args): k += 1 return outarr else: - Ntot = product(outshape,axis=0) + Ntot = product(outshape) holdshape = outshape outshape = list(arr.shape) outshape[axis] = len(res) diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index deca8fa06..db7c00db6 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -126,7 +126,7 @@ def who(vardict=None): namestr = name original=1 shapestr = " x ".join(map(str, var.shape)) - bytestr = str(var.itemsize*product(var.shape,axis=0)) + bytestr = str(var.itemsize*product(var.shape)) sta.append([namestr, shapestr, bytestr, var.dtype.name, original]) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index e0b3268a6..e48e52fd3 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -661,7 +661,7 @@ Singular values less than s[0]*rcond are treated as zero. if one_eq: x = array(ravel(bstar)[:n], dtype=result_t, copy=True) if results['rank']==n and m>n: - resids = array([sum((ravel(bstar)[n:])**2,axis=0)], dtype=result_t) + resids = array([sum((ravel(bstar)[n:])**2)], dtype=result_t) else: x = array(transpose(bstar)[:n,:], dtype=result_t, copy=True) if results['rank']==n and m>n: diff --git a/numpy/numarray/functions.py b/numpy/numarray/functions.py index 95738d220..55922e9fe 100644 --- a/numpy/numarray/functions.py +++ b/numpy/numarray/functions.py @@ -206,7 +206,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT, ##file whose size may be determined before allocation, should be ##quick -- only one allocation will be needed. - recsize = dtype.itemsize * N.product([i for i in shape if i != -1],axis=0) + recsize = dtype.itemsize * N.product([i for i in shape if i != -1]) blocksize = max(_BLOCKSIZE/recsize, 1)*recsize ##try to estimate file size @@ -268,7 +268,7 @@ def fromstring(datastring, type=None, shape=None, typecode=None, dtype=None): if shape is None: count = -1 else: - count = N.product(shape,axis=0)*dtype.itemsize + count = N.product(shape)*dtype.itemsize res = N.fromstring(datastring, count=count) if shape is not None: res.shape = shape diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index 550af720c..e8d386ce4 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -166,7 +166,7 @@ def multinomial(trials, probs, shape=[]): trials is the number of trials in each multinomial distribution. probs is a one dimensional array. There are len(prob)+1 events. prob[i] is the probability of the i-th event, 0<=i<len(prob). - The probability of event len(prob) is 1.-Numeric.sum(prob,axis=0). + The probability of event len(prob) is 1.-Numeric.sum(prob). The first form returns a single 1-D array containing one multinomially distributed vector. |