| 635 | |
| 636 | |
| 637 | def test_blockwise_different_optimization(c): |
| 638 | # Regression test for incorrect results due to SubgraphCallable.__eq__ |
| 639 | # not correctly handling subgraphs with the same outputs and arity but |
| 640 | # different internals (GH-7632). The bug is triggered by distributed |
| 641 | # because it uses a function cache. |
| 642 | np = pytest.importorskip("numpy") |
| 643 | da = pytest.importorskip("dask.array") |
| 644 | |
| 645 | u = da.from_array(np.arange(3)) |
| 646 | v = da.from_array(np.array([10 + 2j, 7 - 3j, 8 + 1j])) |
| 647 | cv = v.conj() |
| 648 | x = u * cv |
| 649 | (cv,) = dask.optimize(cv) |
| 650 | y = u * cv |
| 651 | expected = np.array([0 + 0j, 7 + 3j, 16 - 2j]) |
| 652 | with dask.config.set({"optimization.fuse.active": False}): |
| 653 | x_value = x.compute() |
| 654 | y_value = y.compute() |
| 655 | np.testing.assert_equal(x_value, expected) |
| 656 | np.testing.assert_equal(y_value, expected) |
| 657 | |
| 658 | |
| 659 | @gen_cluster(client=True) |