guppylang icon indicating copy to clipboard operation
guppylang copied to clipboard

docs: add qsystem gate definitions

Open CalMacCQ opened this issue 9 months ago • 4 comments

Testing out adding some gate definitions and doctests to the qsystem docs

Couple things

  • potentially quite a pain to add defintions for all gates across std.qsystem and std.quantum.
  • We would also have to duplciate content across qsystem and qsystem_functional (also quantum and qauntum_functional)
  • Need to ensure the doctests are working properly

Screenshot 2025-04-08 at 18 07 44

Screenshot 2025-04-08 at 18 07 51

CalMacCQ avatar Apr 08 '25 17:04 CalMacCQ

Codecov Report

Attention: Patch coverage is 83.82353% with 11 lines in your changes missing coverage. Please review.

Project coverage is 92.29%. Comparing base (2217bbc) to head (1188e13). Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
guppylang/std/quantum/functional.py 18.18% 9 Missing :warning:
guppylang/std/quantum/__init__.py 95.55% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #912      +/-   ##
==========================================
+ Coverage   92.26%   92.29%   +0.03%     
==========================================
  Files         106      112       +6     
  Lines       10406    10909     +503     
==========================================
+ Hits         9601    10069     +468     
- Misses        805      840      +35     

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Apr 08 '25 17:04 codecov-commenter

  1. Increasingly it looks like it would be handy to have a utility that defines and compiles a single function. To be used in exmamples, doc tests, prototyping, etc. @mark-koch are you opposed to adding a dedicated decorator for this? (prompted by having to call compile() at the end of the doctest)
  2. Don't duplicate docs, cross-link to the non-functional one in each case. e.g. "Functional variant of zz_phase, see guppylang.std.qsystem.zz_phase"

ss2165 avatar Apr 17 '25 09:04 ss2165

are you opposed to adding a dedicated decorator for this?

If we use this in all examples then that's what people will copy and use themselves. So I think we have to be careful that this doesn't become an anti-pattern. In particular, it would be bad if people slapped that decorator on every function.

Also, where would you get the compiled Hugr from? Returning it from the decorator would make it hard to use those functions for comptime

mark-koch avatar Apr 17 '25 09:04 mark-koch

we have to be careful that this doesn't become an anti-pattern

yes good point, what about a kwarg to @guppy that makes it clear that this is a thing you shouldn't do normally? Or a check kwarg that only does the checking stage and not compilation to hugr?

ss2165 avatar Apr 17 '25 09:04 ss2165

I started going through the changes but found that my comments had been marked as resolved but not addressed. Is this due to git issues?

Hmm strange. I don't know why the changes were not applied. Will fix, sorry.

CalMacCQ avatar Jul 17 '25 08:07 CalMacCQ