-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c46779b
Fix from_diagram docstring on GridQubit.
MichaelBroughton f99102f
Orion feedback.
MichaelBroughton d5f3fdb
Merge branch 'master' into update_gridqubit
MichaelBroughton d99ad65
space.
MichaelBroughton 355cc3d
Merge branch 'update_gridqubit' of github.com:MichaelBroughton/Cirq i…
MichaelBroughton 818e2f1
revert to bristlecone grid.
MichaelBroughton 3aa2e2d
format.
MichaelBroughton 81b0117
Merge branch 'master' into update_gridqubit
CirqBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
r"""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. | ||
|
||
``` | ||
.....AB..... | ||
....ABCD.... | ||
...ABCDEF... | ||
|
@@ -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 | ||
Dots ('.'), dashes ('-'), and spaces are treated as | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why drop the |
||
empty locations in the grid. If diagram has characters other | ||
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. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, as noted in the "Args: diagram" section below. Periods and spaces are also treated as non-Qid positions, and non-alphanumeric characters produce an error.