Esempio n. 1
0
    def test_concat(self):
        ''' Concat. '''
        fr = FmapRange((0, ) * 4, (30, ) * 4)

        dl = DataLayout.concat(self.dl1, self.dl2)
        self.assertEqual(dl.complete_fmap_range(),
                         FmapRange((0, 0, 0, 0), (4, 7, 16, 16)))
        self.assertEqual(
            dl.complete_fmap_range().size(),
            self.dl1.complete_fmap_range().size() +
            self.dl2.complete_fmap_range().size())
        self.assertEqual(
            dl.nhops_to(fr, PhyDim2(0, 0)),
            self.dl1.nhops_to(fr, PhyDim2(0, 0)) +
            self.dl2.nhops_to(fr, PhyDim2(0, 0)))

        dl_ = DataLayout.concat(self.dl2, self.dl1)
        self.assertEqual(dl.complete_fmap_range(), dl_.complete_fmap_range())
        self.assertEqual(dl.nhops_to(fr, PhyDim2(0, 0)),
                         dl_.nhops_to(fr, PhyDim2(0, 0)))
Esempio n. 2
0
    def test_concat_unmatch(self):
        ''' Concat unmatch. '''
        for fr in [
                FmapRange((0, ) * 4, (4, 4, 10, 16)),
                FmapRange((0, ) * 4, (4, 4, 16, 32)),
                FmapRange((0, ) * 4, (3, 4, 16, 16))
        ]:
            dl = DataLayout(frngs=(fr, ),
                            regions=(self.region1, ),
                            parts=(self.part1, ))

            with self.assertRaisesRegexp(ValueError, 'DataLayout: .*match.*'):
                _ = DataLayout.concat(self.dl1, dl)
Esempio n. 3
0
 def test_concat_invalid_type(self):
     ''' Concat invalid type. '''
     with self.assertRaisesRegexp(TypeError, 'DataLayout: .*concat.*'):
         _ = DataLayout.concat(self.dl1, self.frng1)
     with self.assertRaisesRegexp(TypeError, 'DataLayout: .*concat.*'):
         _ = DataLayout.concat(self.dl1, PhyDim2(1, 3))