RuntimeError when converting posterior samples to a lalinference result file
When trying to convert a specific set of posterior samples to a lalinference file stored in the GW190412 metafile, the following error is raised:
f.to_lalinference(outdir=outdir_dat, labels=[runtag], dat=True, overwrite=True, filenames={runtag: "{}_posterior_samples.dat".format(event_name)})
File "/home/danny.laghi/.local/lib/python3.7/site-packages/pesummary/gw/file/formats/pesummary.py", line 320, in to_lalinference
filename=filenames[label]
File "/home/danny.laghi/.local/lib/python3.7/site-packages/pesummary/gw/file/formats/lalinference.py", line 481, in write_to_file
for param in _samples.keys():
RuntimeError: dictionary changed size during iteration
This was spotted by @danny.laghi. I think the reason for this error is because the lalinference parameter name for final_spin_non_evolved
(af_nonevol
) is already in the posterior table, therefore when trying to rename the final_spin_non_evolved
column, the posterior table is essentially removing one of the entries (hence the error).