-
Notifications
You must be signed in to change notification settings - Fork 17
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
Coloring labels by a continuous variable fixed #344
Conversation
Codecov ReportAttention: Patch coverage is
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
|
for more information, see https://pre-commit.ci
…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) |
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 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
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.
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
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 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.
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 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.
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.
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.
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.