Skip to content

Commit

Permalink
some test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-s-s committed Sep 17, 2017
1 parent cbd53f0 commit e379e3f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/test_eventsinfo.py
Expand Up @@ -6,9 +6,6 @@
from dicetables import AdditiveEvents
import dicetables.eventsinfo as ti

from unittest import util

unittest.util._MAX_LENGTH=2000

class TestEventsInfo(unittest.TestCase):

Expand Down Expand Up @@ -435,9 +432,19 @@ def test_EventsCalculations_stats_strings_max_power_for_commaed(self):
expected = ('1', '1', '1,000,000,001', '1,000,000,001', '1.000e-7')
self.assertEqual(calculator.stats_strings([1], max_power_for_commaed=9), expected)

def test_EventsCalculations_stats_strings_max_power_for_commaed_rounding(self):
calculator = ti.EventsCalculations(AdditiveEvents({1: 2, 2: 199986}))
expected = ('1', '2', '2.000e+5', '99,994', '0.001000')
self.assertEqual(calculator.stats_strings([1], max_power_for_commaed=4), expected)

# once the first four digits round up (shown_digits defaults to 4), it switches to scientific notation.
calculator = ti.EventsCalculations(AdditiveEvents({1: 2, 2: 199989}))
expected = ('1', '2', '2.000e+5', '1.000e+5', '0.001000')
self.assertEqual(calculator.stats_strings([1], max_power_for_commaed=4), expected)

def test_EventsCalculations_stats_strings_max_power_for_commaed_at_zero(self):
calculator = ti.EventsCalculations(AdditiveEvents({1: 1, 2: 1}))
expected = ('1', '1', '2', '2.000', '5.000e+1')
expected = ('1', '1', '2', '2.000', '5.000e+1') # The '2' is from an int. The '2.000' is from a float.
self.assertEqual(calculator.stats_strings([1], max_power_for_commaed=0), expected)

def test_EventsCalculations_stats_strings_max_power_for_commaed_at_neg_one(self):
Expand Down

0 comments on commit e379e3f

Please sign in to comment.