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

Method test_1d_with_missing

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

Source from the content-addressed store, hash-verified

1253 cov(x, rowvar=False, bias=True))
1254
1255 def test_1d_with_missing(self):
1256 # Test cov 1 1D variable w/missing values
1257 x = self.data
1258 x[-1] = masked
1259 x -= x.mean()
1260 nx = x.compressed()
1261 assert_almost_equal(np.cov(nx), cov(x))
1262 assert_almost_equal(np.cov(nx, rowvar=False), cov(x, rowvar=False))
1263 assert_almost_equal(np.cov(nx, rowvar=False, bias=True),
1264 cov(x, rowvar=False, bias=True))
1265 #
1266 try:
1267 cov(x, allow_masked=False)
1268 except ValueError:
1269 pass
1270 #
1271 # 2 1D variables w/ missing values
1272 nx = x[1:-1]
1273 assert_almost_equal(np.cov(nx, nx[::-1]), cov(x, x[::-1]))
1274 assert_almost_equal(np.cov(nx, nx[::-1], rowvar=False),
1275 cov(x, x[::-1], rowvar=False))
1276 assert_almost_equal(np.cov(nx, nx[::-1], rowvar=False, bias=True),
1277 cov(x, x[::-1], rowvar=False, bias=True))
1278
1279 def test_2d_with_missing(self):
1280 # Test cov on 2D variable w/ missing value

Callers

nothing calls this directly

Calls 4

assert_almost_equalFunction · 0.90
covFunction · 0.90
meanMethod · 0.45
compressedMethod · 0.45

Tested by

no test coverage detected