def test_not_a_single_tile_fits(): tile = [(0, 0), (1, 0), (2, 0), (3, 0)] tileset = many(tile) board = Rectangle(2, 2) with pytest.raises(PolyominoError): problem = board.tile_with_set(tileset) problem.make_problem()
def test_problem_with_no_mandatory_tiles(): tileset = Tileset([], ALL_PENTOMINOS, [DOMINO]) board = Rectangle(20, 20) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a is not None
def test_simple_problem_check_array(): tile = TETROMINOS["T"] tileset = many(tile).and_repeated_exactly(3, MONOMINO) board = Rectangle(3, 5) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a.shape == (65, 18) expected_sums = np.array([2] * 45 + [4] * 20) np.testing.assert_array_equal(a.sum(axis=1), expected_sums)
def test_right_number_of_tile_positions(l, x, y): assume(l < x and l < y) assume(x * y % l == 0) tile = [(0, i) for i in range(0, l)] tileset = many(tile) board = Rectangle(x, y) size = x * y n_positions = (x - l + 1) * y + x * (y - l + 1) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a.shape == (n_positions, size)