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

Enforce string tokens? #420

Closed
ajavadia opened this issue Apr 22, 2018 · 0 comments
Closed

Enforce string tokens? #420

ajavadia opened this issue Apr 22, 2018 · 0 comments

Comments

@ajavadia
Copy link
Member

Since #308, in qiskit we allow non-string identifiers for qreg, creg, and circuits. This is creating a problem for non-python components, for example the c++ simulator. In c++ you have to assume a type for each parsed value, so its hard to accommodate "any" type. Another major issue is compatibility with the OpenQASM spec, which requires identifiers to begin with a letter (i.e. be strings).

Plus, I don't really understand the use case for allowing types other than strings. I know PR #308 was in response to issue #290, but if you want to number your registers or circuits, you can make those string numbers. Also, the ease of use has been addressed since we have now made names optional, and you can rely on auto-naming (via PR #346 and PR #376)

So.. I think we should roll back most of #308, and enforce string ID tokens.

Steps to Reproduce (for bugs)

The following code fails on the cpp simulator. It uses a number as circuit name identifier.

import qiskit as qk
from qiskit._compiler import compile, execute
from pprint import pprint
from qiskit.backends.local import QasmSimulator,  QasmSimulatorCpp
qr = qk.QuantumRegister(2, 0)
cr = qk.ClassicalRegister(2, "")
qc = qk.QuantumCircuit(qr, cr, name=10)
qc.h(qr[0])
qc.measure(qr[0], cr[0])
backend = QasmSimulatorCpp()
result = execute(qc, backend=backend)
pprint(result._qobj)
pprint(result._result)

Context

I am trying to make sure cross-compatibility between the python and cpp simulators. This is a problem there.

Your Environment

  • Version used:
  • Environment name and version (e.g. Python 3.6.1):
  • Operating System and version:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant