Skip to content

Cannot load in result file using custom cosmological prior

I have defined a custom cosmological prior class, run PE with it, and am now trying to load in the resulting result file. I get the following error:

Traceback (most recent call last):                                                                                                                                                    
  File "<stdin>", line 1, in <module> 
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/site-packages/bilby/core/result.py", line 562, in from_json                                              
    dictionary = load_json(filename, gzip)                                                                                                                                            
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/site-packages/bilby/core/utils/io.py", line 144, in load_json                                                   
    dictionary = json.load(file, object_hook=decode_bilby_json)                                                                                                                       
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/json/__init__.py", line 293, in load                                                                            
    return loads(fp.read(),
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/json/__init__.py", line 359, in loads                                                                          
    return cls(**kw).decode(s)
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/json/decoder.py", line 337, in decode                                                                          
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/json/decoder.py", line 353, in raw_decode                                                                      
    obj, end = self.scan_once(s, idx)
  File "/cvmfs/software.igwn.org/conda/envs/igwn-py310/lib/python3.10/site-packages/bilby/core/utils/io.py", line 165, in decode_bilby_json                                          
    obj = cls(**dct["kwargs"])
TypeError: Prior.__init__() got an unexpected keyword argument 'cosmology'

I think this is because the __name__ is unrecognized, so it's entering this block of code that attempts to load it in with the standard prior class, which doesn't accept a cosmology kwarg.