@@ -273,45 +273,32 @@ def _format_unknown_results(self):
273273
274274 def _translate_microsoft_v2_results (self ):
275275 """ Translate Microsoft's batching job results histograms into a format that can be consumed by qiskit libraries. """
276- az_result = self ._azure_job .get_results ()
277-
278- if not "DataFormat" in az_result :
279- raise ValueError ( "DataFormat missing from Job results" )
280-
281- if not "Results" in az_result :
282- raise ValueError ( "Results missing from Job results" )
283-
276+ az_result_histogram = self ._azure_job .get_results_histogram ()
277+ az_result_shots = self . _azure_job . get_results_shots ()
278+
279+ # If it is a non-batched result, format to be in batch format so we can have one code path
280+ if isinstance ( az_result_histogram , dict ):
281+ az_result_histogram = [ az_result_histogram ]
282+ az_result_shots = [ az_result_shots ]
283+
284284 histograms = []
285- results = az_result [ "Results" ]
286- for circuit_results in results :
285+
286+ for ( histogram , shots ) in zip ( az_result_histogram , az_result_shots ) :
287287 counts = {}
288288 probabilities = {}
289289
290- if not "TotalCount" in circuit_results :
291- raise ValueError ("TotalCount missing from Job results" )
290+ total_count = len (shots )
292291
293- total_count = circuit_results ["TotalCount" ]
294-
295- if total_count <= 0 :
296- raise ValueError ("TotalCount must be a positive non-zero integer" )
297-
298- if not "Histogram" in circuit_results :
299- raise ValueError ("Histogram missing from Job results" )
300-
301- histogram = circuit_results ["Histogram" ]
302- for result in histogram :
303- if not "Display" in result :
304- raise ValueError ("Dispaly missing from histogram result" )
305-
306- if not "Count" in result :
307- raise ValueError ("Count missing from histogram result" )
308-
309- bitstring = AzureQuantumJob ._qir_to_qiskit_bitstring (result ["Display" ])
310- count = result ["Count" ]
292+ for (display , result ) in histogram .items ():
293+ bitstring = AzureQuantumJob ._qir_to_qiskit_bitstring (display )
294+ count = result ["count" ]
311295 probability = count / total_count
312296 counts [bitstring ] = count
313297 probabilities [bitstring ] = probability
314- histograms .append ((total_count , {"counts" : counts , "probabilities" : probabilities }))
298+
299+ formatted_shots = [AzureQuantumJob ._qir_to_qiskit_bitstring (shot ) for shot in shots ]
300+
301+ histograms .append ((total_count , {"counts" : counts , "probabilities" : probabilities , "memory" : formatted_shots }))
315302 return histograms
316303
317304 def _get_entry_point_names (self ):
0 commit comments