get_extent(circles, exact=True) (the default) is wrong for anisotropic/shearing transformations, while exact=False is right
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start in src/spatialdata/_core/data_extent.py, focusing on the exact=True path through transform(e), scale_radii(), and _get_extent_of_circles(). Run the supplied repro.py with uv run to confirm the anisotropic Scale case. Done means exact=True returns the true transformed bounding box for the circle, matching the expected x=(36, 44) and y=(9, 11) behavior.
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
Circle centre (10, 10), radius 1, Scale([4, 1]): true extent x=(36, 44), y=(9, 11); get_extent(exact=True) gives x=(37.5, 42.5), y=(7.5, 12.5); get_extent(exact=False) gives the correct result.
Severity (agent's assessment): medium — the default 'exact' extent of circles is off in both axes under a non-isotropic affine
Where: src/spatialdata/_core/data_extent.py (exact=True branch → transform(e) → scale_radii() scales the radius by the mean of the eigenvalue moduli; _get_extent_of_circles then treats it as a circle)
Expected behaviour
The default path returns the true bounding box.
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",
# ]
# ///
"""get_extent(circles, exact=True) (default) is wrong for anisotropic transformations; exact=False is right."""
import warnings
import geopandas as gpd
from shapely.geometry import Point
from spatialdata import get_extent, to_polygons, transform
from spatialdata.models import ShapesModel
from spatialdata.transformations import Scale
warnings.simplefilter("ignore")
circles = ShapesModel.parse(gpd.GeoDataFrame({"geometry": [Point(10, 10)], "radius": [1.0]}), transformations={"global": Scale([4.0, 1.0], axes=("x", "y"))})
truth = transform(to_polygons(circles, buffer_resolution=64), to_coordinate_system="global").total_bounds
e_exact = get_extent(circles, exact=True)
e_approx = get_extent(circles, exact=False)
print(f"true extent (buffered polygon, transformed): x=({truth[0]:.2f}, {truth[2]:.2f}) y=({truth[1]:.2f}, {truth[3]:.2f})")
print("get_extent exact=True :", {k: tuple(round(float(x), 2) for x in v) for k, v in e_exact.items()})
print("get_extent exact=False:", {k: tuple(round(float(x), 2) for x in v) for k, v in e_approx.items()})
bug = abs(e_exact["x"][0] - truth[0]) > 0.1 or abs(e_exact["y"][1] - truth[3]) > 0.1
print("VERDICT:", "BUG REPRODUCED" if bug else "NOT REPRODUCED")
Observed output
true extent (buffered polygon, transformed): x=(36.00, 44.00) y=(9.00, 11.00)
get_extent exact=True : {'x': (37.5, 42.5), 'y': (7.5, 12.5)}
get_extent exact=False: {'x': (36.0, 44.0), 'y': (9.0, 11.0)}
VERDICT: BUG REPRODUCED
Possible fix direction (unverified)
For circles in the exact=True branch compute the extent from the intrinsic circle bounds transformed to the target coordinate system (what exact=False does), or buffer to polygons before transforming when the transformation is not a similarity (scale_radii already detects anisotropy).
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.
Possibly related issues
#693
Automatically generated; discovered by an AI agent (Claude) and not yet reviewed by a human.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 5
Getting set up
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 1 day
-
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 1 day
-
bug 🚨 element: images 🌌 element: labels 🏷️ needs: triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1239 ·
Maintainers usually reply within 1 day
-
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 1 day
-
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 1 day
All issues in scverse/spatialdata
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
gradio-app/gradio#13895 ·
Maintainers usually reply within 1 day
-
build-error
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spack/spack-packages#6713 ·
Maintainers usually reply within 1 day
-
Use issue templates Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ActivityWatch/activitywatch#1464 · 1 reaction ·
Maintainers usually reply within 1 day
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search results Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bytedance/trae-agent#483 ·
Maintainers usually reply within 1 day