Skip to content

Commit 9e446e1

Browse files
a-alveyblancinducer
authored andcommitted
add namedisl.Map.coalesce()
1 parent f9dbac4 commit 9e446e1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

namedisl/set_like.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ class Map(_NamedIslMapLike[isl.Map], _NamedIslUnbasic[isl.Map]):
553553
.. automethod:: complement
554554
.. automethod:: convex_hull
555555
.. automethod:: get_basic_maps
556+
.. automethod:: coalesce
556557
.. automethod:: domain
557558
.. automethod:: range
558559
.. automethod:: intersect_domain
@@ -574,6 +575,9 @@ def convex_hull(self) -> BasicMap:
574575
def get_basic_maps(self) -> list[BasicMap]:
575576
return [BasicMap(bs, self.space) for bs in self._obj.get_basic_maps()]
576577

578+
def coalesce(self) -> Self:
579+
return type(self)(self._obj.coalesce(), self.space)
580+
577581
def domain(self) -> Set:
578582
return Set(
579583
self._obj.domain(),

namedisl/test/test_set_like.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ def test_map_from_map() -> None:
307307
print(named_map)
308308

309309

310+
def test_map_coalesce() -> None:
311+
map_ = nisl.make_map(
312+
"{ [i] -> [j = i] : 0 <= i < 5 or 5 <= i < 10 }"
313+
)
314+
assert len(map_.get_basic_maps()) == 2
315+
assert len(map_.coalesce().get_basic_maps()) == 1
316+
317+
310318
@pytest.mark.parametrize("ndims_domain", [2, 3, 4, 5])
311319
@pytest.mark.parametrize("ndims_range", [2, 3, 4, 5])
312320
@pytest.mark.parametrize("has_params", [True, False])

0 commit comments

Comments
 (0)