Open larrybradley opened 5 months ago
Hi Larry,
Has this actually been causing problems for you? My understanding is that this basically only ever comes up when there's a bug in the fitting somewhere which is causing the likelihood function to return a nan. In those cases it's not a super helpful error message that gets generated I'll admit, but potentially it's better than the code just proceeding anyway. The solution is probably to implement this, but also probably to figure out what values coming back from MultiNest mean the likelihood function returned nan and raise an exception in that case.
Cheers, Adam
@ACCarnall This isn't really causing an issue for me. I did have had it occur on a few occasions when I was first using Bagpipes, but I don't recall the specifics (perhaps max redshift set too low, or NaN/inf in error arrays?). Clearly something had to go wrong to get triple-digit exponents. In any case this PR prevents the cryptic error message. I'm not sure if the code would later fail downstream of this or just produce garbage results. Unfortunately, I don't have a reproducible test case. It might be a good idea to raise an exception with a meaningful error message for triple-digit exponents.
Indeed, I can reproduce the error if I try to fit a high-z galaxy (z > 10) with a low max_redshift
in config.py
:
samples2d = np.loadtxt(self.fname + "post_equal_weights.dat")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
arr = _load_from_filelike(
^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string '0.233419537011120611-312' to float64 at row 0, column 8.
I recall that this specific issue only occurs when something is terribly wrong, for example the incorrection max_redshift setting mentioned above, and when I replace the likelihood function into something custom but incorrect.
By default, Fortran drops the "E" symbol for 3-digit exponent output (e.g., '0.148232-104'). This impacts the output files currently being written by (Py)MultiNest.
This PR adds a custom function to read MultiNest output data, including cases of 3-digit exponents. For such cases, the reader inserts the "E" symbol into the number string so that the number can be converted to a float.
ref: https://github.com/JohannesBuchner/PyMultiNest/issues/212