| 487 | ) |
| 488 | @pytest.mark.parametrize("fuse", [True, False, None]) |
| 489 | def test_blockwise_array_creation(c, io, fuse): |
| 490 | np = pytest.importorskip("numpy") |
| 491 | da = pytest.importorskip("dask.array") |
| 492 | |
| 493 | chunks = (5, 2) |
| 494 | shape = (10, 4) |
| 495 | |
| 496 | if io == "ones": |
| 497 | darr = da.ones(shape, chunks=chunks) |
| 498 | narr = np.ones(shape) |
| 499 | elif io == "zeros": |
| 500 | darr = da.zeros(shape, chunks=chunks) |
| 501 | narr = np.zeros(shape) |
| 502 | elif io == "full": |
| 503 | darr = da.full(shape, 10, chunks=chunks) |
| 504 | narr = np.full(shape, 10) |
| 505 | |
| 506 | darr += 2 |
| 507 | narr += 2 |
| 508 | with dask.config.set({"optimization.fuse.active": fuse}): |
| 509 | darr.compute() |
| 510 | dsk = dask.array.optimize(darr.dask, darr.__dask_keys__()) |
| 511 | # dsk should be a dict unless fuse is explicitly False |
| 512 | assert isinstance(dsk, dict) == (fuse is not False) |
| 513 | da.assert_eq(darr, narr, scheduler=c) |
| 514 | |
| 515 | |
| 516 | @ignore_sync_scheduler_warning |