Skip to content

Commit

Permalink
Feature/parts per when exp=0 99 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerber48 authored Jan 10, 2024
2 parents 3ff0f53 + de4b4c9 commit 673eda9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ Removed
more confusing to understand.
[`#97 <https://github.com/jagerber48/sciform/issues/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 <https://github.com/jagerber48/sciform/issues/99>`_]

----

0.31.1 (2024-01-06)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/exp replacement.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/sciform/prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
}

pp_val_to_prefix_dict = {
0: "",
-6: "ppm",
-9: "ppb",
-12: "ppt",
Expand Down
16 changes: 16 additions & 0 deletions tests/test_float_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 673eda9

Please sign in to comment.