Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crush warning about ds.dims deprecation #718

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pangeo_forge_recipes/rechunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def split_fragment(
dimsize = getattr(index[concat_dim], "dimsize", 0)
concat_position = index[concat_dim]
start = concat_position.value
stop = start + ds.dims[dim_name]
stop = start + ds.sizes[dim_name]
dim_slice = slice(start, stop)
rechunked_concat_dims.append(concat_dim)
else:
# If there is a target_chunk that is NOT present as a concat_dim
# in the fragment index, then we can assume that the entire span of
# that dimension is present in the dataset.
# This would arise e.g. when decimating a contiguous dimension
dimsize = ds.dims[dim_name]
dimsize = ds.sizes[dim_name]
dim_slice = slice(0, dimsize)

target_chunks_and_dims[dim_name] = (chunk, dimsize)
Expand Down Expand Up @@ -195,7 +195,7 @@ def combine_fragments(
(
dim.name,
[index[dim].value for index in all_indexes],
[ds.dims[dim.name] for ds in all_dsets],
[ds.sizes[dim.name] for ds in all_dsets],
)
for dim in concat_dims
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rechunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_split_multidim():

nt = 2
ds = make_ds(nt=nt)
nlat = ds.dims["lat"]
nlat = ds.sizes["lat"]
dimension = Dimension("time", CombineOp.CONCAT)
index = Index({dimension: IndexedPosition(0, dimsize=nt)})

Expand Down Expand Up @@ -211,7 +211,7 @@ def test_combine_fragments_multidim(time_chunk, lat_chunk):

nt = 10
ds = make_ds(nt=nt)
ny = ds.dims["lat"]
ny = ds.sizes["lat"]

fragments = []
time_dim = Dimension("time", CombineOp.CONCAT)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_rechunk(
def correct_chunks():
def _check_chunks(actual):
for index, ds in actual:
actual_chunked_dims = {dim: ds.dims[dim] for dim in target_chunks}
actual_chunked_dims = {dim: ds.sizes[dim] for dim in target_chunks}
assert all(
position.indexed
for dimension, position in index.items()
Expand Down