Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions qiskit/circuit/commutation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
from __future__ import annotations

from collections.abc import Sequence
import typing

from qiskit.circuit.operation import Operation
from qiskit.circuit import Qubit
from qiskit._accelerate.commutation_checker import CommutationChecker as RustChecker

if typing.TYPE_CHECKING:
from qiskit.dagcircuit import DAGOpNode


class CommutationChecker:
r"""Check commutations of two operations.
Expand Down Expand Up @@ -60,12 +64,16 @@ def __init__(

def commute_nodes(
self,
op1,
op2,
op1: DAGOpNode,
op2: DAGOpNode,
max_num_qubits: int = 3,
approximation_degree: float = 1.0,
) -> bool:
"""Checks if two DAGOpNodes commute."""
"""Checks if two :class:`.DAGOpNode`\ s commute.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either

Suggested change
"""Checks if two :class:`.DAGOpNode`\ s commute.
"""Checks if two :class:`.DAGOpNode`\\ s commute.

(bad Python escape character) or

Suggested change
"""Checks if two :class:`.DAGOpNode`\ s commute.
"""Checks if two :class:`.DAGOpNode` objects commute.

The docs team usually prefer the second because it's easier to translate or to read for less-fluent English speakers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly sure pylint used to complain about this, but it looks like Ruff doesn't.


This is equivalent to :meth:`commute` but with the operation, qubits, and clbits
bundled in the :class:`.DAGOpNode` object. See :meth:`commute` for more details.
"""
return self.cc.commute_nodes(op1, op2, max_num_qubits, approximation_degree, max_num_qubits)

def commute(
Expand Down