Skip to content

Add another exception to catch in `plot_with_data`

Matthew Pitkin requested to merge matthew-pitkin/bilby:fix_plot_with_data into master

Currently, the plot_with_data function tries to check if results.posterior.log_likelihood exists using np.isnan within a try...except... block, for which the exception only catches AttributeErrors. If using, for example, the emcee sampler the results.posterior.log_likelihood values in the pandas DataFrame default to being filled with None-types, as the log_likelihood values are not set. When these are tested using np.isnan it results in a TypeError, which is not caught by the except block and the function does not work. This MR allows the except to also catch a TypeError.

It would be good to set the log_likelihood values if using emcee from the lnprobability values that it can return (but that's for another issue...)

Merge request reports