[Numpy-svn] r3097 - in trunk/numpy: core f2py/tests/array_from_pyobj/tests fft lib linalg numarray oldnumeric

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Aug 29 12:56:34 CDT 2006


Author: oliphant
Date: 2006-08-29 12:56:21 -0500 (Tue, 29 Aug 2006)
New Revision: 3097

Modified:
   trunk/numpy/core/ma.py
   trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
   trunk/numpy/fft/fftpack.py
   trunk/numpy/lib/arraysetops.py
   trunk/numpy/lib/function_base.py
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/utils.py
   trunk/numpy/linalg/linalg.py
   trunk/numpy/numarray/functions.py
   trunk/numpy/oldnumeric/random_array.py
Log:
Clean-up some un-needed default axes. Fix default axes of ma.sum and ma.product

Modified: trunk/numpy/core/ma.py
===================================================================
--- trunk/numpy/core/ma.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/core/ma.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -1604,9 +1604,18 @@
     """
     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)
        Computes average along indicated axis.

Modified: trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
===================================================================
--- trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -222,7 +222,7 @@
         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)

Modified: trunk/numpy/fft/fftpack.py
===================================================================
--- trunk/numpy/fft/fftpack.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/fft/fftpack.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -200,7 +200,7 @@
         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)

Modified: trunk/numpy/lib/arraysetops.py
===================================================================
--- trunk/numpy/lib/arraysetops.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/lib/arraysetops.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -179,7 +179,7 @@
         dt1s.append( dt1 )
         dt2s.append( dt2 )
 
-        assert numpy.alltrue( b == c)
+        assert numpy.alltrue( b == c )
 
 
     print nItems

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/lib/function_base.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -540,9 +540,9 @@
     """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

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/lib/shape_base.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -32,7 +32,7 @@
     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 @@
             k += 1
         return outarr
     else:
-        Ntot = product(outshape,axis=0)
+        Ntot = product(outshape)
         holdshape = outshape
         outshape = list(arr.shape)
         outshape[axis] = len(res)

Modified: trunk/numpy/lib/utils.py
===================================================================
--- trunk/numpy/lib/utils.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/lib/utils.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -126,7 +126,7 @@
                 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])
 

Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/linalg/linalg.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -661,7 +661,7 @@
     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:

Modified: trunk/numpy/numarray/functions.py
===================================================================
--- trunk/numpy/numarray/functions.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/numarray/functions.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -206,7 +206,7 @@
     ##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 @@
     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

Modified: trunk/numpy/oldnumeric/random_array.py
===================================================================
--- trunk/numpy/oldnumeric/random_array.py	2006-08-29 17:20:29 UTC (rev 3096)
+++ trunk/numpy/oldnumeric/random_array.py	2006-08-29 17:56:21 UTC (rev 3097)
@@ -166,7 +166,7 @@
            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.



More information about the Numpy-svn mailing list