예제 #1
0
파일: test.py 프로젝트: vrmarathe/startpad
 def test_zero(self):
     sc = calc.Score(log_score=0)
     sLog = sc.log_score
     sc.increment(0)
     self.assertEqual(sc.log_score, sLog)
     sc.increment(0, 1)
     self.assertEqual(sc.log_score, sLog)
예제 #2
0
파일: test.py 프로젝트: vrmarathe/startpad
 def test_base(self):
     sc = calc.Score()
     self.assertEqual(sc.score, 1.0)
     self.assertEqual(sc.log_score, 0.0)
     self.assertEqual(sc.time_last, 0)
     sc.increment(0)
     self.assertEqual(sc.score, 1.0)
     self.assertEqual(sc.log_score, 0.0)
예제 #3
0
파일: test.py 프로젝트: vrmarathe/startpad
    def test_series(self):
        sc = calc.Score()
        for t in range(1, 10):
            sc.increment(1, t)
        self.assertAlmostEqual(sc.score, 2.0, 2)

        for t in range(10, 20):
            sc.increment(1, t)
        self.assertAlmostEqual(sc.score, 2.0, 5)
예제 #4
0
 def score_now(self, half_life, dt=None, value=0):
     """
     Return the current timescore for the given half_life - optionally add a
     value to the current score.
     
     NOT written back to the data store
     """
     ts = calc.Score(half_life, getattr(self, halflife_attr(half_life)), time_last=self.TS_hrs)
     ts.increment(value, hours_from_datetime(dt))
     return ts
예제 #5
0
파일: test.py 프로젝트: vrmarathe/startpad
    def test_series24(self):
        sc = calc.Score(time_half=24)

        for t in range(1, 20):
            sc.increment(1, t * 24)
        self.assertAlmostEqual(sc.score, 2.0, 5)
예제 #6
0
파일: test.py 프로젝트: vrmarathe/startpad
 def test_incr(self):
     sc = calc.Score()
     sc.increment(1)
     self.assertEqual(sc.score, 2.0)
     sc.increment(1, 1)
     self.assertEqual(sc.score, 2.0)