Beispiel #1
0
 def testCreateAndClear(self):
     s = SegmentList()
     self.assertEqual(0, len(s))
     s.add(0, 100)
     self.assertEqual(1, len(s))
     s.clear()
     self.assertEqual(0, len(s))
Beispiel #2
0
    def testNormalize2(self):
        '''overlapping segments.'''

        ss = [(x, x + 1000) for x in range(0, 1000, 100)]
        random.shuffle(ss)
        s = SegmentList()
        for start, end in ss:
            s.add(start, end)
        s.normalize()
        self.assertEqual(len(s), 1)
        self.assertEqual(s.sum(), 1900)
Beispiel #3
0
 def testNormalize4(self):
     # test multiple interleaved segments
     ss = [(x, x + 100) for x in range(0, 1000, 10)]
     s = SegmentList()
     for start, end in ss:
         s.add(start, end)
     s.normalize()
     self.assertEqual(len(s), 1)
     self.assertEqual(s.sum(), 1090)
     s2 = SegmentList(iter=ss)
     s2.merge(-1)
     self.assertEqual(s, s2)
Beispiel #4
0
    def testNormalize1b(self):
        '''non-overlapping segments.'''

        ss = [(x, x + 10) for x in range(100, 1100, 100)]
        random.shuffle(ss)
        s = SegmentList()
        for start, end in ss:
            s.add(start, end)
        s.normalize()
        self.assertEqual(len(s), 10)
        self.assertEqual(s.sum(), 100)
        s2 = SegmentList(iter=ss)
        s2.merge(-1)
        self.assertEqual(s, s2)