コード例 #1
0
ファイル: test_regionset.py プロジェクト: tipech/overlapGraph
 def _test_regionset(self, regionset: RegionSet, nregions: int,
                     bounds: Region, regions: Iterable[Region]):
     #print(f'{regionset}')
     self.assertEqual(regionset.length, nregions)
     self.assertTrue(bounds.encloses(regionset.minbounds))
     for i, region in enumerate(regions):
         #print(f'{region}')
         self.assertEqual(region, regionset[i])
         self.assertEqual(region, regionset[region.id])
         self.assertTrue(region in regionset)
         self.assertTrue(region.id in regionset)
         self.assertTrue(bounds.encloses(region))
コード例 #2
0
ファイル: test_regionset.py プロジェクト: tipech/overlapGraph
    def test_regionset_filter(self):
        nregions = 50
        bounds = Region([0] * 2, [10] * 2)
        sizepc = Region([0] * 2, [0.5] * 2)
        regionset = RegionSet.from_random(nregions,
                                          bounds,
                                          sizepc=sizepc,
                                          precision=1)
        filter_bound = Region([5] * 2, [10] * 2)
        filtered = regionset.filter(filter_bound)

        self.assertEqual(filter_bound, filtered.bounds)
        for region in regionset:
            #print(f'{region}: {region in filtered}')
            self.assertEqual(filter_bound.encloses(region), region in filtered)
        for region in filtered:
            #print(f'{region}')
            self.assertTrue(filter_bound.encloses(region))
コード例 #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))