Skip to content

Commit

Permalink
fix: parameter interval in scientific notation
Browse files Browse the repository at this point in the history
  • Loading branch information
wcxve committed Jul 16, 2024
1 parent 1221f73 commit 82fcdb1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/elisa/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,12 @@ def report_interval(

def get_sci_notation_exponent(num: float) -> int:
"""Get the exponent of a number in scientific notation."""
return math.floor(math.log10(abs(num)))
return math.floor(math.log10(abs(round(num, precision))))

def get_sci_notation_significand(num: float, exp: int) -> str:
"""Get the significand of a number in scientific notation."""
significand = num * 10**-exp
rounded = round(significand, precision)
if rounded < 10 ** (exp - precision):
if abs(num) < 10 ** (exp - precision):
p = abs(get_sci_notation_exponent(num) - exp)
return f'{significand:+.{p}f}'.rstrip('0')
else:
Expand Down

0 comments on commit 82fcdb1

Please sign in to comment.