Skip to content

NumpyStatevectorQuantumState

Bases: BaseQuantumState

NumpyStatevectorQuantumState

NumpyStatevectorQuantumState(state: NumpyStatevectorLike, qubit_labels: Sequence[QubitTypes] | None = None, seed: int | None = None, kraus_sampling: str | None = None, contraction: str | None = None, d: int | Sequence[int] = 2) -> None

Parameters:

Name Type Description Default
state NumpyStatevectorLike

A representation of the underlying state. If an integer is passed, an all-0 state with that number of qubits is passed

required
qubit_labels Sequence[QubitTypes] | None

Optional qubit labels. If not provided, the default range of ints is used.

None
seed int | None

Optional RNG seed. If not provided, default NumPy RNG behavior applies.

None
kraus_sampling str | None

Kraus sampling mode; see KRAUS_SAMPLING_MODES. If not provided, inherited from state when copy-constructing, otherwise defaults to "lazy".

None
contraction str | None

Operator contraction mode; see CONTRACTION_MODES. If not provided, inherited from state when copy-constructing, otherwise defaults to "matmul".

None

Attributes

Name Type Value Doc
contraction str unset Operator contraction mode; see CONTRACTION_MODES.
d list[int] unset List of dimensions of each subsystem (e.g. 2 for qubits, 3 for qutrits).
input_reps list[type[GateRep | InstrumentRep]] read-only property Gate and instrument rep classes this state can take as input.
kraus_sampling str unset Kraus sampling mode; see KRAUS_SAMPLING_MODES.
name str 'NumPy Statevector' Name of state backend
qubit_labels list[QubitTypes] unset Qubit labels.
seed int | None unset RNG seed; None indicates default NumPy behavior.
state numpy.ndarray read-only property Get the underlying quantum state vector.

apply_reps

apply_reps(reps: Sequence[OperationRep]) -> tuple[NumpyStatevectorQuantumState, OutcomeDict]

Apply the reps to the state in-place.

Parameters:

Name Type Description Default
reps Sequence[OperationRep] required

Returns:

Type Description
(BaseQuantumState, OutcomeDict)

A copy of the state with reps applied, and dictionary of outcomes. Outcomes can be empty if no measurements were performed.


apply_reps_inplace

apply_reps_inplace(reps: Sequence[OperationRep]) -> OutcomeDict

Apply the reps to the state in-place.

Parameters:

Name Type Description Default
reps Sequence[OperationRep]

Operator representations to apply

required

Returns:

Type Description
OutcomeDict

Dictionary of outcomes. Can be empty if no measurements were performed.


copy

copy() -> NumpyStatevectorQuantumState

Deep-copy a state object.

Returns:

Type Description
Copied state

decode

Inherited static method from Serializable.decode().


display

Inherited method from Displayable.display().


dump

Inherited method from Serializable.dump().


encode

Inherited static method from Serializable.encode().


load

Inherited class method from Serializable.load().


print_bitstring_amplitudes

print_bitstring_amplitudes()

Print the amplitudes of all bitstrings in the quantum state.

This method prints the qubit labels and then iterates through all possible bitstrings, displaying those with amplitudes greater than a threshold (1e-6).


read

Inherited class method from Serializable.read().


reset_seed

reset_seed(new_seed: int | None) -> None

Reset the RNG seed.


serialize_function

Inherited static method from Serializable.serialize_function().


write

Inherited method from Serializable.write().