Exemplo n.º 1
0
def gps_indices_direction_owncol_ownrow_ignoreparent_includeempty(strategy):
    return [
        strategy(
            gps=gps,
            indices=indices,
            direction=direction,
            own_col=own_col,
            own_row=own_row,
            ignore_parent=ignore_parent,
            include_empty=include_empty,
        ) for (
            gps,
            indices,
        ), direction, own_col, own_row, ignore_parent, include_empty in
        product(
            (
                ((GriddedPerm(Perm((0, )), ((0, 0), )), ), (0, )),
                ((GriddedPerm.single_cell(Perm((0, 1, 2)), (2, 1)), ), (1, )),
                (
                    (
                        GriddedPerm(Perm((0, 1)), ((0, 1), (1, 1))),
                        GriddedPerm(Perm((1, 0)), ((2, 2), (3, 1))),
                    ),
                    (1, 0),
                ),
            ),
            (DIR_EAST, DIR_WEST, DIR_NORTH, DIR_SOUTH),
            (True, False),
            (True, False),
            (True, False),
            (True, False),
        )
    ]
Exemplo n.º 2
0
 def test_new_obs(self, obs_inf1, obs_inf2):
     assert set(obs_inf1.potential_new_obs()) == set(
         [GriddedPerm(Perm((0, )), ((1, 0), ))])
     assert set(obs_inf2.potential_new_obs()) == set([
         GriddedPerm(Perm((0, )), ((0, 0), )),
         GriddedPerm(Perm((0, )), ((2, 0), ))
     ])
Exemplo n.º 3
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()
Exemplo n.º 4
0
 def enum_not_verified(self, onebyone_enum):
     t = Tiling(obstructions=[
         GriddedPerm(Perm((0, 1)), ((0, 0), (0, 1))),
         GriddedPerm(Perm((0, 1)), ((0, 0), (0, 0))),
         GriddedPerm(Perm((0, 1)), ((0, 1), (0, 1))),
     ])
     return [t, onebyone_enum]
Exemplo n.º 5
0
def test_domino():
    domino = Tiling(obstructions=[
        GriddedPerm((0, 2, 1), [(0, 0), (0, 0), (0, 0)]),
        GriddedPerm((1, 0, 2), [(0, 1), (0, 1), (0, 1)]),
        GriddedPerm((0, 2, 1, 3), [(0, 0), (0, 1), (0, 0), (0, 1)]),
    ])
    tilescope = TileScope(
        domino,
        TileScopePack.row_and_col_placements().make_fusion(tracked=True,
                                                           component=True),
    )
    spec = tilescope.auto_search()
    assert isinstance(spec, CombinatorialSpecification)
    assert [spec.count_objects_of_size(i) for i in range(15)] == [
        1,
        2,
        6,
        22,
        91,
        408,
        1938,
        9614,
        49335,
        260130,
        1402440,
        7702632,
        42975796,
        243035536,
        1390594458,
    ]
Exemplo n.º 6
0
 def test_with_123_subclass_12req(self, strategy):
     t2 = Tiling(
         obstructions=[
             GriddedPerm((2, 1, 0), ((0, 0),) * 3),
             GriddedPerm((1, 0, 3, 2), ((0, 0),) * 4),
         ],
         requirements=[[GriddedPerm((1, 0), ((0, 0),) * 2)]],
     )
     assert strategy.verified(t2)
     genf = strategy.get_genf(t2)
     assert taylor_expand(genf, 16) == [
         0,
         0,
         1,
         4,
         12,
         32,
         79,
         184,
         410,
         884,
         1861,
         3852,
         7880,
         15992,
         32283,
         64944,
         130358,
     ]
Exemplo n.º 7
0
def not_fact_tiling():
    not_fact_tiling = Tiling(obstructions=[
        GriddedPerm((0, 1), ((0, 0), (0, 0))),
        GriddedPerm((0, 1), ((0, 0), (0, 1))),
        GriddedPerm((0, 1), ((0, 1), (0, 1))),
    ])
    return not_fact_tiling
Exemplo n.º 8
0
def col_tiling():
    t = Tiling(obstructions=[
        GriddedPerm(Perm((0, 2, 1)), ((0, 0), ) * 3),
        GriddedPerm(Perm((0, 2, 1)), ((1, 0), ) * 3),
        GriddedPerm(Perm((0, 1)), ((0, 0), (1, 0))),
    ])
    return t
Exemplo n.º 9
0
def tiling_no_trans_col():
    return Tiling(
        obstructions=[
            GriddedPerm(Perm((0, 1)), [(0, 0), (0, 1)]),
            GriddedPerm(Perm((0, 1)), [(0, 1), (0, 2)]),
        ]
    )
Exemplo n.º 10
0
 def obs_inf1(self, tiling1):
     obs_trans = ObstructionInferral(tiling1)
     obs_trans.potential_new_obs = MagicMock(return_value=[
         GriddedPerm((0, 1), [(0, 0), (0, 0)]),
         GriddedPerm((1, 0), [(0, 0), (1, 0)]),
     ])
     return obs_trans
Exemplo n.º 11
0
def tiling_no_trans_row():
    return Tiling(
        obstructions=[
            GriddedPerm(Perm((0, 1)), [(0, 0), (1, 0)]),
            GriddedPerm(Perm((0, 1)), [(1, 0), (2, 0)]),
        ]
    )
Exemplo n.º 12
0
def test_remove_cells(simpleob):
    assert simpleob.remove_cells([
        (0, 0)
    ]) == GriddedPerm(Perm((1, 0)), ((2, 2), (2, 1)))
    assert simpleob.remove_cells([(0, 0), (2, 2)
                                  ]) == GriddedPerm(Perm((0, )), ((2, 1), ))
    assert simpleob.remove_cells([(0, 1), (1, 2)]) == simpleob
Exemplo n.º 13
0
 def test_new_obs(self, obs_not_inf, obs_inf1, obs_inf2):
     assert obs_inf1.new_obs() == [
         GriddedPerm((0, 1), ((0, 0), (0, 0))),
     ]
     assert obs_not_inf.new_obs() == []
     assert obs_inf2.new_obs() == [
         GriddedPerm((0, 1), ((0, 0), (2, 0))),
     ]
Exemplo n.º 14
0
 def enum_with_interleaving(self):
     return Tiling(
         obstructions=[
             GriddedPerm((0, 1, 2), ((0, 1),) * 3),
             GriddedPerm((0, 1, 2), ((1, 2),) * 3),
             GriddedPerm((0, 1, 2), ((1, 0),) * 3),
         ]
     )
Exemplo n.º 15
0
def tiling_simple_trans_row():
    return Tiling(
        obstructions=[
            GriddedPerm(Perm((0, 1)), [(0, 0), (1, 0)]),
            GriddedPerm(Perm((0, 1)), [(1, 0), (2, 0)]),
        ],
        requirements=[[GriddedPerm(Perm((0,)), [(1, 0)])]],
    )
Exemplo n.º 16
0
def simple_trans_col():
    return Tiling(
        obstructions=[
            GriddedPerm((0, 1), [(0, 0), (0, 1)]),
            GriddedPerm((0, 1), [(0, 1), (0, 2)]),
        ],
        requirements=[[GriddedPerm((0,), [(0, 1)])]],
    )
Exemplo n.º 17
0
def test_contradictory(simpleob, singlecellob, everycellob):
    assert not simpleob.contradictory()
    assert not singlecellob.contradictory()
    assert not everycellob.contradictory()
    gp = GriddedPerm(Perm((0, 1)), [(0, 1), (1, 0)])
    assert gp.contradictory()
    gp = GriddedPerm(Perm((0, 1)), [(1, 0), (0, 0)])
    assert gp.contradictory()
Exemplo n.º 18
0
 def test_fuse_counter(self, row_fusion, col_fusion, gp1, gp2):
     assert row_fusion._fuse_counter([gp1, gp2]) == {
         GriddedPerm((0, 1, 2), ((0, 0), (1, 0), (1, 0))): 2
     }
     assert col_fusion._fuse_counter([gp1, gp2]) == {
         GriddedPerm((0, 1, 2), ((0, 0), (0, 0), (0, 1))): 1,
         GriddedPerm((0, 1, 2), ((0, 0), (0, 0), (0, 0))): 1,
     }
Exemplo n.º 19
0
def simple_tiling():
    return Tiling(
        obstructions=[GriddedPerm(Perm((1, 0)), [(0, 1), (1, 0)])],
        requirements=[[
            GriddedPerm(Perm((0, 1)), [(0, 0), (1, 0)]),
            GriddedPerm(Perm((0, 1)), [(0, 0), (1, 1)]),
        ]],
    )
Exemplo n.º 20
0
 def enum_not_verified(self, enum_onebyone, enum_with_interleaving):
     t = Tiling(obstructions=[
         GriddedPerm(Perm((0, 1, 2)), ((0, 1), ) * 3),
         GriddedPerm(Perm((0, 1, 2)), ((1, 2), ) * 3),
         GriddedPerm(Perm((0, 1, 2)), ((1, 0), ) * 3),
         GriddedPerm(Perm((1, 2, 0)), ((0, 1), (1, 2), (1, 0))),
     ])
     return [t, enum_onebyone, enum_with_interleaving]
Exemplo n.º 21
0
def test_point_requirements(placement1, placement1owncol, placement1ownrow):
    assert placement1._point_requirements((2, 3)) == [[GriddedPerm((0,), ((3, 4),))]]
    assert placement1ownrow._point_requirements((2, 3)) == [
        [GriddedPerm((0,), ((2, 4),))]
    ]
    assert placement1owncol._point_requirements((2, 3)) == [
        [GriddedPerm((0,), ((3, 3),))]
    ]
Exemplo n.º 22
0
 def enum_verified(self, enum_with_req):
     t = Tiling(obstructions=[
         GriddedPerm(Perm((0, 2, 1)), ((0, 1), ) * 3),
         GriddedPerm(Perm((0, 2, 1)), ((1, 2), ) * 3),
         GriddedPerm(Perm((0, 2, 1)), ((2, 0), ) * 3),
         GriddedPerm(Perm((1, 2, 0)), ((0, 1), (1, 2), (2, 0))),
     ])
     return [t, enum_with_req]
Exemplo n.º 23
0
def test_extend():
    gp = GriddedPerm((1, 0), ((0, 1), (1, 0)))
    assert set(gp.extend(2, 2)) == {
        GriddedPerm((2, 1, 0), ((0, 1), (0, 1), (1, 0))),
        GriddedPerm((1, 2, 0), ((0, 1), (0, 1), (1, 0))),
        GriddedPerm((1, 2, 0), ((0, 1), (1, 1), (1, 0))),
        GriddedPerm((1, 0, 2), ((0, 1), (1, 0), (1, 1))),
    }
Exemplo n.º 24
0
def test_apply_map(typicalob, simpleob):
    def cell_mapping(x):
        return (x[0] + 1, x[1] + 2)

    assert typicalob.apply_map(cell_mapping) == GriddedPerm(
        (1, 0, 2, 4, 3), ((1, 2), (1, 2), (2, 2), (2, 3), (2, 3)))
    assert simpleob.apply_map(cell_mapping) == GriddedPerm(
        (1, 0, 3, 2), ((1, 2), (1, 2), (3, 4), (3, 3)))
Exemplo n.º 25
0
 def enum_verified(self):
     t = Tiling(obstructions=[
         GriddedPerm((0, 1), ((0, 0), ) * 2),
         GriddedPerm((0, 1), ((0, 1), ) * 2),
         GriddedPerm((0, 1), ((0, 2), ) * 2),
         GriddedPerm((0, 1), ((2, 0), ) * 2),
         GriddedPerm((0, 1, 2), ((1, 1), ) * 3),
     ])
     return MonotoneTreeEnumeration(t)
def t_fully_placed():
    return Tiling(
        obstructions=[
            GriddedPerm((0, 1), ((0, 0), (0, 0))),
            GriddedPerm((0, 1), ((1, 1), (1, 1))),
            GriddedPerm((1, 0), ((1, 1), (1, 1))),
        ],
        requirements=[[GriddedPerm((0,), ((1, 1),))]],
    )
def t_col_placed2():
    return Tiling(
        obstructions=[
            GriddedPerm((0, 1), ((0, 0), (0, 0))),
            GriddedPerm((0, 1), ((1, 0), (1, 0))),
            GriddedPerm((1, 0), ((1, 0), (1, 0))),
        ],
        requirements=[[GriddedPerm((0, 1), ((0, 0), (1, 0)))]],
    )
Exemplo n.º 28
0
 def enum_with_list_req(self):
     t = Tiling(
         obstructions=[
             GriddedPerm((0, 1), ((0, 0), (0, 0))),
             GriddedPerm((0, 1), ((1, 0), (1, 0))),
         ],
         requirements=[[GriddedPerm((0,), ((0, 0),)), GriddedPerm((0,), ((1, 0),))]],
     )
     return t
Exemplo n.º 29
0
def test_stretch_gridded_perms(placement1, placement1owncol, placement1ownrow):
    gps = [
        GriddedPerm((0, 1), [(0, 0), (1, 1)]),
        GriddedPerm((0, 1), [(1, 1), (2, 2)]),
    ]
    for p in (placement1, placement1ownrow, placement1owncol):
        assert set(p._stretch_gridded_perms(gps, (1, 1))) == set(
            chain.from_iterable(p._stretch_gridded_perm(gp, (1, 1)) for gp in gps)
        )
Exemplo n.º 30
0
 def test_potential_new_obs(self, obs_inf1, obs_not_inf):
     assert set(obs_inf1.potential_new_obs()) == set([
         GriddedPerm((0, ), ((0, 0), )),
         GriddedPerm((0, 1), ((0, 0), (0, 0))),
         GriddedPerm((0, 1), ((0, 0), (1, 0))),
         GriddedPerm((1, 0), ((0, 0), (1, 0))),
     ])
     print(obs_not_inf._tiling)
     assert set(obs_not_inf.potential_new_obs()) == set([])