Restructure valid waveform mask in Heterodyne likelihood#125
Conversation
for more information, see https://pre-commit.ci
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
ChangesHeterodyne bin-edge representation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/jimgw/core/single_event/likelihood.py`:
- Around line 697-699: In HeterodynedTransientLikelihoodFD.__init__, reorder the
assignments so self.freq_grid_low and self.freq_grid_high are set from freq_grid
before calculating self.bin_widths; then derive bin_widths from those
initialized attributes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b56adbe-eb3a-4fa0-a369-4536edb125be
📒 Files selected for processing (1)
src/jimgw/core/single_event/likelihood.py
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/jimgw/core/single_event/likelihood.py (1)
556-561: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the spaces from these jaxtyping shape strings —
" n_bins + 1"/" n_valid+1"are parsed as separate axes, so these annotations need compact symbolic expressions. Ruff already ignores F722, so no config change is needed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/jimgw/core/single_event/likelihood.py` around lines 556 - 561, The jaxtyping shape annotations in the affected likelihood definitions use spaces around symbolic expressions, causing them to parse as separate axes. Update the relevant annotations, including `freq_grid_low`, `freq_grid_high`, `bin_widths`, `waveform_low_ref`, `waveform_high_ref`, and `summary_data`, to use compact shape strings such as `"n_bins+1"` and `"n_valid+1"` without spaces; leave Ruff configuration unchanged.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/jimgw/core/single_event/likelihood.py`:
- Around line 849-875: Remove the self references from _compute_coefficients,
using the supplied f_bins to derive the bin edges and centers needed for the
mask and frequency-shift calculations. Replace self.freq_grid_low and
self.freq_grid_high with values computed from f_bins while preserving the
final-bin inclusive equality handling.
- Line 817: In the relevant likelihood class initialization logic, replace the
assignment to self.nbins with self.n_bins so the valid-bin count is stored in
the declared attribute expected by downstream callers and tests.
In `@tests/unit/core/single_event/test_likelihood.py`:
- Around line 1174-1234: Restore and activate
test_low_frequency_reference_cutoff_does_not_reindex_summary_data, updating its
assertions and setup to match the final HeterodynedTransientLikelihoodFD
contract; retain coverage for masked bin-edge reindexing, reduced n_bins,
frequency bounds, and per-detector coefficient dimensions, and remove the
commented-out test block.
---
Nitpick comments:
In `@src/jimgw/core/single_event/likelihood.py`:
- Around line 556-561: The jaxtyping shape annotations in the affected
likelihood definitions use spaces around symbolic expressions, causing them to
parse as separate axes. Update the relevant annotations, including
`freq_grid_low`, `freq_grid_high`, `bin_widths`, `waveform_low_ref`,
`waveform_high_ref`, and `summary_data`, to use compact shape strings such as
`"n_bins+1"` and `"n_valid+1"` without spaces; leave Ruff configuration
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ee9ecd0d-aa26-4e37-800c-91668c5e69b5
📒 Files selected for processing (2)
src/jimgw/core/single_event/likelihood.pytests/unit/core/single_event/test_likelihood.py
This PR refactors much of the code of the masking applied to the waveform and frequencies during initialisation of the Heterodyned Likelihood. This mask aimed to mask out non-physical/invalid and trivial waveform pieces, which was introduced in kazewong/jim@93023114b.
The mask is defined as:
At the time, it was necessary to mask out the
NaNsfrom the waveform, since theself.frequenciesattribute at the time begins at zero (see e.g. here), where the waveform evaluation is invalid. But this is no longer needed with the introduction ofsliced_frequenciesin kazewong/jim@b745e04.That being said, the mask is still needed to remove the waveform where it is trivial (= 0), which occurs soon after the merger frequency. For otherwise it would lead to
NaN(from 0/0) later when taking the ratio between waveform pieces.Summary by CodeRabbit [edited]