def test_kraus_matrix(self, tol, operators, wires, expected_Ks): """Test sevaral resulting kraus matrices for sevaral configurations""" c = channel.PauliError(operators, 0.5, wires=wires) assert np.allclose(c.kraus_matrices, expected_Ks, atol=tol, rtol=0)
def test_warning_many_qubits(self): """Test if warning is thrown when huge matrix""" with pytest.warns(UserWarning): Ks = channel.PauliError("X" * 512, 0.5, wires=list(range(512)))
def test_p_one(self, tol): """Test resulting Kraus matrices for p=1""" expected_Ks = [np.zeros((2**5, 2**5)), np.flip(np.eye(2**5), axis=1)] c = channel.PauliError("XXXXX", 1, wires=[0, 1, 2, 3, 4]) assert np.allclose(c.kraus_matrices, expected_Ks, atol=tol, rtol=0)
def test_wrong_parameters(self, operators, p, wires, error, message): """Test wrong parametrizations of PauliError""" with pytest.raises(error, match=message): Ks = channel.PauliError(operators, p, wires=wires)