Skip to content

Fix from_diagram docstring on GridQubit. #5307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 1, 2022
Merged
Changes from 4 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
31 changes: 19 additions & 12 deletions cirq-core/cirq/devices/grid_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def rect(

@staticmethod
def from_diagram(diagram: str, dimension: int) -> List['GridQid']:
r"""Parse ASCII art device layout into a device.
"""Parse ASCII art device layout into a device.

As an example, the below diagram will create a list of GridQid in a
pyramid structure.
Expand All @@ -218,8 +218,8 @@ def from_diagram(diagram: str, dimension: int) -> List['GridQid']:
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
You can use any character other than a hyphen, period or space to mark a
qid. As an example, the qids for a Sycamore 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.

Expand All @@ -240,9 +240,9 @@ def from_diagram(diagram: str, dimension: int) -> List['GridQid']:
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
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 Expand Up @@ -371,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 Sycamore 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 @@ -395,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