Commit cd81829 1 parent 3d5fc06 commit cd81829 Copy full SHA for cd81829
File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -487,7 +487,27 @@ def run_aer(job: Job):
487
487
result = extract_result (result_sim , job , job .device )
488
488
489
489
elif job .job_type == JobType .OBSERVABLE :
490
- result = compute_expectation_value (qiskit_circuit , job , backend_sim )
490
+ if isinstance (job .device , (IBMDevice , IBMSimulatedDevice )):
491
+
492
+ results = []
493
+
494
+ for _ in job .measure .observables :
495
+ expectation_value = compute_expectation_value (
496
+ qiskit_circuit , job , backend_sim
497
+ )
498
+
499
+ if isinstance (expectation_value , BatchResult ):
500
+ results .extend (expectation_value .results )
501
+ elif isinstance (expectation_value , Result ):
502
+ results .append (expectation_value )
503
+ else :
504
+ raise TypeError (
505
+ f"compute_expectation_value() returned { type (expectation_value )} , expected Result or BatchResult."
506
+ )
507
+
508
+ # results.append(expectation_value)
509
+
510
+ result = BatchResult (results ) if len (results ) > 1 else results [0 ]
491
511
492
512
else :
493
513
raise ValueError (f"Job type { job .job_type } not handled." )
You can’t perform that action at this time.
0 commit comments