Beispiel #1
0
 def test_pre_check_not_adjacent(self):
     t = Tiling(obstructions=[
         GriddedPerm((0, 1), ((0, 0), ) * 2),
         GriddedPerm((0, 1), ((1, 1), ) * 2),
     ])
     assert not ComponentFusion(t, row_idx=0)._pre_check()
     assert not ComponentFusion(t, col_idx=0)._pre_check()
Beispiel #2
0
 def test_init(self, col_tiling, tiling_with_req, row_tiling):
     ComponentFusion(col_tiling, col_idx=0)
     ComponentFusion(row_tiling, row_idx=0)
     with pytest.raises(RuntimeError):
         ComponentFusion(col_tiling, row_idx=0, col_idx=1)
     with pytest.raises(RuntimeError):
         ComponentFusion(tiling_with_req, col_idx=0)
Beispiel #3
0
 def __call__(self, comb_class: Tiling) -> Iterator[Rule]:
     if comb_class.requirements:
         return
     cols, rows = comb_class.dimensions
     for row_idx in range(rows - 1):
         algo = ComponentFusion(
             comb_class,
             row_idx=row_idx,
             tracked=self.tracked,
             isolation_level=self.isolation_level,
         )
         if algo.fusable():
             fused_tiling = algo.fused_tiling()
             yield ComponentFusionStrategy(row_idx=row_idx,
                                           tracked=self.tracked)(
                                               comb_class, (fused_tiling, ))
     for col_idx in range(cols - 1):
         algo = ComponentFusion(
             comb_class,
             col_idx=col_idx,
             tracked=self.tracked,
             isolation_level=self.isolation_level,
         )
         if algo.fusable():
             fused_tiling = algo.fused_tiling()
             yield ComponentFusionStrategy(col_idx=col_idx,
                                           tracked=self.tracked)(
                                               comb_class, (fused_tiling, ))
Beispiel #4
0
 def test_fusable(self, col_fusion, row_fusion, not_prechecked_fusion):
     assert col_fusion.fusable()
     assert row_fusion.fusable()
     assert not not_prechecked_fusion.fusable()
     t = Tiling(obstructions=[
         GriddedPerm((0, 1, 2), ((0, 0), (0, 0), (0, 0))),
         GriddedPerm((0, 1, 2), ((0, 0), (0, 0), (1, 0))),
         GriddedPerm((0, 1, 2), ((0, 0), (1, 0), (1, 0))),
         GriddedPerm((0, 1, 2), ((1, 0), (1, 0), (1, 0))),
     ])
     assert not ComponentFusion(t, col_idx=0).fusable()
Beispiel #5
0
 def test_has_crosssing_len2_ob(self, row_fusion, col_fusion):
     assert row_fusion.has_crossing_len2_ob()
     assert col_fusion.has_crossing_len2_ob()
     t1 = Tiling(obstructions=[
         GriddedPerm((0, 2, 1), ((0, 0), ) * 3),
         GriddedPerm((0, 2, 1), ((1, 0), ) * 3),
         GriddedPerm((1, 0), ((0, 0), (1, 0))),
     ])
     assert ComponentFusion(t1, col_idx=0).has_crossing_len2_ob()
     t2 = Tiling(obstructions=[
         GriddedPerm((0, 1, 2), ((0, 0), ) * 3),
         GriddedPerm((0, 1, 2), ((0, 1), ) * 3),
         GriddedPerm((0, 1, 2), ((0, 2), ) * 3),
         GriddedPerm((0, 1), ((1, 2), ) * 2),
         GriddedPerm((1, 0), ((0, 1), (0, 0))),
         GriddedPerm((0, 1), ((0, 0), (0, 2))),
         GriddedPerm((0, 1), ((0, 1), (0, 2))),
         GriddedPerm((2, 0, 1), ((0, 2), (0, 0), (1, 2))),
         GriddedPerm((2, 0, 1), ((0, 2), (0, 1), (1, 2))),
     ])
     # Tiling with no crossing length 2 obstruction.
     assert ComponentFusion(t2, row_idx=0).has_crossing_len2_ob()
     t3 = Tiling(obstructions=[
         GriddedPerm((0, 2, 1), ((0, 0), ) * 3),
         GriddedPerm((0, 2, 1), ((1, 0), ) * 3),
     ])
     assert not ComponentFusion(t3, col_idx=0).has_crossing_len2_ob()
     t4 = Tiling(obstructions=[
         GriddedPerm((0, 1, 2), ((0, 0), ) * 3),
         GriddedPerm((0, 1, 2), ((0, 1), ) * 3),
         GriddedPerm((0, 1, 2), ((0, 2), ) * 3),
         GriddedPerm((0, 1), ((1, 2), ) * 2),
         GriddedPerm((0, 1), ((0, 0), (0, 2))),
         GriddedPerm((0, 1), ((0, 1), (0, 2))),
         GriddedPerm((2, 0, 1), ((0, 2), (0, 0), (1, 2))),
         GriddedPerm((2, 0, 1), ((0, 2), (0, 1), (1, 2))),
     ])
     assert not ComponentFusion(t4, row_idx=0).has_crossing_len2_ob()
Beispiel #6
0
 def fusion_algorithm(self, tiling: Tiling) -> Fusion:
     return ComponentFusion(
         tiling, row_idx=self.row_idx, col_idx=self.col_idx, tracked=self.tracked
     )
Beispiel #7
0
 def test_requirements_fuse_counters(self, row_fusion, col_fusion,
                                     tiling_with_req):
     assert row_fusion.requirements_fuse_counters == []
     assert col_fusion.requirements_fuse_counters == []
     with pytest.raises(RuntimeError):
         ComponentFusion(tiling_with_req).requirements_fuse_counters
Beispiel #8
0
 def test_pre_check_diff_basis(self):
     t = Tiling(obstructions=[
         GriddedPerm((0, 1, 2), ((0, 0), ) * 3),
         GriddedPerm((0, 1), ((0, 1), ) * 2),
     ])
     assert not ComponentFusion(t, row_idx=0)._pre_check()
Beispiel #9
0
 def not_prechecked_fusion(self, row_tiling):
     t = row_tiling.add_single_cell_obstruction(Perm((0, 2, 1)), (0, 0))
     return ComponentFusion(t, row_idx=0)
Beispiel #10
0
 def row_fusion(self, row_tiling):
     return ComponentFusion(row_tiling, row_idx=0)
Beispiel #11
0
 def col_fusion(self, col_tiling):
     return ComponentFusion(col_tiling, col_idx=0)