Saving result file after sampling fails if lal dict is passed
@ish.gupta recently found out that adding a lal_waveform_dictionary to the waveform_arguments works fine while sampling, but fails to save to file at the end of sampling with the following error traceback.
File "/Users/aytida/work/rough/bilby/bilby/core/result.py", line 795, in save_to_file
json.dump(dictionary, file, indent=2, cls=BilbyJsonEncoder)
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/Users/aytida/work/rough/bilby/bilby/core/utils/io.py", line 87, in default
return json.JSONEncoder.default(self, obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Dict is not JSON serializable
<more stuff>
TypeError: cannot pickle 'lal.Dict' object
I created a patch that resolves this issue by ignoring the lal_waveform_dictionary
altogether while saving the file, but I guess that isn't the nicest way to fix this. Happy to start an MR with any suggestions!
Edited by Aditya Vijaykumar