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
Check existence of signal.metadata.Markers before deleting it (was PR #3070) #3091
Conversation
Codecov ReportBase: 80.60% // Head: 80.64% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## RELEASE_next_major #3091 +/- ##
======================================================
+ Coverage 80.60% 80.64% +0.03%
======================================================
Files 176 176
Lines 24476 24474 -2
Branches 5383 5383
======================================================
+ Hits 19729 19737 +8
+ Misses 3421 3412 -9
+ Partials 1326 1325 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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 made some comment and it would be good to add a test along the line of:
import hyperspy.api as hs
import numpy as np
s = hs.signals.Signal1D(np.arange(10))
m = hs.plot.markers.Point(x=5, y=5)
s.add_marker(m, permanent=True)
fname = "test.hspy"
s.save(fname)
s2 = hs.load(fname)
assert s.metadata.Markers == ...
s2.plot()
upcoming_changes/3070.bugfix.rst
Outdated
@@ -0,0 +1,3 @@ | |||
Clean up codes around signal.metadata |
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.
Clean up codes around signal.metadata | |
Improve syntax in the `io` module. |
hyperspy/io.py
Outdated
if "Markers" in signal.metadata: | ||
del signal.metadata.Markers |
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.
if "Markers" in signal.metadata: | |
del signal.metadata.Markers |
What's about removing it completely? It is very very rare that we use del
before an assignment in python and I don't see why it is necessary here. Looking at the history using git blame, it doesn't seem that there is a reason.
Description of the change
Progress of the PR
upcoming_changes
folder (seeupcoming_changes/README.rst
),readthedocs
doc build of this PR (link in github checks)Minimal example of the bug fix or the new feature
This error does not shown in RELEASE_next_major branch, but potentially raised when broken file reader is loaded.