QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
918 stars 119 forks source link

More density matrix support #461

Closed jlbosse closed 1 year ago

jlbosse commented 1 year ago

I added tests and docstrings to #408 .

Before this gets merged, two more questions:

  1. Currently qubit_type() is defined only for YaoArrayRegister and DensityMatrix. But its definition is sufficiently general, that it could be moved into YaoAPI. Shall I do that?
  2. More aesthetic: Currently a generic density matrix is referred to as ρ, rho, r or dm in the different files of the code (and also has different names in different docstrings). Should I go ahead and homogenize the naming there, and if yes to which of the four options?
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 :tada:

Comparison is base (dc9d152) 88.24% compared to head (deb661f) 88.28%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #461 +/- ## ========================================== + Coverage 88.24% 88.28% +0.04% ========================================== Files 77 77 Lines 4807 4824 +17 ========================================== + Hits 4242 4259 +17 Misses 565 565 ``` | [Impacted Files](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS) | Coverage Δ | | |---|---|---| | [lib/YaoArrayRegister/src/error.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL2Vycm9yLmps) | `53.06% <ø> (ø)` | | | [lib/YaoBlocks/src/YaoBlocks.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvWWFvQmxvY2tzLmps) | `100.00% <ø> (ø)` | | | [lib/YaoArrayRegister/src/density\_matrix.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL2RlbnNpdHlfbWF0cml4Lmps) | `98.98% <100.00%> (+2.56%)` | :arrow_up: | | [lib/YaoArrayRegister/src/focus.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL2ZvY3VzLmps) | `90.32% <100.00%> (+0.32%)` | :arrow_up: | | [lib/YaoArrayRegister/src/register.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL3JlZ2lzdGVyLmps) | `95.84% <100.00%> (ø)` | | | [lib/YaoBlocks/src/channel/error\_channel.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvY2hhbm5lbC9lcnJvcl9jaGFubmVsLmps) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

Roger-luo commented 1 year ago

Currently qubit_type() is defined only for YaoArrayRegister and DensityMatrix. But its definition is sufficiently general, that it could be moved into YaoAPI. Shall I do that?

In a separate PR, yes.

More aesthetic: Currently a generic density matrix is referred to as ρ, rho, r or dm in the different files of the code (and also has different names in different docstrings). Should I go ahead and homogenize the naming there, and if yes to which of the four options?

Yes, they should use the same variable name, but this is kinda written by different people at different times, so we haven't been careful. And since you are doing it, you have the right to pick your favorite except r (it's too short as a general convention)

But please also do this in a separate PR. I think this PR is good on its own already.

GiggleLiu commented 1 year ago

qubit_type() returns a string for printing. It is not an essential API that people will be interested in implementing it. We have to keep YaoAPI easy to understand and easy to extend, so any nonessential API should not go to YaoAPI.