MCPcopy
hub / github.com/numpy/numpy / test_count_func

Method test_count_func

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

Source from the content-addressed store, hash-verified

1300 assert np.sqrt(np.ma.masked) is np.ma.masked
1301
1302 def test_count_func(self):
1303 # Tests count
1304 assert_equal(1, count(1))
1305 assert_equal(0, array(1, mask=[1]))
1306
1307 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
1308 res = count(ott)
1309 assert_(res.dtype.type is np.intp)
1310 assert_equal(3, res)
1311
1312 ott = ott.reshape((2, 2))
1313 res = count(ott)
1314 assert_(res.dtype.type is np.intp)
1315 assert_equal(3, res)
1316 res = count(ott, 0)
1317 assert_(isinstance(res, ndarray))
1318 assert_equal([1, 2], res)
1319 assert_(getmask(res) is nomask)
1320
1321 ott = array([0., 1., 2., 3.])
1322 res = count(ott, 0)
1323 assert_(isinstance(res, ndarray))
1324 assert_(res.dtype.type is np.intp)
1325 assert_raises(AxisError, ott.count, axis=1)
1326
1327 def test_count_on_python_builtins(self):
1328 # 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
assert_Function · 0.85
reshapeMethod · 0.80

Tested by

no test coverage detected