-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
Milestone
Description
Discussed in #64
Originally posted by jagerber48 October 17, 2023
Consider
from sciform import Formatter, FormatOptions, ExpMode, ExpFormat
pp_formatter = Formatter(FormatOptions(exp_mode=ExpMode.ENGINEERING,
exp_format=ExpFormat.PARTS_PER,
add_ppth_form=True,
pdg_sig_figs=True))
print(pp_formatter(123e-9, 42e-9))
print(pp_formatter(123e-6, 42e-6))
print(pp_formatter(123e-3, 42e-3))
print(pp_formatter(123e-0, 42e-0))
Which prints
(120 +/- 40) ppb
(120 +/- 40) ppm
(120 +/- 40) ppth
(120 +/- 40)e+00
I'm wondering if, by default, the last output (for when the exponent equals zero) should be
(120 +/- 40)
I lean towards "yes".
This behavior can currently be realized using extra_parts_per_forms={0: ''}
.
from sciform import Formatter, FormatOptions, ExpMode, ExpFormat
pp_formatter = Formatter(FormatOptions(exp_mode=ExpMode.ENGINEERING,
exp_format=ExpFormat.PARTS_PER,
add_ppth_form=True,
pdg_sig_figs=True, extra_parts_per_forms={0: ''}))
print(pp_formatter(123e-9, 42e-9))
print(pp_formatter(123e-6, 42e-6))
print(pp_formatter(123e-3, 42e-3))
print(pp_formatter(123e-0, 42e-0))
which gives
(120 +/- 40) ppb
(120 +/- 40) ppm
(120 +/- 40) ppth
(120 +/- 40)
```</div>