racklet / electronics-prototyping

Design files for electronic components for use in Racklet
Apache License 2.0
3 stars 0 forks source link

Implement pretty printing for the evaluator #27

Closed twelho closed 3 years ago

twelho commented 3 years ago

Fixes #20. This implements pretty formatting for floating point values in the evaluator output. It limits their precision to maximally two decimal places and supports metric prefixes. Especially for large integers (e.g. counts) we don't want a loss of precision, so those are unaffected by the pretty printing and will use the default formatting provided by evalexpr like other value types. A space is added between the value and metric prefix if a unit is provided, following the conventions defined for the SI units. This work also introduces unit tests for the pretty printing as the first module to do so in this codebase :sweat_smile: