amazon-braket-sdk-python
amazon-braket-sdk-python copied to clipboard
feature: add support for OpenQASM measure on a subset of qubits
Issue #, if available:
Description of changes:
- Add a
Measure
operator that measures the qubit targets specified. - Removed the Validation error in GateModelQuantumTaskResult to check that measured qubits match the qubit count
- Added
Measure
to the circuit diagram
Testing done:
tox
and tox -e integ-tests
Merge Checklist
Put an x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.
General
- [ ] I have read the CONTRIBUTING doc
- [ ] I used the commit message format described in CONTRIBUTING
- [ ] I have updated any necessary documentation, including READMEs and API docs (if appropriate)
Tests
>>> circ = Circuit().h(0).cnot(0, 1).measure([0])
>>> print(circ)
T : │ 0 │ 1 │ 2 │
┌───┐ ┌───┐
q0 : ─┤ H ├───●───┤ M ├─
└───┘ │ └───┘
┌─┴─┐
q1 : ───────┤ X ├───────
└───┘
T : │ 0 │ 1 │ 2 │
>>> print(circ.to_ir("OPENQASM"))
OPENQASM 3.0;
bit[1] b;
qubit[2] q;
h q[0];
cnot q[0], q[1];
b[0] = measure q[0];
- [ ] I have added tests that prove my fix is effective or that my feature works (if appropriate)
- [ ] I have checked that my tests are not configured for a specific region or account (if appropriate)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.