2 Copyright 2020 Peter Rakyta, Ph.D. 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 8 http://www.apache.org/licenses/LICENSE-2.0 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see http://www.gnu.org/licenses/. 23 from qiskit
import QuantumCircuit
24 from qiskit.visualization
import plot_histogram
27 from squander.gates.gates_Wrapper
import R
29 from scipy.stats
import unitary_group
32 """This is a test class of the python iterface to the gates of the QGD package""" 38 This method is called by pytest. 39 Test to create an instance of RX gate. 45 parameters = np.array( [pi/2*0.32,np.pi/2*0.32] )
47 for qbit_num
in range(1,7):
50 target_qbit = qbit_num-1
53 R_gate = R( qbit_num, target_qbit )
58 R_squander = R_gate.get_Matrix( parameters )
63 circuit = QuantumCircuit(qbit_num)
66 circuit.r(parameters[0]*2,parameters[1], target_qbit)
70 R_qiskit = np.asarray(R_qiskit)
73 delta_matrix=R_squander-R_qiskit
76 error=np.linalg.norm(delta_matrix)
79 assert( error < 1e-3 )
83 This method is called by pytest. 84 Test to create an instance of U3 gate and compare with qiskit. 90 parameters = np.array( [pi/2*0.32,np.pi/2*0.32] )
92 for qbit_num
in range(1,7):
95 target_qbit = qbit_num-1
98 R_gate = R( qbit_num, target_qbit )
101 test_matrix= np.identity( 2**qbit_num, dtype=np.complex128 )
106 circuit = QuantumCircuit(qbit_num)
109 circuit.r(parameters[0]*2,parameters[1], target_qbit)
113 R_qiskit = np.asarray(R_qiskit)
116 circuit = QuantumCircuit(qbit_num)
123 R_squander=test_matrix
124 print(R_squander.dtype)
127 R_gate.apply_to( R_squander, parameters )
130 delta_matrix=R_squander-R_qiskit
133 error=np.linalg.norm(delta_matrix)
136 assert( error < 1e-3 )
def test_R_apply_to(self)
def test_R_get_matrix(self)
def get_unitary_from_qiskit_circuit
Call to retrieve the unitary from QISKIT circuit.