When transforming DataTree elements, discard scales resulting in zero shape
This PR implements a fix for https://github.com/scverse/spatialdata/issues/947.
Problem summary: spatialdata.transform transforms each of the scales of a multi-scale image and it can happen that (especially lower resolution) scales result in shape 0. One one hand it doesn't make sense to keep zero shape scales, on the other this leads to an error later on when the scale factors of the resulting image are extracted.
Fix proposed in this PR: scales resulting in zero shape are discarded, similarly to the postprocessing of bounding_box_query:
https://github.com/scverse/spatialdata/blob/7604a3d2325079293ff523c5dff4483dffc890cb/src/spatialdata/_core/query/_utils.py#L116-L126
In the case of 'scale0' resulting in zero shape, the PR proposes to raise an error.
Happy to work on any review points!
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 92.14%. Comparing base (7604a3d) to head (ba9fe16).
:warning: Report is 7 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #948 +/- ##
=======================================
Coverage 92.14% 92.14%
=======================================
Files 48 48
Lines 7473 7477 +4
=======================================
+ Hits 6886 6890 +4
Misses 587 587
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/spatialdata/_core/operations/transform.py | 90.98% <100.00%> (+0.15%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.