fix: support raster labels above uint16#1167
Open
stanbot8 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1167 +/- ##
==========================================
+ Coverage 92.44% 92.47% +0.03%
==========================================
Files 51 51
Lines 7820 7817 -3
==========================================
Hits 7229 7229
+ Misses 591 588 -3
🚀 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.
2 implementations exist. This implementation uses 1 canvas and only removes the label-count limit. The other implementation adds opt-in output tiles after this commit to limit output memory. Compare the limitations.
Summary
In issue 987,
rasterize(..., return_regions_as_labels=True)rejects more than65,535labels. Select the output dtype from the maximum label. Closes #987.Design
Use the existing
_get_uint_dtype()helper, as proposed in the maintainer direction. Small outputs remainuint16. Larger outputs useuint32oruint64only when required.The implementation changes
src/spatialdata/_core/operations/rasterize.py.Limitations
This implementation uses 1 canvas. It removes the label-count limit, but it does not bound output memory.
Tests
1 boundary test rasterizes
65,536indexed points. It preserves label65,536inuint32output.The focused rasterization suites pass with
28tests. The complete suite passes with1,365tests,7skips, and1expected failure. An isolated installed wheel passes the same boundary case.The test is in
tests/core/operations/test_rasterize.py.Commands
uv run pytest tests/core/operations/test_rasterize.py::test_rasterize_points_selects_label_dtype -q