polygon_query on points resets the index and rewrites the coordinate systems (adds a bogus `global: Identity`)
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
調査の方向性
src/spatialdata/_core/query/spatial_query.py の DaskDataFrame オーバーロードである polygon_query と、src/spatialdata/models/_utils.py の points_dask_dataframe_to_geopandas から始めます。まず、提供されている repro.py を実行してください。polygon_query と bounding_box_query を比較し、クエリされたポイントがインデックス [100, 200] と座標系 ['aligned', 'other'] を保持し、'global' を追加しないことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
[!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
The dask → geopandas → dask round trip used by polygon_query calls reset_index(drop=True) and loses .attrs, so PointsModel.parse installs the default {"global": Identity()} and only the queried coordinate system is set on top. For points with index [100, 200, 300] and transformations {"aligned": Scale, "other": Identity} (no global), the result has index [0, 1] and transformations {"global": Identity, "aligned": Scale}: the original ids are gone, other is dropped and an invented mapping to global is added. bounding_box_query on the same element behaves correctly.
Severity (agent's assessment): high — point ids are lost and the returned element is mis-positioned in global
Where: src/spatialdata/_core/query/spatial_query.py, DaskDataFrame overload of polygon_query; src/spatialdata/models/_utils.py::points_dask_dataframe_to_geopandas (reset_index(drop=True))
Expected behaviour
Same behaviour as bounding_box_query: original index and all coordinate systems preserved, no global added.
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",
# ]
# ///
"""polygon_query on points resets the index and rewrites the coordinate systems (adds a bogus global Identity)."""
import warnings
import pandas as pd
from shapely.geometry import box
from spatialdata import bounding_box_query, polygon_query
from spatialdata.models import PointsModel
from spatialdata.transformations import Identity, Scale, get_transformation
warnings.simplefilter("ignore")
df = pd.DataFrame({"x": [1.0, 5.0, 9.0], "y": [1.0, 5.0, 9.0], "gene": pd.Categorical(["a", "b", "c"])}, index=[100, 200, 300])
points = PointsModel.parse(df, feature_key="gene", transformations={"aligned": Scale([2.0, 2.0], axes=("x", "y")), "other": Identity()})
print("original index:", df.index.tolist(), "| original coordinate systems:", sorted(get_transformation(points, get_all=True)))
poly = polygon_query(points, polygon=box(0, 0, 12, 12), target_coordinate_system="aligned")
bbox = bounding_box_query(points, axes=("x", "y"), min_coordinate=[0, 0], max_coordinate=[12, 12], target_coordinate_system="aligned")
print("polygon_query -> index:", poly.index.compute().tolist(), "| coordinate systems:", {k: type(v).__name__ for k, v in get_transformation(poly, get_all=True).items()})
print("bounding_box_query -> index:", bbox.index.compute().tolist(), "| coordinate systems:", sorted(get_transformation(bbox, get_all=True)))
print("expected for both: index [100, 200] and coordinate systems ['aligned', 'other'] (no 'global')")
bug = poly.index.compute().tolist() != [100, 200] or "global" in get_transformation(poly, get_all=True) or "other" not in get_transformation(poly, get_all=True)
print("VERDICT:", "BUG REPRODUCED" if bug else "NOT REPRODUCED")
Observed output
original index: [100, 200, 300] | original coordinate systems: ['aligned', 'other']
polygon_query -> index: [0, 1] | coordinate systems: {'global': 'Identity', 'aligned': 'Scale'}
bounding_box_query -> index: [100, 200] | coordinate systems: ['aligned', 'other']
expected for both: index [100, 200] and coordinate systems ['aligned', 'other'] (no 'global')
VERDICT: BUG REPRODUCED
Possible fix direction (unverified)
Filter the computed pandas frame directly (as bounding_box_query does) and re-parse with transformations=get_transformation(points, get_all=True).copy(); or make points_dask_dataframe_to_geopandas keep the index and attrs.
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.
- 主要言語
- Python
- スター
- 397
- フォーク
- 98
- 平均マージ
- 5日 9時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scverse/spatialdata のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
scverse/spatialdata#1256 ·
メンテナーはふだん 2 日以内に返信
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
scverse/spatialdata#1249 ·
メンテナーはふだん 2 日以内に返信
-
bug 🚨 element: images 🌌 element: labels 🏷️ needs: triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
scverse/spatialdata#1239 ·
メンテナーはふだん 2 日以内に返信
-
bug 🚨 element: shapes ▲ models needs: triage priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
scverse/spatialdata#1234 ·
メンテナーはふだん 2 日以内に返信
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
scverse/spatialdata#1230 ·
メンテナーはふだん 2 日以内に返信
scverse/spatialdata の issue をすべて見る
似ている issue
-
adr
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kristofdegrave/homeassistant-smart-charging#1607 ·
メンテナーはふだん 1 日以内に返信
-
namespace operations
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
EclipseFdn/open-vsx.org#13665 ·
メンテナーはふだん 1 日以内に返信
-
doc good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
collective/icalendar#1865 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
canonical/opentelemetry-collector-operator#409 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
mozilla/addons-release-tests#1243 ·
メンテナーはふだん 1 日以内に返信