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

Extend Circuit parsing of qubit labels #495

Open
sserita opened this issue Oct 3, 2024 · 0 comments
Open

Extend Circuit parsing of qubit labels #495

sserita opened this issue Oct 3, 2024 · 0 comments
Labels
bug A bug or regression
Milestone

Comments

@sserita
Copy link
Contributor

sserita commented Oct 3, 2024

Describe the bug
Circuit parsing currently fails if the qubit labels are not integers or begin with 'Q'. This is both very restrictive, and the error message is uninformative.

To Reproduce

from pygsti.circuit import Circuit

c = Circuit([("Gxpi2", "A0")]) # This is fine
c.str # This is also fine

Circuit(c.str) # Errors with ValueError: invalid literal for int() with base 10: ''

Expected behavior
At the very least, a clearer error message. The current error message is because it assumes it is not a valid str since it doesn't start with Q, therefore it must be an int, and then the int cast fails. We should catch this and output a more useful message.

But we should also consider allowing arbitrary qubit labels (these can be used if not deserializing from string without issue, and can be serialized with no problem. It's just deserialization that is a problem). I'll note that there is some importance assigned to state space label prefixes; specifically, I believe Q is used to automatically set the state space dimensions to those of a qubit. Others exist (i.e. L for leakage, etc), so the user would maybe have to specify the state space more explicitly in these cases.

Environment (please complete the following information):

  • pyGSTi 0.9.12.3
  • python 3.11
  • OSX 14
@sserita sserita added the bug A bug or regression label Oct 3, 2024
@sserita sserita added this to the 0.9.14 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug or regression
Projects
None yet
Development

No branches or pull requests

1 participant