Skip to content

Added better error message for edge-case in which user modifies adata in place outside of sdata #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading