Skip to content

✨ Convenience features #226

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

Merged
merged 7 commits into from
Dec 2, 2022
Merged

✨ Convenience features #226

merged 7 commits into from
Dec 2, 2022

Conversation

burgholzer
Copy link
Member

This PR adds some convenience functions that allow easier creation of QuantumComputations.
Specifically, a QuantumComputation can now be easily converted to an Operation. This allows one to create compound operations by first building a quantum circuit and, then, turning it into an operation.
Furthermore, a convenience function for adding classically-controlled operations to circuits is provided. This avoids the verbose code of having to create the quantum operation, constructing the ClassicControlled operation out of that, and then emplacing the resulting operation in the circuit.

Furthermore, it adds a method to determine the circuit depth.

Most of the changes here are actually in the tests, which have been refactored to take advantage of the new convenience features and, imho, look much nicer and less verbose now.

@burgholzer burgholzer added the enhancement New feature or request label Dec 1, 2022
@burgholzer burgholzer requested a review from hillmich December 1, 2022 21:32
@burgholzer burgholzer self-assigned this Dec 1, 2022
Signed-off-by: Lukas Burgholzer <[email protected]>
@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #226 (3b3ca8b) into main (64a8919) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #226   +/-   ##
=====================================
  Coverage   84.6%   84.6%           
=====================================
  Files         51      51           
  Lines       8715    8761   +46     
=====================================
+ Hits        7374    7419   +45     
- Misses      1341    1342    +1     
Impacted Files Coverage Δ
include/operations/NonUnitaryOperation.hpp 92.0% <ø> (-4.5%) ⬇️
include/operations/Operation.hpp 93.6% <ø> (-0.3%) ⬇️
include/QuantumComputation.hpp 94.4% <100.0%> (+0.2%) ⬆️
include/operations/CompoundOperation.hpp 82.1% <100.0%> (+1.0%) ⬆️
src/QuantumComputation.cpp 70.1% <100.0%> (+0.2%) ⬆️
src/algorithms/QFT.cpp 100.0% <100.0%> (ø)
src/algorithms/QPE.cpp 86.7% <100.0%> (-0.2%) ⬇️
src/operations/NonUnitaryOperation.cpp 75.1% <100.0%> (+0.4%) ⬆️
src/operations/Operation.cpp 87.7% <100.0%> (+0.7%) ⬆️
test/unittests/test_qfr_functionality.cpp 100.0% <100.0%> (ø)
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@hillmich hillmich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Avoiding the boilerplate for classically controlled operations is really nice.

@burgholzer burgholzer merged commit c0ea534 into main Dec 2, 2022
@burgholzer burgholzer deleted the convenience-features branch December 2, 2022 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants