(self)
| 7206 | np.arange(10).mean(axis=2) |
| 7207 | |
| 7208 | def test_mean_where(self): |
| 7209 | a = np.arange(16).reshape((4, 4)) |
| 7210 | wh_full = np.array([[False, True, False, True], |
| 7211 | [True, False, True, False], |
| 7212 | [True, True, False, False], |
| 7213 | [False, False, True, True]]) |
| 7214 | wh_partial = np.array([[False], |
| 7215 | [True], |
| 7216 | [True], |
| 7217 | [False]]) |
| 7218 | _cases = [(1, True, [1.5, 5.5, 9.5, 13.5]), |
| 7219 | (0, wh_full, [6., 5., 10., 9.]), |
| 7220 | (1, wh_full, [2., 5., 8.5, 14.5]), |
| 7221 | (0, wh_partial, [6., 7., 8., 9.])] |
| 7222 | for _ax, _wh, _res in _cases: |
| 7223 | assert_allclose(a.mean(axis=_ax, where=_wh), |
| 7224 | np.array(_res)) |
| 7225 | assert_allclose(np.mean(a, axis=_ax, where=_wh), |
| 7226 | np.array(_res)) |
| 7227 | |
| 7228 | a3d = np.arange(16).reshape((2, 2, 4)) |
| 7229 | _wh_partial = np.array([False, True, True, False]) |
| 7230 | _res = [[1.5, 5.5], [9.5, 13.5]] |
| 7231 | assert_allclose(a3d.mean(axis=2, where=_wh_partial), |
| 7232 | np.array(_res)) |
| 7233 | assert_allclose(np.mean(a3d, axis=2, where=_wh_partial), |
| 7234 | np.array(_res)) |
| 7235 | |
| 7236 | with pytest.warns(RuntimeWarning) as w: |
| 7237 | assert_allclose(a.mean(axis=1, where=wh_partial), |
| 7238 | np.array([np.nan, 5.5, 9.5, np.nan])) |
| 7239 | with pytest.warns(RuntimeWarning) as w: |
| 7240 | assert_equal(a.mean(where=False), np.nan) |
| 7241 | with pytest.warns(RuntimeWarning) as w: |
| 7242 | assert_equal(np.mean(a, where=False), np.nan) |
| 7243 | |
| 7244 | def test_var_values(self): |
| 7245 | rmat, cmat, omat = self._create_data() |
nothing calls this directly
no test coverage detected