LupoA / lsdensities

Smeared spectral densities from lattice correlators
GNU General Public License v3.0
3 stars 0 forks source link

Add comment justifying roundtrips to strings #37

Closed edbennett closed 5 months ago

edbennett commented 6 months ago

In https://github.com/LupoA/rhos/blob/3bcbd9021027c56247efeec45a485409975575ef/rhos/HLT_class.py#L42, why do some variables get turned into strings, only then to get turned into mpf objects? This should not be necessary, and increases confusion reading the code.

LupoA commented 6 months ago

I thought it was required by mpmath. I remember reading mpf() can take integers or strings but no floats. I might be wrong :)

edbennett commented 6 months ago

The documentation suggests that's it's supported, but it does raise concerns when promoting to higher precision. I can see the logic behind this—the example in the notes is for literals, but it can also apply for parameters.

It might be worth adding a comment along the lines of

# Round trip via a string to avoid introducing spurious precision
# per recommendations at https://mpmath.org/doc/current/basics.html
nickforce989 commented 5 months ago

Solved.