Multi-box bounding_box_query works on elements but crashes on a SpatialData object (TypeError: Unsupported type list)
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start in src/spatialdata/_core/query/spatial_query.py, focusing on the SpatialData overload of bounding_box_query and _dict_query_dispatcher. Run the supplied repro.py with uv run to confirm the element-level and SpatialData-level behavior. Done means multi-box queries no longer crash, instead returning one SpatialData object per box or raising a clear ValueError.
Written by the indexing model from the issue text.
Description
[!NOTE]
This whole message is AI-generated. The issue was automatically discovered and reported by an AI agent (Claude) during an autonomous bug hunt on thespatialdatacode base. It has not been verified or triaged by a human yet; theneeds: triagelabel 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.
Summary
Element-level multi-box queries return a list; the SpatialData overload passes those lists into SpatialData(points={...}) → TypeError: Unsupported type <class 'list'>.
Severity (agent's assessment): low/medium — the docstring advertises min_coordinate of shape (n_boxes, n_axes)
Where: src/spatialdata/_core/query/spatial_query.py, SpatialData overload of bounding_box_query / _dict_query_dispatcher (element results that are lists are fed to the SpatialData constructor)
Expected behaviour
A list of SpatialData objects (one per box) or a clear ValueError.
Reproduction
Save as repro.py and run uv run repro.py (the PEP 723 header pins spatialdata to the commit the bug was found on; replace the URL fragment with @main to test the current main branch).
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "spatialdata @ git+https://github.com/scverse/spatialdata.git@ccf1ea048d054b6624214bf618008a9f9ae223e0",
# ]
# ///
"""Multi-box bounding_box_query works on elements but crashes on a SpatialData object."""
import warnings
import numpy as np
import pandas as pd
from spatialdata import SpatialData, bounding_box_query
from spatialdata.models import PointsModel
warnings.simplefilter("ignore")
points = PointsModel.parse(pd.DataFrame({"x": [1.0, 5.0, 9.0], "y": [1.0, 5.0, 9.0]}, index=[100, 200, 300]))
boxes_min, boxes_max = np.array([[0, 0], [4, 4]]), np.array([[3, 3], [8, 8]])
res = bounding_box_query(points, axes=("x", "y"), min_coordinate=boxes_min, max_coordinate=boxes_max, target_coordinate_system="global")
print("element-level multi-box query ->", [r.index.compute().tolist() for r in res])
bug = False
try:
bounding_box_query(SpatialData(points={"pts": points}), axes=("x", "y"), min_coordinate=boxes_min, max_coordinate=boxes_max, target_coordinate_system="global")
print("SpatialData-level multi-box query -> OK")
except Exception as e: # noqa: BLE001
print("SpatialData-level multi-box query ->", type(e).__name__, e)
bug = True
print("VERDICT:", "BUG REPRODUCED" if bug else "NOT REPRODUCED")
Observed output
element-level multi-box query -> [[100], [200]]
SpatialData-level multi-box query -> TypeError Unsupported type <class 'list'>
VERDICT: BUG REPRODUCED
Possible fix direction (unverified)
Either build one SpatialData per box or raise early when min_coordinate.ndim == 2.
Environment
uv run repro.py with the PEP 723 metadata in the script (fresh, isolated environment; spatialdata built from main @ ccf1ea0 (2026-08-28); Python 3.13, latest releases of the dependencies at run time: pandas 3.0, anndata 0.13, zarr 3.3, dask 2026.8, numpy 2.5, geopandas 1.1, shapely 2.1). macOS (arm64). Also reproduced in a second environment with pandas 2.3.3 / anndata 0.12.11 / numpy 2.4.4 / zarr 3.2.1.
Automatically generated; discovered by an AI agent (Claude) and not yet reviewed by a human.
- Dominant language
- Python
- Stars
- 397
- Forks
- 98
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 3
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scverse/spatialdata
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
scverse/spatialdata#1256 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
scverse/spatialdata#1249 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: images 🌌 element: labels 🏷️ needs: triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1239 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: shapes ▲ models needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1234 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1230 ·
Maintainers usually reply within 2 days
All issues in scverse/spatialdata
Similar issues
-
repo-audit
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
scverse/repo-health#20 ·
Maintainers usually reply within 1 day
-
/context/prime scope override double-prefixes an entity-ref project and drops its scoped memoriesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
phasespace-labs/palinode#232 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
collective/icalendar#1858 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
langflow-ai/langflow#15496 ·
Maintainers usually reply within 1 day