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

Method testkeepdims

numpy/ma/tests/test_core.py:5509–5523  ·  view source on GitHub ↗
(f, a, d)

Source from the content-addressed store, hash-verified

5507 numpy_f(d[..., :-1], axis=(0, 1)))
5508
5509 def testkeepdims(f, a, d):
5510 numpy_f = numpy.__getattribute__(f)
5511 ma_f = np.ma.__getattribute__(f)
5512
5513 # test keepdims arg
5514 assert_equal(ma_f(a, keepdims=True).shape,
5515 numpy_f(d, keepdims=True).shape)
5516 assert_equal(ma_f(a, keepdims=False).shape,
5517 numpy_f(d, keepdims=False).shape)
5518
5519 # test both at once
5520 assert_equal(ma_f(a, axis=1, keepdims=True)[..., :-1],
5521 numpy_f(d[..., :-1], axis=1, keepdims=True))
5522 assert_equal(ma_f(a, axis=(0, 1), keepdims=True)[..., :-1],
5523 numpy_f(d[..., :-1], axis=(0, 1), keepdims=True))
5524
5525 for f in ['sum', 'prod', 'mean', 'var', 'std']:
5526 testaxis(f, a, d)

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
__getattribute__Method · 0.45

Tested by

no test coverage detected