CircuitOperation has non-deterministic diagrams, making tests hard to write
See original GitHub issueI filled in a diagram test from output during one run:
cirq.testing.assert_has_diagram(
cirq.Circuit(
cirq.Moment(
cirq.CircuitOperation(
cirq.FrozenCircuit(cirq.X(cirq.LineQubit(0)))),
),
),
"""
0: ───Circuit_0x92933a3050ff70c4:───
[ 0: ───X─── ]
""")
But then it fails in the next run:
E Diagram of actual circuit:
E 0: ───Circuit_0xd4e3300492f7877d:───
E [ 0: ───X─── ]
E
E Desired text diagram:
E 0: ───Circuit_0x92933a3050ff70c4:───
E [ 0: ───X─── ]
E
E Highlighted differences:
E 0: ───Circuit_0x███33█████f█████:───
E [ 0: ───X─── ]
The issue is that the hash id is going into the diagram, but hash ids are not stable over time.
The hash is entirely based on the contents, which we can see anyways. I suggest just dropping it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Eradicating Non-Determinism in Tests - Martin Fowler
Non-deterministic tests have two problems, firstly they are useless, secondly they are a virulent infection that can completely ruin your entire ...
Read more >The Challenges of Testing in a Non-Deterministic World
Testing provides false confidence that such defects do not exist in the system, and they escape into system operation where they can lead...
Read more >non-deterministic finite automaton state transition table ...
I still cant really understand how to create a transition state diagram from the information given since all the resources ive found seem...
Read more >Purely Functional Lazy Non-deterministic Programming
Abstract. Functional logic programming and probabilistic programming have demonstrated the broad benefits of combining laziness (non-strict.
Read more >A Quick Non-Deterministic to Deterministic Finite Automata ...
In this lesson, we convert a non - deterministic finite automata (NFA) ... Relabeling the states 14:32 | Creating the DFA state diagram...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe this issue is now fixed with merge of PR #4712
Responded to (2) in #3605.
Your thoughts on CircuitGate mirror the early design stages for CircuitOperation - we strongly considered that option, but ultimately determined that CircuitOperation was the cleaner solution. This mostly boiled down to Circuits being more similar to Operations (both have defined qubits, while Gates do not) and Operations having better access to certain features (e.g. tags are defined at the Operation level).