Test pack/unpack of blockwise that includes a NumPy literal argument
(c, s, a, b)
| 602 | |
| 603 | @gen_cluster(client=True) |
| 604 | async def test_blockwise_numpy_args(c, s, a, b): |
| 605 | """Test pack/unpack of blockwise that includes a NumPy literal argument""" |
| 606 | pytest.importorskip("numpy") |
| 607 | da = pytest.importorskip("dask.array") |
| 608 | np = pytest.importorskip("numpy") |
| 609 | |
| 610 | def fn(x, dt): |
| 611 | assert type(dt) is np.uint16 |
| 612 | return x.astype(dt) |
| 613 | |
| 614 | arr = da.blockwise( |
| 615 | fn, "x", da.ones(1000), "x", np.uint16(42), None, dtype=np.uint16 |
| 616 | ) |
| 617 | res = await c.compute(arr.sum(), optimize_graph=False) |
| 618 | assert res == 1000 |
| 619 | |
| 620 | |
| 621 | @gen_cluster(client=True) |