Skip to content

Commit

Permalink
Exclude empty paths on ChunkDict creation (#198)
Browse files Browse the repository at this point in the history
* Update docs

* handle empty paths

* reset releases

* remove experimental chunk validation skip

* add docs
  • Loading branch information
ghidalgo3 authored Jul 20, 2024
1 parent 5d08519 commit 10ef7e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Deprecations
Bug fixes
~~~~~~~~~

- Exclude empty chunks during `ChunkDict` construction. (:pull:`198`)
By `Gustavo Hidalgo <https://github.com/ghidalgo3>`_.

Documentation
~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion virtualizarr/manifests/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def dict(self) -> ChunkDict:
[*coord_vectors, self._paths, self._offsets, self._lengths],
flags=("refs_ok",),
)
if path.item()[0] != "" # don't include entry if path='' (i.e. empty chunk)
if path.item() != "" # don't include entry if path='' (i.e. empty chunk)
}

return cast(
Expand Down
8 changes: 8 additions & 0 deletions virtualizarr/tests/test_manifests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def test_invalid_chunk_keys(self):
with pytest.raises(ValueError, match="Inconsistent number of dimensions"):
ChunkManifest(entries=chunks)

def test_empty_chunk_paths(self):
chunks = {
"0.0.0": {"path": "", "offset": 0, "length": 100},
"1.0.0": {"path": "s3://bucket/foo.nc", "offset": 100, "length": 100},
}
manifest = ChunkManifest(entries=chunks)
assert len(manifest.dict()) == 1


class TestProperties:
def test_chunk_grid_info(self):
Expand Down

0 comments on commit 10ef7e5

Please sign in to comment.