@@ -8,21 +8,29 @@ using Test
8
8
put (2 => Y),
9
9
put (3 => Z),
10
10
put (2 => T),
11
+ put (2 => I2),
11
12
swap (1 , 2 ),
12
13
put (3 => Ry (0.7 )),
13
14
control (2 , 1 => Y),
14
15
control (3 , 2 => Z),
15
16
)
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
+ )
17
25
18
26
header = Dict (" description" => " test circuits" )
19
27
exp_header = [Dict (" description" => " 1" ), Dict (" description" => " 2" )]
20
- circuits = [qc, qc1]
21
-
28
+ circuits = [qc, qc1]
29
+
22
30
q = convert_to_qobj (circuits, id = " test" , header = header, exp_header = exp_header)
23
31
q1 = convert_to_qobj (circuits)
24
32
q2 = convert_to_qobj (circuits, exp_header = exp_header)
25
-
33
+
26
34
set = [q, q1, q2]
27
35
for i in set
28
36
experiments = i. experiments
@@ -35,17 +43,45 @@ using Test
35
43
ir = convert_to_qbir (inst)
36
44
@test ir == circuits[i]
37
45
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 )))
42
46
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 = [
44
55
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
+ ]
48
59
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
51
87
end
0 commit comments