connorferster / forallpeople

Python SI units library: your 'daily driver' for calculations.
Apache License 2.0
307 stars 40 forks source link

.factor attributes are now Fractions (for precision) #47

Closed connorferster closed 2 years ago

connorferster commented 2 years ago

This has been on my mind for a while now. Previously, the .factor attribute was held as a float which meant that precision was lost every time that factor attributes were combined/reduced through multiplication/division. Eventually, this ended up in issues like #41.

Now, all .factor attributes are stored as fractions.Fraction. While this dramatically increases precision and the ability to carry defined units through a calculation it does not work consistently for all values in .factor. Notably, inches will correctly render, generally, for even powers of inches when raised to a power (e.g. si.inch**4). si.inch**3 will not be recognized as cubic inches because of a floating point error that creeps when performing the necessary cube root.

review-notebook-app[bot] commented 2 years ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB