amazon-braket / amazon-braket-sdk-python

A Python SDK for interacting with quantum devices on Amazon Braket
https://aws.amazon.com/braket/
Apache License 2.0
294 stars 118 forks source link

fix: prevent repeated measurements on a qubit #937

Closed ashlhans closed 3 months ago

ashlhans commented 3 months ago

Issue #, if available:

Description of changes:

Currently, the following circuits are allowed where a qubit appears to be measured more than once:

circ = Circuit().h(0).cnot(0, 1).rx(0, 0.9).ry(1, 0.2).measure([0,0,0,0])

circ = Circuit().h(0).cnot(0, 1).measure([1]).measure([0,1])

A qubit can only be measured once so we should raise an error for repeated qubits in a measure instruction.

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

Tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (d5580dc) to head (3444e18).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #937 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 133 133 Lines 8901 8905 +4 Branches 2004 2006 +2 ========================================= + Hits 8901 8905 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.