Skip to content

Commit

Permalink
Revert "Extend format_number"
Browse files Browse the repository at this point in the history
This reverts commit ec44610.
  • Loading branch information
Johannes Bechberger committed Jul 29, 2019
1 parent ec44610 commit f7c7838
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions temci/utils/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def format_number(number: Number, deviation: float = 0.0,
force_min_decimal_places: bool = True,
relative_to_deviation: bool = False,
sigmas: int = 2,
parentheses_mode: ParenthesesMode = ParenthesesMode.ORDER_OF_MAGNITUDE,
parentheses_format: str = "({})"
parentheses_mode: ParenthesesMode = ParenthesesMode.ORDER_OF_MAGNITUDE
) -> str:
"""
Format the passed number
Expand Down Expand Up @@ -184,7 +183,6 @@ def format_number(number: Number, deviation: float = 0.0,
:param relative_to_deviation: format the number relative to its deviation, i.e. "10 sigma"
:param sigmas: number of standard deviations for significance
:param parentheses_mode: mode for selecting the significant digits
:param parentheses_format: format string to use
:return: the number formatted as a string
"""
prefix = ""
Expand All @@ -204,8 +202,7 @@ def format_number(number: Number, deviation: float = 0.0,
"relative_to_deviation": relative_to_deviation,
"scientific_notation": scientific_notation,
"sigmas": sigmas,
"parentheses_mode": parentheses_mode,
"parenthese_format": parentheses_format
"parentheses_mode": parentheses_mode
}
if math.isinf(number):
return "inf"
Expand Down Expand Up @@ -233,8 +230,7 @@ def _format_number(number: Number, deviation: float,
scientific_notation: bool = False,
scientific_notation_si_prefixes: bool = True,
sigmas: int = 2,
parentheses_mode: ParenthesesMode = ParenthesesMode.ORDER_OF_MAGNITUDE,
parentheses_format: str = "({})") -> str:
parentheses_mode: ParenthesesMode = ParenthesesMode.ORDER_OF_MAGNITUDE) -> str:
app = ""
if relative_to_deviation:
app = "𝜎"
Expand All @@ -255,8 +251,7 @@ def _format_number(number: Number, deviation: float,
scientific_notation=scientific_notation,
scientific_notation_si_prefixes=scientific_notation_si_prefixes,
sigmas=sigmas,
parentheses_mode=parentheses_mode,
parentheses_format=parentheses_format)
parentheses_mode=parentheses_mode)
dev = format_number(deviation, deviation, parentheses=False, explicit_deviation=False,
is_deviation_absolute=True, min_decimal_places=min_decimal_places,
max_decimal_places=max_decimal_places,
Expand Down Expand Up @@ -302,7 +297,7 @@ def _format_number(number: Number, deviation: float,
if max_decimal_places is not 0:
num += "."
if parentheses:
num += parentheses_format.format(dec_part)
num += "(" + dec_part + ")"
else:
num += dec_part
else:
Expand All @@ -312,7 +307,7 @@ def _format_number(number: Number, deviation: float,
if max_decimal_places is not 0:
num += "."
if parentheses and len(dec_part[abs(last_sig):]) > 0:
num += dec_part[0:abs(last_sig)] + parentheses_format.format(dec_part[abs(last_sig):])
num += dec_part[0:abs(last_sig)] + "(" + dec_part[abs(last_sig):] + ")"
else:
num += dec_part
return num + app
Expand Down

0 comments on commit f7c7838

Please sign in to comment.