-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: Warn user about implicit qubit permutations in tk_to_qiskit
#412
Conversation
def test_implicit_swap_warning() -> None: | ||
c = Circuit(2).H(0).SWAP(0, 1) | ||
c.replace_SWAPs() | ||
with pytest.warns(UserWarning, match="The pytket Circuit contains implicit qubit"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindof suprised that python can use this UserWarning
class without it being imported.
I guess errors like NotImplementedError
don't need to be imported either so its not so surprising.
@@ -855,6 +856,11 @@ def append_tk_command_to_qiskit( | |||
supported_gate_rebase = AutoRebase(_protected_tket_gates) | |||
|
|||
|
|||
def _has_implicit_permutation(circ: Circuit) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better defined in pytket rather than this extension: there's nothing specific to qiskit about it. But for now there is no need to factor it out as a method, since it's only used in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Maybe it should just be a property/method of Circuit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But for the purpose of this PR the check can just be inlined.
Co-authored-by: Alec Edgington <[email protected]>
Description
Minor change to
tk_to_qiskit
. The user now gets a warning if the input pytketCircuit
contains implicit qubit permutations.closes #411
Related issues
#411
Checklist