Skip to content
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

Add binary literal example to methods of SimulatesAmplitudes class #5818

Merged
merged 6 commits into from
Aug 10, 2022
Prev Previous commit
Next Next commit
Add binary literal example to methods of SimulatesAmplitudes class (#…
  • Loading branch information
Caffetaria committed Aug 8, 2022
commit 81155b369fe76703fda7d4aafc62e1b720fd1918
8 changes: 4 additions & 4 deletions cirq-core/cirq/sim/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def compute_amplitudes(
as an integer array where each integer is formed from measured
qubit values according to `qubit_order` from most to least
significant qubit, i.e. in big-endian ordering.
Binary literals should be input with the prefix 0b or 0B.
For example, 0010 should be input as 0b0010 or 0B0010.
If inputting a binary literal add the prefix 0b or 0B.
For example: 0010 can be input as 0b0010, 0B0010, 2, 0x2, etc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be indented by four spaces to align with the line above. Also, you can put "If inputting" on line 159 above that.

(Applies to the comment on lines 221-222 as well.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viathor Made these changes in the latest commit :)

Copy link
Collaborator

@viathor viathor Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only meant a part of the "if inputting" line since there is an overall line length limit (and in any case we should stick to the rough right text boundary of the surrounding text). I'm approving this PR, but note that you will need to take care of this before the merge since at the moment the line-too-long issue makes the formatter and linter checks go red.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The last two recent commits resolve this (only 'if inputting' is on the previous line).


param_resolver: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This
Expand Down Expand Up @@ -218,8 +218,8 @@ def compute_amplitudes_sweep_iter(
as an integer array where each integer is formed from measured
qubit values according to `qubit_order` from most to least
significant qubit, i.e. in big-endian ordering.
Binary literals should be input with the prefix 0b or 0B.
For example, 0010 should be input as 0b0010 or 0B0010.
If inputting a binary literal add the prefix 0b or 0B.
For example: 0010 can be input as 0b0010, 0B0010, 2, 0x2, etc.
params: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This
is often used in specifying the initial state, i.e. the
Expand Down