-
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
Add cirq.testing.assert_same_diagram #830
Comments
For use cases I have encountered, I often want to ignore differences due to insertion strategies, i.e., I'd want to shove all gates to the left before comparing. |
That would be better described as a circuit equivalence rather than a diagram equivalence. |
|
Yes, except CircuitDag doesn't implement equality yet. |
Does the library we use have a graph isomorphism method? |
Probably, but it would have to support customizing node equality. The matching in the two graphs wouldn't compare equal by default. |
You can do it with is_isomorphic. |
@dlyongemallo thanks for doing this, it is awesome how clear it is. |
At some point we might want a better edit distance metric when making the difs, so that the later parts aren't so noisy, but this works really well. |
This method would do two things:
For point 2, the main thing that is required is to append the actual diagram and reference diagram without abbreviation. Pytest is far too abbreviation heavy for the diagrams.
Secondarily for point 2, a better diff should be included. The information is 2d instead of line-based, and the diff should be similarly 2d. Show a copy of the actual diagram with any character positions that differ from the reference diagram replaced by ■ or some other obtrusive char.
The text was updated successfully, but these errors were encountered: