Skip to content

Commit c0bf5aa

Browse files
[API docs] line_qubit api format. (quantumlib#5501)
Improves line qubit rendering on api docs.
1 parent df93d23 commit c0bf5aa

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

cirq/devices/line_qubit.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def with_dimension(self, dimension: int) -> 'LineQid':
4444
return LineQid(self.x, dimension)
4545

4646
def is_adjacent(self, other: 'cirq.Qid') -> bool:
47-
"""Determines if two qubits are adjacent line qubits."""
47+
"""Determines if two qubits are adjacent line qubits.
48+
49+
Args:
50+
other: `cirq.Qid` to test for adjacency.
51+
52+
Returns: True iff other and self are adjacent.
53+
"""
4854
return isinstance(other, _BaseLineQid) and abs(self.x - other.x) == 1
4955

5056
def neighbors(self, qids: Optional[Iterable[ops.Qid]] = None) -> Set['_BaseLineQid']:
@@ -115,13 +121,14 @@ class LineQid(_BaseLineQid):
115121
identifies the qids location on the line. `LineQid`s are ordered by
116122
this integer.
117123
118-
One can construct new `LineQid`s by adding or subtracting integers:
124+
One can construct new `cirq.LineQid`s by adding or subtracting integers:
125+
126+
>>> cirq.LineQid(1, dimension=2) + 3
127+
cirq.LineQid(4, dimension=2)
119128
120-
>>> cirq.LineQid(1, dimension=2) + 3
121-
cirq.LineQid(4, dimension=2)
129+
>>> cirq.LineQid(2, dimension=3) - 1
130+
cirq.LineQid(1, dimension=3)
122131
123-
>>> cirq.LineQid(2, dimension=3) - 1
124-
cirq.LineQid(1, dimension=3)
125132
"""
126133

127134
def __init__(self, x: int, dimension: int) -> None:
@@ -208,13 +215,14 @@ class LineQubit(_BaseLineQid):
208215
identifies the qubits location on the line. LineQubits are ordered by
209216
this integer.
210217
211-
One can construct new LineQubits by adding or subtracting integers:
218+
One can construct new `cirq.LineQubit`s by adding or subtracting integers:
219+
220+
>>> cirq.LineQubit(1) + 3
221+
cirq.LineQubit(4)
212222
213-
>>> cirq.LineQubit(1) + 3
214-
cirq.LineQubit(4)
223+
>>> cirq.LineQubit(2) - 1
224+
cirq.LineQubit(1)
215225
216-
>>> cirq.LineQubit(2) - 1
217-
cirq.LineQubit(1)
218226
"""
219227

220228
@property

0 commit comments

Comments
 (0)