Validate element-type selection when reading Zarr stores - #1253
Open
kayoderaheem wants to merge 2 commits into
Open
kayoderaheem wants to merge 2 commits into
kayoderaheem wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1253 +/- ##
==========================================
+ Coverage 91.40% 91.66% +0.25%
==========================================
Files 53 53
Lines 8381 8384 +3
==========================================
+ Hits 7661 7685 +24
+ Misses 720 699 -21
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1172.
Invalid selection names currently pass through silently, which can return an empty SpatialData object or load only part of the requested data.
This change validates selection names before opening the Zarr store and raises a descriptive ValueError for invalid names or a bare string. It also narrows the type annotations for both reader entry points and corrects the SpatialData.read() documentation to use "tables".
Existing behavior is preserved for None, empty tuples, duplicate valid names, and valid element types absent from the store.
Testing: the new regression tests produced 8 failures and 14 passes before the fix, and all 22 passed afterward. Together with the existing read/write and partial-read suites, 177 tests passed, with 545 warnings. Ruff lint, formatting, and whitespace checks also passed. The full project suite and Python-version matrix were not run.
The issue discussion suggests narrower typing and optionally an assertion. This implementation uses ValueError so validation remains active under optimized Python. Feedback on that choice is welcome.