Skip to content

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

python
QCloudResult(result_string: str, chip_id: str)

Parameters

ParameterTypeDescription
result_stringstrJSON string containing the job result data
chip_idstrThe 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

python
get_probs(base: DataBase = DataBase.Binary) -> dict[str, float]

Retrieves the probability distribution over measured quantum states.

ParameterTypeDefaultDescription
baseDataBaseBinaryBase representation for state labels (Binary or Hex)

Returns: A dictionary mapping state strings to their probabilities.

get_counts

python
get_counts(base: DataBase = DataBase.Binary) -> dict[str, int]

Retrieves the measurement count for each observed quantum state.

ParameterTypeDefaultDescription
baseDataBaseBinaryBase representation for state labels (Binary or Hex)

Returns: A dictionary mapping state strings to their observed counts.

get_probs_list

python
get_probs_list(base: DataBase = DataBase.Binary) -> list[dict[str, float]]

Retrieves a list of probability distributions, one per measurement round or sub-task.

ParameterTypeDefaultDescription
baseDataBaseBinaryBase representation for state labels

Returns: A list of dictionaries, each mapping state strings to probabilities.

get_counts_list

python
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.

ParameterTypeDefaultDescription
baseDataBaseBinaryBase representation for state labels

Returns: A list of dictionaries, each mapping state strings to counts.

get_amplitudes

python
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

python
get_state_fidelity() -> float

Retrieves the state fidelity from a quantum state tomography job.

Returns: A float representing the state fidelity value.

get_state_tomography_density

python
get_state_tomography_density() -> object

Retrieves the density matrix from a quantum state tomography computation.

Returns: The state tomography density matrix.

origin_data

python
origin_data() -> str

Retrieves the raw result data in JSON format.

Returns: The original JSON result string.

job_id

python
job_id() -> str

Retrieves the job ID associated with this result.

Returns: The job ID string.

error_message

python
error_message() -> str

Retrieves the error message if the job failed.

Returns: The error message string, or an empty string if no error occurred.

job_status

python
job_status() -> JobStatus

Retrieves the status of the job associated with this result.

Returns: A JobStatus enumeration value.

timing_info

python
timing_info() -> dict

Retrieves timing information for the quantum job execution.

KeyTypeDescription
qpuRunTimefloatQPU 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

python
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

Released under the MIT License.