From be5ef845399266195df2c5253011cd20af2b17f9 Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Mon, 17 Aug 2026 01:51:48 -0700 Subject: [PATCH 1/2] Pop the frequency bin edges --- bilby/gw/source.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bilby/gw/source.py b/bilby/gw/source.py index 11411b468..97ad51b51 100644 --- a/bilby/gw/source.py +++ b/bilby/gw/source.py @@ -783,6 +783,7 @@ def lal_binary_neutron_star_relative_binning( waveform_kwargs.update(kwargs) if fiducial == 1: + _ = waveform_kwargs.pop("frequency_bin_edges", None) return _base_lal_cbc_fd_waveform( frequency_array=frequency_array, mass_1=mass_1, mass_2=mass_2, luminosity_distance=luminosity_distance, theta_jn=theta_jn, phase=phase, From f463aa9d965e0c9298ee442de658bfc990a8653c Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Mon, 17 Aug 2026 02:55:31 -0700 Subject: [PATCH 2/2] Add tests --- test/gw/source_test.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/gw/source_test.py b/test/gw/source_test.py index 7ade78e15..db96cdffb 100644 --- a/test/gw/source_test.py +++ b/test/gw/source_test.py @@ -620,6 +620,23 @@ def test_relbin_bbh_runs_without_fiducial_option(self): dict, ) + def test_relbin_fiducial_bbh_ignores_frequency_bin_edges(self): + """ + Once bins are set up, ``RelativeBinningGravitationalWaveTransient`` + leaves ``frequency_bin_edges`` in the waveform generator's persistent + ``waveform_arguments``, so any later fiducial (full-resolution) call + is made with it still present. The fiducial branch must drop it + rather than pass it through as an unused kwarg. + """ + self.parameters.update(self.waveform_kwargs_fiducial) + self.parameters["frequency_bin_edges"] = np.arange(20, 1500, 50) + self.assertIsInstance( + bilby.gw.source.lal_binary_black_hole_relative_binning( + self.frequency_array, **self.parameters + ), + dict, + ) + def test_relbin_bbh_xpprecession_version(self): self.parameters.update(self.waveform_kwargs_fiducial) self.parameters["waveform_approximant"] = "IMRPhenomXP" @@ -700,6 +717,26 @@ def test_relbin_bns_fails_without_fiducial_option(self): dict, ) + def test_relbin_fiducial_bns_ignores_frequency_bin_edges(self): + """ + Regression test for the missing ``frequency_bin_edges`` pop in the + fiducial branch (unlike the BBH counterpart, which already drops it). + Once bins are set up, ``RelativeBinningGravitationalWaveTransient`` + leaves ``frequency_bin_edges`` in the waveform generator's persistent + ``waveform_arguments``, so any later fiducial (full-resolution) call + -- e.g. from an iterative fiducial-parameter update, or an external + Fisher-matrix calculation -- is made with it still present. Before the + fix this raised the "unused waveform kwargs" ``ValueError``. + """ + self.parameters.update(self.waveform_kwargs_fiducial) + self.parameters["frequency_bin_edges"] = np.arange(20, 1500, 50) + self.assertIsInstance( + bilby.gw.source.lal_binary_neutron_star_relative_binning( + self.frequency_array, **self.parameters + ), + dict, + ) + def test_fiducial_fails_without_tidal_parameters(self): self.parameters.pop("lambda_1") self.parameters.pop("lambda_2")