Skip to content

Commit

Permalink
Merge pull request #708 from pangeo-forge/multidim-rechunk-fix
Browse files Browse the repository at this point in the history
Minimal multidim rechunk fix
  • Loading branch information
cisaacstern authored Mar 15, 2024
2 parents c76269a + 4780101 commit eb519e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pangeo_forge_recipes/rechunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def _invert_meshgrid(*arrays):
selectors[n] = tuple(selectors[n])
xi = [a[s] for a, s in zip(arrays, selectors)]
assert all(
np.equal(actual, expected).all() for actual, expected in zip(arrays, np.meshgrid(*xi))
np.equal(actual, expected.squeeze()).all()
for actual, expected in zip(arrays, np.meshgrid(*xi))
)
return xi

Expand Down
5 changes: 3 additions & 2 deletions tests/test_rechunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
[(5, "1D"), (10, "2D")],
)
@pytest.mark.parametrize("time_chunks", [1, 2, 5])
def test_split_and_combine_fragments_with_merge_dim(nt_dayparam, time_chunks):
@pytest.mark.parametrize("other_chunks", [{}, {"lat": 5}, {"lat": 5, "lon": 5}])
def test_split_and_combine_fragments_with_merge_dim(nt_dayparam, time_chunks, other_chunks):
"""Test if sub-fragments split from datasets with merge dims can be combined with each other."""

target_chunks = {"time": time_chunks}
target_chunks = {"time": time_chunks, **other_chunks}
nt, dayparam = nt_dayparam
ds = make_ds(nt=nt)
dsets, _, _ = split_up_files_by_variable_and_day(ds, dayparam)
Expand Down

0 comments on commit eb519e1

Please sign in to comment.