Skip to content

Use dict's getter in `get_all_injection_credible_levels`

Avi Vajpeyi requested to merge avi.vajpeyi/bilby:pp_test_key_error into master

Explaination

isinstance(self.injection_parameters[key], float) can result in KeyError if key does not exist inside self.injection_parameters (I got a KeyError: 'time_jitter' from here)

This can be avoided by using the dict's getter:

self.injection_parameters.get(key, None) where None is the default value returned if the key does not exist inside self.injection_parameters.

Test

After adding this fix, I was able to successfully create the following pp-plot for a set of 585 bilby result.json

Screen_Shot_2019-07-17_at_3.18.28_pm

Merge request reports

Loading