QuantumBFS / Yao.jl

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

update docs for @ket_str #389

Closed hros closed 2 years ago

hros commented 2 years ago

the doc for @ket_str macro:

  Create a ket register. See also @bra_str.

  Example
  ≡≡≡≡≡≡≡≡≡

  a symbolic quantum state can be created simply by

  julia> ket"110" + 2ket"111"
  |110⟩ + 2.0|111⟩

  qubits can be partially actived by focus!

  julia> ket"100" + ket"111" |> focus!(1:2)
  ERROR: UndefVarError: focus! not defined
  Stacktrace:
   [1] top-level scope
     @ none:1

It seems that focus! no longer accepts ranges, only a tuple of indices The docs for @ket_str should be updated accordingly, or reimplement the support for ranges in focus!

Roger-luo commented 2 years ago

I just checked again the following works, It seems to me that you didn't using Yao to get the definition of focus! function?

julia> using Yao, SymEngine

julia> ket"110" + 2ket"111"
|110⟩ + 2.0|111⟩

julia> r = ket"110" + 2ket"111"
|110⟩ + 2.0|111⟩

julia> ket"100" + ket"111" |> focus!(1:2)
|100⟩ + |111⟩
hros commented 2 years ago

I did use the package with using Yao, otherwise I wouldn't have gotten the help message for @ket_str

I can confirm that the command accepts ranges, though for some reason the error message in the doc for @ket_str is still there

Roger-luo commented 2 years ago

Which version are you using?

hros commented 2 years ago

The error message in the help os both in the stable and the dev versions

Roger-luo commented 2 years ago

can you point out how to reproduce this? I'm not able to reproduce this in any recent versions or on master branch. I just double-checked error message ERROR: UndefVarError: focus! not defined doesn't exists anywhere in our documentation, so I'm wondering what's the full stacktrace of this and how did you reproduce this?

GiggleLiu commented 2 years ago

I can not reproduce the error neither.

hros commented 2 years ago

I have reinstalled both versions (0.6.2, and 0.7.4) and now the error message is not showing anymore Probably some quirk with Julia's package manager (I had installed the stable version globally, and the dev version in a project directory). Since it is now working correctly, I see no reason for further investigation. Thanks for you help