deeplearning_sudoku_solver / tests /test_symetries.py
Sebastien
first commit
4484b8a
raw
history blame
769 Bytes
import pytest
import numpy as np
from sudoku.symetries import mat_sym
def test_same_output_under_rotation():
assert mat_sym.shape == (9 * 9 * 9, 16, 9 * 9 * 9)
arr1 = np.zeros((9, 9, 9))
arr1[0, 1, 2] = 1
arr1_sym = np.dot(mat_sym, arr1.reshape(9 * 9 * 9, -1)).reshape(9, 9, 9, -1)
arr2 = np.zeros((9, 9, 9))
arr2[1, 2, 3] = 1
arr2_sym = np.dot(mat_sym, arr2.reshape(9 * 9 * 9, -1)).reshape(9, 9, 9, -1)
assert arr1_sym.shape == (9, 9, 9, 16)
assert (arr1_sym[0, 1, 2] == arr2_sym[1, 2, 3]).all()
assert (arr1_sym[5, 1, 2] == arr2_sym[5, 2, 3]).all()
assert (arr1_sym[0, 1, 1] == arr2_sym[1, 2, 4]).all()
assert (arr1_sym[0, 5, 1] == arr2_sym[1, 8, 4]).all()
assert (arr1_sym[6, 5, 1] == arr2_sym[6, 8, 4]).all()