[Numpy-svn] r8188 - in trunk: numpy/core numpy/distutils numpy/f2py numpy/lib numpy/lib/tests numpy/ma numpy/ma/tests numpy/oldnumeric tools

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:20:10 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:20:10 -0600 (Sat, 20 Feb 2010)
New Revision: 8188

Modified:
   trunk/numpy/core/arrayprint.py
   trunk/numpy/distutils/system_info.py
   trunk/numpy/f2py/auxfuncs.py
   trunk/numpy/lib/arrayterator.py
   trunk/numpy/lib/tests/test_arrayterator.py
   trunk/numpy/ma/core.py
   trunk/numpy/ma/tests/test_core.py
   trunk/numpy/ma/tests/test_old_ma.py
   trunk/numpy/ma/timer_comparison.py
   trunk/numpy/oldnumeric/ma.py
   trunk/tools/py3tool.py
Log:
3K: BUG: work around bugs in Python 3.1.1 2to3 by not using fixes_reduce

Instead, manually import reduce where necessary.

Modified: trunk/numpy/core/arrayprint.py
===================================================================
--- trunk/numpy/core/arrayprint.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/core/arrayprint.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -29,6 +29,8 @@
 _nan_str = 'NaN'
 _inf_str = 'Inf'
 
+if sys.version_info[0] >= 3:
+    from functools import reduce
 
 def set_printoptions(precision=None, threshold=None, edgeitems=None,
                      linewidth=None, suppress=None,

Modified: trunk/numpy/distutils/system_info.py
===================================================================
--- trunk/numpy/distutils/system_info.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/distutils/system_info.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -132,6 +132,9 @@
 from numpy.distutils.command.config import config as cmd_config
 from numpy.distutils.compat import get_exception
 
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 # Determine number of bits
 import platform
 _bits = {'32bit':32,'64bit':64}

Modified: trunk/numpy/f2py/auxfuncs.py
===================================================================
--- trunk/numpy/f2py/auxfuncs.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/f2py/auxfuncs.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -32,6 +32,9 @@
 debugoptions=[]
 wrapfuncs = 1
 
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 def outmess(t):
     if options.get('verbose',1):
         sys.stdout.write(t)

Modified: trunk/numpy/lib/arrayterator.py
===================================================================
--- trunk/numpy/lib/arrayterator.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/lib/arrayterator.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -14,6 +14,10 @@
 
 __all__ = ['Arrayterator']
 
+import sys
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 class Arrayterator(object):
     """
     Buffered iterator for big arrays.

Modified: trunk/numpy/lib/tests/test_arrayterator.py
===================================================================
--- trunk/numpy/lib/tests/test_arrayterator.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/lib/tests/test_arrayterator.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -4,6 +4,10 @@
 from numpy.random import randint
 from numpy.lib import Arrayterator
 
+import sys
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 def test():
     np.random.seed(np.arange(10))
 

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/ma/core.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -79,6 +79,9 @@
 from numpy import expand_dims as n_expand_dims
 import warnings
 
+import sys
+if sys.version_info[0] >= 3:
+    from functools import reduce
 
 MaskType = np.bool_
 nomask = MaskType(0)

Modified: trunk/numpy/ma/tests/test_core.py
===================================================================
--- trunk/numpy/ma/tests/test_core.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/ma/tests/test_core.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -19,6 +19,10 @@
 
 pi = np.pi
 
+import sys
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 #..............................................................................
 class TestMaskedArray(TestCase):
     "Base test class for MaskedArrays."

Modified: trunk/numpy/ma/tests/test_old_ma.py
===================================================================
--- trunk/numpy/ma/tests/test_old_ma.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/ma/tests/test_old_ma.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -5,6 +5,10 @@
 from numpy.ma.core import umath
 from numpy.testing import *
 
+import sys
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 pi = numpy.pi
 def eq(v,w, msg=''):
     result = allclose(v,w)

Modified: trunk/numpy/ma/timer_comparison.py
===================================================================
--- trunk/numpy/ma/timer_comparison.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/ma/timer_comparison.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -1,5 +1,6 @@
 import timeit
 
+import sys
 import numpy as np
 from numpy import float_
 import np.core.fromnumeric as fromnumeric
@@ -10,8 +11,10 @@
 
 pi = np.pi
 
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 class moduletester:
-    #-----------------------------------
     def __init__(self, module):
         self.module = module
         self.allequal = module.allequal
@@ -46,7 +49,7 @@
         except AttributeError:
             self.umath = module.core.umath
         self.testnames = []
-    #........................
+
     def assert_array_compare(self, comparison, x, y, err_msg='', header='',
                          fill_value=True):
         """Asserts that a comparison relation between two masked arrays is satisfied
@@ -100,19 +103,19 @@
         except ValueError:
             msg = build_err_msg([x, y], err_msg, header=header, names=('x', 'y'))
             raise ValueError(msg)
-    #............................
+
     def assert_array_equal(self, x, y, err_msg=''):
         """Checks the elementwise equality of two masked arrays."""
         self.assert_array_compare(self.equal, x, y, err_msg=err_msg,
                                   header='Arrays are not equal')
-    #----------------------------------
+
     def test_0(self):
         "Tests creation"
         x = np.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
         m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
         xm = self.masked_array(x, mask=m)
         xm[0]
-    #----------------------------------
+
     def test_1(self):
         "Tests creation"
         x = np.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
@@ -126,13 +129,13 @@
         zm = self.masked_array(z, mask=[0,1,0,0])
         xf = np.where(m1, 1.e+20, x)
         xm.set_fill_value(1.e+20)
-        #.....
+
         assert((xm-ym).filled(0).any())
         #fail_if_equal(xm.mask.astype(int_), ym.mask.astype(int_))
         s = x.shape
         assert(xm.size == reduce(lambda x,y:x*y, s))
         assert(self.count(xm) == len(m1) - reduce(lambda x,y:x+y, m1))
-        #.....
+
         for s in [(4,3), (6,2)]:
             x.shape = s
             y.shape = s
@@ -141,7 +144,7 @@
             xf.shape = s
 
             assert(self.count(xm) == len(m1) - reduce(lambda x,y:x+y, m1))
-    #----------------------------------
+
     def test_2(self):
         "Tests conversions and indexing"
         x1 = np.array([1,2,4,3])
@@ -193,7 +196,7 @@
         m3 = self.make_mask(m, copy=1)
         assert(m is not m3)
 
-    #----------------------------------
+
     def test_3(self):
         "Tests resize/repeat"
         x4 = self.arange(4)

Modified: trunk/numpy/oldnumeric/ma.py
===================================================================
--- trunk/numpy/oldnumeric/ma.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/numpy/oldnumeric/ma.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -18,6 +18,9 @@
 import numpy.core.numeric as numeric
 import warnings
 
+if sys.version_info[0] >= 3:
+    from functools import reduce
+
 # Ufunc domain lookup for __array_wrap__
 ufunc_domain = {}
 # Ufunc fills lookup for __array__

Modified: trunk/tools/py3tool.py
===================================================================
--- trunk/tools/py3tool.py	2010-02-20 18:19:37 UTC (rev 8187)
+++ trunk/tools/py3tool.py	2010-02-20 18:20:10 UTC (rev 8188)
@@ -39,6 +39,15 @@
     'numpy/core/defchararray.py': '-x unicode',
     'numpy/compat/py3k.py': '-x unicode',
     'numpy/ma/timer_comparison.py': 'skip',
+    'numpy/distutils/system_info.py': '-x reduce',
+    'numpy/f2py/auxfuncs.py': '-x reduce',
+    'numpy/lib/arrayterator.py': '-x reduce',
+    'numpy/lib/tests/test_arrayterator.py': '-x reduce',
+    'numpy/ma/core.py': '-x reduce',
+    'numpy/ma/tests/test_core.py': '-x reduce',
+    'numpy/ma/tests/test_old_ma.py': '-x reduce',
+    'numpy/ma/timer_comparison.py': '-x reduce',
+    'numpy/oldnumeric/ma.py': '-x reduce',
 }
 
 def main():



More information about the Numpy-svn mailing list