FEATURE: Warn users when waveform_kwargs are being overwritten or set to defaults
When setting the waveform_kwargs for the waveform_generator it is easy to make seemingly harmless mistakes like setting waveform_arguments['approximant'] = approximant rather than waveform_arguments['waveform_approximant'] = approximant, for example (speaking from experience). This means that the user's intended setting for the approximant to use is silently set to the default "IMRPhenomPv2" in this line for lal_binary_black_hole (different source models have different default kwargs). I think this is an easy enough mistake to make that bilby should log a warning when updating waveform_kwargs to default values so that users can track down where their intended settings do not match what bilby is assuming under the hood.
I think such a warning cannot be put where the kwargs are updated here, because that would mean it is printed every time the source model is called by the sampler. There also does not seem to be a straightforward place to put this in the waveform_generator's init, since the waveform_generator object cannot access the default waveform_kwargs which is stored as a local variable inside the source model. My proposal is to organize source.py a bit better by making the default waveform_kwargs no longer local variables defined inside the function (i.e. here), but make a dict default_kwargs
with a map for each source model, which would be stored outside the function. For example, the line linked above would be accessed with default_kwargs['lal_binary_black_hole']
. Also this means the waveform_generator could access this dict and determine what bilby will be adding to the user-specified waveform_kwargs. (i.e. f"{key} not specified in waveform_kwargs, setting to {default_kwargs[frequency_domain_model][key]}").
If this seems like a sensible proposal I can make an MR. I don't see it causing any backwards-incompatible changes.