Skip to content

Commit

Permalink
Added better error message for edge-case in which user modifies adata…
Browse files Browse the repository at this point in the history
… in place outside of sdata (#322)
  • Loading branch information
timtreis authored Aug 15, 2024
1 parent a5e12d5 commit 87801ac
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/spatialdata_plot/pl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,15 @@ def _get_collection_shape(
def assign_fill_and_outline_to_row(
shapes: list[GeoDataFrame], fill_c: list[Any], outline_c: list[Any], row: pd.Series, idx: int
) -> None:
if len(shapes) > 1 and len(fill_c) == 1:
row["fill_c"] = fill_c
row["outline_c"] = outline_c
else:
row["fill_c"] = fill_c[idx]
row["outline_c"] = outline_c[idx]
try:
if len(shapes) > 1 and len(fill_c) == 1:
row["fill_c"] = fill_c
row["outline_c"] = outline_c
else:
row["fill_c"] = fill_c[idx]
row["outline_c"] = outline_c[idx]
except IndexError as e:
raise IndexError("Could not assign fill and outline colors due to a mismatch in row-numbers.") from e

# Match colors to the geometry, potentially expanding the row in case of
# multipolygons
Expand Down

0 comments on commit 87801ac

Please sign in to comment.