8000 Merge pull request #4699 from charris/fix-ma.count-return-type-check · numpy/numpy@afe32d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit afe32d7

Browse files
committed
Merge pull request #4699 from charris/fix-ma.count-return-type-check
BUG, TST: Fix tests of ma.count return type.
2 parents d1987d1 + 9592bfa commit afe32d7

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

numpy/ma/tests/test_core.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -808,27 +808,29 @@ def test_basic_ufuncs(self):
808808

809809
def test_count_func(self):
810810
# Tests count
811-
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
812-
ott1= array([0., 1., 2., 3.])
813-
if sys.version_info[0] >= 3:
814-
self.assertTrue(isinstance(count(ott), np.integer))
815-
else:
816-
self.assertTrue(isinstance(count(ott), int))
817-
assert_equal(3, count(ott))
818811
assert_equal(1, count(1))
819812
assert_equal(0, array(1, mask=[1]))
813+
814+
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
815+
res = count(ott)
816+
self.assertTrue(res.dtype.type is np.intp)
817+
assert_equal(3, res)
818+
820819
ott = ott.reshape((2, 2))
821-
assert_(isinstance(count(ott, 0), ndarray))
822-
if sys.version_info[0] >= 3:
823-
assert_(isinstance(count(ott), np.integer))
824-
else:
825-
assert_(isinstance(count(ott), int))
826-
assert_equal(3, count(ott))
827-
assert_(getmask(count(ott, 0)) is nomask)
828-
assert_equal([1, 2], count(ott, 0))
829-
assert_equal(type(count(ott, 0)), type(count(ott1, 0)))
830-
assert_equal(count(ott, 0).dtype, count(ott1, 0).dtype)
831-
assert_raises(IndexError, ott1.count, 1)
820+
res = count(ott)
821+
assert_(res.dtype.type is np.intp)
822+
assert_equal(3, res)
823+
res = count(ott, 0)
824+
assert_(isinstance(res, ndarray))
825+
assert_equal([1, 2], res)
826+
assert_(getmask(res) is nomask)
827+
828+
ott= array([0., 1., 2., 3.])
829+
res = count(ott, 0)
830+
assert_(isinstance(res, ndarray))
831+
assert_(res.dtype.type is np.intp)
832+
833+
assert_raises(IndexError, ott.count, 1)
832834

833835
def test_minmax_func(self):
834836
# Tests minimum and maximum.

numpy/ma/tests/test_old_ma.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,14 @@ def test_testUfuncs1(self):
153153
def test_xtestCount(self):
154154
# Test count
155155
ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
156-
if sys.version_info[0] >= 3:
157-
self.assertTrue(isinstance(count(ott), np.integer))
158-
else:
159-
self.assertTrue(isinstance(count(ott), int))
156+
self.assertTrue(count(ott).dtype.type is np.intp)
160157
self.assertEqual(3, count(ott))
161158
self.assertEqual(1, count(1))
162159
self.assertTrue(eq(0, array(1, mask=[1])))
163160
ott = ott.reshape((2, 2))
161+
self.assertTrue(count(ott).dtype.type is np.intp)
164162
assert_(isinstance(count(ott, 0), np.ndarray))
165-
if sys.version_info[0] >= 3:
166-
assert_(isinstance(count(ott), np.integer))
167-
else:
168-
assert_(isinstance(count(ott), int))
163+
self.assertTrue(count(ott).dtype.type is np.intp)
169164
self.assertTrue(eq(3, count(ott)))
170165
assert_(getmask(count(ott, 0)) is nomask)
171166
self.assertTrue(eq([1, 2], count(ott, 0)))

0 commit comments

Comments
 (0)
0