-
Notifications
You must be signed in to change notification settings - Fork 13
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 clims when plotting shapes element annotations with matplotlib rendering #368
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #368 +/- ##
==========================================
+ Coverage 83.76% 83.90% +0.14%
==========================================
Files 8 8
Lines 1540 1535 -5
==========================================
- Hits 1290 1288 -2
+ Misses 250 247 -3
|
There were some tests that had an expected figure that was wrong in the first place so I fixed that. Think it is good to go for now. Here and there in the test code base I also saw no copies of anndata being created, spamming warnings so I silenced those. |
elif vcenter is None: | ||
norm = Normalize(vmin=vmin, vmax=vmax, clip=True) | ||
else: | ||
norm = TwoSlopeNorm(vmin=vmin, vmax=vmax, vcenter=vcenter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that vcenter
is removed, it should be removed also from the function signature. Also, kwargs
is in the signature but not used, so I would remove it.
@@ -339,7 +338,7 @@ def _get_collection_shape( | |||
c = cmap(c) | |||
else: | |||
try: | |||
norm = colors.Normalize(vmin=min(c), vmax=max(c)) | |||
norm = colors.Normalize(vmin=min(c), vmax=max(c)) if norm is None else norm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this function Normalize()
is initialized without clip
, while in _prepare_cmap_norm()
the default is to set clip=True
. I would choose one of the two as our default choice. The user will be able to specify clip
, vcenter
, etc by passing a norm
object directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm let me double check that if we don't pass norm as user, whether ultimately the norm is always created anyway, then we can get rid of normalize instance initiated here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok there is code left over of when vmin and vmax were removed. Not certain whether to address this in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the two files different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just different color perhaps due to made changes and then generating the labels with a different color. Other than that there are no changes.
@@ -144,7 +144,7 @@ def test_plot_colorbar_respects_input_limits(self, sdata_blobs: SpatialData): | |||
sdata_blobs.pl.render_shapes("blobs_polygons", color="cluster", groups=["c1"]).pl.show() | |||
|
|||
def test_plot_colorbar_can_be_normalised(self, sdata_blobs: SpatialData): | |||
sdata_blobs["table"].obs["region"] = ["blobs_polygons"] * sdata_blobs["table"].n_obs | |||
sdata_blobs["table"].obs["region"] = "blobs_polygons" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no region is the region_key_key
@@ -144,7 +144,7 @@ def test_plot_colorbar_respects_input_limits(self, sdata_blobs: SpatialData): | |||
sdata_blobs.pl.render_shapes("blobs_polygons", color="cluster", groups=["c1"]).pl.show() | |||
|
|||
def test_plot_colorbar_can_be_normalised(self, sdata_blobs: SpatialData): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does groups=["c1"]
do here? My understanding is that it doesn't have any effect because:
cluster
is numerical and not categorical- the values of
clusters
do not includec1
But I may be missing something and be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does nothing. @timtreis is this purely to test that the colorbar stays limited from 1-50?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the argument now as typically it is used to just color certain categorical values within a column, which from the title of the test function definition is not the intention.
closes #324
This PR fixes the issue described in #324. When creating the patch collection a default Normalize was always created instead of using the one provided by the user. Furthermore in this PR some legacy code was removed which did not do anything.