diff --git a/experimental/AlgebraicStatistics/src/PhylogeneticModels.jl b/experimental/AlgebraicStatistics/src/PhylogeneticModels.jl index db852ff54d47..dd21b0b410b6 100644 --- a/experimental/AlgebraicStatistics/src/PhylogeneticModels.jl +++ b/experimental/AlgebraicStatistics/src/PhylogeneticModels.jl @@ -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 @@ -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 @@ -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 diff --git a/experimental/AlgebraicStatistics/test/runtests.jl b/experimental/AlgebraicStatistics/test/runtests.jl index 228f0cb929b0..6eaa95ca0a0b 100644 --- a/experimental/AlgebraicStatistics/test/runtests.jl +++ b/experimental/AlgebraicStatistics/test/runtests.jl @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 @@ -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