@@ -68,21 +68,32 @@ def test_incorrect_quasi_dist(self):
6868 def test_correct_expval_one_obs (self ):
6969 """should raise no error and evaluate the observable ZZ to 1"""
7070 result = Plugin ().execute (
71- "aer" , "./tests/valid_expval.qasm" , {"obs" : [("ZZ" , 1 )]}, "expval"
71+ "aer" , "./tests/valid_expval.qasm" , {"obs" : [[ ("ZZ" , 1 )] ]}, "expval"
7272 )
7373
74- assert result == 1.0
74+ assert result == [ 1.0 ]
7575
76- def test_correct_expval_two_obs (self ):
76+ def test_correct_expval_two_obs_same_pub (self ):
7777 """should raise no error and sum up all expectation values (total=3)"""
7878 result = Plugin ().execute (
7979 "aer" ,
8080 "./tests/valid_expval.qasm" ,
81- {"obs" : [("ZI" , 1 ), ("IZ" , 1 ), ("ZZ" , 1 )]},
81+ {"obs" : [[ ("ZI" , 1 ), ("IZ" , 1 ), ("ZZ" , 1 )] ]},
8282 "expval" ,
8383 )
8484
85- assert result == 3.0
85+ assert result == [3.0 ]
86+
87+ def test_correct_expval_one_obs_per_pub (self ):
88+ """should return a list of expectation values with size 2"""
89+ result = Plugin ().execute (
90+ "aer" ,
91+ "./tests/valid_expval.qasm" ,
92+ {"obs" : [[("ZI" , 1 )], [("ZI" , 1 )]]},
93+ "expval" ,
94+ )
95+
96+ assert result == [1.0 , 1.0 ]
8697
8798 def test_incorrect_expval_no_obs (self ):
8899 """should raise an error, once there's no observables defined."""
@@ -94,6 +105,6 @@ def test_incorrect_expval_circuit_with_measurements(self):
94105 """should raise no error, once the circuit has measurements but we can evaluate the expval as well."""
95106
96107 result = Plugin ().execute (
97- "aer" , "./tests/expval_measurements.qasm" , {"obs" : [("II" , 1 )]}, "expval"
108+ "aer" , "./tests/expval_measurements.qasm" , {"obs" : [[ ("II" , 1 )] ]}, "expval"
98109 )
99- assert result == 1.0
110+ assert result == [ 1.0 ]
0 commit comments