Skip to content

Coloring labels by a continuous variable fixed #344

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

Conversation

timtreis
Copy link
Member

@timtreis timtreis commented Sep 3, 2024

As reported by @clwgg, there was a bug with the color of continuous annotations which resulted in them having incorrect colors. This is now fixed and the tests have been updated. Furthermore, within this fix I noticed our testing threshold was way too high and let a bunch of bugs pass. So I also lowered that and fixed the bugs this revealed.

@codecov-commenter
Copy link

codecov-commenter commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.32%. Comparing base (ffd4a1f) to head (a9c7609).

Files with missing lines Patch % Lines
src/spatialdata_plot/pl/utils.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #344      +/-   ##
==========================================
+ Coverage   84.27%   84.32%   +0.05%     
==========================================
  Files           8        8              
  Lines        1558     1557       -1     
==========================================
  Hits         1313     1313              
+ Misses        245      244       -1     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/utils.py 77.37% <91.66%> (+0.08%) ⬆️

@timtreis
Copy link
Member Author

timtreis commented Sep 3, 2024

The two failing tests can probably be traced back to #324 and #303

timtreis and others added 9 commits September 3, 2024 19:14
…ears-to-be-broken-labels-associated-with-wrong-colors' of github.com:scverse/spatialdata-plot into bugfix/342-coloring-labels-by-a-continuous-variable-appears-to-be-broken-labels-associated-with-wrong-colors
if np.any(color_source_vector.isna()):
cell_id[color_source_vector.isna()] = 0
val_im: ArrayLike = map_array(seg, cell_id, color_vector.codes + 1)
val_im: ArrayLike = map_array(seg.copy(), cell_id, color_vector.codes + 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm is the copy really required here? I thought that map array returns an array with same shape as the original array, but it would not have the same pointer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I remember. Don't ask me why, but if I don't copy(), one of the tests fails with:

ValueError: buffer source array is read-only

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same issue with the current main: whenever I tried to color labels by a column in table.obs, I'd get ValueError: buffer source array is read-only, and putting in those .copy() calls fixed it. This happened regardless of whether the SpatialData object was buffered to disk or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this is probably a bug in skimage actually. For now we could keep it as it is, but please add a comment with the issue so we remove this when we can.

@timtreis timtreis requested a review from melonora September 4, 2024 18:17
Copy link
Contributor

@melonora melonora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preapproving for the vmin vmax fix, but please if you can open an issue in skimage regarding the buffer error. I have seen similar errors in pandas at some point, I believe it had to do with some cython code not allowing for read only buffer, but this could be fixed I think and then prevents a copy.

@timtreis timtreis merged commit 6cef5df into main Sep 4, 2024
3 of 5 checks passed
@timtreis timtreis deleted the bugfix/342-coloring-labels-by-a-continuous-variable-appears-to-be-broken-labels-associated-with-wrong-colors branch September 4, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants