Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude empty paths on ChunkDict creation #198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading