def test_confirm_failure(): """Check failure cases.""" symmetry = [ [[1, 2], 1.0, False], [[2, 1], 1.0, True], ] temp = np.random.rand(4, 4) + np.random.rand(4, 4) * 1.0j matrix = temp + np.conjugate(temp.T) matrix[1, 0] = -matrix[0, 1] with pytest.raises(ValueError): tensor_utils.confirm_symmetry(matrix, symmetry)
def test_confirm_symmetry_four_index_conjugate(): """Check that complex conjugation is built correctly.""" symmetry = [ [[1, 2, 3, 4], 1.0, False], [[2, 1, 3, 4], 1.0, True], [[1, 2, 4, 3], 1.0, True], ] matrix = np.zeros((2, 2, 2, 2), dtype=np.complex64) matrix[0, 0, 0, 0] = 1.0 matrix[1, 0, 0, 0] = 1.5 matrix[0, 1, 0, 0] = 1.5 matrix[0, 0, 1, 0] = 2.0 matrix[0, 0, 0, 1] = 2.0 matrix[1, 1, 0, 0] = 2.5 - 0.0j matrix[0, 0, 1, 1] = 3.0 + 0.0j matrix[0, 1, 1, 1] = 3.5 matrix[1, 0, 1, 1] = 3.5 matrix[1, 1, 0, 1] = 4.0 matrix[1, 1, 1, 0] = 4.0 matrix[1, 0, 1, 0] = 5.0 + 1.0j matrix[0, 1, 1, 0] = 5.0 - 1.0j matrix[1, 0, 0, 1] = 5.0 - 1.0j matrix[0, 1, 0, 1] = 5.0 + 1.0j matrix[1, 1, 1, 1] = 6.0 assert tensor_utils.confirm_symmetry(matrix, symmetry) is None
def test_confirm_symmetry_real(): """Check that real symmetry is obeyed.""" symmetry = [[[1, 2, 3, 4], 1.0, True]] matrix = np.zeros((2, 2, 2, 2), dtype=np.complex64) matrix[0, 0, 0, 0] = 1.0 + 0.0j matrix[1, 1, 0, 0] = 2.0 + 0.0j matrix[0, 0, 1, 1] = 2.0 + 0.0j matrix[1, 1, 1, 1] = 3.0 + 0.0j assert tensor_utils.confirm_symmetry(matrix, symmetry) is None
def test_confirm_symmetry_four_index_all(): """Check that all symmetry operations are built correctly.""" test = [ [[1, 2, 3, 4], 1.0, False], [[2, 1, 3, 4], -1.0, True], [[1, 2, 4, 3], 1.0, True], [[1, 4, 2, 3], 1.0, False], [[4, 3, 2, 1], 1.0, False], ] matrix = np.zeros((2, 2, 2, 2), dtype=np.complex64) assert tensor_utils.confirm_symmetry(matrix, test) is None
def test_confirm_hermitian(): """Check Hermitian cases.""" symmetry = [ [[1, 2], 1.0, False], [[2, 1], 1.0, True], ] temp = np.random.rand(4, 4) + np.random.rand(4, 4) * 1.0j matrix = temp + np.conjugate(temp.T) assert tensor_utils.confirm_symmetry(matrix, symmetry) is None
def test_confirm_anti_symmetric(): """Check antisymmetric cases.""" symmetry = [ [[1, 2], 1.0, False], [[2, 1], -1.0, False], ] temp = np.random.rand(4, 4) + np.random.rand(4, 4) * 1.0j matrix = temp - temp.T assert tensor_utils.confirm_symmetry(matrix, symmetry) is None
def test_only_unity(): """If the only symmetry is unity there is no validation to do.""" symmetry = [[[1, 2], 1.0, False]] temp = np.random.rand(4, 4) + np.random.rand(4, 4) * 1.0j assert tensor_utils.confirm_symmetry(temp, symmetry) is None