(self)
| 6241 | np.arange(10).mean(axis=2) |
| 6242 | |
| 6243 | def test_mean_where(self): |
| 6244 | a = np.arange(16).reshape((4, 4)) |
| 6245 | wh_full = np.array([[False, True, False, True], |
| 6246 | [True, False, True, False], |
| 6247 | [True, True, False, False], |
| 6248 | [False, False, True, True]]) |
| 6249 | wh_partial = np.array([[False], |
| 6250 | [True], |
| 6251 | [True], |
| 6252 | [False]]) |
| 6253 | _cases = [(1, True, [1.5, 5.5, 9.5, 13.5]), |
| 6254 | (0, wh_full, [6., 5., 10., 9.]), |
| 6255 | (1, wh_full, [2., 5., 8.5, 14.5]), |
| 6256 | (0, wh_partial, [6., 7., 8., 9.])] |
| 6257 | for _ax, _wh, _res in _cases: |
| 6258 | assert_allclose(a.mean(axis=_ax, where=_wh), |
| 6259 | np.array(_res)) |
| 6260 | assert_allclose(np.mean(a, axis=_ax, where=_wh), |
| 6261 | np.array(_res)) |
| 6262 | |
| 6263 | a3d = np.arange(16).reshape((2, 2, 4)) |
| 6264 | _wh_partial = np.array([False, True, True, False]) |
| 6265 | _res = [[1.5, 5.5], [9.5, 13.5]] |
| 6266 | assert_allclose(a3d.mean(axis=2, where=_wh_partial), |
| 6267 | np.array(_res)) |
| 6268 | assert_allclose(np.mean(a3d, axis=2, where=_wh_partial), |
| 6269 | np.array(_res)) |
| 6270 | |
| 6271 | with pytest.warns(RuntimeWarning) as w: |
| 6272 | assert_allclose(a.mean(axis=1, where=wh_partial), |
| 6273 | np.array([np.nan, 5.5, 9.5, np.nan])) |
| 6274 | with pytest.warns(RuntimeWarning) as w: |
| 6275 | assert_equal(a.mean(where=False), np.nan) |
| 6276 | with pytest.warns(RuntimeWarning) as w: |
| 6277 | assert_equal(np.mean(a, where=False), np.nan) |
| 6278 | |
| 6279 | def test_var_values(self): |
| 6280 | for mat in [self.rmat, self.cmat, self.omat]: |
nothing calls this directly
no test coverage detected