MCPcopy
hub / github.com/numpy/numpy / test_anom

Method test_anom

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

Source from the content-addressed store, hash-verified

4210 assert_(np.ma.is_masked(a.anom()))
4211
4212 def test_anom(self):
4213 a = masked_array(np.arange(1, 7).reshape(2, 3))
4214 assert_almost_equal(a.anom(),
4215 [[-2.5, -1.5, -0.5], [0.5, 1.5, 2.5]])
4216 assert_almost_equal(a.anom(axis=0),
4217 [[-1.5, -1.5, -1.5], [1.5, 1.5, 1.5]])
4218 assert_almost_equal(a.anom(axis=1),
4219 [[-1., 0., 1.], [-1., 0., 1.]])
4220 a.mask = [[0, 0, 1], [0, 1, 0]]
4221 mval = -99
4222 assert_almost_equal(a.anom().filled(mval),
4223 [[-2.25, -1.25, mval], [0.75, mval, 2.75]])
4224 assert_almost_equal(a.anom(axis=0).filled(mval),
4225 [[-1.5, 0.0, mval], [1.5, mval, 0.0]])
4226 assert_almost_equal(a.anom(axis=1).filled(mval),
4227 [[-0.5, 0.5, mval], [-1.0, mval, 1.0]])
4228
4229 def test_trace(self):
4230 # 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