Skip to content

Commit

Permalink
Remove useless catch in circuit visualisation intersection check
Browse files Browse the repository at this point in the history
The intersection logic in here previously included a catch statement
that was attempting to avoid to count the span of a `DAGOpNode` if it
was already in the layer being examined.  If the node to be inserted is
already in the layer being examined, the drawer should not be attempting
to re-insert it at all - it's already been accounted for.

The previous catch should always have failed, because `DAGOpNode`
equality would have decayed to `object.__eq__`, which is just `is`
logic.  On this new branch, `DAGOpNode` has an actual equality check,
which can allow two non-referentially equal nodes (as might be created
by `DAGCircuit.layers`) to compare logically equal.
  • Loading branch information
jakelishman committed Aug 7, 2024
1 parent ae3ecb8 commit 41be5f1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions qiskit/visualization/circuit/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,11 @@ def _get_gate_span(qubits, node):

def _any_crossover(qubits, node, nodes):
"""Return True .IFF. 'node' crosses over any 'nodes'."""
gate_span = _get_gate_span(qubits, node)
all_indices = []
for check_node in nodes:
if check_node != node:
all_indices += _get_gate_span(qubits, check_node)
return any(i in gate_span for i in all_indices)
return bool(
set(_get_gate_span(qubits, node)).intersection(
bit for check_node in nodes for bit in _get_gate_span(qubits, check_node)
)
)


class _LayerSpooler(list):
Expand Down

0 comments on commit 41be5f1

Please sign in to comment.