(
actual: DataTree, expected: DataTree, enforce_dask: bool = False
)
| 68 | |
| 69 | |
| 70 | def assert_chunks_equal( |
| 71 | actual: DataTree, expected: DataTree, enforce_dask: bool = False |
| 72 | ) -> None: |
| 73 | __tracebackhide__ = True |
| 74 | |
| 75 | from xarray.namedarray.pycompat import array_type |
| 76 | |
| 77 | dask_array_type = array_type("dask") |
| 78 | |
| 79 | comparison = { |
| 80 | (path, name): ( |
| 81 | ( |
| 82 | not enforce_dask |
| 83 | or isinstance(node1.variables[name].data, dask_array_type) |
| 84 | ) |
| 85 | and node1.variables[name].chunksizes == node2.variables[name].chunksizes |
| 86 | ) |
| 87 | for path, (node1, node2) in xr.group_subtrees(actual, expected) |
| 88 | for name in node1.variables.keys() |
| 89 | } |
| 90 | |
| 91 | assert all(comparison.values()), diff_chunks(comparison, actual, expected) |
| 92 | |
| 93 | |
| 94 | @pytest.fixture(scope="module") |
no test coverage detected
searching dependent graphs…