11from permuta import Perm
2- from tilescopethree .strategies import all_cell_insertions
2+ from tilescopethree .strategies import (all_cell_insertions , all_col_insertions ,
3+ all_factor_insertions ,
4+ all_requirement_extensions ,
5+ all_requirement_insertions ,
6+ all_row_insertions )
37from tilings import Obstruction , Requirement , Tiling
48
59pytest_plugins = [
@@ -26,7 +30,7 @@ def test_all_cell_insertions_points(simple_tiling):
2630 obstructions = [Obstruction (Perm ((0 ,)), ((0 , 1 ),)),
2731 Obstruction (Perm ((0 ,)), ((1 , 0 ),))],
2832 requirements = [[Requirement (Perm ((0 , 1 )), ((0 , 0 ), (1 , 1 )))]]),
29- Tiling (
33+ Tiling (
3034 obstructions = [Obstruction (Perm ((0 ,)), ((0 , 1 ),))],
3135 requirements = [[Requirement (Perm ((0 ,)), ((1 , 0 ),))],
3236 [Requirement (Perm ((0 , 1 )), ((0 , 0 ), (1 , 0 ))),
@@ -41,11 +45,12 @@ def test_all_cell_insertions_points(simple_tiling):
4145
4246 actual .add ((Tiling (
4347 requirements = [[Requirement (Perm ((0 , 1 )), ((0 , 0 ), (1 , 0 )))]]),
44- Tiling (
48+ Tiling (
4549 obstructions = [Obstruction (Perm ((1 , 0 )), ((0 , 1 ), (1 , 0 )))],
4650 requirements = [[Requirement (Perm ((0 ,)), ((1 , 1 ),))],
4751 [Requirement (Perm ((0 , 1 )), ((0 , 0 ), (1 , 0 ))),
4852 Requirement (Perm ((0 , 1 )), ((0 , 0 ), (1 , 1 )))]])))
53+ print (simple_tiling )
4954 assert strats == actual
5055
5156
@@ -60,8 +65,96 @@ def test_all_cell_insertions(typical_redundant_requirements,
6065 obstructions = typical_redundant_obstructions + [
6166 Obstruction (Perm ((0 , 1 , 2 )), [(0 , 1 ), (0 , 1 ), (0 , 1 )])],
6267 requirements = typical_redundant_requirements ),
63- Tiling (
68+ Tiling (
6469 obstructions = typical_redundant_obstructions ,
6570 requirements = typical_redundant_requirements + [
6671 [Requirement (Perm ((0 , 1 , 2 )), [(0 , 1 ), (0 , 1 ), (0 , 1 )])]])
67- ) in strats )
72+ ) in strats )
73+
74+
75+ def test_all_requirement_extension ():
76+ t = Tiling .from_string ('123_132' ).add_single_cell_requirement (
77+ Perm ((0 , 1 )), (0 , 0 ))
78+ strats = set ([tuple (s .comb_classes )
79+ for s in all_requirement_extensions (t , maxreqlen = 3 )])
80+ actual = set ([
81+ (t .add_single_cell_obstruction (Perm ((2 , 0 , 1 )), (0 , 0 )),
82+ t .add_single_cell_requirement (Perm ((2 , 0 , 1 )), (0 , 0 ))),
83+ (t .add_single_cell_obstruction (Perm ((1 , 0 , 2 )), (0 , 0 )),
84+ t .add_single_cell_requirement (Perm ((1 , 0 , 2 )), (0 , 0 ))),
85+ (t .add_single_cell_obstruction (Perm ((1 , 2 , 0 )), (0 , 0 )),
86+ t .add_single_cell_requirement (Perm ((1 , 2 , 0 )), (0 , 0 ))),
87+ ])
88+ assert actual == strats
89+
90+
91+ def test_all_row_insertion ():
92+ t = Tiling (obstructions = [
93+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ),)* 2 ),
94+ Obstruction (Perm ((0 , 1 )), ((1 , 0 ),)* 2 ),
95+ Obstruction (Perm ((0 , 1 , 2 )), ((0 , 1 ),)* 3 ),
96+ ], requirements = [
97+ [Requirement (Perm ((0 , 1 )), ((0 , 1 ),)* 2 )]
98+ ])
99+ strats = set ([tuple (s .comb_classes )
100+ for s in all_row_insertions (t )])
101+ actual = set ([
102+ (Tiling (obstructions = [Obstruction (Perm ((0 , 1 , 2 )), ((0 , 0 ),)* 3 )],
103+ requirements = [[Requirement (Perm ((0 , 1 )), ((0 , 0 ),)* 2 )]]),
104+ t .add_list_requirement ([Requirement (Perm ((0 ,)), ((0 , 0 ),)),
105+ Requirement (Perm ((0 ,)), ((1 , 0 ),)), ])), ])
106+ assert actual == strats
107+ assert (next (all_row_insertions (t )).formal_step ==
108+ 'Either row 0 is empty or not.' )
109+
110+
111+ def test_all_col_insertion ():
112+ t = Tiling (obstructions = [
113+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ),)* 2 ),
114+ Obstruction (Perm ((0 , 1 )), ((1 , 0 ),)* 2 ),
115+ Obstruction (Perm ((0 , 1 , 2 )), ((0 , 1 ),)* 3 ),
116+ ], requirements = [
117+ [Requirement (Perm ((0 , 1 )), ((0 , 1 ),)* 2 )]
118+ ])
119+ strats = set ([tuple (s .comb_classes )
120+ for s in all_col_insertions (t )])
121+ actual = set ([
122+ (t .add_single_cell_obstruction (Perm ((0 ,)), (1 , 0 )),
123+ t .add_single_cell_requirement (Perm ((0 ,)), (1 , 0 )),)
124+ ])
125+ assert actual == strats
126+ assert (next (all_col_insertions (t )).formal_step ==
127+ 'Either column 1 is empty or not.' )
128+
129+
130+ def test_all_requirement_insertion ():
131+ t = Tiling (obstructions = [
132+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ), (0 , 0 ))),
133+ Obstruction (Perm ((0 , 1 )), ((1 , 0 ), (1 , 0 ))),
134+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ), (1 , 0 ))),
135+ ])
136+ strats = set (tuple (s .comb_classes )
137+ for s in all_requirement_insertions (t , 2 ))
138+ assert len (strats ) == 5
139+ strat_formal_steps = (
140+ set (s .formal_step for s in all_requirement_insertions (t , 2 )))
141+ assert 'Insert 0 in cell (1, 0).' in strat_formal_steps
142+ assert 'Insert 10: (0, 0), (1, 0).' in strat_formal_steps
143+
144+
145+ def test_all_factor_insertions ():
146+ t = Tiling (obstructions = [
147+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ), (0 , 0 ))),
148+ Obstruction (Perm ((0 , 1 )), ((1 , 0 ), (1 , 0 ))),
149+ Obstruction (Perm ((1 , 0 )), ((1 , 1 ), (1 , 1 ))),
150+ Obstruction (Perm ((1 , 0 )), ((1 , 2 ), (1 , 2 ))),
151+ Obstruction (Perm ((0 , 1 , 2 )), ((0 , 0 ), (1 , 1 ), (1 , 2 ))),
152+ Obstruction (Perm ((0 , 1 )), ((0 , 0 ), (1 , 0 ))),
153+ ])
154+ strats = set (tuple (s .comb_classes )
155+ for s in all_factor_insertions (t ))
156+ assert len (strats ) == 2
157+ strat_formal_steps = (
158+ set (s .formal_step for s in all_factor_insertions (t )))
159+ assert 'Insert 0 in cell (0, 0).' in strat_formal_steps
160+ assert 'Insert 01: (1, 1), (1, 2).' in strat_formal_steps
0 commit comments