Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for exceptional behavior when initializing PauliList.from_symplectic #13751

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ def test_init_from_settings(self):
from_settings = PauliList(**pauli_list.settings)
self.assertEqual(pauli_list, from_settings)

def test_from_symplectic_phase_check(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll likely need a docstring on this function to satisfy the linter (though tbh, we'd disable the rule for the test suite if it was easier to give pytest different configurations based on file path).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks. Also checked locally to pass tox -elint.

"""Test the from_symplectic method of PauliList for phase dimension check."""
z = np.array([[0], [0]])
x = np.array([[0], [0]])
phase = np.array([[0], [0]]) # 2D phase
with self.assertRaisesRegex(ValueError, "phase should be at most 1D but has 2 dimensions."):
PauliList.from_symplectic(z, x, phase)


@ddt
class TestPauliListProperties(QiskitTestCase):
Expand Down