PolyChord / PolyChordLite

Public version of PolyChord: See polychord.co.uk for PolyChordPro
https://polychord.io/
Other
83 stars 26 forks source link

bug when loading as pandas.DataFrame if infinities present #16

Closed JesusTorrado closed 5 years ago

JesusTorrado commented 5 years ago

Hi Will,

@vivianmiranda has stumbled on a weird bug (https://github.com/CobayaSampler/cobaya/issues/23): PolyChord writes infinities as "[-]Infinity" (a Fortran convention, I guess), but Pandas only understands infinities as "[-]inf", so the new version of output.py (line 186) does not read the equal weights file correctly when there are infinities: it loads the full column as strings, and this produces some errors later in the code. This is known (https://github.com/pandas-dev/pandas/issues/10065).

I wonder if it would make sense to take some precaution there, e.g. running on each non-float column:

column = column.replace("Infinity", "inf").replace("-Infinity", "-inf").astype(float)

Cheers

williamjameshandley commented 5 years ago

Sounds like a good idea to me. If you would like this to be included in the released version, feel free to submit a pull request.