-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix table name and add unit test for colors passed via .uns #413
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
…ot into fix_table_name
for more information, see https://pre-commit.ci
…ot into fix_table_name
Hi @ArneDefauw, thanks for the contribution. Two initial comments:
Thanks! |
Hi @LucaMarconato , I've linked an issue #414. For the failed unit tests, there was a KeyError, because I overlooked that For me all unit tests fail locally on the main branch of spatialdata-plot, so it is difficult to test. Therfore, I did not include base images for the unit tests I've added, because they would probably fail anyway in the CI/CD testing environment. The unit tests I've added are for documentation of the issue, some of them can probably be removed when merging to main. |
Thanks for updating the PR! Regarding the failing tests, could you please give a try to the approach described here? https://github.com/scverse/spatialdata-plot/blob/main/docs/contributing.md Locally generally the tests are reproducible on Ubuntu, but for other OS I use a Docker image, as described in the link above. |
My configuration with PyCharm is described here #397. |
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #413 +/- ##
==========================================
+ Coverage 83.83% 84.23% +0.40%
==========================================
Files 8 8
Lines 1732 1732
==========================================
+ Hits 1452 1459 +7
+ Misses 280 273 -7
|
I managed to fix the tests (using a centOS server). Note that I had to move this line
to have the same results when running one test versus all the tests, because its internal state was moving forward due to multiple calls to it. Because of this I also had to update this figure https://github.com/scverse/spatialdata-plot/blob/main/tests/_images/Labels_can_annotate_labels_with_table_layer.png |
Fantastic! Thanks a lot! |
spatialdata_plot.pl.render._render_labels
still hadsdata.table
, changed tosdata.tables[table_name]
, otherwise colors passed via .uns where ignored.also in
spatialdata-plot/src/spatialdata_plot/pl/utils.py
Line 854 in 43f25f6
I would remove the check
cluster_key
inadata.uns
. Because of this I had to setas a placeholder in https://github.com/ArneDefauw/spatialdata-plot/blob/b5cb0260c32a859783f87f10b8af05dc26feab76/tests/pl/test_render_labels.py#L219 .
I also stumbled upon a subtle bug while testing this feature. With the small fix in this PR, one can pass colors via .uns[ f"{cluster_key}_colors" ], and all works as expected, see
https://github.com/ArneDefauw/spatialdata-plot/blob/b5cb0260c32a859783f87f10b8af05dc26feab76/tests/pl/test_render_labels.py#L219
We get:

But if we do a bounding box query, we get:

While we expect:

In short, this is caused by https://github.com/scverse/spatialdata/blob/03d3be80fad69ff54097e90a9e80ad02e9e0e242/src/spatialdata/_utils.py#L203
also see scverse/anndata#997
For details see https://github.com/ArneDefauw/spatialdata-plot/blob/b5cb0260c32a859783f87f10b8af05dc26feab76/tests/pl/test_render_labels.py#L227 and possible workaround https://github.com/ArneDefauw/spatialdata-plot/blob/b5cb0260c32a859783f87f10b8af05dc26feab76/tests/pl/test_render_labels.py#L252
Note that being able to plot a subset in the same colors as the orignal is a rather common use case. However, I am not sure where to fix. Maybe documenting the workaround suffices for now.