| 737 | |
| 738 | |
| 739 | def test_blockwise_chunks(): |
| 740 | x = da.ones((5, 5), chunks=((2, 1, 2), (3, 2))) |
| 741 | |
| 742 | def double(a, axis=0): |
| 743 | return np.concatenate([a, a], axis=axis) |
| 744 | |
| 745 | y = da.blockwise( |
| 746 | double, |
| 747 | "ij", |
| 748 | x, |
| 749 | "ij", |
| 750 | adjust_chunks={"i": lambda n: 2 * n}, |
| 751 | axis=0, |
| 752 | dtype=x.dtype, |
| 753 | ) |
| 754 | assert y.chunks == ((4, 2, 4), (3, 2)) |
| 755 | assert_eq(y, np.ones((10, 5))) |
| 756 | |
| 757 | y = da.blockwise( |
| 758 | double, |
| 759 | "ij", |
| 760 | x, |
| 761 | "ij", |
| 762 | adjust_chunks={"j": lambda n: 2 * n}, |
| 763 | axis=1, |
| 764 | dtype=x.dtype, |
| 765 | ) |
| 766 | assert y.chunks == ((2, 1, 2), (6, 4)) |
| 767 | assert_eq(y, np.ones((5, 10))) |
| 768 | |
| 769 | x = da.ones((10, 10), chunks=(5, 5)) |
| 770 | y = da.blockwise( |
| 771 | double, "ij", x, "ij", axis=0, adjust_chunks={"i": 10}, dtype=x.dtype |
| 772 | ) |
| 773 | assert y.chunks == ((10, 10), (5, 5)) |
| 774 | assert_eq(y, np.ones((20, 10))) |
| 775 | |
| 776 | y = da.blockwise( |
| 777 | double, "ij", x, "ij", axis=0, adjust_chunks={"i": (10, 10)}, dtype=x.dtype |
| 778 | ) |
| 779 | assert y.chunks == ((10, 10), (5, 5)) |
| 780 | assert_eq(y, np.ones((20, 10))) |
| 781 | |
| 782 | |
| 783 | def test_blockwise_numpy_arg(): |