amazon-braket / autoqasm

AutoQASM is an experimental module offering a new quantum-imperative programming experience in Python for developing quantum programs.
Apache License 2.0
15 stars 9 forks source link

feature: add support for typecasting #27

Closed abidart closed 5 months ago

abidart commented 5 months ago

Issue #, if available: Related to #10.

Description of changes: In an attempt to add support for int and float conversion, I made 3 changes:

The goal is to add a functionality such that the following two compile to the same QASM instructions, or very similar:

syndrome = int(measure([0,1]))
################################
a1 = aq.IntVar(measure(1))
a0 = aq.IntVar(measure(0))
syndrome = 2*a1 + a0

Testing done:

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.

abidart commented 5 months ago

I added 3 unit tests but I was not sure if they should go into test_api.py, test_operator.py, or test_converter.py, what do you think? Also, do you think that the expected_irs look reasonable?

codecov[bot] commented 5 months ago

Codecov Report

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

Project coverage is 100.00%. Comparing base (f83bb15) to head (f50afec). Report is 8 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #27 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 47 49 +2 Lines 2057 2090 +33 Branches 343 345 +2 ========================================= + Hits 2057 2090 +33 ```

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

rmshaffer commented 5 months ago

I added 3 unit tests but I was not sure if they should go into test_api.py, test_operator.py, or test_converter.py, what do you think?

@abidart Probably test_operators.py makes the most sense. test_api.py is getting too large and needs to be split apart at some point.

abidart commented 5 months ago

@rmshaffer I pushed a new commit with cosmetic changes based on the review from #29 anticipating similar comments.