MCPcopy
hub / github.com/pydata/xarray / test_unify_chunks

Function test_unify_chunks

xarray/tests/test_dask.py:1126–1151  ·  view source on GitHub ↗
(map_ds)

Source from the content-addressed store, hash-verified

1124
1125
1126def test_unify_chunks(map_ds):
1127 ds_copy = map_ds.copy()
1128 ds_copy["cxy"] = ds_copy.cxy.chunk({"y": 10})
1129
1130 with pytest.raises(ValueError, match=r"inconsistent chunks"):
1131 _ = ds_copy.chunks
1132
1133 expected_chunks = {"x": (4, 4, 2), "y": (5, 5, 5, 5)}
1134 with raise_if_dask_computes():
1135 actual_chunks = ds_copy.unify_chunks().chunks
1136 assert actual_chunks == expected_chunks
1137 assert_identical(map_ds, ds_copy.unify_chunks())
1138
1139 out_a, out_b = xr.unify_chunks(ds_copy.cxy, ds_copy.drop_vars("cxy"))
1140 assert out_a.chunks == ((4, 4, 2), (5, 5, 5, 5))
1141 assert out_b.chunks == expected_chunks
1142
1143 # Test unordered dims
1144 da = ds_copy["cxy"]
1145 out_a, out_b = xr.unify_chunks(da.chunk({"x": -1}), da.T.chunk({"y": -1}))
1146 assert out_a.chunks == ((4, 4, 2), (5, 5, 5, 5))
1147 assert out_b.chunks == ((5, 5, 5, 5), (4, 4, 2))
1148
1149 # Test mismatch
1150 with pytest.raises(ValueError, match=r"Dimension 'x' size mismatch: 10 != 2"):
1151 xr.unify_chunks(da, da.isel(x=slice(2)))
1152
1153
1154@pytest.mark.parametrize("obj", [make_ds(), make_da()])

Callers

nothing calls this directly

Calls 7

raise_if_dask_computesFunction · 0.90
assert_identicalFunction · 0.90
copyMethod · 0.45
chunkMethod · 0.45
unify_chunksMethod · 0.45
drop_varsMethod · 0.45
iselMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…