Skip to content

Commit 725258e

Browse files
authored
Fix .chunks loading lazy backed array data (#6721)
1 parent b5207aa commit 725258e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ Bug fixes
212212
- Fixed silent overflow issue when decoding times encoded with 32-bit and below
213213
unsigned integer data types (:issue:`6589`, :pull:`6598`).
214214
By `Spencer Clark <https://github.com/spencerkclark>`_.
215+
- Fixed ``.chunks`` loading lazy data (:issue:`6538`).
216+
By `Deepak Cherian <https://github.com/dcherian>`_.
215217

216218
Documentation
217219
~~~~~~~~~~~~~

xarray/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ def get_chunksizes(
17181718

17191719
chunks: dict[Any, tuple[int, ...]] = {}
17201720
for v in variables:
1721-
if hasattr(v.data, "chunks"):
1721+
if hasattr(v._data, "chunks"):
17221722
for dim, c in v.chunksizes.items():
17231723
if dim in chunks and c != chunks[dim]:
17241724
raise ValueError(

xarray/tests/test_dataset.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,13 @@ def test_attrs(self) -> None:
992992
assert data.attrs["foobar"], "baz"
993993
assert isinstance(data.attrs, dict)
994994

995+
def test_chunks_does_not_load_data(self) -> None:
996+
# regression test for GH6538
997+
store = InaccessibleVariableDataStore()
998+
create_test_data().dump_to_store(store)
999+
ds = open_dataset(store)
1000+
assert ds.chunks == {}
1001+
9951002
@requires_dask
9961003
def test_chunk(self) -> None:
9971004
data = create_test_data()

0 commit comments

Comments
 (0)