Browse Source

Road to 100% Code Coverage (#19)

* Added a couple more tests to make up for missing code coverage

* Added test for base iterate

* Added some more tests

* Added some more tests

* last test addition

* Version bump
pull/21/head v0.4.1
Micah Halter 1 year ago committed by GitHub
parent
commit
a17dac529d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Project.toml
  2. 1
      src/Types.jl
  3. 38
      test/types.jl

2
Project.toml

@ -2,7 +2,7 @@ name = "AlgebraicPetri" @@ -2,7 +2,7 @@ name = "AlgebraicPetri"
uuid = "4f99eebe-17bf-4e98-b6a1-2c4f205a959b"
license = "MIT"
authors = ["Micah Halter <micah@mehalter.com>"]
version = "0.4.0"
version = "0.4.1"
[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"

1
src/Types.jl

@ -213,7 +213,6 @@ sname(p::Union{AbstractLabelledPetriNet, AbstractLabelledReactionNet},s) = subpa @@ -213,7 +213,6 @@ sname(p::Union{AbstractLabelledPetriNet, AbstractLabelledReactionNet},s) = subpa
tname(p::Union{AbstractLabelledPetriNet, AbstractLabelledReactionNet},t) = subpart(p,t,:tname)
vectorfield(pn::Union{AbstractLabelledPetriNet,AbstractLabelledReactionNet}) = begin
println("HELLO")
tm = TransitionMatrices(pn)
dt_T = transpose(tm.output - tm.input)
f(du,u,p,t) = begin

38
test/types.jl

@ -1,19 +1,47 @@ @@ -1,19 +1,47 @@
sir_petri = PetriNet(3, ((1, 2), (2, 2)), (2, 3))
sir_lpetri = LabelledPetriNet([:S, :I, :R], :inf=>((:S, :I), (:I, :I)), :rec=>(:I, :R))
sir_rxn = ReactionNet{Number, Int}([990, 10, 0], (.0001)=>((1, 2)=>(2,2)), (.25)=>(2=>3))
sir_lrxn = LabelledReactionNet{Number, Int}((:S=>990, :I=>10, :R=>0), (:inf, .0001)=>((:S, :I)=>(:I,:I)), (:rec, .25)=>(:I=>:R))
β(u,t) = 1 / sum(u)
γ = .25
sir_rxn = ReactionNet{Function, Int}([990, 10, 0], (β)=>((1, 2)=>(2,2)), (t->γ)=>(2=>3))
sir_lrxn = LabelledReactionNet{Number, Int}((:S=>990, :I=>10, :R=>0), (:inf, .001)=>((:S, :I)=>(:I,:I)), (:rec, .25)=>(:I=>:R))
sir_tpetri= PetriNet(TransitionMatrices(sir_petri))
next = iterate(PetriCospanOb(5))
while next !== nothing
(i, state) = next
@test i == state && i <= 5
global next = iterate(PetriCospanOb(5), state)
end
pf = id(PetriFunctor)
@test pf.F(FinSet(3))(sir_petri)
@test !(pf.F(FinSet(5))(sir_petri))
@test sir_tpetri == sir_petri
@test Petri.Model(sir_petri) == Petri.Model(sir_rxn)
@test Petri.Model(sir_lpetri) == Petri.Model(sir_lrxn)
@test concentration(sir_rxn, 1) == 990
@test rate(sir_rxn, 1) == β
@test concentrations(sir_rxn) == [990, 10, 0]
@test rates(sir_rxn) == [.0001, .25]
@test typeof(rates(sir_rxn)) <: Array{Function}
@test concentrations(sir_lrxn) == LVector(S=990, I=10, R=0)
@test rates(sir_lrxn) == LVector(inf=.0001, rec=.25)
@test rates(sir_lrxn) == LVector(inf=.001, rec=.25)
du = [0.0, 0.0, 0.0]
out = vectorfield(sir_rxn)(du, concentrations(sir_rxn), rates(sir_rxn), 0.01)
@test out[1] -9.9
@test out[2] 7.4
@test out[3] 2.5
du = LVector(S=0.0, I=0.0, R=0.0)
out = vectorfield(sir_lrxn)(du, concentrations(sir_lrxn), rates(sir_lrxn), 0.01)
@test out.S -9.9
@test out.I 7.4
@test out.R 2.5
@test ns(sir_petri) == 3
add_species!(sir_petri)
@ -31,4 +59,4 @@ add_input!(sir_petri, 4, 4) @@ -31,4 +59,4 @@ add_input!(sir_petri, 4, 4)
add_output!(sir_petri, 4, 3)
@test ni(sir_petri) == 5
@test no(sir_petri) == 5
@test sir_petri == PetriNet(4, ((1, 2), (2, 2)), (2, 3), (1, 4), (4, 3))
@test sir_petri == PetriNet(4, ((1, 2), (2, 2)), (2, 3), (1, 4), (4, 3))
Loading…
Cancel
Save