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
{{ message }}
Repository navigation
More informative error when subsetting results in no observations retained in Visium HD #1096
The resulting table, if filtered using the mask, would contain no observations.
However, the error provided does not indicate this, and instead suggests a different type of data mismatch:
schema = get_model(value)
File "/home/admin/.local/lib/python3.10/site-packages/spatialdata/models/models.py", line 1195, in get_model
return _validate_and_return(TableModel, e)
File "/home/admin/.local/lib/python3.10/site-packages/spatialdata/models/models.py", line 1178, in _validate_and_return
schema().validate(e)
File "/home/admin/.local/lib/python3.10/site-packages/spatialdata/models/models.py", line 1056, in validate
self._validate_table_annotation_metadata(data)
File "/home/admin/.local/lib/python3.10/site-packages/spatialdata/models/models.py", line 1034, in _validate_table_annotation_metadata
raise ValueError(f"Regions in the AnnData object and `{attr[self.REGION_KEY_KEY]}` do not match.")
ValueError: Regions in the AnnData object and `region` do not match.
It may be useful to first have a check that the relevant table is non-empty before throwing this ValueError, as it suggested to be that a metadata column was corrupted or removed during processing.
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",# ]# ///"""#1096: a table filtered to zero observations fails validation with a misleading 'Regions ... do not match' error."""importwarningsimportnumpyasnpimportpandasaspdfromanndataimportAnnDatafromspatialdataimportSpatialDatafromspatialdata.modelsimportLabels2DModel, TableModelwarnings.simplefilter("ignore")
labels=Labels2DModel.parse(np.array([[0, 1], [2, 3]], dtype=np.uint16))
obs=pd.DataFrame({"region": pd.Categorical(["labels"] *3), "instance_id": [1, 2, 3], "n_counts": [10, 20, 30]})
table=TableModel.parse(AnnData(X=np.ones((3, 2)), obs=obs), region="labels", region_key="region", instance_key="instance_id")
sdata=SpatialData(labels={"labels": labels}, tables={"table": table})
mask=table.obs["n_counts"] >=500# too strict: keeps nothingempty=table[mask].copy()
print("filtered table shape:", empty.shape)
try:
sdata.tables["filtered"] =emptyprint("assigning the empty table: OK")
bug=FalseexceptExceptionase: # noqa: BLE001print("assigning the empty table:", type(e).__name__, str(e)[:120])
bug="do not match"instr(e)
print("VERDICT:", "REPRODUCED (misleading error for an empty table)"ifbugelse"NOT REPRODUCED")
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):
filtered table shape: (0, 2)
assigning the empty table: ValueError Regions in the AnnData object and `region` do not match.
VERDICT: REPRODUCED (misleading error for an empty table)
exit=0
Agent's severity assessment: low (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: low (see the
priority: *label added to this issue).Automatically generated; discovered by an AI agent (Claude) and not yet reviewed by a human.