예제 #1
0
    def test_max_overflow_bin(self):
        obj = RoundLog(0.1, 100, max = 1000, overflow_bin = 1000)
        self.assertEqual(  100, obj(  100))
        self.assertEqual( 1000, obj( 1000))
        self.assertEqual( 1000, obj( 5000))

        self.assertEqual( 1000, obj.next(1000)) # the next to the overflow bin
예제 #2
0
    def test_min_underflow_bin(self):
        obj = RoundLog(0.1, 100, min = 10, underflow_bin = 0)
        self.assertEqual(  100, obj( 100))
        self.assertAlmostEqual(   10, obj(  10))
        self.assertEqual( 0, obj(   9))

        self.assertEqual( obj(10), obj.next( 0)) # the next to the underflow
예제 #3
0
 def test_inf(self):
     obj = RoundLog(0.1, 100)
     self.assertIsNone(obj(float('inf')))
     self.assertIsNone(obj(float('-inf')))
     self.assertIsNone(obj.next(float('inf')))
     self.assertIsNone(obj.next(float('-inf')))
예제 #4
0
    def test_call_zero(self):
        obj = RoundLog()
        self.assertEqual(0, obj(0))

        self.assertEqual(0, obj.next(0)) # next to 0 is 0 unless 0 is the
예제 #5
0
 def test_next(self):
     obj = RoundLog(retvalue = 'center')
     self.assertAlmostEqual( 2.818382931264, obj.next(2.23872113856834))
     self.assertAlmostEqual( 28.18382931264, obj.next(22.3872113856834))
     self.assertAlmostEqual( 281.8382931264, obj.next(223.872113856834))