| 355 | |
| 356 | @pytest.mark.parametrize(["dfunc", "func"], [(da.min, np.min), (da.max, np.max)]) |
| 357 | def test_min_max_empty_chunks(dfunc, func): |
| 358 | x1 = np.arange(10) |
| 359 | a1 = da.from_array(x1, chunks=1) |
| 360 | assert_eq(dfunc(a1[a1 < 2]), func(x1[x1 < 2])) |
| 361 | |
| 362 | x2 = np.arange(10) |
| 363 | a2 = da.from_array(x2, chunks=((5, 0, 5),)) |
| 364 | assert_eq(dfunc(a2), func(x2)) |
| 365 | |
| 366 | x3 = np.array([[1, 1, 2, 3], [1, 1, 4, 0]]) |
| 367 | a3 = da.from_array(x3, chunks=1) |
| 368 | assert_eq(dfunc(a3[a3 >= 2]), func(x3[x3 >= 2])) |
| 369 | |
| 370 | a4 = da.arange(10) |
| 371 | with pytest.raises( |
| 372 | ValueError |
| 373 | ): # Checking it mimics numpy behavior when all chunks are empty |
| 374 | dfunc(a4[a4 < 0]).compute() |
| 375 | |
| 376 | |
| 377 | @pytest.mark.parametrize("func", ["argmax", "nanargmax"]) |