def test_pa_score(self): score = [PAScore(IntegerScore(x)) for x in range(0, 11)] self.assertLess(score[0], score[5]) self.assertLess(score[5], score[10]) self.assertLess(score[5] + score[5], score[10]) self.assertLess(score[5] + score[5], score[2] + score[2] + score[6]) self.assertLess(score[10], score[2] + score[4] + score[5]) self.assertLess(score[2] + score[2] + score[6], score[1] + score[3] + score[6]) dist1 = ScoreDistribution([0] * 8 + [2, 4]) dist2 = ScoreDistribution([0] * 8 + [1, 6]) score1 = PAScore(IntegerScore(8), dist1) score2 = PAScore(IntegerScore(8), dist2) self.assertLess(score2, score1) score3 = score[10] + score[10] + score[10] + score[4] + score[2] + \ score1 + score2 self.assertEqual(score3, (3 * 10 + 4 + 2 + 2 * 8)) self.assertEqual( repr(score3), 'PAScore(IntegerScore(52), ScoreDistribution(10: 3, 9: 0, 8: ' '0, 7: 0, 6: 0, 5: 0, 4: 1, 3: 0, 2: 4, 1: 10))') self.assertEqual( score3._to_repr(), '0000000000000000052;00003:00000:' '00000:00000:00000:00000:00001:00000:00004:00010') self.assertEqual(score3, PAScore._from_repr(score3._to_repr()))
def test_score_distribution(self): dist1 = ScoreDistribution([1] + [0] * 9) dist2 = ScoreDistribution([0] + [10] * 9) dist_null = ScoreDistribution([0] * 10) self.assertLess(dist2, dist1) self.assertLess(dist1, dist1 + dist2) self.assertLess(dist2 + dist2, dist1) self.assertLess(dist_null, dist1) self.assertLess(dist_null, dist2) self.assertEqual(dist_null, ScoreDistribution()) self.assertEqual(dist_null + dist_null, dist_null) self.assertEqual(dist1 + dist_null, dist1) self.assertEqual(dist1._to_repr(), '00001:00000:00000:00000:00000:00000:00000:00000:00000:00000') self.assertEqual(dist2._to_repr(), '00000:00010:00010:00010:00010:00010:00010:00010:00010:00010') self.assertEqual((dist1 + dist2)._to_repr(), '00001:00010:00010:00010:00010:00010:00010:00010:00010:00010') self.assertEqual(dist1, ScoreDistribution._from_repr(dist1._to_repr())) self.assertEqual(dist2, ScoreDistribution._from_repr(dist2._to_repr())) self.assertEqual(repr(dist1), 'ScoreDistribution(10: 1, 9: 0, 8: 0, 7: 0, 6: 0, 5: 0, 4: 0, ' '3: 0, 2: 0, 1: 0)')
def test_score_distribution(self): dist1 = ScoreDistribution([1] + [0] * 9) dist2 = ScoreDistribution([0] + [10] * 9) dist_null = ScoreDistribution([0] * 10) self.assertLess(dist2, dist1) self.assertLess(dist1, dist1 + dist2) self.assertLess(dist2 + dist2, dist1) self.assertLess(dist_null, dist1) self.assertLess(dist_null, dist2) self.assertEqual(dist_null, ScoreDistribution()) self.assertEqual(dist_null + dist_null, dist_null) self.assertEqual(dist1 + dist_null, dist1) self.assertEqual( dist1._to_repr(), '00001:00000:00000:00000:00000:00000:00000:00000:00000:00000') self.assertEqual( dist2._to_repr(), '00000:00010:00010:00010:00010:00010:00010:00010:00010:00010') self.assertEqual( (dist1 + dist2)._to_repr(), '00001:00010:00010:00010:00010:00010:00010:00010:00010:00010') self.assertEqual(dist1, ScoreDistribution._from_repr(dist1._to_repr())) self.assertEqual(dist2, ScoreDistribution._from_repr(dist2._to_repr())) self.assertEqual( repr(dist1), 'ScoreDistribution(10: 1, 9: 0, 8: 0, 7: 0, 6: 0, 5: 0, 4: 0, ' '3: 0, 2: 0, 1: 0)')