| 201 | |
| 202 | |
| 203 | def test_nanfunctions_matrices_general(): |
| 204 | # Check that it works and that type and |
| 205 | # shape are preserved |
| 206 | # 2018-04-29: moved here from core.tests.test_nanfunctions |
| 207 | mat = np.matrix(np.eye(3)) |
| 208 | for f in (np.nanargmin, np.nanargmax, np.nansum, np.nanprod, |
| 209 | np.nanmean, np.nanvar, np.nanstd): |
| 210 | res = f(mat, axis=0) |
| 211 | assert_(isinstance(res, np.matrix)) |
| 212 | assert_(res.shape == (1, 3)) |
| 213 | res = f(mat, axis=1) |
| 214 | assert_(isinstance(res, np.matrix)) |
| 215 | assert_(res.shape == (3, 1)) |
| 216 | res = f(mat) |
| 217 | assert_(np.isscalar(res)) |
| 218 | |
| 219 | for f in np.nancumsum, np.nancumprod: |
| 220 | res = f(mat, axis=0) |
| 221 | assert_(isinstance(res, np.matrix)) |
| 222 | assert_(res.shape == (3, 3)) |
| 223 | res = f(mat, axis=1) |
| 224 | assert_(isinstance(res, np.matrix)) |
| 225 | assert_(res.shape == (3, 3)) |
| 226 | res = f(mat) |
| 227 | assert_(isinstance(res, np.matrix)) |
| 228 | assert_(res.shape == (1, 3*3)) |
| 229 | |
| 230 | |
| 231 | def test_average_matrix(): |