Skip to content

Commit

Permalink
Improve unit string in console output
Browse files Browse the repository at this point in the history
This fixes #24.
  • Loading branch information
Splines committed Mar 18, 2024
1 parent dfb865b commit 59ffc71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/console_stringifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def _modify_unit(self, unit: str) -> str:
unit = (
unit.replace(r"\squared", "^2")
.replace(r"\cubed", "^3")
.replace("\\per\\", "/")
.replace(r"\per", "/")
.replace("\\", "")
.replace("\\", " ")
.strip()
)

if unit[0] == "/":
Expand Down
2 changes: 1 addition & 1 deletion tests/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# wiz.res("", 42.0).print()
# -> Error: "name must not be empty"

wiz.res("a911", 1.0, r"\mm")
wiz.res("a911", 1.0, r"\mm\s\per\N\kg")
# a: 1.0 \mm

wiz.res("1 b", 1.0, 0.01, r"\per\mm\cubed").print()
Expand Down

0 comments on commit 59ffc71

Please sign in to comment.