qat.core.Result

class qat.core.Result(lsb_first=False, nbqbits=None, value=None, values=None, parameter_map=None, **kwargs)

Simple higher level wrapper for the serializable Result class.

Parameters
  • result (ThriftResult, optional) – result

  • lsb_first (bool, optional) – whether to use convention with least significant bit first. Defaults to False.

  • nbqbits (int, optional) – number of qubits, required if lsb_first is False. Defaults to None.

Instance attributes:
  • raw_data (list<Sample>, optional): the raw data sampling, if requested

  • value (float, optional): scalar output

  • value_data (map<str, float>, optional): Information on the scalar output (deviation, etc)

  • meta_data (map<str, str>): any information the QPU might want to transmit to the user (logs, resource usage, etc)

  • has_statevector (bool): set to True iff the .statevector attribute is non-empty

  • statevector: a low level description of the result. Usually contains a numpy array describing either a state vector or a probability distribution. Not always set.

add_sample(state, amplitude=None, probability=None, err=None, intermediate_measurements=None)

Add sample to result. If required, reverts bit order.

Parameters
  • state (int) – the index of the state in comput. basis

  • amplitude (complex, optional) – a complex number for the amplitude

  • probability (float, optional) – the probability

  • err (float, optional) – the error on the probability estimate

  • intermediate_measurements (IntermediateMeasurements, optional) – the intermediate measures

display()

Display the result in a Jupyter notebook

dump(fname)

Dumps the Result inside a file in binary format.

Parameters

fname (str) – the file name

classmethod from_bytes(data: bytes)

Builds a result from raw bytes object

classmethod from_thrift(tobject)

Builds a Result object from a thrift object

static load(fname)

Loads a Result from a file.

Parameters

fname (str) – the file name

Returns

Result

property parameter_map

complex}

Type

Dictionnary {str

plot(**kwargs)

Plots an histogram of the probability distribution stored in the result.

Only works inside a notebook and if the result contains samples.

unpack()

Unpacks the result to extract the evaluated energy (if any).

property value

Scalar output - complex number

property values

Scalar output - complex number

wrap_samples(qreg_list)

Wraps the samples using a list of quantum registers Also serializes the underlying statevector object, if any