QuantumBFS / ZXCalculus.jl

An implementation of ZX-calculus in Julia
http://yaoquantum.org/ZXCalculus.jl/dev/
MIT License
48 stars 7 forks source link

convert real to rational #51

Closed GiggleLiu closed 4 years ago

GiggleLiu commented 4 years ago
julia> zxd = ZXDiagram(4);

julia> push_gate!(zxd, Val(:X), 3, 0.5);

julia> push_gate!(zxd, Val(:X), 3, 0.3);

julia> push_gate!(zxd, Val(:X), 3, 1/3)
ZX-diagram with 11 vertices and 7 multiple edges:
(S_1{input} <-1-> S_2{output})
(S_3{input} <-1-> S_4{output})
(S_5{input} <-1-> S_9{phase = 1//2⋅π})
(S_6{output} <-1-> S_11{phase = 1//3⋅π})
(S_7{input} <-1-> S_8{output})
(S_9{phase = 1//2⋅π} <-1-> S_10{phase = 3//10⋅π})
(S_10{phase = 3//10⋅π} <-1-> S_11{phase = 1//3⋅π})
codecov[bot] commented 4 years ago

Codecov Report

Merging #51 into master will increase coverage by 0.02%. The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage   89.95%   89.98%   +0.02%     
==========================================
  Files          13       13              
  Lines        1225     1238      +13     
==========================================
+ Hits         1102     1114      +12     
- Misses        123      124       +1     
Impacted Files Coverage Δ
src/zx_diagram.jl 96.86% <93.33%> (-0.29%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b52116f...a0fbe70. Read the comment docs.

Roger-luo commented 4 years ago

I'm wondering what if the phase is not something like 0.5, but something like 0.31491304324324423423, will it still get converted? If so, I think call this function explicitly could be better, or have an option to use this.