Example #1
0
    def test_overlap(self):
        ''' Get overlap. '''
        fr1 = FmapRange((-11, -4, 3, 0), (3, 5, 7, 11))
        fr2 = FmapRange((0, 3, 3, -5), (3, 10, 4, 3))
        ofr = fr1.overlap(fr2)
        self.assertListEqual(ofr.beg_end(), [(0, 3), (3, 5), (3, 4), (0, 3)],
                             'overlap')
        self.assertEqual(fr2.overlap(fr1), ofr, 'overlap: commutative')

        fr3 = FmapRange((0, 7, 3, -5), (3, 10, 4, 3))
        ofr = fr1.overlap(fr3)
        self.assertListEqual(ofr.beg_end(), [(0, 0)] * 4, 'overlap: no')

        fr4 = FmapRange((-12, -12, -12, -12), (12, 12, 12, 12))
        self.assertEqual(fr1.overlap(fr4), fr1)
 def test_overlap_error(self):
     ''' Get overlap error. '''
     fr1 = FmapRange((-11, -4, 3, 0), (3, 5, 7, 11))
     with self.assertRaisesRegex(TypeError, 'FmapRange: .*'):
         fr1.overlap(((0,) * 4, (2,) * 4))