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

fix #464

Open sophiamaedler opened this issue 8 months ago • 1 comments

Code which previously failed now generates the expected results:

import spatialdata
import spatialdata_plot
sdata = spatialdata.datasets.blobs()

# add some labelling we want to color with a custom defined palette
sdata["table"].obs["labelling"] = (sdata["table"].obs["instance_id"]>10).astype('int').astype('str')
sdata["table"].obs["labelling"] = sdata["table"].obs["labelling"].astype('category')

# with labels it works
sdata.pl.render_labels("blobs_labels", color = "labelling", palette = ["red", "blue"], groups = ["0", "1"]).pl.show()
# transform to shapes and add necessary annotation
sdata["test_labels"] = spatialdata.to_polygons(sdata["blobs_labels"])

adata = sdata["table"].copy()
adata.obs["region"] = "test_labels"
adata.uns["spatialdata_attrs"]["region"] = "test_labels"
sdata["test_annotation"] = spatialdata.models.TableModel.parse(adata)

# with shapes it throws an error
sdata.pl.render_shapes("test_labels", color = "labelling", palette = ["red", "blue"], groups = ["0", "1"]).pl.show()

image

sophiamaedler avatar May 18 '25 20:05 sophiamaedler

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 85.00%. Comparing base (c5cb734) to head (34ad288). :warning: Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #465   +/-   ##
=======================================
  Coverage   85.00%   85.00%           
=======================================
  Files           8        8           
  Lines        1794     1794           
=======================================
  Hits         1525     1525           
  Misses        269      269           
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 96.47% <100.00%> (ø)
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar May 18 '25 21:05 codecov-commenter

Thank you @sophiamaedler !

timtreis avatar Sep 09 '25 20:09 timtreis