From f45f0f0716d58a005d69bedb20bcc2c07fcd1832 Mon Sep 17 00:00:00 2001 From: Christian Hernandez Date: Fri, 10 Apr 2026 21:42:18 -0600 Subject: [PATCH] docs: fix matched filter SNR docstrings (closes #731) The docstring for matched_filter_snr() incorrectly stated it returned the SNR squared, but the function actually returns the complex matched filter SNR (not squared): rho_mf = / sqrt() This is the standard complex matched filter SNR, where <.|.> is the noise-weighted inner product. The denominator sqrt() is the optimal SNR, so dividing by it yields the matched filter SNR directly. Additionally, updated the optimal_snr_squared() docstring to be more precise by calling it "the square of the optimal matched filter SNR" as suggested by @ColmTalbot in the issue discussion. References: - Maggiore, "Gravitational Waves Vol 1", Chapter 7 - Finn 1992 (PRD 46, 5236) --- CHANGELOG.md | 3 +++ bilby/gw/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c762f38..20b2e823f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The original MRs are only visible on the [LIGO GitLab repository](https://git.li ## [Unreleased] +### Fixes +* Corrected incorrect docstrings for `matched_filter_snr` and `optimal_snr_squared` in `bilby/gw/utils.py` (closes #731) + ## [2.7.1] ### Fixes diff --git a/bilby/gw/utils.py b/bilby/gw/utils.py index f1f4c0291..420e1fc04 100644 --- a/bilby/gw/utils.py +++ b/bilby/gw/utils.py @@ -155,7 +155,7 @@ def matched_filter_snr(signal, frequency_domain_strain, power_spectral_density, Returns ======= - float: The matched filter signal to noise ratio squared + complex: The complex matched filter signal to noise ratio """ rho_mf = noise_weighted_inner_product( @@ -184,7 +184,7 @@ def optimal_snr_squared(signal, power_spectral_density, duration): Returns ======= - float: The matched filter signal to noise ratio squared + float: The square of the optimal matched filter signal to noise ratio """ return noise_weighted_inner_product(signal, signal, power_spectral_density, duration)