Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3574171
Replace empty chunks with auto, just to see the blast radius
charles-turner-1 Jul 31, 2026
9f21db6
If we find a chunk mapping where every key maps to auto, then additio…
charles-turner-1 Jul 31, 2026
7ad1153
Add a test asserting changes pass without raising
charles-turner-1 Jul 31, 2026
3de48f8
Restore `xarray/namedarray/utils.py` to version on main - early test …
charles-turner-1 Jul 31, 2026
26131d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2026
3d16821
Merge branch 'main' into empty-partial-chunk
charles-turner-1 Jul 31, 2026
67635db
Turned out the AI was right, pushing it down into `namedarray/core.py…
charles-turner-1 Jul 31, 2026
d02e58b
Merge branch 'empty-partial-chunk' of https://github.com/charles-turn…
charles-turner-1 Jul 31, 2026
2c61c0b
Migrate from nbsphinx/jupyter-sphinx to myst_nb (#11456)
VeckoTheGecko Jul 31, 2026
66ae0da
Harmonize encoding from h5netcdf with netcdf4 (#11067)
hmaarrfk Jul 31, 2026
2a4448e
Fix indentation
charles-turner-1 Jul 31, 2026
523a399
Merge branch 'empty-partial-chunk' of https://github.com/charles-turn…
charles-turner-1 Jul 31, 2026
01ec2ba
Refactor to respect duplicate chunk stuff
charles-turner-1 Jul 31, 2026
1886867
Update xarray/namedarray/core.py
charles-turner-1 Jul 31, 2026
e8484eb
Make comment clearer
charles-turner-1 Jul 31, 2026
4a2d1f5
Add tests
charles-turner-1 Jul 31, 2026
50b84fe
Update xarray/tests/test_dataarray.py
charles-turner-1 Jul 31, 2026
89b4c37
Merge branch 'main' into empty-partial-chunk
charles-turner-1 Aug 3, 2026
c09ef08
Merge branch 'main' into empty-partial-chunk
charles-turner-1 Aug 4, 2026
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
12 changes: 12 additions & 0 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,18 @@ def chunk(
for dim_number, dim in enumerate(self.dims)
if dim in chunks
}
# Runs the same iteration as above, could extract to a shared helper
if any(val == "auto" for val in chunks.values()):
# If any chunks are "auto", we can add extra "auto" chunks for any
# zero-length dimensions to avoid dask errors. Need at least one existing
# auto or we might try to auto object dtype arrays incorrectly.
extra_autos = {
dim_number: "auto"
for dim_number, dim in enumerate(self.dims)
if dim_number not in chunks # keys are dim numbers now
and self.sizes[dim] == 0
}
chunks = {**chunks, **extra_autos}

chunkmanager = guess_chunkmanager(chunked_array_type)

Expand Down
12 changes: 12 additions & 0 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,18 @@ def test_auto_chunk_da(obj):
assert actual.chunks == expected.chunks


@pytest.mark.parametrize("obj", [make_da(), make_ds()])
def test_partial_auto_chunk_zero_len_dim(obj):
obj = obj.isel(x=[])
obj.chunk({"y": "auto"})


@pytest.mark.parametrize("obj", [make_ds()])
def test_partial_auto_chunk_zero_len_dim_variable(obj):
obj = obj.isel(x=[])["a"].variable
obj.chunk({"y": "auto"})


def test_auto_chunk_da_cftime():
yrs = np.arange(2000, 2120)
cftime_dates = xr.date_range(
Expand Down
Loading