kestrelquantum / QuantumCollocation.jl

Quantum Optimal Control with Direct Collocation
MIT License
29 stars 7 forks source link

[Feature]: quantum utils docstrings and tests #117

Closed Fe-r-oz closed 3 months ago

Fe-r-oz commented 4 months ago

This PR aims to Resolve Issue https://github.com/aarontrowbridge/QuantumCollocation.jl/issues/102 and is an improvement over the PR #111

Sorry, my earlier PR #111 was rough. I have made sure this one is nice and clear! This will save your time during the review, @aarontrowbridge and @andgoldschmidt!

I have also newely added test for the newly added CZgates as well!

    @test apply(:CZ, [1, 0, 0, 0]) == [1, 0, 0, 0]  # CZ |00⟩ = |00⟩
    @test apply(:CZ, [0, 1, 0, 0]) == [0, 1, 0, 0]  # CZ |01⟩ = |01⟩
    @test apply(:CZ, [0, 0, 1, 0]) == [0, 0, 1, 0]  # CZ |10⟩ = |10⟩
    @test apply(:CZ, [0, 0, 0, 1]) == [0, 0, 0, -1] # CZ |11⟩ = -|11⟩

Implementation details are as follows:

  1. Write docstrings for all of the functions in src/quantum_utils.jl
  2. Addtests for the functions in test/quantum_utils_test.jl

This PR implements tests for QuantumUtils along with providing docstrings in thesrc/quantum_utils.

TestItems creates for the following:

  1. GATES
  2. apply
  3. qubit_system_state function
  4. lift function
  5. isomorphism utilities
  6. quantum harmonic oscillator operators

Docstrings include the argument signatures, and a short description. The copiolot stuff is not touched upon in this PR. Only a few relevant commits with complete description are done so make a clear and concise PR.

Testing: Complete testing of the TestItems have done locally. Instead of 19 commits, only few commits is done and files are shortened and redundant comments have been removed.

Test Summary:                                           | Pass  Fail  Total     Time
Package                                                 |  218     2    220  3m20.4s
  test/direct_sums_test.jl                              |   44           44    55.6s
  test/quantum_utils_test.jl                            |   71           71     9.6s
  test/rollouts_test.jl                                 |   18           18     7.2s
  test/problems_test.jl                                 |    1            1     4.5s
  src/problem_templates/unitary_minimum_time_problem.jl |    3            3    49.3s
  test/quantum_system_utils_test.jl                     |   15           15     4.8s
  src/problem_templates/unitary_robustness_problem.jl   |    3     2      5    57.4s
    Robust and Subspace Templates                       |    3     2      5    57.4s
  src/problem_templates/unitary_smooth_pulse_problem.jl |    1            1     5.3s
  test/losses_test.jl                                   |   21           21     0.7s
  test/embedded_operators_test.jl                       |   28           28     1.2s
  src/problem_templates/unitary_direct_sum_problem.jl   |   13           13     4.8s
Fe-r-oz commented 3 months ago

Hi, Please review the PR so that the review comments can be addressed before the deadline.

aarontrowbridge commented 3 months ago

sorry i caught something and have been under the weather so i missed a bunch of stuff. this looks good! thanks @Fe-r-oz

Fe-r-oz commented 3 months ago

No worries at all, Please take care and get well soon! @aarontrowbridge