Skip to content

Commit

Permalink
Updated with threshold tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darsnack committed Aug 9, 2020
1 parent 1720948 commit 2d9a245
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions test/threshold-test.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
@testset "Threshold Poisson" begin
for rng in [nothing, Random.MersenneTwister()]
baserate = rand()
theta = rand()
deltav = rand()
v = rand()
t = 1
dt = 1
threshold = isnothing(rng) ? Threshold.Poisson(baserate, theta, deltav) : Threshold.Poisson(baserate, theta, deltav; rng = rng)
rho = baserate * exp((v - theta) / deltav)
if rand(threshold.rng) < rho * dt
@test evaluate!(threshold,t,v) == t
else
@test evaluate!(threshold,t,v) == zero(t)
end
end
end
# @testset "Threshold Poisson" begin
# for rng in [nothing, Random.MersenneTwister()]
# baserate = rand()
# theta = rand()
# deltav = rand()
# v = rand()
# t = 1
# dt = 1
# threshold = isnothing(rng) ? Threshold.Poisson(baserate, theta, deltav) : Threshold.Poisson(baserate, theta, deltav; rng = rng)
# rho = baserate * exp((v - theta) / deltav)
# if rand(threshold.rng) < rho * dt
# @test evaluate!(threshold,t,v) == t
# else
# @test evaluate!(threshold,t,v) == zero(t)
# end
# end
# end

@testset "Threshold Ideal" begin
let v = rand()
for vth in [v .+ (1-v)*(1 .- rand()), v * rand()] # Setting the (v,1] and [0,v) bound for vth
t = rand()
threshold = Threshold.Ideal(vth)
if v < threshold.vth
@test evaluate!(threshold, t, v) == zero(t)
else
@test evaluate!(threshold, t, v) == t
end
v = rand()
for vth in [v .+ (1-v)*(1 .- rand()), v * rand()] # Setting the (v,1] and [0,v) bound for vth
t = rand()
threshold = Threshold.Ideal(vth)
if v < threshold.vth
@test evaluate!(threshold, t, v) == zero(t)
else
@test evaluate!(threshold, t, v) == t
end
end
end
end

2 comments on commit 2d9a245

@darsnack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/19247

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 2d9a2451c9a0c46608f7afaf9bb9ff1b6e8f31f4
git push origin v0.1.0

Please sign in to comment.