-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move to method dispatch using act_on for CliffordState, Tableau and ChForm #3456
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
Conversation
from cirq.sim import simulator | ||
from cirq.sim.clifford import clifford_tableau, stabilizer_state_ch_form | ||
from cirq.sim.clifford import (act_on_clifford_tableau_args, |
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.
it seems that we could just import the types from these packages in cirq.sim.clifford.__init__.py
and then use them directly. It is the more typical style in Cirq allowing for shorter names and easier code completion. Then you can do from cirq.sim import clifford as clifford
and clifford.ActOn...
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.
You're right, and the style guide agrees with you https://cirq.readthedocs.io/en/latest/docs/dev/style.html.
But I feel I have seen the reverse pattern being followed, the most specific subpaths are imported instead of the top-level module (except in tests where it's cirq.Whatever
). But I'll at least fix the clifford stuff for this PR to follow the style guide.
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.
Had to shuffle the clifford.__init__.py
to avoid circular dependencies. Since these all classes are very closely intertwined, there is a high chance of circular dependencies if using cirq.sim.clifford
directly.
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.
Yeah now that happens. The init module orderings is a dark art.
Delete all the now-unneeded methods.
Remaining work: refactor the measurement code
#2948 #2423