diff --git a/tests/test_basis_rotation.py b/tests/test_basis_rotation.py index 52fce8a..242c795 100644 --- a/tests/test_basis_rotation.py +++ b/tests/test_basis_rotation.py @@ -11,21 +11,32 @@ from qibochem.driver.molecule import Molecule from qibochem.measurement.expectation import expectation +def test_swap_matrices(): + """Test for swap_matrices""" + permutations = [[(0,1),(2,3)]] + n_qubits = 4 + smat = basis_rotation.swap_matrices(permutations, n_qubits) + ref_smat = np.array([[0., 1., 0., 0.], + [1., 0., 0., 0.], + [0., 0., 0., 1.], + [0., 0., 1., 0.]]) + + assert np.allclose(smat, ref_smat) + def test_unitary_rot_matrix(): """Test for unitary rotation matrix""" occ = [0] vir = [1, 2] - parameters = np.zeros(len(occ) * len(vir)) + parameters = np.zeros(len(occ)*len(vir)) parameters += 0.1 u = basis_rotation.unitary_rot_matrix(parameters, occ, vir) - ref_u = np.array( - [[0.99001666, 0.099667, 0.099667], [-0.099667, 0.99500833, -0.00499167], [-0.099667, -0.00499167, 0.99500833]] - ) - + ref_u = np.array([[ 0.99001666, 0.099667, 0.099667], + [-0.099667, 0.99500833, -0.00499167], + [-0.099667, -0.00499167, 0.99500833]]) + assert np.allclose(u, ref_u) - def test_br_ansatz(): """Test of basis rotation ansatz against hardcoded HF energies""" h2_ref_energy = -1.117349035 diff --git a/tests/test_ucc.py b/tests/test_ucc.py index ea4094f..e806455 100644 --- a/tests/test_ucc.py +++ b/tests/test_ucc.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from scipy.optimize import minimize from qibochem.ansatz.hf_reference import hf_circuit