FIX: Handle hidden annotations during deletion in mpl plot#13703
FIX: Handle hidden annotations during deletion in mpl plot#13703DerAndereJohannes wants to merge 2 commits intomne-tools:mainfrom
Conversation
a085fd5 to
b6a3413
Compare
larsoner
left a comment
There was a problem hiding this comment.
Code looks good to me. Any way you could update a test that would fail on main but pass on this PR? Maybe somewhere in
mne-python/mne/viz/tests/test_raw.py
Line 768 in 8dd298f
And you can look at _annotation_helper to see some logic/magic to interact with the window using code.
It'll be a pain (harder than implementing the actual fix!) but I fear without this we can too easily regress in the future
|
No worries, I will give it a shot! Thank you for the hints. |
|
I gave the test a shot and it worked on my machine (comparing the current main implementation to the updated version in this PR. Main branch fails the new test, the update here passes it). I am unsure of the failing checks however, they seem not relevant to this PR. |
Reference issue
Fixes #13511.
What does this implement/fix?
This pull request fixes an issue in which removing annotations from the raw matplotlib figure would remove additional unintended annotations.
The issue with the current live code is that it assumes that the visible annotations are all grouped together in a continuous block starting from offset. However, this logic does not hold up.
For example, if
is_onscreenis[True, False, True], then the offset is 0. Thereforezorders[0:2]get thevisible_zordersinstead of index 0 and 2.The fix simply masks the zorders using the
is_onscreento assignvisible_zordersto the correct indices.Additional information
I have just implemented the fix here without a new regression pytest. Let me know how I should implement one if it is needed. Thank you!