Skip to content

Add ability to load results produced with custom priors

Currently if you try to load in a result file that has a parameter that was sampled using a custom prior defined in the analysis script, you get something like the following error:

 File "<stdin>", line 1, in <module>
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/site-packages/bilby/core/result.py", line 538, in from_json
    dictionary = load_json(filename, gzip)
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/site-packages/bilby/core/utils/io.py", line 120, in load_json
    dictionary = json.load(file, object_hook=decode_bilby_json)
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/json/__init__.py", line 361, in loads
    return cls(**kw).decode(s)
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/sylvia.biscoveanu/.conda/envs/bilby_fork/lib/python3.7/site-packages/bilby/core/utils/io.py", line 130, in decode_bilby_json
    cls = getattr(import_module(dct['__module__']), dct['__name__'])
AttributeError: module '__main__' has no attribute 'UniformReflected'

This MR adds a catch to default to the base Prior object in cases where the prior class is not recognized.

Merge request reports