render_labels raises IndexError when the table has rows for instances absent from the mask
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- numpy, pandas, python
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Chạy bản tái hiện Python được cung cấp, sau đó kiểm tra spatialdata_plot/pl/render.py quanh dòng 2409 và spatialdata_plot/pl/_color.py quanh dòng 791. Theo dõi cách mask labels và các vector ColorSpec được lọc; hoàn thành khi render_labels(color=...) xử lý các hàng trong bảng không có trong labels mà không gây ra IndexError, đồng thời giữ nguyên hành vi hiện tại đối với các hàng khớp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A table may annotate instances that no longer exist in the labels element — e.g. objects lost when segmentation is regenerated, or a table read from an upstream pipeline. render_labels(color=...) then fails instead of treating them as missing.
import anndata as ad, numpy as np, pandas as pd, spatialdata as sd, spatialdata_plot # noqa
from spatialdata.models import Labels2DModel, TableModel
labels = np.zeros((16, 16), np.uint32)
labels[2:6, 2:6] = 1
labels[8:12, 8:12] = 2
obs = pd.DataFrame({"instance_id": [1, 2, 3], "region": pd.Categorical(["labels"] * 3)})
obs.index = obs.index.astype(str)
table = TableModel.parse(
ad.AnnData(np.zeros((3, 1), np.float32), obs=obs),
region="labels", region_key="region", instance_key="instance_id",
)
table.obs["value"] = [1.0, 2.0, 3.0]
sdata = sd.SpatialData(
labels={"labels": Labels2DModel.parse(labels, dims=("y", "x"))},
tables={"table": table},
)
sdata.pl.render_labels("labels", color="value", table_name="table").pl.show()
IndexError: boolean index did not match indexed array along axis 0;
size of axis is 2 but size of corresponding boolean axis is 3
The mask is computed from the instance ids present in the labels, but ColorSpec.source_vector/color_vector still have one entry per table row, so ColorSpec.filter indexes a length-2 array with a length-3 mask:
spatialdata_plot/pl/render.py:2409 → spatialdata_plot/pl/_color.py:791
Rendering without color works, as does dropping the unmatched rows from the table.
spatialdata 0.8.0, spatialdata-plot 0.4.2, Python 3.14.
- Ngôn ngữ chính
- Python
- Star
- 86
- Fork
- 21
- Merge trung bình
- 14 giờ 50 phút
- Pull request đã merge (30 ngày)
- 3
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scverse/spatialdata-plot
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
scverse/spatialdata-plot#777 ·
-
`pl.show()` leading to `ValueError` due to mismatch between number of axes and number of panels Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
scverse/spatialdata-plot#749 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
scverse/spatialdata-plot#747 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
scverse/spatialdata-plot#677 ·
-
enhancement priority: medium utils :wrench:
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
scverse/spatialdata-plot#632 ·
Tất cả issue của scverse/spatialdata-plot
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100