-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 constructor methods to build QuantumCircuits from QASM #1172
Conversation
can we get some tests and update the example also i would depreciate the wrapper functions that use load_from_file and load_from_string |
Sure, I'll add some tests for this and deprecate the wrapper methods |
8e98b4d
to
c71d007
Compare
this looks good. Its just failing in the linter. |
sigh, it's failing on tempfile in appveyor just like @nonhermitian PR. I guess I'll do the same skip on the tests here too |
4543160
to
5a36392
Compare
@mtreinish can you fix the conflicts with @ajavadia addition and then we should merge |
This commit adds 2 new static methods to the QuantumCircuit class to enable constructing a QuantumCircuit from a QASM string or file. This gives users to option of building a QuantumCircuit object with a qasm file simply by calling: circuit = QuantumCircuit.from_qasm_file(path) or circuit = QuantumCircuit.from_qasm_str(qasm_str) As part of this change the circuitbackend imports for Unroller() had to be updated to be module imports. This was to avoid having a circular import with the _quantumcircuit module (now that _quantumcircuit leverages uses it). Fixes Qiskit#971
This commit deprecates the qasm loading functions from the wrapper module. Now that we have top level static constructor methods off the quantum circuit class these aren't needed anymore.
This commit adds unit test coverage for the new from_qasm_str() and from_qasm_file() constructor methods on the QuantumCircuit class.
d844c55
to
b48e186
Compare
* Add constructor methods to build QuantumCircuits from QASM This commit adds 2 new static methods to the QuantumCircuit class to enable constructing a QuantumCircuit from a QASM string or file. This gives users to option of building a QuantumCircuit object with a qasm file simply by calling: circuit = QuantumCircuit.from_qasm_file(path) or circuit = QuantumCircuit.from_qasm_str(qasm_str) As part of this change the circuitbackend imports for Unroller() had to be updated to be module imports. This was to avoid having a circular import with the _quantumcircuit module (now that _quantumcircuit leverages uses it). Fixes Qiskit#971 * Disable cyclic import pylint * Deprecate qasm loading functions in wrapper This commit deprecates the qasm loading functions from the wrapper module. Now that we have top level static constructor methods off the quantum circuit class these aren't needed anymore. * Add tests for new from_qasm*() QuantumCircuit methods This commit adds unit test coverage for the new from_qasm_str() and from_qasm_file() constructor methods on the QuantumCircuit class. * Fix pylint nitpicks * Add skip for appveyor
Summary
This commit adds 2 new static methods to the QuantumCircuit class to
enable constructing a QuantumCircuit from a QASM string or file. This
gives users to option of building a QuantumCircuit object with a qasm
file simply by calling:
circuit = QuantumCircuit.from_qasm_file(path)
or
circuit = QuantumCircuit.from_qasm_str(qasm_str)
Details and comments
As part of this change the circuitbackend imports for Unroller() had to
be updated to be module imports. This was to avoid having a circular
import with the _quantumcircuit module (now that _quantumcircuit
leverages uses it).
Fixes #971