Skip to content

Commit

Permalink
Fix from_diagram docstring on GridQubit. (#5307)
Browse files Browse the repository at this point in the history
Fixes broken docstring for `from_diagram` on gridqubit page.
  • Loading branch information
MichaelBroughton authored Jun 1, 2022
1 parent 209c76e commit 6de1a3f
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions cirq-core/cirq/devices/grid_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,25 @@ def rect(

@staticmethod
def from_diagram(diagram: str, dimension: int) -> List['GridQid']:
r"""Parse ASCII art device layout into info about qids and
connectivity. As an example, the below diagram will create a list of
GridQid in a pyramid structure.
"""Parse ASCII art device layout into a device.
As an example, the below diagram will create a list of GridQid in a
pyramid structure.
```
---A---
--AAA--
-AAAAA-
AAAAAAA
```
You can use any character other than a hyphen to mark a qid. As an
example, the qids for the Bristlecone device could be represented by
the below diagram. This produces a diamond-shaped grid of qids, and
qids with the same letter correspond to the same readout line.
You can use any character other than a hyphen, period or space to mark a
qid. As an example, the qids for a Bristlecone device could be
represented by the below diagram. This produces a diamond-shaped grid of
qids, and qids with the same letter correspond to the same readout line.
```
.....AB.....
....ABCD....
...ABCDEF...
Expand All @@ -229,20 +235,22 @@ def from_diagram(diagram: str, dimension: int) -> List['GridQid']:
...GHIJKL...
....IJKL....
.....KL.....
```
Args:
diagram: String representing the qid layout. Each line represents
a row. Alphanumeric characters are assigned as qid.
Dots ('.'), dashes ('-'), and spaces (' ') are treated as
empty locations in the grid. If diagram has characters other
than alphanumerics, spacers, and newlines ('\n'), an error will
than alphanumerics, spacers, and newlines ('\\n'), an error will
be thrown. The top-left corner of the diagram will be have
coordinate (0,0).
dimension: The dimension of the qubits in the `GridQid`s used
coordinate (0, 0).
dimension: The dimension of the qubits in the `cirq.GridQid`s used
in this construction.
Returns:
A list of GridQid corresponding to qids in the provided diagram
A list of `cirq.GridQid`s corresponding to qids in the provided diagram
Raises:
ValueError: If the input string contains an invalid character.
Expand Down Expand Up @@ -363,19 +371,25 @@ def rect(rows: int, cols: int, top: int = 0, left: int = 0) -> List['GridQubit']

@staticmethod
def from_diagram(diagram: str) -> List['GridQubit']:
"""Parse ASCII art device layout into info about qubits and
connectivity. As an example, the below diagram will create a list of
"""Parse ASCII art into device layout info.
As an example, the below diagram will create a list of
GridQubit in a pyramid structure.
```
---A---
--AAA--
-AAAAA-
AAAAAAA
```
You can use any character other than a hyphen to mark a qubit. As an
example, the qubits for the Bristlecone device could be represented by
the below diagram. This produces a diamond-shaped grid of qids, and
qids with the same letter correspond to the same readout line.
You can use any character other than a hyphen, period or space to mark
a qubit. As an example, the qubits for a Bristlecone device could be
represented by the below diagram. This produces a diamond-shaped grid
of qids, and qids with the same letter correspond to the same readout
line.
```
.....AB.....
....ABCD....
...ABCDEF...
Expand All @@ -387,13 +401,14 @@ def from_diagram(diagram: str) -> List['GridQubit']:
...GHIJKL...
....IJKL....
.....KL.....
```
Args:
diagram: String representing the qubit layout. Each line represents
a row. Alphanumeric characters are assigned as qid.
Dots ('.'), dashes ('-'), and spaces (' ') are treated as
empty locations in the grid. If diagram has characters other
than alphanumerics, spacers, and newlines ('\n'), an error will
than alphanumerics, spacers, and newlines ('\\n'), an error will
be thrown. The top-left corner of the diagram will be have
coordinate (0,0).
Expand Down

0 comments on commit 6de1a3f

Please sign in to comment.