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

Method test_anom

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

Source from the content-addressed store, hash-verified

3973 assert_(np.ma.is_masked(a.anom()))
3974
3975 def test_anom(self):
3976 a = masked_array(np.arange(1, 7).reshape(2, 3))
3977 assert_almost_equal(a.anom(),
3978 [[-2.5, -1.5, -0.5], [0.5, 1.5, 2.5]])
3979 assert_almost_equal(a.anom(axis=0),
3980 [[-1.5, -1.5, -1.5], [1.5, 1.5, 1.5]])
3981 assert_almost_equal(a.anom(axis=1),
3982 [[-1., 0., 1.], [-1., 0., 1.]])
3983 a.mask = [[0, 0, 1], [0, 1, 0]]
3984 mval = -99
3985 assert_almost_equal(a.anom().filled(mval),
3986 [[-2.25, -1.25, mval], [0.75, mval, 2.75]])
3987 assert_almost_equal(a.anom(axis=0).filled(mval),
3988 [[-1.5, 0.0, mval], [1.5, mval, 0.0]])
3989 assert_almost_equal(a.anom(axis=1).filled(mval),
3990 [[-0.5, 0.5, mval], [-1.0, mval, 1.0]])
3991
3992 def test_trace(self):
3993 # Tests trace on MaskedArrays.

Callers

nothing calls this directly

Calls 4

assert_almost_equalFunction · 0.90
reshapeMethod · 0.80
anomMethod · 0.80
filledMethod · 0.45

Tested by

no test coverage detected