def test_always_up(self): assert almost_equals(cute_round(7.456, RoundMode.ALWAYS_UP), 8) assert almost_equals(cute_round(7.654, RoundMode.ALWAYS_UP), 8) assert almost_equals(cute_round(7.5, RoundMode.ALWAYS_UP), 8) assert almost_equals(cute_round(7.456, RoundMode.ALWAYS_UP, step=0.1), 7.5) assert almost_equals(cute_round(7.456, RoundMode.ALWAYS_UP, step=0.2), 7.6) assert almost_equals(cute_round(7.456, RoundMode.ALWAYS_UP, step=0.01), 7.46)
def test_always_down(self): assert almost_equals(cute_round(7.456, RoundMode.ALWAYS_DOWN), 7) assert almost_equals(cute_round(7.654, RoundMode.ALWAYS_DOWN), 7) assert almost_equals(cute_round(7.5, RoundMode.ALWAYS_DOWN), 7) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.1), 7.4) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.2), 7.4) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.01), 7.45)
def test_closest_or_down(self): arg_spec = inspect.getargspec(cute_round) assert RoundMode.CLOSEST_OR_DOWN in arg_spec.defaults assert almost_equals(cute_round(7.456), 7) assert almost_equals(cute_round(7.654), 8) assert almost_equals(cute_round(7.5), 7) assert almost_equals(cute_round(7.456, step=0.1), 7.5) assert almost_equals(cute_round(7.456, step=0.2), 7.4) assert almost_equals(cute_round(7.456, step=0.01), 7.46)
def test_closest_or_up(self): assert almost_equals(cute_round(7.456, RoundMode.CLOSEST_OR_UP), 7) assert almost_equals(cute_round(7.654, RoundMode.CLOSEST_OR_UP), 8) assert almost_equals(cute_round(7.5, RoundMode.CLOSEST_OR_UP), 8) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.1), 7.5) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.2), 7.4) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.01), 7.46)
def test_always_down(self): assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN), 7 ) assert almost_equals( cute_round(7.654, RoundMode.ALWAYS_DOWN), 7 ) assert almost_equals( cute_round(7.5, RoundMode.ALWAYS_DOWN), 7 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.1), 7.4 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.2), 7.4 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_DOWN, step=0.01), 7.45 )
def test_always_up(self): assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_UP), 8 ) assert almost_equals( cute_round(7.654, RoundMode.ALWAYS_UP), 8 ) assert almost_equals( cute_round(7.5, RoundMode.ALWAYS_UP), 8 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_UP, step=0.1), 7.5 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_UP, step=0.2), 7.6 ) assert almost_equals( cute_round(7.456, RoundMode.ALWAYS_UP, step=0.01), 7.46 )
def test_closest_or_up(self): assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP), 7 ) assert almost_equals( cute_round(7.654, RoundMode.CLOSEST_OR_UP), 8 ) assert almost_equals( cute_round(7.5, RoundMode.CLOSEST_OR_UP), 8 ) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.1), 7.5 ) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.2), 7.4 ) assert almost_equals( cute_round(7.456, RoundMode.CLOSEST_OR_UP, step=0.01), 7.46 )
def get_bag(*args, **kwargs): kwargs.update({ 'round_mode': RoundMode.PROBABILISTIC, }) return nifty_collections.Bag( cute_round(*args, **kwargs) for i in range(1000))
def get_bag(*args, **kwargs): kwargs.update({'round_mode': RoundMode.PROBABILISTIC,}) return nifty_collections.Bag( cute_round(*args, **kwargs) for i in range(1000) )