-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow "unsafe" (faster) Spectrum1DCollection.from_spectra() #327
Conversation
When filtering or otherwise manipulating spectra from an existing collection, we can be confident the axes remain consistent. The safety checks are quite expensive so this should be a useful optimisation.
While refactoring, change assert statements to explicit logic and Errors. This avoids them being ignored in some runtime modes.
Profiling results a bit odd: there is a decent speedup, but also there is a significant penalty on the first call to from_spectra, regardless of
This is driven by the construction of the Quantity for output data (an unavoidable step)
Presumably Pint is doing some setup/caching. It would be good to understand this better so the information can be separated out more clearly and we know where it might effect production calculations. |
This has a surprisingly large performance impact as Pint has to reinvent what a Quantity is. (Good luck finding the Quantity constructor in Pint's source code!)
Have removed that bottleneck: the problem was bare use of
|
Next I am looking at some performance improvements to item access by building a bare Spectrum with |
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.
All looks sensible. Just some style suggestions to think about rather than needed.
A little more safety seems healthy here! Co-authored-by: Jacob Wilkins <[email protected]>
Co-authored-by: Jacob Wilkins <[email protected]>
I keep forgetting about this, it really is much better
Co-authored-by: Jacob Wilkins <[email protected]>
Thanks for review 😄 |
When filtering or otherwise manipulating spectra from an existing collection, we can be confident the axes remain consistent. The safety checks are quite expensive so this should be a useful optimisation.