Skip to content

fix model printing #53

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

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ $(TYPEDEF)

### Fields
* `nvars` is the number of variables,
* `nclique` is the number of cliques,
* `cards` is a vector of cardinalities for variables,
* `factors` is a vector of factors,
"""
struct UAIModel{ET, FT <: Factor{ET}}
nvars::Int
nclique::Int
cards::Vector{Int}
factors::Vector{FT}
end

Base.show(io::IO, ::MIME"text/plain", uai::UAIModel) = Base.show(io, uai)
function Base.show(io::IO, uai::UAIModel)
println(io, "UAIModel(nvars = $(uai.nvars), nclique = $(uai.nclique))")
println(io, " variables :")
println(io, "UAIModel(nvars = $(uai.nvars), nfactors = $(length(uai.factors))")
println(io, " cards : $(uai.cards)")
println(io, " factors : ")
for (k, f) in enumerate(uai.factors)
print(io, " $(summary(f))")
Expand Down
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function read_model_from_string(str::AbstractString; factor_eltype = Float64)::U
# Wrap the tables with their corresponding scopes in an array of Factor type
factors = [Factor{factor_eltype, length(scope)}(Tuple(scope), table) for (scope, table) in zip(scopes_sorted, tables_sorted)]

return UAIModel(nvars, ntables, cards, factors)
return UAIModel(nvars, cards, factors)
end

"""
Expand Down Expand Up @@ -304,4 +304,4 @@ function get_artifact_path(artifact_name::String)
Pkg.ensure_artifact_installed(artifact_name, artifact_toml)
artifact_hash = Pkg.Artifacts.artifact_hash(artifact_name, artifact_toml)
return Pkg.Artifacts.artifact_path(artifact_hash)
end
end