Skip to content

Conversation

sophiamaedler
Copy link
Contributor

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

@codecov-commenter
Copy link

codecov-commenter commented May 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.00%. Comparing base (c5cb734) to head (34ad288).
⚠️ 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%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis
Copy link
Member

timtreis commented Sep 9, 2025

Thank you @sophiamaedler !

@timtreis timtreis merged commit a3aa9e4 into scverse:main Sep 9, 2025
4 checks passed
@timtreis timtreis changed the title fix #464 render_shapes now respects palette and group Sep 10, 2025
@timtreis timtreis added bug Something isn't working release-fixed labels Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working release-fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants