diff --git a/cirq-core/cirq/devices/line_qubit.py b/cirq-core/cirq/devices/line_qubit.py index 0f446b0dca4..980db2be91a 100644 --- a/cirq-core/cirq/devices/line_qubit.py +++ b/cirq-core/cirq/devices/line_qubit.py @@ -44,7 +44,13 @@ def with_dimension(self, dimension: int) -> 'LineQid': return LineQid(self.x, dimension) def is_adjacent(self, other: 'cirq.Qid') -> bool: - """Determines if two qubits are adjacent line qubits.""" + """Determines if two qubits are adjacent line qubits. + + Args: + other: `cirq.Qid` to test for adjacency. + + Returns: True iff other and self are adjacent. + """ return isinstance(other, _BaseLineQid) and abs(self.x - other.x) == 1 def neighbors(self, qids: Optional[Iterable[ops.Qid]] = None) -> Set['_BaseLineQid']: @@ -115,13 +121,14 @@ class LineQid(_BaseLineQid): identifies the qids location on the line. `LineQid`s are ordered by this integer. - One can construct new `LineQid`s by adding or subtracting integers: + One can construct new `cirq.LineQid`s by adding or subtracting integers: + + >>> cirq.LineQid(1, dimension=2) + 3 + cirq.LineQid(4, dimension=2) - >>> cirq.LineQid(1, dimension=2) + 3 - cirq.LineQid(4, dimension=2) + >>> cirq.LineQid(2, dimension=3) - 1 + cirq.LineQid(1, dimension=3) - >>> cirq.LineQid(2, dimension=3) - 1 - cirq.LineQid(1, dimension=3) """ def __init__(self, x: int, dimension: int) -> None: @@ -208,13 +215,14 @@ class LineQubit(_BaseLineQid): identifies the qubits location on the line. LineQubits are ordered by this integer. - One can construct new LineQubits by adding or subtracting integers: + One can construct new `cirq.LineQubit`s by adding or subtracting integers: + + >>> cirq.LineQubit(1) + 3 + cirq.LineQubit(4) - >>> cirq.LineQubit(1) + 3 - cirq.LineQubit(4) + >>> cirq.LineQubit(2) - 1 + cirq.LineQubit(1) - >>> cirq.LineQubit(2) - 1 - cirq.LineQubit(1) """ @property