yunruse / Noether

Just another units package
MIT License
9 stars 0 forks source link

Automatic uncertainty from `Decimal` #30

Open yunruse opened 1 year ago

yunruse commented 1 year ago

Relies on:

If some conf.uncertainty_automatic is enabled, then, for example, the following could occur when a Decimal (or str) is passed:

>>> cm('2.0')
2.0(1) cm  # length

The uncertainty in the last digit comes about from two half-precisions; this is a good heuristic for most measurements made, where we implicitly make two measurements (the zero and the extent) in e.g. a ruler.

In doing this, it may be helpful to make a Decimal subclass that can gracefully handle float multiplication in order to do this. It should err on the side of avoiding floating point detail when there are a great deal of trailing 0 or 9s (eg Decimal(0.01).)