Skip to content

Commit b72c17b

Browse files
committed
correct hdf5 chunks after data operations
1 parent 0509135 commit b72c17b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

cf/data/array/mixin/filearraymixin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def __dask_tokenize__(self):
1717
.. versionadded:: 3.15.0
1818
1919
"""
20-
print(6666)
2120
return (
2221
self.__class__,
2322
self.shape,

cf/data/data.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8650,6 +8650,13 @@ def insert_dimension(self, position=0, inplace=False):
86508650
data_axes.insert(position, axis)
86518651
d._axes = data_axes
86528652

8653+
# Update the HDF5 chunking strategy
8654+
chunksizes = d.nc_hdf5_chunksizes()
8655+
if isinstance(chunksizes, tuple):
8656+
chunksizes = list(chunksizes)
8657+
chunksizes.insert(position, 1)
8658+
d.nc_set_hdf5_chunksizes(chunksizes)
8659+
86538660
return d
86548661

86558662
@_deprecated_kwarg_check("size", version="3.14.0", removed_at="5.0.0")
@@ -11891,6 +11898,14 @@ def squeeze(self, axes=None, inplace=False, i=False):
1189111898
# Remove the squeezed axes names
1189211899
d._axes = [axis for i, axis in enumerate(d._axes) if i not in iaxes]
1189311900

11901+
# Update the HDF5 chunking strategy
11902+
chunksizes = d.nc_hdf5_chunksizes()
11903+
if isinstance(chunksizes, tuple):
11904+
chunksizes = [
11905+
size for i, size in enumerate(chunksizes) if i not in iaxes
11906+
]
11907+
d.nc_set_hdf5_chunksizes(chunksizes)
11908+
1189411909
return d
1189511910

1189611911
@_deprecated_kwarg_check("i", version="3.0.0", removed_at="4.0.0")
@@ -12137,6 +12152,13 @@ def transpose(self, axes=None, inplace=False, i=False):
1213712152
)
1213812153

1213912154
d._set_dask(dx)
12155+
12156+
# Update the HDF5 chunking strategy
12157+
chunksizes = d.nc_hdf5_chunksizes()
12158+
if isinstance(chunksizes, tuple):
12159+
chunksizes = [chunksizes[i] for i in axes]
12160+
d.nc_set_hdf5_chunksizes(chunksizes)
12161+
1214012162
return d
1214112163

1214212164
@_deprecated_kwarg_check("i", version="3.0.0", removed_at="4.0.0")

0 commit comments

Comments
 (0)