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 compute_amplitudes_sweep and compute_amplitudes methods of SimulatesAmplitudes class. #2603

Closed
iamvamsikrishnad opened this issue Nov 27, 2019 · 2 comments · Fixed by #5818
Labels
area/simulation complexity/low introduces/modifies 1-2 concepts, should take 1-2 days max for an advanced contributor kind/docs Documentation related problems, ideas, requests skill-level/beginner No background required, self-contained issue triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@iamvamsikrishnad
Copy link
Collaborator

The signature of compute_amplitudes_sweep and compute_amplitudes requires bitstrings to be a list of int's. Because of the semantics in python3 of not allowing leading zeros for int's (https://stackoverflow.com/questions/36386346/syntaxerror-invalid-token) this can be confusing.

For eg: if I want to measure a bitstring 0010, I need to provide 10 as input to the bitstring which is confusing to the user.

I propose to change the type of bitstrings to Sequence[str].

@dabacon
Copy link
Collaborator

dabacon commented May 8, 2020

I think the way to do this in python is to use the binary prefix: 0b0010 or 0B0010. I'm going to change this to adding binary as example usage.

@dabacon dabacon changed the title bitstrings as Sequence[int] is confusing in compute_amplitudes_sweep and compute_amplitudes methods of SimulatesAmplitudes class. Add binary literal example to compute_amplitudes_sweep and compute_amplitudes methods of SimulatesAmplitudes class. May 8, 2020
@95-martin-orion 95-martin-orion added area/simulation complexity/low introduces/modifies 1-2 concepts, should take 1-2 days max for an advanced contributor kind/docs Documentation related problems, ideas, requests skill-level/beginner No background required, self-contained issue triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed question labels Sep 22, 2020
Caffetaria added a commit to Caffetaria/Cirq that referenced this issue Aug 6, 2022
Caffetaria added a commit to Caffetaria/Cirq that referenced this issue Aug 6, 2022
@viathor
Copy link
Collaborator

viathor commented Aug 8, 2022

For eg: if I want to measure a bitstring 0010, I need to provide 10 as input to the bitstring which is confusing to the user.

Not at all. To measure bitstring 0010, you need to provide 2 as input which you may choose to write as 0b0010 or 0b10 or 0x2 or 2 or even 0o2 (no longer fashionable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/simulation complexity/low introduces/modifies 1-2 concepts, should take 1-2 days max for an advanced contributor kind/docs Documentation related problems, ideas, requests skill-level/beginner No background required, self-contained issue triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants