@@ -8,21 +8,29 @@ using Test
88 put (2 => Y),
99 put (3 => Z),
1010 put (2 => T),
11+ put (2 => I2),
1112 swap (1 , 2 ),
1213 put (3 => Ry (0.7 )),
1314 control (2 , 1 => Y),
1415 control (3 , 2 => Z),
1516 )
16- qc1 = chain (3 , put (1 => H), put (3 => Rx (0.7 )), control (2 , 1 => Y), control (3 , 2 => Z), put (1 => Yao. Measure (1 )))
17+ qc1 = chain (
18+ 3 ,
19+ put (1 => H),
20+ put (3 => Rx (0.7 )),
21+ control (2 , 1 => Y),
22+ control (3 , 2 => Z),
23+ put (1 => Yao. Measure (1 )),
24+ )
1725
1826 header = Dict (" description" => " test circuits" )
1927 exp_header = [Dict (" description" => " 1" ), Dict (" description" => " 2" )]
20- circuits = [qc, qc1]
21-
28+ circuits = [qc, qc1]
29+
2230 q = convert_to_qobj (circuits, id = " test" , header = header, exp_header = exp_header)
2331 q1 = convert_to_qobj (circuits)
2432 q2 = convert_to_qobj (circuits, exp_header = exp_header)
25-
33+
2634 set = [q, q1, q2]
2735 for i in set
2836 experiments = i. experiments
@@ -35,17 +43,45 @@ using Test
3543 ir = convert_to_qbir (inst)
3644 @test ir == circuits[i]
3745 end
38-
39- qc_inst = chain (1 , put (1 => YaoBlocksQobj. U1 {Float64} (2 )),
40- put (1 => YaoBlocksQobj. U2 {Float64} (1 , 0.7 )),
41- put (1 => YaoBlocksQobj. U3 {Float64} (0 , 1 , 0.7 )))
4246
43- inst = [
47+ qc_inst = chain (
48+ 1 ,
49+ put (1 => YaoBlocksQobj. U1 {Float64} (2 )),
50+ put (1 => YaoBlocksQobj. U2 {Float64} (1 , 0.7 )),
51+ put (1 => YaoBlocksQobj. U3 {Float64} (0 , 1 , 0.7 )),
52+ )
53+
54+ inst = [
4455 IBMQClient. Schema. Gate (" u1" , [0 ], [2 ], nothing , nothing ),
45- IBMQClient. Schema. Gate (" u2" , [0 ], [1 , 0.7 ], nothing , nothing ),
46- IBMQClient. Schema. Gate (" u3" , [0 ],[0 ,1 , 0.7 ], nothing , nothing ),
47- ]
56+ IBMQClient. Schema. Gate (" u2" , [0 ], [1 , 0.7 ], nothing , nothing ),
57+ IBMQClient. Schema. Gate (" u3" , [0 ], [0 , 1 , 0.7 ], nothing , nothing ),
58+ ]
4859
49- @test qc_inst == convert_to_qbir (inst)
50- end
60+ @test qc_inst == convert_to_qbir (inst)
61+ end
62+
63+ @testset " qbir misc." begin
64+ @test YaoBlocksQobj. mat (Number, YaoBlocksQobj. U1 (0.7 )) ≈ Number[
65+ 1 0
66+ 0 exp (im * 0.7 )
67+ ]
68+
69+ @test YaoBlocksQobj. mat (Number, YaoBlocksQobj. U2 (0.7 , 0.5 )) ≈ Number[
70+ 1 /√ 2 (- exp (im * 0.5 ))/√ 2
71+ (exp (im * 0.7 ))/√ 2 (exp (im * (1.2 )))/√ 2
72+ ]
73+
74+ @test YaoBlocksQobj. mat (Number, YaoBlocksQobj. U3 (0.7 , 0.5 , 0.2 )) ≈ Number[
75+ cos (0.7 / 2 ) - sin (0.7 / 2 )* exp (im * 0.2 )
76+ sin (0.7 / 2 )* exp (im * 0.5 ) cos (0.7 / 2 )* exp (im * (0.7 ))
77+ ]
78+
79+ @test YaoBlocksQobj. iparams_eltype (YaoBlocksQobj. U1 (0.7 )) == Float64
80+ @test YaoBlocksQobj. iparams_eltype (YaoBlocksQobj. U2 (0.7 , 0.5 )) == Float64
81+ @test YaoBlocksQobj. iparams_eltype (YaoBlocksQobj. U3 (0.7 , 0.5 , 0.2 )) == Float64
82+
83+ @test YaoBlocksQobj. getiparams (YaoBlocksQobj. U1 (0.7 )) == (0.7 )
84+ @test YaoBlocksQobj. getiparams (YaoBlocksQobj. U2 (0.7 , 0.5 )) == (0.7 , 0.5 )
85+ @test YaoBlocksQobj. getiparams (YaoBlocksQobj. U3 (0.7 , 0.5 , 0.2 )) == (0.7 , 0.5 , 0.2 )
86+ end
5187end
0 commit comments