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