diff --git a/doc/source/_apidoc/qutip_qip.decompose.rst b/doc/source/_apidoc/qutip_qip.decompose.rst new file mode 100644 index 00000000..1d0f4e18 --- /dev/null +++ b/doc/source/_apidoc/qutip_qip.decompose.rst @@ -0,0 +1,21 @@ +qutip\_qip.decompose package +============================ + +Submodules +---------- + +qutip\_qip.decompose.decompose\_single\_qubit\_gate module +---------------------------------------------------------- + +.. automodule:: qutip_qip.decompose.decompose_single_qubit_gate + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: qutip_qip.decompose + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/_apidoc/qutip_qip.rst b/doc/source/_apidoc/qutip_qip.rst index 55d395e1..1c3bf8d5 100644 --- a/doc/source/_apidoc/qutip_qip.rst +++ b/doc/source/_apidoc/qutip_qip.rst @@ -9,6 +9,7 @@ Subpackages qutip_qip.algorithms qutip_qip.compiler + qutip_qip.decompose qutip_qip.device qutip_qip.operations qutip_qip.transpiler @@ -32,14 +33,6 @@ qutip\_qip.circuit\_latex module :undoc-members: :show-inheritance: -qutip\_qip.decompose module ---------------------------- - -.. automodule:: qutip_qip.decompose - :members: - :undoc-members: - :show-inheritance: - qutip\_qip.gates module ----------------------- diff --git a/src/qutip_qip/decompose/decompose_single_qubit_gate.py b/src/qutip_qip/decompose/decompose_single_qubit_gate.py index 81387000..7c8c7a5f 100644 --- a/src/qutip_qip/decompose/decompose_single_qubit_gate.py +++ b/src/qutip_qip/decompose/decompose_single_qubit_gate.py @@ -37,7 +37,7 @@ def _angles_for_ZYZ(input_gate): return (alpha, -theta, beta, global_phase_angle) -def ZYZ_rotation(input_gate): +def _ZYZ_rotation(input_gate): r"""An input 1-qubit gate is expressed as a product of rotation matrices :math:`\textrm{R}_z` and :math:`\textrm{R}_y`. @@ -77,7 +77,7 @@ def ZYZ_rotation(input_gate): return (Rz_alpha, Ry_theta, Rz_beta, Phase_gate) -def ZXZ_rotation(input_gate): +def _ZXZ_rotation(input_gate): r"""An input 1-qubit gate is expressed as a product of rotation matrices :math:`\textrm{R}_z` and :math:`\textrm{R}_x`. @@ -123,7 +123,7 @@ def ZXZ_rotation(input_gate): # Functions for ABC_decomposition -def ZYZ_pauli_X(input_gate): +def _ZYZ_pauli_X(input_gate): """Returns a 1 qubit unitary as a product of ZYZ rotation matrices and Pauli X.""" check_gate(input_gate, num_qubits=1) @@ -171,9 +171,9 @@ def ZYZ_pauli_X(input_gate): _single_decompositions_dictionary = { - "ZYZ": ZYZ_rotation, - "ZXZ": ZXZ_rotation, - "ZYZ_PauliX": ZYZ_pauli_X, + "ZYZ": _ZYZ_rotation, + "ZXZ": _ZXZ_rotation, + "ZYZ_PauliX": _ZYZ_pauli_X, } # other combinations to add here diff --git a/tests/decomposition_functions/test_single_qubit_gate_decompositions.py b/tests/decomposition_functions/test_single_qubit_gate_decompositions.py index b74e9b3b..0f697e01 100644 --- a/tests/decomposition_functions/test_single_qubit_gate_decompositions.py +++ b/tests/decomposition_functions/test_single_qubit_gate_decompositions.py @@ -6,9 +6,9 @@ Qobj, average_gate_fidelity, rand_unitary, sigmax, sigmay, sigmaz ) from qutip_qip.decompose.decompose_single_qubit_gate import ( - ZYZ_rotation, - ZXZ_rotation, - ZYZ_pauli_X, + _ZYZ_rotation, + _ZXZ_rotation, + _ZYZ_pauli_X, ) from qutip_qip.decompose import decompose_one_qubit_gate from qutip_qip.circuit import decomposed_gates_to_circuit, compute_unitary @@ -31,7 +31,7 @@ "gate", [H, sigmax, sigmay, sigmaz, SQRTNOT, S, T, rand_unitary(2)] ) @pytest.mark.parametrize( - "method", [ZYZ_rotation, ZXZ_rotation, ZYZ_pauli_X] + "method", [_ZYZ_rotation, _ZXZ_rotation, _ZYZ_pauli_X] ) def test_single_qubit_to_rotations(gate, method): """Initial matrix and product of final decompositions are same within some @@ -68,7 +68,7 @@ def test_check_single_qubit_to_decompose_to_rotations(gate, method): "gate", [H, sigmax, sigmay, sigmaz, SQRTNOT, S, T, rand_unitary(2)] ) @pytest.mark.parametrize( - "method", [ZYZ_rotation, ZXZ_rotation, ZYZ_pauli_X] + "method", [_ZYZ_rotation, _ZXZ_rotation, _ZYZ_pauli_X] ) def test_output_is_tuple(gate, method): """Initial matrix and product of final decompositions are same within some diff --git a/tests/test_circuit.py b/tests/test_circuit.py index c2cbfd38..bd304229 100644 --- a/tests/test_circuit.py +++ b/tests/test_circuit.py @@ -48,7 +48,7 @@ _para_gates ) -from qutip_qip.decompose.decompose_single_qubit_gate import ZYZ_rotation +from qutip_qip.decompose.decompose_single_qubit_gate import _ZYZ_rotation import qutip as qp @@ -691,8 +691,8 @@ def test_decomposed_gates_to_circuit(invalid_input): H = Qobj([[1/np.sqrt(2), 1/np.sqrt(2)], [1/np.sqrt(2), -1/np.sqrt(2)]]) sigmax = Qobj([[0, 1], [1, 0]]) -H_zyz_gates = ZYZ_rotation(H) -sigmax_zyz_gates = ZYZ_rotation(sigmax) +H_zyz_gates = _ZYZ_rotation(H) +sigmax_zyz_gates = _ZYZ_rotation(sigmax) @pytest.mark.parametrize("valid_input", [H_zyz_gates, sigmax_zyz_gates])