Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

render_labels raises IndexError when the table has rows for instances absent from the mask

Offen Anfängerfreundlich
#775 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
numpy, pandas, python

Rechercherichtung

Führen Sie die bereitgestellte Python-Reproduktion aus und untersuchen Sie anschließend spatialdata_plot/pl/render.py ungefähr bei Zeile 2409 sowie spatialdata_plot/pl/_color.py ungefähr bei Zeile 791. Verfolgen Sie, wie die labels-Maske und die ColorSpec-Vektoren gefiltert werden. Erledigt ist die Aufgabe, wenn render_labels(color=...) Tabellenzeilen, die in den labels fehlen, ohne IndexError verarbeitet und dabei das bestehende Verhalten für übereinstimmende Zeilen beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
86
Forks
21
Ø Merge
4 Std. 58 Min.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus scverse/spatialdata-plot

Alle Issues in scverse/spatialdata-plot

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.