-
Notifications
You must be signed in to change notification settings - Fork 64
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 circuit plot error for gates with classical controls when reverse_states=False #221
Conversation
Thank you! Could you add the simple example to the qutip-qip/tests/test_circuit.py Lines 678 to 693 in 6a2977e
|
Certainly and thanks for the quick response. Is adding the following code below the function def test_latex_code_classical_controls(self):
qc = QubitCircuit(1, num_cbits=1, reverse_states=True)
qc.add_gate("X", targets=0, classical_controls=[0])
latex = qc.latex_code()
assert latex == self._latex_template % "\n".join([
r" & & \ctrl{1} & \qw \\ ",
r" & & \gate{X} & \qw \\ ",
"",
])
def test_latex_code_classical_controls_non_reversed(self):
qc = QubitCircuit(1, num_cbits=1, reverse_states=False)
qc.add_gate("X", targets=0, classical_controls=[0])
latex = qc.latex_code()
assert latex == self._latex_template % "\n".join([
r" & & \gate{X} & \qw \\ ",
r" & & \ctrl{-1} & \qw \\ ",
"",
]) |
Yes, precisely. Maybe in one test function instead of two. After being added, these tests will be automatically executed on GitHub. You can also test it locally with |
Done, I updated the PR and it passes the tests locally. I see a message "3 workflows awaiting approval", so you may need to approve running the tests on Github. |
All looks good, thanks for your contribution! |
fix circuit plot error for gates with classical controls when reverse_states=False
For circuits with a classical control and when
reverse_state=False
, the error reported in #220 occurs. This pull request changes the sign of the argument of\ctrl
whenreverse_state=False
. With this change, the test circuit is plotted without errors:A more complex test case: