| 450 | |
| 451 | |
| 452 | def test_nonzero(): |
| 453 | data = np.arange(9).reshape((3, 3)) |
| 454 | mask = np.array([[True, False, False], [True, True, False], [True, False, True]]) |
| 455 | a = np.ma.array(data, mask=mask) |
| 456 | d_a = da.ma.masked_array(data=data, mask=mask, chunks=2) |
| 457 | |
| 458 | for c1, c2 in [ |
| 459 | (a > 4, d_a > 4), |
| 460 | (a, d_a), |
| 461 | (a <= -2, d_a <= -2), |
| 462 | (a == 0, d_a == 0), |
| 463 | ]: |
| 464 | sol = np.ma.nonzero(c1) |
| 465 | res = da.ma.nonzero(c2) |
| 466 | |
| 467 | assert isinstance(res, type(sol)) |
| 468 | assert len(res) == len(sol) |
| 469 | |
| 470 | for i in range(len(sol)): |
| 471 | assert_eq(res[i], sol[i]) |
| 472 | |
| 473 | |
| 474 | def test_where(): |