-
Notifications
You must be signed in to change notification settings - Fork 3
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 option to skip generator caching #16
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
from warnings import warn | ||
|
||
|
||
@functools.lru_cache(maxsize=128) | ||
def get_waveform_genner(log_mf_min, run_phenomd=True): | ||
# See below where this function is called for description of how we handle | ||
# log_mf_min. | ||
|
@@ -19,6 +18,12 @@ def get_waveform_genner(log_mf_min, run_phenomd=True): | |
return wave_gen | ||
|
||
|
||
@functools.lru_cache(maxsize=128) | ||
def cached_get_waveform_genner(log_mf_fin, run_phenomd=True): | ||
"""Cached version of get_waveform_genner""" | ||
return get_waveform_genner(log_mf_fin, run_phenomd) | ||
|
||
|
||
@functools.lru_cache(maxsize=10) | ||
def cached_arange(start, stop, spacing): | ||
return np.arange(start, stop, spacing) | ||
|
@@ -129,6 +134,7 @@ def _bbhx_fd( | |
direct=False, | ||
num_interp=100, | ||
interp_f_lower=1e-4, | ||
cache_generator=True, | ||
**params | ||
): | ||
|
||
|
@@ -157,6 +163,8 @@ def _bbhx_fd( | |
interp_f_lower : float | ||
Lower frequency cutoff used for interpolation when computing the | ||
chirp time. | ||
cache_generator : bool | ||
If true, the BBHx waveform generator is cached based on | ||
|
||
Returns | ||
------- | ||
|
@@ -269,9 +277,18 @@ def _bbhx_fd( | |
# To solve this we *round* the *logarithm* of this mass-dependent start | ||
# frequency. The factor of 25 ensures reasonable spacing while doing this. | ||
# So we round down to the nearest 1/25 of the logarithm of the frequency | ||
log_mf_min = int(math.log(f_min*MTSUN_SI*(m1+m2)) * 25) | ||
|
||
wave_gen = get_waveform_genner(log_mf_min, run_phenomd=run_phenomd) | ||
log_mf_min = math.log(f_min*MTSUN_SI*(m1+m2)) * 25 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the PR! Why do you remove |
||
if cache_generator: | ||
# Use int to round down | ||
wave_gen = cached_get_waveform_genner( | ||
int(log_mf_min), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, OK, you moved it here. |
||
run_phenomd=run_phenomd, | ||
) | ||
else: | ||
wave_gen = get_waveform_genner( | ||
log_mf_min, | ||
run_phenomd=run_phenomd, | ||
) | ||
|
||
if sample_points is None: | ||
if 'delta_f' in params and params['delta_f'] > 0: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 would suggest to make the default
False
. Easier to avoid issues if the user has to "opt-in" to use this