diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 54bf35b8..fe482ea4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -31,6 +31,16 @@ Removed more confusing to understand. [`#97 `_] +Changed +^^^^^^^ + +* **[BREAKING]** Previously ``12.3`` would format as ``"12.3e+00"`` + when using parts per formatting mode. + Now, when using parts per formatting mode, the ``e+00`` exponent is + translated to be an empty string so that ``12.3`` would format as + ``"12.3"``. + [`#99 `_] + ---- 0.31.1 (2024-01-06) diff --git a/docs/source/exp replacement.rst b/docs/source/exp replacement.rst index 4a1fd9b4..34c13f5a 100644 --- a/docs/source/exp replacement.rst +++ b/docs/source/exp replacement.rst @@ -122,6 +122,9 @@ Parts Per Forms * - Exponent Value - Prefix Name - Prefix + * - 10\ :sup:`0` + - unity + - ``no symbol`` * - 10\ :sup:`-6` - parts-per-million - ppm diff --git a/src/sciform/prefix.py b/src/sciform/prefix.py index d733fb92..c77ce25d 100644 --- a/src/sciform/prefix.py +++ b/src/sciform/prefix.py @@ -37,6 +37,7 @@ } pp_val_to_prefix_dict = { + 0: "", -6: "ppm", -9: "ppb", -12: "ppt", diff --git a/tests/test_float_formatter.py b/tests/test_float_formatter.py index 75bda1a4..1127247d 100644 --- a/tests/test_float_formatter.py +++ b/tests/test_float_formatter.py @@ -183,6 +183,22 @@ def test_parts_per_exp(self): ( 123e-3, [ + ( + Formatter( + exp_mode="scientific", + exp_val=3, + exp_format="parts_per", + ), + "0.000123e+03", + ), + ( + Formatter( + exp_mode="scientific", + exp_val=0, + exp_format="parts_per", + ), + "0.123", + ), ( Formatter( exp_mode="scientific",