Skip to content

Commit

Permalink
Revert back to the default of 6 decimal points in raw value formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeengland committed Sep 10, 2020
1 parent 37a7665 commit 979c838
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fireant/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _format_decimal(value, thousands="", precision=None, suffix=None, use_raw_va
precision += 2

if use_raw_value:
precision_pattern = f'{{:.{precision if precision is not None else 16}f}}'
precision_pattern = f'{{:.{precision if precision is not None else 6}f}}'
elif precision is not None:
precision_pattern = f'{{:{thousands}.{precision}f}}'
else:
Expand Down
8 changes: 6 additions & 2 deletions fireant/tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,14 @@ def test_style_numbers_with_mixed(self):
)
self.assertEqual("$-1,000,000.00", formats.display_value(-1000000, euro_field))

def test_use_raw_value(self):
def test_use_raw_value_int(self):
field = Field("number", None, data_type=DataType.number, suffix="€", prefix="$")
self.assertEqual("1234", formats.display_value(1234, field, use_raw_value=True))

def test_use_raw_value_float(self):
field = Field("number", None, data_type=DataType.number, suffix="€", prefix="$")
self.assertEqual("1.546346", formats.display_value(1.546346346, field, use_raw_value=True))

def test_raw_value_formats_integers_with_trailing_zeros(self):
field = Field("number", None, data_type=DataType.number)
self.assertEqual("126500", formats.display_value(126500, field, use_raw_value=True))
Expand All @@ -264,7 +268,7 @@ def test_raw_value_when_precision_specified(self):
def test_converts_percentage_to_decimal_when_use_raw_value_True_and_suffix_is_percentage(self):
with self.subTest('when no precision'):
field = Field("number", None, data_type=DataType.number, suffix="%")
self.assertEqual("0.87123123131", formats.display_value(87.123123131, field, use_raw_value=True))
self.assertEqual("0.871231", formats.display_value(87.123123131, field, use_raw_value=True))

with self.subTest('when precision'):
field = Field("number", None, data_type=DataType.number, suffix="%", precision=2)
Expand Down

0 comments on commit 979c838

Please sign in to comment.