MCPcopy Index your code
hub / github.com/pydata/xarray / assert_chunks_equal

Function assert_chunks_equal

xarray/tests/test_backends_datatree.py:70–91  ·  view source on GitHub ↗
(
    actual: DataTree, expected: DataTree, enforce_dask: bool = False
)

Source from the content-addressed store, hash-verified

68
69
70def 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")

Calls 4

array_typeFunction · 0.90
diff_chunksFunction · 0.85
keysMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…