Skip to main contentIBM Quantum Documentation mirror

PrimitiveResult

class qiskit.primitives.PrimitiveResult(pub_results, metadata=None)

GitHub

Bases: Generic[T]

A container for multiple pub results and global metadata.

This is the return value from any V2 primitive’s run().result(). This object corresponds to the entire execution, not any single pub; it does not contain any actual data, but may contain freeform metadata returned by the primitive implementer about the entire submission (as opposed to PubResult.metadata, which is metadata about a single pub).

You access the actual data of each individual pub either by iterating through this object (for pub_result in primitive_result: ...), or by direct list-like index access pub_result = primitive_result[0]. The type of each individual pub result is PubResult, or potentially a primitive- and implementation-specific subclass of that.

Most likely, if you submitted a single pub to a primitive like:

primitive_result = primitive.run([(qc,)]).result()

then the data you care about is in primitive_result[0].data, which is a DataBin. The object primitive_result[0] is a PubResult.

Parameters

  • pub_results (Iterable[T]) – Pub results.
  • metadata (dict[str, Any] | None) – Metadata that is common to all pub results; metadata specific to particular pubs should be placed in their metadata fields. Keys are expected to be strings.

Attributes

metadata

The metadata of this primitive result.