Skip to content
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

[Code together] Add matrix form to Grover Operator #1553

Merged
merged 52 commits into from Aug 19, 2021

Conversation

ingstra
Copy link
Contributor

@ingstra ingstra commented Aug 18, 2021

Issue #1514

Add matrix attribute to Grover template.

@ingstra
Copy link
Contributor Author

ingstra commented Aug 18, 2021

In case you prefer the first one, I'll remove the new private function __getMultiControlledX(self), which I just introduced to not have duplicated code.

@antalszava
Copy link
Contributor

Hi @ingstra, thank you for the submission! 🙂 No clear preference for the approach, other than it producing the correct matrix representation. Overall, the more performant approach would be preferable, though this is not required for us to accept the solution. It could be nice to go with one of them and add further parts of the PR (e.g., testing). Also, don't forget to update the changelog with an entry about the addition and by adding yourself to the list of contributors. 🙂

@codecov
Copy link

codecov bot commented Aug 18, 2021

Codecov Report

Merging #1553 (30bcfe2) into master (c403e27) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1553   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files         189      189           
  Lines       13417    13431   +14     
=======================================
+ Hits        13303    13317   +14     
  Misses        114      114           
Impacted Files Coverage Δ
pennylane/templates/subroutines/grover.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c403e27...30bcfe2. Read the comment docs.

@ingstra
Copy link
Contributor Author

ingstra commented Aug 18, 2021

Hi @ingstra, thank you for the submission! slightly_smiling_face No clear preference for the approach, other than it producing the correct matrix representation. Overall, the more performant approach would be preferable, though this is not required for us to accept the solution. It could be nice to go with one of them and add further parts of the PR (e.g., testing). Also, don't forget to update the changelog with an entry about the addition and by adding yourself to the list of contributors. slightly_smiling_face

Ok! Where in the changelog should I write? Top? Bottom?

@ingstra
Copy link
Contributor Author

ingstra commented Aug 18, 2021

Sorry for the billion commits, it's my first time...
Edit: Finally, I think it's good now.

antalszava and others added 4 commits August 18, 2021 11:36
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Hi @ingstra, this is looking nice! 🙂 Overall, it's already in a good shape. Left some suggestions, feel free to address those that were marked as minor last.

Also, there seems to be a conflict in the changelog. This can be resolved by pulling master (git checkout master followed by git pull), switching to the feature branch (git checkout add_reseterror_support) and then merging master (git merge master). The culprit seems to be the changelog file. We'd like to have all the entries kept there, for some reason git could not resolve the addition there well.

pennylane/templates/subroutines/grover.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_grover.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/grover.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_grover.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_grover.py Outdated Show resolved Hide resolved
tests/templates/test_subroutines/test_grover.py Outdated Show resolved Hide resolved
ingstra and others added 2 commits August 18, 2021 22:30
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Thank you so much for this contribution @ingstra! 🎉 🙂


@property
def matrix(self):
# Redefine the property here to allow for a custom _matrix signature
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to have this comment!

Comment on lines +145 to +146
# s1 = H|0>, Hadamard on a single qubit in the ground state
s1 = np.array([1, 1]) / np.sqrt(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@antalszava antalszava merged commit 29d1daa into PennyLaneAI:master Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants