Skip to content
Merged
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
30 changes: 19 additions & 11 deletions cirq-core/cirq/devices/line_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down