Skip to content

Commit

Permalink
Make small fix regarding parenthesis in output strings and test it in…
Browse files Browse the repository at this point in the history
… playground
  • Loading branch information
paul019 committed Mar 14, 2024
1 parent 8e99d5a commit b700b33
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/stringifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def result_to_str(cls, result: _Result):

string += rf"e{exponent}"
else:
if len(uncertainties) > 0:
if len(uncertainties) > 0 and unit != "":
string += "("

value_normalized = value.get_abs()
Expand All @@ -83,7 +83,7 @@ def result_to_str(cls, result: _Result):
if len(uncertainties) > 1:
string += rf" ({u.name})"

if len(uncertainties) > 0:
if len(uncertainties) > 0 and unit != "":
string += ")"

if has_unit:
Expand Down
4 changes: 2 additions & 2 deletions src/application/latexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _create_latex_str(cls, value: _Value, uncertainties: List[_Uncertainty], uni

latex_str += rf" \cdot 10^{{{exponent}}}"
else:
if len(uncertainties) > 0:
if len(uncertainties) > 0 and unit != "":
latex_str += "("

value_normalized = value.get_abs()
Expand All @@ -202,7 +202,7 @@ def _create_latex_str(cls, value: _Value, uncertainties: List[_Uncertainty], uni
if len(uncertainties) > 1:
latex_str += rf"_{{\text{{{u.name}}}}}"

if len(uncertainties) > 0:
if len(uncertainties) > 0 and unit != "":
latex_str += ")"

if has_unit:
Expand Down
2 changes: 1 addition & 1 deletion tests/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# wiz.standard_sigfigs(3)

wiz.res("f", "1.0e4").print()
wiz.res("f", "1.0e1", 25e-1).print()
# f: 1.0

# wiz.res("g", 1.0, sys=0.01, stat=0.02, unit=r"\mm").print()
Expand Down

0 comments on commit b700b33

Please sign in to comment.