diff --git a/src/qualitative_networks.jl b/src/qualitative_networks.jl index fa8c18e..f2c2e3c 100644 --- a/src/qualitative_networks.jl +++ b/src/qualitative_networks.jl @@ -307,8 +307,12 @@ end """ $(TYPEDSIGNATURES) + +Returns the limited value of `next_value` which is at most 1 different than `prev_value`. + +It is also never negative, or larger than `N`. """ -function limit_change(prev_value, next_value, N::Integer) +function limit_change(prev_value::Integer, next_value::Integer, N::Integer) if next_value > prev_value limited_value = min(prev_value + 1, N) elseif next_value < prev_value diff --git a/test/test-qn.jl b/test/test-qn.jl index b223cd9..b7e7fcd 100644 --- a/test/test-qn.jl +++ b/test/test-qn.jl @@ -68,11 +68,14 @@ end end @testset "Async QN" begin - for i = 1:100 - async_qn = aqn(network, N + i) - step!(async_qn, 10) - @test all(get_state(async_qn.model) .<= N + i) + for N = 2:5 # a few different levels of N + for _ = 1:100 # 100 different initializations + async_qn = aqn(network, N) + step!(async_qn, 100) + @test all(get_state(async_qn.model) .<= N) + end end + end @testset "Get attractors" begin