qiskit_pytest_helper.hypothesis_strategies
¶
Hypothesis strategies for quantum states and for axes representable by qubits.
The strategies of numbers, axes and signals themselves are the ones of
python_pytest_helper.hypothesis_strategies, e.g. signals on qubit axes are
positive_polynomial_signals(qubit_axes(AxisDomain.POSITION)).
Functions:
-
quantum_state_array–A strategy for generating quantum states as a NumPy array.
-
normalized_quantum_state_array–A strategy for generating normalized quantum states as a NumPy array.
-
non_normalized_quantum_state_array–A strategy for generating non-normalized quantum states as a NumPy array.
-
valid_qiskit_statevector–A strategy for normalized quantum states as Qiskit
Statevectors. -
state_pairs_with_equal_qubits–A strategy for generating pairs of quantum states with the same number of qubits.
-
qubit_sizes–A strategy for the numbers of samples
2**nrepresentable bynqubits. -
qubit_axes–A strategy for axes of
2**nsamples, representable bynqubits.
Attributes:
-
moderate_alphas–A strategy for coefficients of monomial signals keeping their phases moderate.
moderate_alphas
module-attribute
¶
moderate_alphas = st.floats(min_value=MIN_MAGNITUDE, max_value=MAX_MAGNITUDE)
A strategy for coefficients of monomial signals keeping their phases moderate.
quantum_state_array
¶
quantum_state_array(draw, min_qubits=MIN_QUBITS, max_qubits=MAX_QUBITS, min_magnitude=MIN_MAGNITUDE, max_magnitude=MAX_MAGNITUDE) -> NDArray[complex128]
A strategy for generating quantum states as a NumPy array.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
normalized_quantum_state_array
¶
normalized_quantum_state_array(draw, min_qubits=MIN_QUBITS, max_qubits=MAX_QUBITS, min_magnitude=MIN_MAGNITUDE, max_magnitude=MAX_MAGNITUDE) -> NDArray[complex128]
A strategy for generating normalized quantum states as a NumPy array.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
non_normalized_quantum_state_array
¶
non_normalized_quantum_state_array(draw, min_qubits=MIN_QUBITS, max_qubits=MAX_QUBITS, min_magnitude=MIN_MAGNITUDE, max_magnitude=MAX_MAGNITUDE) -> NDArray[complex128]
A strategy for generating non-normalized quantum states as a NumPy array.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
valid_qiskit_statevector
¶
valid_qiskit_statevector(draw, min_qubits=MIN_QUBITS, max_qubits=MAX_QUBITS, min_magnitude=MIN_MAGNITUDE, max_magnitude=MAX_MAGNITUDE) -> Statevector
A strategy for normalized quantum states as Qiskit Statevectors.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
state_pairs_with_equal_qubits
¶
state_pairs_with_equal_qubits(draw, min_qubits=MIN_QUBITS, max_qubits=MAX_QUBITS, min_magnitude=MIN_MAGNITUDE, max_magnitude=MAX_MAGNITUDE) -> tuple[Statevector, Statevector]
A strategy for generating pairs of quantum states with the same number of qubits.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
qubit_sizes
¶
qubit_sizes(min_qubits: int = MIN_QUBITS, max_qubits: int = MAX_QUBITS) -> SearchStrategy[int]
A strategy for the numbers of samples 2**n representable by n qubits.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
164 165 166 167 168 | |
qubit_axes
¶
qubit_axes(domain: AxisDomain = POSITION, min_qubits: int = MIN_QUBITS, max_qubits: int = MAX_QUBITS, orderings: SearchStrategy[IndexOrdering] = index_orderings) -> SearchStrategy[PhysicalAxis]
A strategy for axes of 2**n samples, representable by n qubits.
Fourier axes are conjugate to a position axis, momenta with hbar = 1, see
python_pytest_helper.hypothesis_strategies.physical_axes. The position spacings
are at most 1, keeping the phases of polynomial signals moderate.
Returns:
-
SearchStrategy[PhysicalAxis]–The strategy of the axes.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/hypothesis_strategies.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |