QCloudResult
QCloudResult stores parsed job output plus optional raw fields returned by the cloud service.
Signature
QCloudResult(cloud_job_id: str, result_string: str)In practice, use the object returned by QCloudJob.query() or QCloudJob.result().
Standard result methods
| Method | Signature | Description |
|---|---|---|
get_probs | get_probs(base: DataBase = DataBase.Binary) -> dict[str, float] | Probability dictionary. |
get_counts | get_counts(base: DataBase = DataBase.Binary) -> dict[str, int] | Count dictionary. |
get_probs_list | get_probs_list(base: DataBase = DataBase.Binary) -> list[dict[str, float]] | Batched probability outputs. |
get_counts_list | get_counts_list(base: DataBase = DataBase.Binary) -> list[dict[str, int]] | Batched count outputs. |
get_amplitudes | get_amplitudes() -> dict[str, complex] | Amplitude results for amplitude tasks. |
get_state_fidelity | get_state_fidelity() -> float | State-tomography fidelity. |
get_state_tomography_density | get_state_tomography_density() -> list[list[complex]] | State-tomography density matrix. |
origin_data | origin_data() -> str | Raw JSON payload string. |
job_id | job_id() -> str | Job id. |
job_status | job_status() -> JobStatus | Status embedded in the result payload. |
error_message | error_message() -> str | Error text if the task failed. |
job_status() returns the status carried in the result; FAILED is terminal. Failed tasks are no longer expressed through exceptions; error_message() prefers obj.errInfo, then message, then errCode. Server-reported task failures are expressed through JobStatus.FAILED and error_message(); network, protocol, or HTTP errors may still be raised by the underlying request. See QCloudJob.result() for the full contract.
Raw-field access
0.4.0 also exposes raw service fields returned by QCloud. The table below shows the mapping between QCloud JSON field names (used in keys= requests and membership checks) and Python accessor methods.
| QCloud JSON field | Python method | Description |
|---|---|---|
convertQProg | instructions() | Cloud-converted instruction stream. |
qprog | qprog() | Raw QProg data submitted to the cloud. |
mappingQprog | mapping_qprog() | QProg after server-side qubit mapping. |
mappingQubit | mapping_qubit() | Virtual-to-physical qubit mapping relationship. |
srcQubits | src_qubits() | Source qubit indices used in the task. |
targetCbits | target_cbits() | Target classical bit indices. |
measureQubits | measure_qubits() | Qubit indices where measurements were applied. |
probCount | prob_count_raw() | Raw probability count data from the backend. |
You can also access raw fields generically:
"mappingQprog" in result
raw_mapping = result["mappingQprog"]Known aliases accept snake_case names in membership and index access.
timing_info
timing_info() -> dict[str, str]Return every non-null field whose key contains "Time", such as startTime, totalTime, pulseTime, or qpuRunTime.
Unlike earlier docs, this is not a fixed 13-field schema.
Example
from pyqpanda3.core import H, QProg, measure
from pyqpanda3.qcloud import DataBase, QCloudService
service = QCloudService("your_api_key")
backend = service.backend("full_amplitude")
prog = QProg()
prog << H(0) << measure(0, 0)
job = backend.run(prog, shots=1000)
result = job.result(keys=["mappingQprog", "mappingQubit", "probCount"])
print(result.get_probs(base=DataBase.Binary))
print("mappingQprog" in result)
print(result.mapping_qubit() if "mappingQubit" in result else "")
print(result.timing_info())
print(result.origin_data()[:200])Example output shape:
{'0x0': 0.501, '0x1': 0.499}
True
{"0": 1}
{'totalTime': '...', 'qpuRunTime': '...'}
{"success":true,"code":10000,...Notes
- Raw-field access depends on what the backend and service actually returned.
timing_info()is dynamic and may differ across QPU, simulator, and tomography tasks.