QCloudResult
QCloudResult contains the results of a completed quantum cloud job. It provides methods for accessing measurement probabilities, counts, amplitudes, state tomography data, and error information.
Signature
QCloudResult(result_string: str, chip_id: str)Parameters
| Parameter | Type | Description |
|---|---|---|
| result_string | str | JSON string containing the job result data |
| chip_id | str | The chip ID associated with the result |
Note: QCloudResult objects are typically returned by QCloudJob.result() or QCloudJob.query() rather than constructed directly.
Methods
get_probs
get_probs(base: DataBase = DataBase.Binary) -> dict[str, float]Retrieves the probability distribution over measured quantum states.
| Parameter | Type | Default | Description |
|---|---|---|---|
| base | DataBase | Binary | Base representation for state labels (Binary or Hex) |
Returns: A dictionary mapping state strings to their probabilities.
get_counts
get_counts(base: DataBase = DataBase.Binary) -> dict[str, int]Retrieves the measurement count for each observed quantum state.
| Parameter | Type | Default | Description |
|---|---|---|---|
| base | DataBase | Binary | Base representation for state labels (Binary or Hex) |
Returns: A dictionary mapping state strings to their observed counts.
get_probs_list
get_probs_list(base: DataBase = DataBase.Binary) -> list[dict[str, float]]Retrieves a list of probability distributions, one per measurement round or sub-task.
| Parameter | Type | Default | Description |
|---|---|---|---|
| base | DataBase | Binary | Base representation for state labels |
Returns: A list of dictionaries, each mapping state strings to probabilities.
get_counts_list
get_counts_list(base: DataBase = DataBase.Binary) -> list[dict[str, int]]Retrieves a list of measurement count maps, one per measurement round or sub-task.
| Parameter | Type | Default | Description |
|---|---|---|---|
| base | DataBase | Binary | Base representation for state labels |
Returns: A list of dictionaries, each mapping state strings to counts.
get_amplitudes
get_amplitudes() -> dict[str, complex]Retrieves the quantum state amplitudes. Use this when the job was submitted with amplitude computation.
Returns: A dictionary mapping state strings to complex amplitude values.
get_state_fidelity
get_state_fidelity() -> floatRetrieves the state fidelity from a quantum state tomography job.
Returns: A float representing the state fidelity value.
get_state_tomography_density
get_state_tomography_density() -> objectRetrieves the density matrix from a quantum state tomography computation.
Returns: The state tomography density matrix.
origin_data
origin_data() -> strRetrieves the raw result data in JSON format.
Returns: The original JSON result string.
job_id
job_id() -> strRetrieves the job ID associated with this result.
Returns: The job ID string.
error_message
error_message() -> strRetrieves the error message if the job failed.
Returns: The error message string, or an empty string if no error occurred.
job_status
job_status() -> JobStatusRetrieves the status of the job associated with this result.
Returns: A JobStatus enumeration value.
timing_info
timing_info() -> dictRetrieves timing information for the quantum job execution.
| Key | Type | Description |
|---|---|---|
| qpuRunTime | float | QPU runtime, the actual time the task spends executing and completing measurements on the quantum chip, in milliseconds (ms) |
Returns: A dictionary containing timing fields. Defaults to 0 if not available.
Examples
from pyqpanda3.qcloud import QCloudService, DataBase
service = QCloudService(api_key="your_api_key")
backend = service.backend("origin_simulation")
# ... create and submit prog ...
job = backend.run(prog, shots=1000)
result = job.result()
# Get probabilities in binary format
probs = result.get_probs()
print("Probabilities:", probs)
# Output example: {"00": 0.498, "01": 0.002, "10": 0.001, "11": 0.499}
# Get probabilities in hexadecimal format
probs_hex = result.get_probs(base=DataBase.Hex)
# Get shot counts
counts = result.get_counts()
print("Counts:", counts)
# Get raw JSON data
raw = result.origin_data()
# Check for errors
if result.error_message():
print("Error:", result.error_message())See Also
- QCloudJob -- Job object that produces this result
- QCloudService -- Cloud service for submitting jobs
- DataBase -- Base representation enumeration