POVMSamplerPub

class POVMSamplerPub(circuit: QuantumCircuit, parameter_values: BindingsArray | None, shots: int, povm: POVMImplementation, *, validate: bool = True)[source]

Bases: ShapedMixin

The Pub (Primitive Unified Bloc) input structure for POVMSampler.run().

Pub is composed of tuple (circuit, parameter_values, shots, povm_implementation).

Initialize a sampler pub.

Parameters:
  • circuit (QuantumCircuit) – the quantum circuit to sample from.

  • parameter_values (BindingsArray | None) – an optional bindings array for the parameters in the circuit.

  • shots (int) – the specific number of shots to run with. This value takes precedence over any value supplied to a sampler.

  • povm (POVMImplementation) – the specific POVM to run with. This value takes precedence over any POVM supplied to a sampler.

  • validate (bool) – whether to validate the input data.

Attributes

circuit

The quantum circuit that is being sampled.

parameter_values

The bindings array of circuit parameters.

povm

The POVM with which to sample.

shots

The number of shots being sampled.

Inherited Attributes

ndim
shape
size

Methods

classmethod coerce(pub: povm_toolbox.sampler.POVMSamplerPubLike, *, shots: int | None = None, povm: POVMImplementation | None = None) POVMSamplerPub[source]

Coerce a POVMSamplerPubLike object.

Parameters:
  • pub (povm_toolbox.sampler.POVMSamplerPubLike) – An object to coerce.

  • shots (int | None) – An optional default number of shots to use if not already specified by the pub-like object.

  • povm (POVMImplementation | None) – An optional default POVM to use if not already specified by the pub-like object.

Raises:
  • TypeError – If a number of shots is specified but it is not a positive integer.

  • ValueError – If the pub-like object does not specify a number of shots and no default number of shots is set or if the pub-like object does not specify a POVM and no default POVM is set.

  • ValueError – If a tuple is supplied but its length exceeds 4, rendering the pub an invalid POVMSamplerPubLike.

  • TypeError – If the pub-like object does not have a valid type.

Returns:

A coerced POVM sampler pub.

Return type:

POVMSamplerPub

to_sampler_pub(pass_manager: StagedPassManager | None = None) tuple[SamplerPub, POVMMetadata][source]

Convert this POVM sampler pub to a standard SamplerPub.

This calls to_sampler_pub() of povm.

Parameters:

pass_manager (StagedPassManager | None) – An optional transpilation pass manager. After the supplied circuit has been composed with the measurement circuit, the pass manager will be used to transpile the composed circuit.

Returns:

A tuple of a sampler pub and a dictionary of metadata which includes the POVMImplementation object itself. The metadata should contain all the information necessary to extract the POVM outcomes out of raw bitstrings.

Return type:

tuple[SamplerPub, POVMMetadata]

validate() None[source]

Validate the pub.

Raises:
  • TypeError – If circuit is not a QuantumCircuit.

  • ValueError – If the pub-like object does not specify a number of shots and that default number of shots is set.

  • TypeError – If the number of shots is specified but is not a positive integer.

  • ValueError – If the number of parameters supplied does not correspond to the number of parameters of the circuit.

  • ValueError – If the pub-like object does not specify a POVM and no default POVM is set.