Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

PreparationBasis

class PreparationBasis(name)[source]

Abstract base class for a tomography preparation basis.

Subclasses should implement the following abstract methods to define a preparation basis:

  • The circuit() method which returns the logical preparation QuantumCircuit for basis element index on the specified qubits. This circuit should be a logical circuit on the specified number of qubits and will be remapped to the corresponding physical qubits during transpilation.

  • The matrix() method which returns the density matrix prepared by the bases element index on the specified qubits.

  • The index_shape() method which returns the shape of allowed basis indices for the specified qubits, and their values.

  • The matrix_shape() method which returns the shape of subsystem dimensions of the density matrix state on the specified qubits.

Initialize a basis.

Parameters:

name (str) – the name for the basis.

Attributes

name

Return the basis name

Methods

abstract circuit(index, qubits=None)

Return the basis preparation circuit.

Parameters:
  • index (Sequence[int]) – a list of basis elements to tensor together.

  • qubits (Sequence[int] | None) – Optional, the physical qubit subsystems for the index. If None this will be set to (0, ..., N-1) for a length N index.

Returns:

The logical basis circuit for the specified index and qubits.

Return type:

QuantumCircuit

Note

This returns a logical circuit on the specified number of qubits and should be remapped to the corresponding physical qubits during experiment transpilation.

abstract index_shape(qubits)

Return the shape for the specified number of indices.

Parameters:

qubits (Sequence[int]) – the basis subsystems to return the index shape for.

Returns:

The shape of allowed values for the index on the specified qubits.

Return type:

Tuple[int, …]

abstract matrix(index, qubits=None)[source]

Return the density matrix data array for the index and qubits.

This state is used by tomography fitters for reconstruction and should correspond to the target state for the corresponding preparation circuit().

Parameters:
  • index (Sequence[int]) – a list of subsystem basis indices.

  • qubits (Sequence[int] | None) – Optional, the physical qubit subsystems for the index. If None this will be set to (0, ..., N-1) for a length N index.

Returns:

The density matrix prepared by the specified index and qubits.

Return type:

ndarray

abstract matrix_shape(qubits)[source]

Return the shape of subsystem dimensions of the state matrix.

Parameters:

qubits (Sequence[int]) – the physical qubit subsystems.

Returns:

A tuple of subsystem dimensions for the specified qubits.

Return type:

Tuple[int, …]