Description
Motivation
Considering that these formats are more useful than only for savetxt and loadtxt, would it make sense to make them available on their own in stdlib_io and simply use them? I am thinking, for example, of any sort of I/O where round-trip accuracy is required (e.g. writing to a CSV, JSON, TOML, YAML, etc...) to override a default behaviour that might be less strict.
Prior Art
Currently the formats used for savetxt
and loadtxt
are private to the stdlib_io
and not usable from the outside:
Lines 22 to 32 in 57cfaf0
They work with scalars and arrays alike:
print FMT_REAL_DP, 1.23d0
print FMT_REAL_DP, [1.23d0, 4.56d0]
outputs
1.2300000000000000E+000
1.2300000000000000E+000 4.5599999999999996E+000
So it seems to me that the solution could be to make the existing constants public. @epagone @certik do you foresee any scenario where it wouldn't work?
Additional Information
@epagone would you like to submit a PR for this?