[Numpy-svn] r8224 - trunk/numpy/ma/tests

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 20:53:27 CST 2010


Author: ptvirtan
Date: 2010-02-20 20:53:26 -0600 (Sat, 20 Feb 2010)
New Revision: 8224

Modified:
   trunk/numpy/ma/tests/test_core.py
   trunk/numpy/ma/tests/test_mrecords.py
   trunk/numpy/ma/tests/test_old_ma.py
Log:
3K: ENH: ma: fix str vs bytes and int issues in ma tests

Modified: trunk/numpy/ma/tests/test_core.py
===================================================================
--- trunk/numpy/ma/tests/test_core.py	2010-02-21 02:53:10 UTC (rev 8223)
+++ trunk/numpy/ma/tests/test_core.py	2010-02-21 02:53:26 UTC (rev 8224)
@@ -803,13 +803,19 @@
     def test_count_func (self):
         "Tests count"
         ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
-        self.assertTrue(isinstance(count(ott), int))
+        if sys.version_info[0] >= 3:
+            self.assertTrue(isinstance(count(ott), np.integer))
+        else:
+            self.assertTrue(isinstance(count(ott), int))
         assert_equal(3, count(ott))
         assert_equal(1, count(1))
         assert_equal(0, array(1, mask=[1]))
         ott = ott.reshape((2, 2))
         assert isinstance(count(ott, 0), ndarray)
-        assert isinstance(count(ott), types.IntType)
+        if sys.version_info[0] >= 3:
+            assert isinstance(count(ott), np.integer)
+        else:
+            assert isinstance(count(ott), types.IntType)
         assert_equal(3, count(ott))
         assert getmask(count(ott, 0)) is nomask
         assert_equal([1, 2], count(ott, 0))

Modified: trunk/numpy/ma/tests/test_mrecords.py
===================================================================
--- trunk/numpy/ma/tests/test_mrecords.py	2010-02-21 02:53:10 UTC (rev 8223)
+++ trunk/numpy/ma/tests/test_mrecords.py	2010-02-21 02:53:26 UTC (rev 8224)
@@ -36,11 +36,9 @@
         "Generic setup"
         ilist = [1,2,3,4,5]
         flist = [1.1,2.2,3.3,4.4,5.5]
-        slist = ['one','two','three','four','five']
+        slist = asbytes_nested(['one','two','three','four','five'])
         ddtype = [('a',int),('b',float),('c','|S8')]
         mask = [0,1,0,0,1]
-        if sys.version_info[0] >= 3:
-            slist = list(map(asbytes, slist))
         self.base = ma.array(list(zip(ilist,flist,slist)),
                              mask=mask, dtype=ddtype)
 
@@ -120,7 +118,7 @@
         assert_equal(mbase.c.mask, [1]*5)
         assert_equal(mbase.c.recordmask, [1]*5)
         assert_equal(ma.getmaskarray(mbase['c']), [1]*5)
-        assert_equal(ma.getdata(mbase['c']), ['N/A']*5)
+        assert_equal(ma.getdata(mbase['c']), [asbytes('N/A')]*5)
         assert_equal(mbase._mask.tolist(),
                      np.array([(0,0,1),(0,1,1),(0,0,1),(0,0,1),(0,1,1)],
                               dtype=bool))

Modified: trunk/numpy/ma/tests/test_old_ma.py
===================================================================
--- trunk/numpy/ma/tests/test_old_ma.py	2010-02-21 02:53:10 UTC (rev 8223)
+++ trunk/numpy/ma/tests/test_old_ma.py	2010-02-21 02:53:26 UTC (rev 8224)
@@ -153,13 +153,19 @@
     def test_xtestCount (self):
         "Test count"
         ott = array([0.,1.,2.,3.], mask=[1,0,0,0])
-        self.assertTrue( isinstance(count(ott), types.IntType))
+        if sys.version_info[0] >= 3:
+            self.assertTrue( isinstance(count(ott), numpy.integer))
+        else:
+            self.assertTrue( isinstance(count(ott), types.IntType))
         self.assertEqual(3, count(ott))
         self.assertEqual(1, count(1))
         self.assertTrue (eq(0, array(1,mask=[1])))
         ott=ott.reshape((2,2))
         assert isinstance(count(ott,0),numpy.ndarray)
-        assert isinstance(count(ott), types.IntType)
+        if sys.version_info[0] >= 3:
+            assert isinstance(count(ott), numpy.integer)
+        else:
+            assert isinstance(count(ott), types.IntType)
         self.assertTrue (eq(3, count(ott)))
         assert getmask(count(ott,0)) is nomask
         self.assertTrue (eq([1,2],count(ott,0)))



More information about the Numpy-svn mailing list