question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CircuitOperation has non-deterministic diagrams, making tests hard to write

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thanaclescommented, Nov 30, 2021

I believe this issue is now fixed with merge of PR #4712

0reactions
95-martin-orioncommented, Nov 29, 2021

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found