bsc-quantic / Tenet.jl

Composable Tensor Network library in Julia
https://bsc-quantic.github.io/Tenet.jl/
Apache License 2.0
17 stars 1 forks source link

Fix plots for `TensorNetworks` with hyperedges #31

Closed jofrevalles closed 1 year ago

jofrevalles commented 1 year ago

From issue #21

Summary

In this PR we fix the plot functions: now these can plot TensorNetworks with hyperedges. The hyperedges are visualized with a grey diamond-shaped COPY tensor, with grey indices coming from it.

Example

julia> using Tenet
julia> using GLMakie
julia> using Makie
julia> tn = TensorNetwork([Tensor(rand([2, 2, 2]...), tuple([:i, :c, :k]...)), Tensor(rand([2, 2, 2, 2]...), tuple([:i, :k, :s, :p]...)), Tensor(rand([2, 2, 2]...), tuple([:i, :s, :c]...)), Tensor(rand([2, 2]...), tuple([:p, :t]...))])
TensorNetwork{Arbitrary}(#tensors=4, #inds=6)
julia> plot(tn; labels=true)
(Scene (800px, 600px):
  0 Plots
  1 Child Scene:
    └ Scene (800px, 600px), Axis (1 plots), Combined{GraphMakie.graphplot, Tuple{Graphs.SimpleGraphs.SimpleGraph{Int64}}})
julia> [tensor.labels for tensor in tn.tensors]
4-element Vector{Tuple{Symbol, Symbol, Vararg{Symbol}}}:
 (:i, :c, :k)
 (:i, :k, :s, :p)
 (:i, :s, :c)
 (:p, :t)

Screenshot from 2023-02-23 16-51-13

jofrevalles commented 1 year ago

PD: Still working in 3D.

image

codecov[bot] commented 1 year ago

Codecov Report

Merging #31 (ab41ce2) into master (c501fe0) will increase coverage by 6.86%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #31      +/-   ##
==========================================
+ Coverage   67.74%   74.60%   +6.86%     
==========================================
  Files           9       10       +1     
  Lines         496      508      +12     
==========================================
+ Hits          336      379      +43     
+ Misses        160      129      -31     
Impacted Files Coverage Δ
src/Transformations.jl 100.00% <100.00%> (+36.00%) :arrow_up:
src/Quantum.jl 65.78% <0.00%> (-8.84%) :arrow_down:
src/Tenet.jl 100.00% <0.00%> (ø)
src/Differentiation.jl 58.97% <0.00%> (ø)
src/MatrixProductState.jl 76.31% <0.00%> (+7.26%) :arrow_up:
src/Tensor.jl 83.14% <0.00%> (+29.69%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

jofrevalles commented 1 year ago

Okey, now it looks something like this: image