lmfit / uncertainties

Transparent calculations with uncertainties on the quantities involved (aka "error propagation"); calculation of derivatives.
http://uncertainties.readthedocs.io/
Other
584 stars 75 forks source link

Adopting a Object-Oriented way of printing the ufloats [Enhancement] #149

Open Xyhlon opened 2 years ago

Xyhlon commented 2 years ago

Is it possible to convert the current api to an object oriented approach, like sympy see here.

This could allow people to write their own printers and lets them customize every aspect of the representation of the nominal value and the standard deviation.

Reasons: The current implementation of Shorthand is incorrect see nist and for a better explanation the corresponding physics stackexchange post. eg. 4.5(1.3)e6 should be 4.5(13)e6 or 11.7(1.7) should be 11.7(17)

Furthermore the possibility of printing the nominal value separated by a delimiter would be great. This would allow people to export uarrays to csv, tex_formatted tables and databases with fiddling with afterwards with the outputted string from ufloat.format("") (nom_val+/-std_dev)common_exp ---> nom_val common_exp delimiter std_dev common_exp eg. 11.7+/-1.7 --> 11.7,1.7 (4.5+-1.3)e6 --> 4.5e6,1.3e6

At last the current behaviour of printing doens't need to change it could still produce the same output by default, yet make the process more flexible

jagerber48 commented 1 year ago

I'm also interested in somewhat of a modernization of the string formatting code but have some thoughts on what you say.