qiskit_pytest_helper.assertions
¶
Assertions comparing quantum states and operators with Qiskit's equality.
The comparisons are exact, global phase included, up to the default tolerances of
Qiskit's Statevector and Operator equality, instead of tolerances chosen per test.
Circuits are compared by what they do: the state they prepare from |0...0>, or
their unitary.
Functions:
-
assert_equal_states–Assert that two states are equal, including their global phase.
-
assert_equal_operators–Assert that two operators are equal, including their global phase.
-
assert_unitary–Assert that an operator, e.g. a matrix, is unitary.
assert_equal_states
¶
Assert that two states are equal, including their global phase.
Parameters:
-
actual(Any) –The state, as a
Statevector, its amplitudes or a circuit preparing it from|0...0>. -
expected(Any) –The expected state, in any of the same forms.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/assertions.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
assert_equal_operators
¶
Assert that two operators are equal, including their global phase.
Parameters:
-
actual(Any) –The operator, as an
Operator, its matrix, a gate or a circuit. -
expected(Any) –The expected operator, in any of the same forms.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/assertions.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
assert_unitary
¶
assert_unitary(operator: Any) -> None
Assert that an operator, e.g. a matrix, is unitary.
Source code in packages-dev/qiskit-pytest-helper/src/qiskit_pytest_helper/assertions.py
57 58 59 | |