Add lru_cache
to _calculate_amat_eigenvecs
to speed up pswf_operator
#10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added
lru_cache
to_calculate_amat_eigenvecs
to speed uppswf_operator
in the case where it's called repeatedly for similar input values. One of the main use cases forpswf_operator
ishera_cal.nucal.compute_spatial_filters
which computes PSWF basis functions for filtering baselines with the same orientation. Sets of baselines within the same orientation use the same eigenvectors and eigenvalues to compute a set of PSWF basis functions, but they're never explicitly cached even though they're the most expensive part of the computation. I set themaxsize
fairly low, since thepswf_operator
function is called repeatedly byhera_cal.nucal.compute_spatial_filters
for baselines which reuse the output of_calculate_amat_eigenvecs
. I also kept themaxsize
low because the returned matrix size of this function can get up tonfreqs x nfreqs