luca-fiorito-11 / sandy

Sampling nuclear data and uncertainty
MIT License
48 stars 29 forks source link

Fix write_float edge case, which crashes NJOY #306

Closed AnderGray closed 4 months ago

AnderGray commented 5 months ago

There is a strange edge case in write_float where

sandy.records.write_float(0.99999995) 
' 9.999999-1'

but

sandy.records.write_float(0.99999996) 
' 1.000000e+00'

Likely because the string interpolation f"{x:13.6e}" is rounding up to 1.000000e+00, and it isn't caught as a case in the function.

This was giving an annoying error from NJOY Fortran runtime error: Bad value during floating point read, where these strings end up in generated pendf files, and are unable to be read by NJOY.

luca-fiorito-11 commented 4 months ago

This was fixed (also in principle tested) by @janmalec in #308 as an answer to issue #307. The changes were pushed to branch v1.1 because we don't touch develop directly.

I guess a release will be issued for v1.1 within the next few months, and only then it will be merged back into develop.

Btw, thanks for spotting this problem. I invite you to check if v1.1 works fine for you, or else give feedback!