Skip to content

Commit

Permalink
more information error message, fix #147
Browse files Browse the repository at this point in the history
  • Loading branch information
cecileane committed Oct 26, 2020
1 parent 6b0e0e0 commit 13aca07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/substitutionModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ struct EqualRatesSubstitutionModel{T} <: TraitSubstitutionModel{T}
eigeninfo::Vector{Float64}
function EqualRatesSubstitutionModel{T}(k::Int, rate::Vector{Float64},
label::Vector{T}, eigeninfo::Vector{Float64}) where T
k >= 2 || error("parameter k must be greater than or equal to 2")
@assert length(label)==k "incorrect number of labels: k=$k, labels: $label"
@assert k >= 2 "need k >= 2 category labels. labels: $label"
@assert length(rate)==1 "rate must be a vector of length 1"
rate[1] > 0 || error("parameter α (rate) must be positive")
@assert length(label)==k "label vector of incorrect length"
new(k, rate, label, eigeninfo)
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/test_traitLikDiscrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ m2 = EqualRatesSubstitutionModel(4, 3.0);
@test PhyloNetworks.nparams(m2)==1
m2 = EqualRatesSubstitutionModel(4, 3.0, ["S1","S2","S3","S4"]);
@test_logs show(devnull, m2)
@test_throws AssertionError PhyloNetworks.EqualRatesSubstitutionModel(2, 0.001, ["abs"]);
@test_throws AssertionError PhyloNetworks.EqualRatesSubstitutionModel(1, 0.001, ["abs"]);
m3 = TwoBinaryTraitSubstitutionModel([2.0,1.2,1.1,2.2,1.0,3.1,2.0,1.1],
["carnivory", "noncarnivory", "wet", "dry"]);
@test_logs show(devnull, m3)
Expand Down

0 comments on commit 13aca07

Please sign in to comment.