Skip to content

Commit e1605f2

Browse files
authored
Fix check for chunk_store in zarr backend (#7923)
* Fix check for chunk_store in zarr backend * Add test and update whats-new * Update the whats-new message
1 parent a80ff50 commit e1605f2

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Bug fixes
6161
By `Tom White <https://github.com/tomwhite>`_ and `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
6262
- Ensure dtype of reindex result matches dtype of the original DataArray (:issue:`7299`, :pull:`7917`)
6363
By `Anderson Banihirwe <https://github.com/andersy005>`_.
64+
- Fix bug where a zero-length zarr ``chunk_store`` was ignored as if it was ``None`` (:pull:`7923`)
65+
By `Juniper Tyree <https://github.com/juntyr>`_.
6466

6567
Documentation
6668
~~~~~~~~~~~~~

xarray/backends/zarr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def open_group(
417417
if consolidated is None:
418418
consolidated = False
419419

420-
if chunk_store:
420+
if chunk_store is not None:
421421
open_kwargs["chunk_store"] = chunk_store
422422
if consolidated is None:
423423
consolidated = False

xarray/tests/test_backends.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,8 @@ def test_with_chunkstore(self) -> None:
18491849
with self.create_zarr_target() as store_target, self.create_zarr_target() as chunk_store:
18501850
save_kwargs = {"chunk_store": chunk_store}
18511851
self.save(expected, store_target, **save_kwargs)
1852+
# the chunk store must have been populated with some entries
1853+
assert len(chunk_store) > 0
18521854
open_kwargs = {"backend_kwargs": {"chunk_store": chunk_store}}
18531855
with self.open(store_target, **open_kwargs) as ds:
18541856
assert_equal(ds, expected)

0 commit comments

Comments
 (0)