Bugfix to plot_posterior when plotting extracted posterior files
#5188
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.
This PR fixes a bug when running
pycbc_inference_plot_posteriorwith an extracted posterior file and wildcard parameters.Standard information about the request
This is a bug fix. This change affects posterior plotting via
plot_posterior. This change changes the behavior ofplot_posteriorwhen using a wildcard parameter argument to call only the parameters present in the file.Motivation
Currently, if using a wildcard (i.e.
--parameters '*'), this script calls thevariable_paramssection of the file, which assumes that the parameters to be plotted are the same as the parameters that were sampled over during PE. However, if the user provides a posterior extracted usingpycbc_inference_extract_samples, the parameters stored in the file are not guaranteed to be the same as thevariable_params(e.g., a waveform transform may have been applied during extraction). Thus, the script will attempt to call parameter names that may not be in the posterior and throw an error. Ideally, the wildcard should call all the parameters present in the file regardless of what was sampled over during PE.Contents
This PR changes the behavior of
plot_posterior(via theResultsArgumentParsercall) to plot all parameters in the file rather than thevariable_paramssection when using the'*'wildcard. All other functionality remains unchanged; i.e. if the user specifies all of the parameters manually, this PR has no effect.Additional notes
This largely produces the same expected functionality of the wildcard parameter. There is one additional side effect: if the posterior contains likelihood parameters (e.g.
loglikelihood,logwt), those will be plotted as their own scatter plots. Ideally, these wouldn't be plotted, but they have no effect on the plotting otherwise. Additional changes can be made to this PR to exclude these parameters if that is the optimal behavior.