Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BayesNets.plot error: no method matching plot #139

Closed
SEICS opened this issue Jul 6, 2022 · 2 comments
Closed

BayesNets.plot error: no method matching plot #139

SEICS opened this issue Jul 6, 2022 · 2 comments

Comments

@SEICS
Copy link

SEICS commented Jul 6, 2022

Hi,

I am new to BayesNets.jl and I am really interested in this new PPL and would like to use it for my project. When I went through some tutorials, I found that BayesNets.plot doesn't work on neither my Jupyter notebook nor my Julia console. I have installed all packages specified at below.

The code for reproducing error from BayesNets.jl docs (Section: representation):

using Random
Random.seed!(0) # seed the random number generator to 0, for a reproducible demonstration
using BayesNets
using TikzGraphs # required to plot tex-formatted graphs (recommended), otherwise GraphPlot.jl is used
using TikzPictures
bn = BayesNet()
push!(bn, StaticCPD(:a, Normal(1.0)))
push!(bn, LinearGaussianCPD(:b, [:a], [2.0], 3.0, 1.0))
plot = BayesNets.plot(bn)
TikzPictures.save(SVG("plot1"), plot)

Expected output:
Screenshot 2022-07-06 at 16 38 01

The corresponding error message:

ERROR: MethodError: no method matching plot(::LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}; layout=TikzGraphs.Layouts.Layered(-1, -1), labels=AbstractString["a", "b"])
Closest candidates are:
  plot(::Any, ::TikzGraphs.Layouts.Layout) at ~/.julia/packages/TikzGraphs/wTGtk/src/TikzGraphs.jl:44 got unsupported keyword arguments "layout", "labels"
  plot(::Any, ::TikzGraphs.Layouts.Layout, ::Vector{T}; args...) where T<:AbstractString at ~/.julia/packages/TikzGraphs/wTGtk/src/TikzGraphs.jl:44
  plot(::Any, ::Vector{T}; args...) where T<:AbstractString at ~/.julia/packages/TikzGraphs/wTGtk/src/TikzGraphs.jl:45
  ...
Stacktrace:
 [1] plot(g::LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, labels::Vector{AbstractString}; args::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ TikzGraphs ~/.julia/packages/TikzGraphs/wTGtk/src/TikzGraphs.jl:45
 [2] plot(g::LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, labels::Vector{AbstractString})
   @ TikzGraphs ~/.julia/packages/TikzGraphs/wTGtk/src/TikzGraphs.jl:45
 [3] plot(dag::LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, nodelabel::Vector{AbstractString})
   @ BayesNets ~/.julia/packages/BayesNets/yBu0u/src/io.jl:20
 [4] plot(bn::BayesNet{CPD})
   @ BayesNets ~/.julia/packages/BayesNets/yBu0u/src/io.jl:35
 [5] top-level scope
   @ REPL[17]:1

Can anyone help me with this? I don't if this's a bug or I did sth. wrong (e.g., missing package installation). Plot method is a really nice feature to have insights to Bayesian Networks' structure and it's helpful during the implementation. Really appreciated!

@mossr
Copy link
Member

mossr commented Jul 6, 2022

This is an (sneaky) issue between TikzGraphs use of Graphs.jl (replacement for LightGraphs.jl) and BayesNets.jl still using LightGraphs.jl.

This is already fixed on the master branch, so I'll release a new BayesNets.jl version today so you can officially get the fix.

@mossr
Copy link
Member

mossr commented Jul 6, 2022

All set. @SEICS update your local BayesNets package and this should be fixed:

] up BayesNets

@mossr mossr closed this as completed Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants