Open arthurmloureiro opened 3 years ago
Thanks! This is a known issue. As far as I recall file lengths are correct for directory name lengths of 4, which is really small. But it can take directory name lengths up to 6 or 7 characters before returning errors. But to get around the problem for longer directory name lengths after already running you can modify line 404-406 of montepython/MultiNest.py
to suit your need depending on directory name length.
replace
with open(accepted_name, 'r') as accepted_file:
mode_lines = [a for a in ''.join(accepted_file.readlines()).split('\n\n')
if a != '']
with
try:
with open(accepted_name, 'r') as accepted_file:
mode_lines = [a for a in ''.join(accepted_file.readlines()).split('\n\n')
if a != '']
except:
accepted_name = accepted_name[:-2]
with open(accepted_name, 'r') as accepted_file:
mode_lines = [a for a in ''.join(accepted_file.readlines()).split('\n\n')
if a != '']
where the -2 in accepted_name = accepted_name[:-2]
is the difference in directory name length between 6 and the length you gave. This could probably be done more generally with a while loop reducing the length until something works. In my case I had misremembered and used directory file lengths of 8 instead of 6, so I only required this specific fix. Note if your directory lengths are far too long I could see this fix not working.
Another option is to just rename the files manually, but that seems more tedious. For a directory named "dir" they should be dir.arguments dir-live.points dir-phys_live.points dir-post_separate.dat dir-stats.dat dir-.txt dir-ev.dat dir.paramnames dir-post_equal_weights.dat dir-resume.dat dir-summary.txt
Ideally we'd apply a fix where this issue never happens in the first place, but I'm not sure we can do that easily on the MontePython side. I'll check. A thought I just had might be to drop base_name (directory name) from the file names. I'll think about it for a future patch.
Best, THejs
Having a limited sized string for output file names causes the
python MontePython info path/to/NS
to break as it cannot find the files which have incomplete file names.