示例#1
0
def test_avoids():
    gp = GriddedPerm(
        Perm((0, 5, 1, 4, 2, 3, 6)),
        ((0, 0), (0, 1), (0, 0), (1, 1), (1, 1), (1, 1), (2, 2)),
    )
    assert gp.avoids(GriddedPerm((0, 2, 1), ((0, 0), ) * 3))
    assert gp.avoids(
        GriddedPerm((0, 2, 1), ((0, 0), ) * 3),
        GriddedPerm((0, 2, 1), ((1, 1), (1, 1), (2, 2))),
    )
示例#2
0
 def satisfies_obstructions(self,
                            gp: GriddedPerm,
                            must_contain: Optional[Cell] = None) -> bool:
     """Check if a gridded permutation avoids the obstructions."""
     if must_contain is None:
         obs = self.get_relevant_obstructions(gp)
     else:
         obs = self.get_relevant_obstructions_by_cell(gp, must_contain)
     return gp.avoids(*obs)
 def forward_map(
     self,
     comb_class: Tiling,
     obj: GriddedPerm,
     children: Optional[Tuple[Tiling, ...]] = None,
 ) -> Tuple[Optional[GriddedPerm], Optional[GriddedPerm]]:
     if children is None:
         children = self.decomposition_function(comb_class)
     if obj.avoids(*self.gps):
         return (children[0].forward_map.map_gp(obj), None)
     return (None, children[1].forward_map.map_gp(obj))
示例#4
0
 def forward_map(
     self,
     tiling: Tiling,
     gp: GriddedPerm,
     children: Optional[Tuple[Tiling, ...]] = None,
 ) -> Tuple[Optional[GriddedPerm], Optional[GriddedPerm]]:
     if children is None:
         children = self.decomposition_function(tiling)
     if gp.avoids(*self.gps):
         return (children[0].forward_map(gp), None)
     return (None, children[1].forward_map(gp))