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

[Samples] Add samples for testing operations in Q# #1732

Merged
merged 47 commits into from
Jul 26, 2024

Conversation

Manvi-Agrawal
Copy link
Contributor

@Manvi-Agrawal Manvi-Agrawal commented Jul 11, 2024

Fixes part of #1268

  • Added samples for testing operations using dump_operation.

  • Also, using CheckOperationsAreEqual inside Fact function to demonstrate another way

  • Hopefully, the new testing samples should be executed in CI. @tcNickolas could you please start a CI run. Snapshot from locally running build.py.
    image

  • Running in CI:
    image

@Manvi-Agrawal Manvi-Agrawal changed the title Testing operations WIP: Testing operations Jul 11, 2024
@Manvi-Agrawal Manvi-Agrawal changed the title WIP: Testing operations [Samples] Add samples for testing operations in Q# Jul 13, 2024
@Manvi-Agrawal Manvi-Agrawal marked this pull request as ready for review July 13, 2024 01:54
@Manvi-Agrawal Manvi-Agrawal marked this pull request as draft July 13, 2024 02:47
Comment on lines +125 to +127
qsharp.eval(
"OperationEquivalence.TestEquivalence()"
)

Check notice

Code scanning / devskim

If untrusted data (data from HTTP requests, user submitted files, etc.) is included in an eval statement it can allow an attacker to inject their own code. Note test

Review eval for untrusted data
Comment on lines +56 to +57
qsharp.eval(
"operation ApplySWAP(qs : Qubit[]) : Unit is Ctl + Adj { SWAP(qs[0], qs[1]); }"

Check notice

Code scanning / devskim

If untrusted data (data from HTTP requests, user submitted files, etc.) is included in an eval statement it can allow an attacker to inject their own code. Note test

Review eval for untrusted data
@swernli
Copy link
Collaborator

swernli commented Jul 25, 2024

Thanks for merging main and confirming things work well with the new sample testing. I can see the auto-generated tests run successfully as well as the new tests added here. It looks great!

Copy link
Member

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

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

This looks a lot better, I like how the code got more concise and matrices in the test are human-readable!

I left some more comments, with them fixed this will be good to go!

samples/testing/operations/test_operations.py Outdated Show resolved Hide resolved
samples/testing/operations/src/BellState.qs Outdated Show resolved Hide resolved
samples/testing/operations/src/BellState.qs Show resolved Hide resolved
samples/testing/operations/src/OperationEquivalence.qs Outdated Show resolved Hide resolved
samples/testing/operations/README.md Outdated Show resolved Hide resolved
samples/testing/operations/README.md Outdated Show resolved Hide resolved
samples/testing/operations/README.md Outdated Show resolved Hide resolved
Copy link
Member

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

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

Looks good. Hopefully one last round of suggestions!

Thank you!

samples/testing/operations/README.md Outdated Show resolved Hide resolved
samples/testing/operations/README.md Outdated Show resolved Hide resolved
samples/testing/operations/src/OperationEquivalence.qs Outdated Show resolved Hide resolved
samples/testing/operations/test_operations.py Outdated Show resolved Hide resolved
Manvi-Agrawal and others added 3 commits July 26, 2024 12:17
Co-authored-by: Mariia Mykhailova <michaylova@gmail.com>
Co-authored-by: Mariia Mykhailova <michaylova@gmail.com>
Copy link
Member

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you so much for working on this!

@tcNickolas tcNickolas enabled auto-merge July 26, 2024 19:34
@tcNickolas tcNickolas added this pull request to the merge queue Jul 26, 2024
Merged via the queue into microsoft:main with commit 10768e2 Jul 26, 2024
19 checks passed
@Manvi-Agrawal Manvi-Agrawal deleted the manvi/test-dump-op branch November 27, 2024 07:36
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.

3 participants