diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-21 02:53:26 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-21 02:53:26 +0000 |
commit | 2a7e659e45db24162bdc49b1a83b7c69796c6be2 (patch) | |
tree | e105ea229e1673a91db24f3a2191b0e7ae626457 /numpy/ma/tests | |
parent | eac637ec20fa18762da0a7961065f30bf5b2e328 (diff) | |
download | numpy-2a7e659e45db24162bdc49b1a83b7c69796c6be2.tar.gz |
3K: ENH: ma: fix str vs bytes and int issues in ma tests
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r-- | numpy/ma/tests/test_core.py | 10 | ||||
-rw-r--r-- | numpy/ma/tests/test_mrecords.py | 6 | ||||
-rw-r--r-- | numpy/ma/tests/test_old_ma.py | 10 |
3 files changed, 18 insertions, 8 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 5a02e554b..036a01ed6 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -803,13 +803,19 @@ class TestMaskedArrayArithmetic(TestCase): 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)) diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py index 87051bfad..f068d4e50 100644 --- a/numpy/ma/tests/test_mrecords.py +++ b/numpy/ma/tests/test_mrecords.py @@ -36,11 +36,9 @@ class TestMRecords(TestCase): "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 @@ class TestMRecords(TestCase): 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)) diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index 5c9448256..cf971b32c 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -153,13 +153,19 @@ class TestMa(TestCase): 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))) |