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
Add context manager to switch iterpath #2795
Add context manager to switch iterpath #2795
Conversation
Codecov Report
@@ Coverage Diff @@
## RELEASE_next_minor #2795 +/- ##
======================================================
- Coverage 78.44% 78.43% -0.01%
======================================================
Files 203 203
Lines 31269 31253 -16
Branches 6861 6857 -4
======================================================
- Hits 24528 24514 -14
+ Misses 4980 4978 -2
Partials 1761 1761
Continue to review 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.
Lots of nice things here!
LGTM!
hyperspy/signal.py
Outdated
"""Iterates over the signal data. | ||
def _iterate_signal(self, iterpath=None): | ||
"""Iterates over the signal data. It is faster than using the signal | ||
iterator. |
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 is "the signal iterator" that this is faster than? Assuming you mean for si in s
?
How about """Iterates over the signal data. It is faster than iterating over a signal, since it returns the array directly and not a HyperSpy signal.
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.
Actually, it would be useful to explain why it is faster! I don't remember right now and I will need to look it up again.
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.
Yes, that was my best guess :p
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 is "the signal iterator" that this is faster than?
The BaseSignal
class has an iterator implementation, i. e. __iter__
and __next__
are implemented, see https://docs.python.org/3/library/stdtypes.html#iterator-types for more explanation.
@thomasaarholt, I have improved the docstring, can you please have a look at it again? |
Yep, that looks good and is sensible! You can merge when you want :) |
Progress of the PR
_iterate_signal
of lazy signal, its non-lazy counterpart works fine_iterate_signal
and make it use__call__
so that lazy signal would benefit from the speed improvement in Improve plotting of lazy signals, by keeping current chunk #2568,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