-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Test round trip of gate to operation to gate #5354
Conversation
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.
LGTM after questions.
for gate_cls in gate_subclasses: | ||
if gate_cls in exceptions: | ||
continue |
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.
Just loop over gate_subclass
less exceptions
for clarity sake ?
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.
done
try: | ||
gates = cirq.read_json(filename) | ||
except FileNotFoundError: | ||
if gate_cls in skip_classes: | ||
skipped.add(gate_cls) | ||
continue |
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.
Can we do an existance check with file.exists
instead of a try catch ?
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.
done
if not isinstance(gates, collections.abc.Iterable): | ||
gates = [gates] |
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.
Is this needed because some json files have lists of things instead of one single thing in them ?
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.
yep...classic python, object or list of objects :(
def all_subclasses(cls): | ||
return set(cls.__subclasses__()).union( | ||
[s for c in cls.__subclasses__() for s in all_subclasses(c)] | ||
) |
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 isn't at risk for infinite recursion right ? (if we had two gates with circular dependencies of some kind)
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.
I think this is fine since the type hierarchy has to be a dag.
Automerge cancelled: A required status check is not present. Missing statuses: ['Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests'] |
We decided that we would do this in lieu of making everything a gate operation #2626
Note that currently PauliStringPhasorGate fails this #5167
This also uncovers some missing gates that should be json serializable, opened #5353 for this.
Also notice that two of the issues in this comment are of the for #XYXY and isn't that amazing.