MCPcopy Index your code
hub / github.com/numpy/numpy / test_varstd

Method test_varstd

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

Source from the content-addressed store, hash-verified

4291 assert_(foo.var(axis=1, out=bar) is bar)
4292
4293 def test_varstd(self):
4294 # Tests var & std on MaskedArrays.
4295 _, X, XX, _, _, mX, mXX, _, _, _ = self._create_data()
4296 assert_almost_equal(mX.var(axis=None), mX.compressed().var())
4297 assert_almost_equal(mX.std(axis=None), mX.compressed().std())
4298 assert_almost_equal(mX.std(axis=None, ddof=1),
4299 mX.compressed().std(ddof=1))
4300 assert_almost_equal(mX.var(axis=None, ddof=1),
4301 mX.compressed().var(ddof=1))
4302 assert_equal(mXX.var(axis=3).shape, XX.var(axis=3).shape)
4303 assert_equal(mX.var().shape, X.var().shape)
4304 (mXvar0, mXvar1) = (mX.var(axis=0), mX.var(axis=1))
4305 assert_almost_equal(mX.var(axis=None, ddof=2),
4306 mX.compressed().var(ddof=2))
4307 assert_almost_equal(mX.std(axis=None, ddof=2),
4308 mX.compressed().std(ddof=2))
4309 for k in range(6):
4310 assert_almost_equal(mXvar1[k], mX[k].compressed().var())
4311 assert_almost_equal(mXvar0[k], mX[:, k].compressed().var())
4312 assert_almost_equal(np.sqrt(mXvar0[k]),
4313 mX[:, k].compressed().std())
4314
4315 @pytest.mark.filterwarnings(WARNING_MARK_SPEC)
4316 def test_varstd_specialcases(self):

Callers

nothing calls this directly

Calls 6

_create_dataMethod · 0.95
assert_almost_equalFunction · 0.90
assert_equalFunction · 0.90
varMethod · 0.45
compressedMethod · 0.45
stdMethod · 0.45

Tested by

no test coverage detected