Skip to content

Commit b83933c

Browse files
Cryorisjakelishman
andauthored
Fix the docstring of CommutationChecker.commute_nodes (#15991)
* Fix the docstring of `CommutationChecker.commute_nodes` With the partial type hints the API docs only showed the last 2 parameters instead of all 4. also added some more explanations. * Apply suggestion from @jakelishman Co-authored-by: Jake Lishman <jake@binhbar.com> --------- Co-authored-by: Jake Lishman <jake@binhbar.com>
1 parent cd99522 commit b83933c

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

qiskit/circuit/commutation_checker.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
from __future__ import annotations
1616

1717
from collections.abc import Sequence
18+
import typing
1819

1920
from qiskit.circuit.operation import Operation
2021
from qiskit.circuit import Qubit
2122
from qiskit._accelerate.commutation_checker import CommutationChecker as RustChecker
2223
from qiskit.utils import deprecate_arg, deprecate_func
2324

25+
if typing.TYPE_CHECKING:
26+
from qiskit.dagcircuit import DAGOpNode
27+
2428

2529
class CommutationChecker:
2630
r"""Check commutations of two operations.
@@ -61,12 +65,16 @@ def __init__(
6165

6266
def commute_nodes(
6367
self,
64-
op1,
65-
op2,
68+
op1: DAGOpNode,
69+
op2: DAGOpNode,
6670
max_num_qubits: int = 3,
6771
approximation_degree: float = 1.0,
6872
) -> bool:
69-
"""Checks if two DAGOpNodes commute."""
73+
"""Checks if two :class:`.DAGOpNode` objects commute.
74+
75+
This is equivalent to :meth:`commute` but with the operation, qubits, and clbits
76+
bundled in the :class:`.DAGOpNode` object. See :meth:`commute` for more details.
77+
"""
7078
return self.cc.commute_nodes(op1, op2, max_num_qubits, approximation_degree, max_num_qubits)
7179

7280
def commute(

0 commit comments

Comments
 (0)