You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to check that the following works when doing aggregation, and add tests:
we can use multiscale images in values
we can use multiscale labels in by
important subtask, we need to check that in a multiscale labels object, when to_multiscale() is called, this doesn't use interpolation, but it keeps the labels.
This whole message is AI-generated. The issue was automatically discovered and reported by an AI agent (Claude) during an autonomous bug hunt on the spatialdata code base. It has not been verified or triaged by a human yet; the needs: triage label is set so that a maintainer can confirm it. The reproduction script below was executed by the agent in an isolated environment (see Environment) and its output is pasted verbatim.
I re-attempted to reproduce this issue on the current main branch (commit ccf1ea048d054b6624214bf618008a9f9ae223e0) as part of a triage pass over open issues, and confirmed it reproduces.
Reproduction script (PEP 723 inline metadata; run with uv run repro.py, no other setup needed):
# /// script# requires-python = ">=3.12"# dependencies = [# "spatialdata @ git+https://github.com/scverse/spatialdata.git@ccf1ea048d054b6624214bf618008a9f9ae223e0",# ]# ///"""Issue #215: aggregation with multiscale objects (multiscale images in `values`, multiscale labels in `by`)and check that multiscale labels are downscaled without interpolation."""importnumpyasnpfromspatialdataimportaggregatefromspatialdata.modelsimportImage2DModel, Labels2DModelrng=np.random.default_rng(0)
img=rng.random((2, 32, 32))
lab=np.zeros((32, 32), dtype=np.int32); lab[2:12, 2:12] =5; lab[16:30, 16:30] =9# uint8 labels crash aggregate(), see #1229single_i, single_l=Image2DModel.parse(img), Labels2DModel.parse(lab)
ms_i, ms_l=Image2DModel.parse(img, scale_factors=[2, 2]), Labels2DModel.parse(lab, scale_factors=[2, 2])
ref=aggregate(values=single_i, by=single_l, agg_func="mean")["table"]
ok= {}
forname, v, bin [("ms image by labels", ms_i, single_l), ("image by ms labels", single_i, ms_l), ("ms image by ms labels", ms_i, ms_l)]:
try:
t=aggregate(values=v, by=b, agg_func="mean")["table"]
dense=lambdaX: X.toarray() ifhasattr(X, 'toarray') elsenp.asarray(X) # noqa: E731same=np.allclose(dense(t.X), dense(ref.X))
ok[name] =sameprint(f"{name:22} -> OK, identical to single-scale result: {same}")
exceptExceptionase: # noqa: BLE001ok[name] =Falseprint(f"{name:22} -> {type(e).__name__}: {str(e)[:100]}")
# label values must be preserved (no interpolation) at lower scalesvals= {k: np.unique(np.asarray(v["image"])).tolist() fork, vinms_l.children.items()}
print("unique label values per scale:", vals)
no_interp=all(set(v) <= {0, 5, 9} forvinvals.values())
ifall(ok.values()) andno_interp:
print("VERDICT: NOT REPRODUCED (multiscale values/by work and labels are downscaled without interpolation)")
else:
print("VERDICT: REPRODUCED (see failures above)")
Environment:uv run --no-project --python 3.13, which resolves spatialdata from git+https://github.com/scverse/spatialdata.git@ccf1ea048d054b6624214bf618008a9f9ae223e0 (extra dependencies, if any, are pinned in the script's inline metadata above).
Output (verbatim, only uv package-resolution/install log lines removed):
ms image by labels -> OK, identical to single-scale result: True
image by ms labels -> AttributeError: 'DataTree' object has no attribute 'dtype'
ms image by ms labels -> AttributeError: 'DataTree' object has no attribute 'dtype'
unique label values per scale: {'scale0': [0, 5, 9], 'scale1': [0, 5, 9], 'scale2': [0, 5, 9]}
VERDICT: REPRODUCED (see failures above)
exit=0
Agent's severity assessment: medium (see the priority: * label added to this issue).
Automatically generated; discovered by an AI agent (Claude) and not yet reviewed by a human.
Activity
LucaMarconato commentedon Sep 13, 2026
I re-attempted to reproduce this issue on the current
mainbranch (commitccf1ea048d054b6624214bf618008a9f9ae223e0) as part of a triage pass over open issues, and confirmed it reproduces.Reproduction script (PEP 723 inline metadata; run with
uv run repro.py, no other setup needed):Environment:
uv run --no-project --python 3.13, which resolvesspatialdatafromgit+https://github.com/scverse/spatialdata.git@ccf1ea048d054b6624214bf618008a9f9ae223e0(extra dependencies, if any, are pinned in the script's inline metadata above).Output (verbatim, only
uvpackage-resolution/install log lines removed):Agent's severity assessment: medium (see the
priority: *label added to this issue).Automatically generated; discovered by an AI agent (Claude) and not yet reviewed by a human.