(self)
| 6325 | np.arange(10).var(axis=2) |
| 6326 | |
| 6327 | def test_var_where(self): |
| 6328 | a = np.arange(25).reshape((5, 5)) |
| 6329 | wh_full = np.array([[False, True, False, True, True], |
| 6330 | [True, False, True, True, False], |
| 6331 | [True, True, False, False, True], |
| 6332 | [False, True, True, False, True], |
| 6333 | [True, False, True, True, False]]) |
| 6334 | wh_partial = np.array([[False], |
| 6335 | [True], |
| 6336 | [True], |
| 6337 | [False], |
| 6338 | [True]]) |
| 6339 | _cases = [(0, True, [50., 50., 50., 50., 50.]), |
| 6340 | (1, True, [2., 2., 2., 2., 2.])] |
| 6341 | for _ax, _wh, _res in _cases: |
| 6342 | assert_allclose(a.var(axis=_ax, where=_wh), |
| 6343 | np.array(_res)) |
| 6344 | assert_allclose(np.var(a, axis=_ax, where=_wh), |
| 6345 | np.array(_res)) |
| 6346 | |
| 6347 | a3d = np.arange(16).reshape((2, 2, 4)) |
| 6348 | _wh_partial = np.array([False, True, True, False]) |
| 6349 | _res = [[0.25, 0.25], [0.25, 0.25]] |
| 6350 | assert_allclose(a3d.var(axis=2, where=_wh_partial), |
| 6351 | np.array(_res)) |
| 6352 | assert_allclose(np.var(a3d, axis=2, where=_wh_partial), |
| 6353 | np.array(_res)) |
| 6354 | |
| 6355 | assert_allclose(np.var(a, axis=1, where=wh_full), |
| 6356 | np.var(a[wh_full].reshape((5, 3)), axis=1)) |
| 6357 | assert_allclose(np.var(a, axis=0, where=wh_partial), |
| 6358 | np.var(a[wh_partial[:,0]], axis=0)) |
| 6359 | with pytest.warns(RuntimeWarning) as w: |
| 6360 | assert_equal(a.var(where=False), np.nan) |
| 6361 | with pytest.warns(RuntimeWarning) as w: |
| 6362 | assert_equal(np.var(a, where=False), np.nan) |
| 6363 | |
| 6364 | def test_std_values(self): |
| 6365 | for mat in [self.rmat, self.cmat, self.omat]: |
nothing calls this directly
no test coverage detected