Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added failing test for generate_solutions() that should pass #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

# build files
build/*
dist/*
dist/*
41 changes: 41 additions & 0 deletions tests/test_solver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from nonogram_solver import solver
from nonogram_solver.nonogram import Nonogram
from nonogram_solver.solver import generate_solutions
import numpy as np


Expand Down Expand Up @@ -73,3 +74,43 @@ def test_nonogram_solver_manual(simple_nonogram_from_string_box):
[0, 0, 1, 1, 0],
[-1, -1, -1, 0, 1],
[-1, -1, 0, 0, 1]]))


def test_generate_solutions_ship_example():
n_rows = 10
n_cols = 10
col_clues = [
[1],
[2, 2],
[2, 2, 3],
[10],
[2, 3],
[2, 3],
[2, 2, 3],
[10],
[2, 2, 3],
[2]]
row_clues = [
[1, 1],
[3, 3],
[3, 3],
[1, 1],
[3, 4],
[3, 4],
[1, 1],
[10],
[9],
[7]]
puzzle = -1 * np.ones((n_rows, n_cols))
generate_solutions(n_rows, n_cols, row_clues, col_clues, puzzle)
assert np.all(puzzle == np.array(
[[0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 1, 1, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
[0, 1, 1, 1, 0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 1, 1, 1, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 1, 1, 1, 0]]))