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

Method test_1d_with_missing

numpy/ma/tests/test_extras.py:1356–1378  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1354 cov(x, rowvar=False, bias=True))
1355
1356 def test_1d_with_missing(self):
1357 # Test cov 1 1D variable w/missing values
1358 x = self._create_data()
1359 x[-1] = masked
1360 x -= x.mean()
1361 nx = x.compressed()
1362 assert_almost_equal(np.cov(nx), cov(x))
1363 assert_almost_equal(np.cov(nx, rowvar=False), cov(x, rowvar=False))
1364 assert_almost_equal(np.cov(nx, rowvar=False, bias=True),
1365 cov(x, rowvar=False, bias=True))
1366 #
1367 try:
1368 cov(x, allow_masked=False)
1369 except ValueError:
1370 pass
1371 #
1372 # 2 1D variables w/ missing values
1373 nx = x[1:-1]
1374 assert_almost_equal(np.cov(nx, nx[::-1]), cov(x, x[::-1]))
1375 assert_almost_equal(np.cov(nx, nx[::-1], rowvar=False),
1376 cov(x, x[::-1], rowvar=False))
1377 assert_almost_equal(np.cov(nx, nx[::-1], rowvar=False, bias=True),
1378 cov(x, x[::-1], rowvar=False, bias=True))
1379
1380 def test_2d_with_missing(self):
1381 # Test cov on 2D variable w/ missing value

Callers

nothing calls this directly

Calls 5

_create_dataMethod · 0.95
assert_almost_equalFunction · 0.90
covFunction · 0.90
meanMethod · 0.45
compressedMethod · 0.45

Tested by

no test coverage detected