Skip to content

fix: clear error when aggregating by labels without instances - #1264

Open
FarisHrvat wants to merge 1 commit into
scverse:mainfrom
FarisHrvat:aggregate-empty-labels
Open

FarisHrvat wants to merge 1 commit into
scverse:mainfrom
FarisHrvat:aggregate-empty-labels

Conversation

@FarisHrvat

Copy link
Copy Markdown

Fixes #1250

Aggregating an image by labels that are all background failed later in TableModel.parse with "Regions in the AnnData object and region do not match". Now it raises "No labelled instances (non-zero label ids) found in by". An error rather than an empty table, since 0-row tables don't validate yet (#1096).

aggregate(values=image, by=labels) with labels that are only background
failed later in TableModel.parse with 'Regions in the AnnData object and
region do not match', which says nothing about the actual cause.

Fixes scverse#1250
@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (ea93a37) to head (2f1ee2e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1264   +/-   ##
=======================================
  Coverage   91.40%   91.41%           
=======================================
  Files          53       53           
  Lines        8381     8383    +2     
=======================================
+ Hits         7661     7663    +2     
  Misses        720      720           
Files with missing lines Coverage Δ
src/spatialdata/_core/operations/aggregate.py 89.32% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aggregate(values, by=<labels with no non-background instance>) raises a misleading 'regions do not match' error

1 participant