Skip to content

fix: aggregate images by multiscale labels - #1261

Open
Sizerta wants to merge 1 commit into
scverse:mainfrom
Sizerta:fix-aggregate-multiscale-labels
Open

Sizerta wants to merge 1 commit into
scverse:mainfrom
Sizerta:fix-aggregate-multiscale-labels

Conversation

@Sizerta

@Sizerta Sizerta commented Sep 24, 2026

Copy link
Copy Markdown

Description

Fixes an AttributeError that occurs when aggregating an image by multiscale labels.

The issue was that multiscale labels are represented as an xarray.DataTree, which doesn’t have a dtype attribute. The fix gets the dtype from the full-resolution pyramid level instead.

Tests

Added a regression test covering single-scale and multiscale combinations of both values and by. The test also checks that the multiscale result matches the corresponding full-resolution result.

  • hatch test tests/core/operations/test_aggregations.py — 54 passed, 6 skipped
  • hatch check types — passed
  • pre-commit — passed locally (check-ast was skipped because Python 3.12 is not installed)

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.55%. Comparing base (e0f7d27) to head (ea9069e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1261      +/-   ##
==========================================
+ Coverage   91.40%   91.55%   +0.15%     
==========================================
  Files          53       53              
  Lines        8381     8388       +7     
==========================================
+ Hits         7661     7680      +19     
+ Misses        720      708      -12     
Files with missing lines Coverage Δ
src/spatialdata/_core/operations/aggregate.py 95.26% <100.00%> (+6.04%) ⬆️
🚀 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.

1 participant