Result module¶
- class Result¶
Implements the Result class. The user is not required to create an instance of this class on their own. The backend creates an instance of this class, once the job is executed and the results of the experiment are available.
See also: JobV1.result()
- Result()¶
The constructor of the Result class.
- Args:
None
- Returns:
Result
- Raises:
None
- Result.backend_name: str¶
Name of the backend that processed the job.
- Result.backend_version: str¶
Version of the backend.
- Result.qobj_id: str¶
Used generated object ID of the result object. Currently not used.
- Result.job_id: str¶
The Job ID corresponding to the results.
- Result.success: bool¶
True: If the job was successful. False: If the job execution failed. The result data may not be accurate.
- Result.results: list[str]¶
A list of the measurement data obtained from each shot of execution.
- Result.date: str¶
The date on which the job was executed.
- Result.status: str¶
A textual description of the status.
- Result.header: str¶
Results header. Currently not used.
- to_dict(self)¶
Provides a dictionary of the default result data.
- Args:
None
- Returns:
dict
- Raises:
None
- data(self)¶
Returns a dictionary of the result data. returns “counts”, “statevector”, “probabilities”, “amplitudes”, and “densitymatrix”. Note that some of these calculations require a lot of memory. For example to obtain statevector, the user is adviced to fetch it for a number of qubits of 12 at a time using the corresponding get methods.
- Args:
None
- Returns:
dict
- Raises:
- MemoryAllocError:
In case there is not enough memory to process the data.
- get_memory(self)¶
Fetches the execution summary. The measurement data of all shots is returned as a list.
- Args:
None
- Returns:
list[str]
- Raises:
None
- get_counts(self)¶
Returns the counts dictionary. For each measurement result, the percentage of occurance is returned as a dictionary.
- Args:
None
- Returns:
dict
- Raises:
None
- get_statevector(self, experiment=0, decimals=0, qubit_list=None)¶
Returns the statevector of the specified qubits
- Args:
- experiment (int):
The experiment for which the statevector is to be returned. This field is unused and only the statevector of the last executed shot is stored by the system.
- decimals (int):
Sets a limit on the number of decimal places to be returned. Currently, this field is not used.
- qubit_list (Optional[list[int]]):
An integer array listing the qubits for which the statevector is to be calculated. If not provided, the entire list of qubits is assumed.
- Returns:
[complex,complex]
- Raises:
- MemoryAllocError:
If there is insufficient memory to calculate the statevector.
- OutOfRangeError:
If the qubit list had invalid qubits.
- get_unitary(self, experiment=0, decimals=0, qubit_list=None)¶
Returns the amplitude vector of the specified qubits
- Args:
- experiment (int):
The experiment for which the amplitude vector is to be returned. This field is unused and only the amplitude vector of the last executed shot is stored by the system.
- decimals (int):
Sets a limit on the number of decimal places to be returned. Currently, this field is not used.
- qubit_list (Optional[list[int]]):
An integer array listing the qubits for which the amplitude vector is to be calculated. If not provided, the entire list of qubits is assumed.
- Returns:
[complex]
- Raises:
- MemoryAllocError:
If there is insufficient memory to calculate the amplitude vector.
- OutOfRangeError:
If the qubit list had invalid qubits.
- from_dict(self, data)¶
This function is not supported.
- Args:
None
- Returns:
None
- Raises:
- NotImplemented:
This function is not supported.
- get_probabilities(self, experiment=0, decimals=0, qubit_list=None)¶
Returns the probability vector of the specified qubits
- Args:
- experiment (int):
The experiment for which the probability vector is to be returned. This field is unused and only the probability vector of the last executed shot is stored by the system.
- decimals (int):
Sets a limit on the number of decimal places to be returned. Currently, this field is not used.
- qubit_list (Optional[list[int]]):
An integer array listing the qubits for which the probability vector is to be calculated. If not provided, the entire list of qubits is assumed.
- Returns:
[float]
- Raises:
- MemoryAllocError:
If there is insufficient memory to calculate the probability vector.
- OutOfRangeError:
If the qubit list had invalid qubits.
- get_densitymatrix(self, experiment=0, decimals=0, qubit_list=None)¶
Returns the density matrix of the specified qubits
- Args:
- experiment (int):
The experiment for which the density matrix is to be returned. This field is unused and only the density matrix of the last executed shot is stored by the system.
- decimals (int):
Sets a limit on the number of decimal places to be returned. Currently, this field is not used.
- qubit_list (Optional[list[int]]):
An integer array listing the qubits for which the density matrix is to be calculated. If not provided, the entire list of qubits is assumed.
- Returns:
[complex, complex]
- Raises:
- MemoryAllocError:
If there is insufficient memory to calculate the density matrix.
- OutOfRangeError:
If the qubit list had invalid qubits.
- get_classicalregister(self)¶
Returns the current state of the classical registers
- Args:
None
- Returns:
str
- Raises:
- MemoryAllocError:
If there is insufficient memory.
- get_fidelity(self)¶
Obtains the fidelity of the simulation.
Computes the fidelity using \(|\langle 0 | \psi \rangle|^2\). This is especially useful for calculating mirror fidelity, where a circuit is composed with its inverse and the probability of returning to the ground state serves as the fidelity metric.
- Args:
None
- Returns:
float: The fidelity of the simulation.
- Raises:
RuntimeError: If the result is not available or if other errors have occurred.
- See Also:
- get_peakmemorysize(self, experiment)¶
Returns the peak memory size of the simulation in bytes.
The peak memory size is the maximum size of the simulation data recorded at any point during circuit execution. Note that the size of tensors can shrink and grow as each gate is applied, so this value may differ from the simulation’s final memory footprint. The reported size also varies depending on the engine and precision mode in use. If a simulation state was saved and subsequently restored, the restored state may report a different peak size upon execution. These are expected behaviors.
- Args:
- experiment (int):
The experiment number to query. Usually
0.
- Returns:
int: Peak memory size of the simulation, in bytes.
- Raises:
RuntimeError: If the result is not available or if other errors have occurred.
- See Also: