Skip to content

Commit

Permalink
Merge pull request #718 from jbusecke/remove-ds.dims-warning
Browse files Browse the repository at this point in the history
Crush warning about ds.dims deprecation
  • Loading branch information
norlandrhagen authored Mar 28, 2024
2 parents 055dbf1 + 4d6c936 commit fe03650
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 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
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

0 comments on commit fe03650

Please sign in to comment.