Example #1
0
 def test_region_random_regions(self):
     region = Region([-5, 0], [15, 10])
     randoms = region.random_regions(5, Region([0.25, 0.25], [0.75, 0.75]))
     randoms += region.random_regions(5,
                                      Region([0.25, 0.25], [0.75, 0.75]),
                                      precision=0)
     #print(f'{region}:')
     for subregion in randoms:
         #print(f'- {subregion}')
         self.assertTrue(subregion in region)
Example #2
0
 def test_create_regionset(self):
     bounds = Region([0, 0], [100, 100])
     regionset = RegionSet(bounds=bounds)
     regions = bounds.random_regions(10)
     for region in regions:
         regionset.add(region)
     self._test_regionset(regionset, len(regions), bounds, regions)
Example #3
0
 def test_region_from_union(self):
     region = Region([0] * 2, [100] * 2)
     regions = region.random_regions(5,
                                     Region([0.1] * 2, [0.25] * 2),
                                     precision=0)
     expected_union = reduce(lambda a, b: a.union(b, 'aggregate'), regions)
     union = Region.from_union(regions, True)
     #print(f'Expected: {expected_union}')
     #print(f'Actual: {union}')
     #print(f'Expected["union"]: {expected_union["union"]}')
     #print(f'Actual["union"]: {union["union"]}')
     self.assertEqual(expected_union, union)
     self.assertListEqual(expected_union['union'], union['union'])
     self.assertTrue(all([union.encloses(r) for r in regions]))
     self.assertTrue(region.encloses(union))