def test_region_from_intersect(self): regions = [Region([-i] * 2, [i] * 2) for i in range(5, 1, -1)] for i in range(1, len(regions)): expected_intersect = reduce( lambda a, b: a.intersect(b, 'aggregate'), regions[0:i + 1]) intersect = Region.from_intersect(regions[0:i + 1], True) #print(f'Expected: {expected_intersect}') #print(f'Expected["intersect"]: {expected_intersect["intersect"]}') #print(f'Actual: {intersect}') #print(f'Actual["intersect"]: {intersect["intersect"]}') self.assertEqual(regions[i], intersect) self.assertListEqual(regions[0:i + 1], intersect['intersect']) self.assertEqual(expected_intersect, intersect) self.assertListEqual(expected_intersect['intersect'], intersect['intersect'])
def compute(self) -> Iterator[RegionIntersect]: """ The resulting Iterator of intersecting Regions as tuple of Region intersection and RegionIntns. Returns: The resulting Iterator of intersecting Regions as tuple of Region intersection and RegionIntns. """ graph = self.G for clique in nx.enumerate_all_cliques(graph.G): if len(clique) > 1: intersect = [graph.region(r) for r in clique] region = Region.from_intersect(intersect, linked=True) assert isinstance(region, Region) yield (region, intersect)