Skip to content

Commit

Permalink
Changed type of root_distribution entries to QQ in all models. Made t…
Browse files Browse the repository at this point in the history
…ests more elaborate. Changed testing for graphs so that false negatives are avoided.
  • Loading branch information
mariusneu committed Sep 27, 2024
1 parent 8723fc9 commit dd43585
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions experimental/AlgebraicStatistics/src/PhylogeneticModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function cavender_farris_neyman_model(graph::Graph{Directed})
ne = n_edges(graph)
R, list_a, list_b = polynomial_ring(QQ, :a => 1:ne, :b => 1:ne; cached=false)

root_distr = repeat([1//ns], outer = ns)
root_distr = repeat([QQ(1,ns)], outer = ns)
edgs = sort_edges(graph)
matrices = Dict{Edge, MatElem}(e => matrix(R, [
a b
Expand Down Expand Up @@ -332,7 +332,7 @@ function kimura2_model(graph::Graph{Directed})
ne = n_edges(graph)
R, list_a, list_b, list_c = polynomial_ring(QQ, :a => 1:ne, :b => 1:ne, :c => 1:ne; cached=false)

root_distr = repeat([1//ns], outer = ns)
root_distr = repeat([QQ(1,ns)], outer = ns)
edgs = sort_edges(graph)
matrices = Dict{Edge, MatElem}(e => matrix(R, [
a b c b
Expand Down Expand Up @@ -375,7 +375,7 @@ function kimura3_model(graph::Graph{Directed})
ne = n_edges(graph)
R, list_a, list_b , list_c, list_d= polynomial_ring(QQ, :a => 1:ne, :b => 1:ne, :c => 1:ne, :d => 1:ne; cached=false)

root_distr = repeat([1//ns], outer = ns)
root_distr = repeat([QQ(1,ns)], outer = ns)
edgs = sort_edges(graph)
matrices = Dict{Edge, MatElem}(e => matrix(R, [
a b c d
Expand Down
32 changes: 22 additions & 10 deletions experimental/AlgebraicStatistics/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end
@testset "Graphical Models tests" begin

tree = graph_from_edges(Directed,[[4,1],[4,2],[4,3]])
group_based_components = [number_states, probability_ring, root_distribution, transition_matrices, fourier_ring, fourier_parameters, group_of_model]

@testset "cavender_farris_neyman_model" begin
model = cavender_farris_neyman_model(tree)
Expand Down Expand Up @@ -43,8 +44,10 @@ end
# serialization working?
mktempdir() do path
test_save_load_roundtrip(path, model) do loaded
@test model == loaded
@test probability_map(model) == probability_map(loaded)
for component in group_based_components
@test component(model) == component(loaded)
@test incidence_matrix(graph(model)) == incidence_matrix(graph(loaded))
end
end
end
end
Expand Down Expand Up @@ -76,8 +79,10 @@ end
# serialization working?
mktempdir() do path
test_save_load_roundtrip(path, model) do loaded
@test model == loaded
@test probability_map(model) == probability_map(loaded)
for component in group_based_components
@test component(model) == component(loaded)
@test incidence_matrix(graph(model)) == incidence_matrix(graph(loaded))
end
end
end
end
Expand Down Expand Up @@ -109,8 +114,10 @@ end
# serialization working?
mktempdir() do path
test_save_load_roundtrip(path, model) do loaded
@test model == loaded
@test probability_map(model) == probability_map(loaded)
for component in group_based_components
@test component(model) == component(loaded)
@test incidence_matrix(graph(model)) == incidence_matrix(graph(loaded))
end
end
end
end
Expand Down Expand Up @@ -142,8 +149,10 @@ end
# serialization working?
mktempdir() do path
test_save_load_roundtrip(path, model) do loaded
@test model == loaded
@test probability_map(model) == probability_map(loaded)
for component in group_based_components
@test component(model) == component(loaded)
@test incidence_matrix(graph(model)) == incidence_matrix(graph(loaded))
end
end
end
end
Expand All @@ -166,10 +175,13 @@ end
# generators of the polynomial ring
@test length(gens(model.prob_ring)) == 148
# serialization working?
gmm_components = [number_states, probability_ring, root_distribution, transition_matrices]
mktempdir() do path
test_save_load_roundtrip(path, model) do loaded
@test model == loaded
@test probability_map(model) == probability_map(loaded)
for component in gmm_components
@test component(model) == component(loaded)
@test incidence_matrix(graph(model)) == incidence_matrix(graph(loaded))
end
end
end
end
Expand Down

0 comments on commit dd43585

Please sign in to comment.