<gh_stars>0
from unittest import TestCase
import numpy as np
import time

from candidates import initialize_candidates
from solver import solve


class TestSolver(TestCase):
    def setUp(self) -> None:
        self.num_tests = 10000
        sudokus = np.load("../data/sudoku.npz")
        self.puzzles = sudokus["puzzles"]
        self.solutions = sudokus["solutions"]

    def test_solver(self):
        start = time.time()
        for i in range(self.num_tests):
            puzzle = self.puzzles[i]
            sol = self.solutions[i]

            cands, blksize = initialize_candidates(puzzle)
            self.assertTrue(solve(puzzle, cands, blksize))
            self.assertTrue(np.all(puzzle == sol))
        end = time.time()
        print(f"solved {self.num_tests} puzzles in {np.round(end - start, 3)}s.")

from unittest import TestCase
import numpy as np
import time

from candidates import initialize_candidates
from solver import solve


class TestSolver(TestCase):
    def setUp(self) -> None:
        self.num_tests = 10000
        sudokus = np.load("../data/sudoku.npz")
        self.puzzles = sudokus["puzzles"]
        self.solutions = sudokus["solutions"]

    def test_solver(self):
        start = time.time()
        for i in range(self.num_tests):
            puzzle = self.puzzles[i]
            sol = self.solutions[i]

            cands, blksize = initialize_candidates(puzzle)
            self.assertTrue(solve(puzzle, cands, blksize))
            self.assertTrue(np.all(puzzle == sol))
        end = time.time()
        print(f"solved {self.num_tests} puzzles in {np.round(end - start, 3)}s.")