예제 #1
0
 def test_union(self):
     s1 = FakeScorer(1, 2, 3, 4, 5, 6, 7, 8)
     s2 = FakeScorer(2, 4, 8, 10, 20, 30)
     s3 = FakeScorer(10, 100, 200)
     result = [1, 2, 3, 4, 5, 6, 7, 8, 10, 20, 30, 100, 200]
     uqs = UnionScorer([s1, s2, s3])
     self.assertEqual(list(uqs.ids()), result)
예제 #2
0
 def test_union(self):
     s1 = FakeScorer(1, 2, 3, 4, 5, 6, 7, 8)
     s2 = FakeScorer(2, 4, 8, 10, 20, 30)
     s3 = FakeScorer(10, 100, 200)
     result = [1, 2, 3, 4, 5, 6, 7, 8, 10, 20, 30, 100, 200]
     uqs = UnionScorer([s1, s2, s3])
     self.assertEqual(list(uqs.ids()), result)
예제 #3
0
    def test_random_union(self):
        testcount = 1000
        rangelimits = (2, 10)
        clauselimits = (2, 10)

        vals = range(100)

        for testnum in xrange(testcount):
            matches = set()
            scorers = []
            for _ in xrange(randint(*clauselimits)):
                nums = sample(vals, randint(*rangelimits))
                matches = matches.union(nums)
                scorers.append(FakeScorer(*sorted(nums)))
            matches = sorted(matches)
            uqs = UnionScorer(scorers)
            self.assertEqual(list(uqs.ids()), matches)
예제 #4
0
 def test_random_union(self):
     testcount = 1000
     rangelimits = (2, 10)
     clauselimits = (2, 10)
     
     vals = range(100)
     
     for testnum in xrange(testcount):
         matches = set()
         scorers = []
         for _ in xrange(randint(*clauselimits)):
             nums = sample(vals, randint(*rangelimits))
             matches = matches.union(nums)
             scorers.append(FakeScorer(*sorted(nums)))
         matches = sorted(matches)
         uqs = UnionScorer(scorers)
         self.assertEqual(list(uqs.ids()), matches)