(self)
| 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 |
| 1382 | x = self._create_data() |
| 1383 | x[-1] = masked |
| 1384 | x = x.reshape(3, 4) |
| 1385 | valid = np.logical_not(getmaskarray(x)).astype(int) |
| 1386 | frac = np.dot(valid, valid.T) |
| 1387 | xf = (x - x.mean(1)[:, None]).filled(0) |
| 1388 | assert_almost_equal(cov(x), |
| 1389 | np.cov(xf) * (x.shape[1] - 1) / (frac - 1.)) |
| 1390 | assert_almost_equal(cov(x, bias=True), |
| 1391 | np.cov(xf, bias=True) * x.shape[1] / frac) |
| 1392 | frac = np.dot(valid.T, valid) |
| 1393 | xf = (x - x.mean(0)).filled(0) |
| 1394 | assert_almost_equal(cov(x, rowvar=False), |
| 1395 | (np.cov(xf, rowvar=False) * |
| 1396 | (x.shape[0] - 1) / (frac - 1.))) |
| 1397 | assert_almost_equal(cov(x, rowvar=False, bias=True), |
| 1398 | (np.cov(xf, rowvar=False, bias=True) * |
| 1399 | x.shape[0] / frac)) |
| 1400 | |
| 1401 | |
| 1402 | class TestCorrcoef: |
nothing calls this directly
no test coverage detected