@@ -129,7 +129,7 @@ def test_run_single_circuit_observable(self):
129
129
self .subTest (f"{ val } " )
130
130
result = est .run ([(qc , op , val )]).result ()
131
131
np .testing .assert_allclose (result [0 ].data .evs , target )
132
- self .assertEqual (result [0 ].metadata ["precision " ], 0 )
132
+ self .assertEqual (result [0 ].metadata ["target_precision " ], 0 )
133
133
134
134
with self .subTest ("One parameter" ):
135
135
param = Parameter ("x" )
@@ -145,7 +145,7 @@ def test_run_single_circuit_observable(self):
145
145
self .subTest (f"{ val } " )
146
146
result = est .run ([(qc , op , val )]).result ()
147
147
np .testing .assert_allclose (result [0 ].data .evs , target )
148
- self .assertEqual (result [0 ].metadata ["precision " ], 0 )
148
+ self .assertEqual (result [0 ].metadata ["target_precision " ], 0 )
149
149
150
150
with self .subTest ("More than one parameter" ):
151
151
qc = self .psi [0 ]
@@ -162,7 +162,7 @@ def test_run_single_circuit_observable(self):
162
162
self .subTest (f"{ val } " )
163
163
result = est .run ([(qc , op , val )]).result ()
164
164
np .testing .assert_allclose (result [0 ].data .evs , target )
165
- self .assertEqual (result [0 ].metadata ["precision " ], 0 )
165
+ self .assertEqual (result [0 ].metadata ["target_precision " ], 0 )
166
166
167
167
def test_run_1qubit (self ):
168
168
"""Test for 1-qubit cases"""
@@ -290,6 +290,23 @@ def test_iter_pub(self):
290
290
np .testing .assert_allclose (result [0 ].data .evs , [- 1.284366511861733 ])
291
291
np .testing .assert_allclose (result [1 ].data .evs , [- 1.284366511861733 ])
292
292
293
+ def test_metadata (self ):
294
+ """Test for metadata"""
295
+ qc = QuantumCircuit (2 )
296
+ qc2 = QuantumCircuit (2 )
297
+ qc2 .metadata = {"a" : 1 }
298
+ estimator = StatevectorEstimator ()
299
+ result = estimator .run ([(qc , "ZZ" ), (qc2 , "ZZ" )], precision = 0.1 ).result ()
300
+
301
+ self .assertEqual (len (result ), 2 )
302
+ self .assertEqual (result .metadata , {"version" : 2 })
303
+ self .assertEqual (
304
+ result [0 ].metadata , {"target_precision" : 0.1 , "circuit_metadata" : qc .metadata }
305
+ )
306
+ self .assertEqual (
307
+ result [1 ].metadata , {"target_precision" : 0.1 , "circuit_metadata" : qc2 .metadata }
308
+ )
309
+
293
310
294
311
if __name__ == "__main__" :
295
312
unittest .main ()
0 commit comments