Repository: PermutaTriangle/Tilings

Issue:
Broken order on assumption
Looks like the ordering on assumption is broken sometime. For example the snippet below doesn't crash
```py
SumComponentAssumption((GriddedPerm((0,), ((1, 1),)), GriddedPerm((0,), ((2, 0),))))
SkewComponentAssumption((GriddedPerm((0,), ((1, 1),)), GriddedPerm((0,), ((2, 0),)), GriddedPerm((0,), ((2, 2),))))
assert ass1 < ass2
assert ass1 > ass2
```


Discussion:
enadeau: > Good catch, it should have been an and, not an or.

The and is actually not the right thing to do because you still can't compare two assumption of a different type. For example comparing a skew and a sum assumption none will be the smallest because the first clause of the `and` can never be satisfied.

Anyway the tuple approach is working so merging it

Patch:
diff --git a/tilings/assumptions.py b/tilings/assumptions.py
index 6b5eb62..76838f9 100644
--- a/tilings/assumptions.py
+++ b/tilings/assumptions.py
@@ -95,10 +95,9 @@ class TrackingAssumption:
 
     def __lt__(self, other) -> bool:
         if isinstance(other, TrackingAssumption):
-            return bool(
-                self.__class__.__name__ < other.__class__.__name__
-                or self.gps < other.gps
-            )
+            key_self = (self.__class__.__name__, self.gps)
+            key_other = (other.__class__.__name__, other.gps)
+            return key_self < key_other
         return NotImplemented
 
     def __hash__(self) -> int:


Test patch:
diff --git a/tests/test_assumptions.py b/tests/test_assumptions.py
index 7f82990..a0c9a17 100644
--- a/tests/test_assumptions.py
+++ b/tests/test_assumptions.py
@@ -1,5 +1,6 @@
 import json
 import os
+from operator import xor
 
 import pytest
 
@@ -7,7 +8,11 @@ from comb_spec_searcher import CombinatorialSpecification
 from permuta import Av, Perm
 from tilings import GriddedPerm, Tiling
 from tilings.algorithms import Factor
-from tilings.assumptions import TrackingAssumption
+from tilings.assumptions import (
+    SkewComponentAssumption,
+    SumComponentAssumption,
+    TrackingAssumption,
+)
 from tilings.strategy_pack import TileScopePack
 from tilings.tilescope import TileScope
 
@@ -107,6 +112,25 @@ def test_factors(tplaced_tracked, tplaced_tracked_factored1, tplaced_tracked_fac
     )
 
 
+def test_order():
+    sum_ass = SumComponentAssumption(
+        (GriddedPerm((0,), ((1, 1),)), GriddedPerm((0,), ((2, 0),)))
+    )
+    skew_ass = SkewComponentAssumption(
+        (
+            GriddedPerm((0,), ((1, 1),)),
+            GriddedPerm((0,), ((2, 0),)),
+            GriddedPerm((0,), ((2, 2),)),
+        )
+    )
+    point_ass = TrackingAssumption([GriddedPerm.single_cell((0,), (0, 0))])
+    point_ass2 = TrackingAssumption([GriddedPerm.single_cell((0,), (2, 0))])
+    assert point_ass < point_ass2 and not point_ass2 < point_ass
+    assert xor(sum_ass < skew_ass, skew_ass < sum_ass)
+    assert xor(sum_ass < point_ass, point_ass < sum_ass)
+    assert xor(point_ass < skew_ass, skew_ass < point_ass)
+
+
 @pytest.mark.timeout(90)
 def test_123_fusion():
     pack = TileScopePack.row_and_col_placements(row_only=True).make_fusion(tracked=True)