| 402 | |
| 403 | |
| 404 | def test_count(): |
| 405 | data = np.arange(120).reshape((12, 10)) |
| 406 | mask = (data % 3 == 0) | (data % 4 == 0) |
| 407 | x = np.ma.masked_where(mask, data) |
| 408 | dx = da.from_array(x, chunks=(2, 3)) |
| 409 | |
| 410 | for axis in (None, 0, 1): |
| 411 | res = da.ma.count(dx, axis=axis) |
| 412 | sol = np.ma.count(x, axis=axis) |
| 413 | assert_eq(res, sol) |
| 414 | |
| 415 | res = da.ma.count(dx, keepdims=True) |
| 416 | sol = np.ma.count(x, keepdims=True) |
| 417 | assert_eq(res, sol) |
| 418 | |
| 419 | # Test all masked |
| 420 | x = np.ma.masked_all((12, 10)) |
| 421 | dx = da.from_array(x, chunks=(2, 3)) |
| 422 | assert_eq(da.ma.count(dx), np.ma.count(x)) |
| 423 | |
| 424 | # Test on non-masked array |
| 425 | x = np.arange(120).reshape((12, 10)) |
| 426 | dx = da.from_array(data, chunks=(2, 3)) |
| 427 | for axis in (None, 0, 1): |
| 428 | res = da.ma.count(dx, axis=axis) |
| 429 | sol = np.ma.count(x, axis=axis) |
| 430 | assert_eq(res, sol, check_dtype=sys.platform != "win32") |
| 431 | |
| 432 | |
| 433 | @pytest.mark.parametrize("funcname", ["ones_like", "zeros_like", "empty_like"]) |