MCPcopy Create free account
hub / github.com/numpy/numpy / test_count_func

Method test_count_func

numpy/ma/tests/test_core.py:1181–1204  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1179 assert_equal(np.conjugate(x), conjugate(xm))
1180
1181 def test_count_func(self):
1182 # Tests count
1183 assert_equal(1, count(1))
1184 assert_equal(0, array(1, mask=[1]))
1185
1186 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
1187 res = count(ott)
1188 assert_(res.dtype.type is np.intp)
1189 assert_equal(3, res)
1190
1191 ott = ott.reshape((2, 2))
1192 res = count(ott)
1193 assert_(res.dtype.type is np.intp)
1194 assert_equal(3, res)
1195 res = count(ott, 0)
1196 assert_(isinstance(res, ndarray))
1197 assert_equal([1, 2], res)
1198 assert_(getmask(res) is nomask)
1199
1200 ott = array([0., 1., 2., 3.])
1201 res = count(ott, 0)
1202 assert_(isinstance(res, ndarray))
1203 assert_(res.dtype.type is np.intp)
1204 assert_raises(np.AxisError, ott.count, axis=1)
1205
1206 def test_count_on_python_builtins(self):
1207 # Tests count works on python builtins (issue#8019)

Callers

nothing calls this directly

Calls 7

assert_equalFunction · 0.90
countFunction · 0.90
arrayFunction · 0.90
getmaskFunction · 0.90
assert_raisesFunction · 0.90
reshapeMethod · 0.80
assert_Function · 0.50

Tested by

no test coverage detected