spatialdata-plot icon indicating copy to clipboard operation
spatialdata-plot copied to clipboard

Fail if color or table do not exist

Open grst opened this issue 10 months ago • 1 comments

When attempting to render_shapes with a color key or a table key that does not exist, spatialdata-plot just plots everything grey. I would expect it to raise a KeyError instead.

Example

# example dataset from tutorial
sdata = sd.read_zarr("visium_brain.zarr/")

(
    sdata.pl.render_images(elements="ST8059050_hires_image")
    .pl.render_shapes(elements="ST8059050", color="doesntexist")
    .pl.show()
)

Image

(
    sdata.pl.render_images(elements="ST8059050_hires_image")
    .pl.render_shapes(elements="ST8059050", color="mt-Co3", table_name="doesntexist")
    .pl.show()
)

Image


Also, somewhat related, the function silently accepts any keyword argument. For instance, if I mistype table instead of table_name it just uses the default table instead of failing, which can be confusing.


EDIT: again, somewhat related, I'd also expect a failure with corresponding error message that tells me if a region could not be found in the table.

grst avatar Jan 21 '25 12:01 grst