Skip to content

Commit 14c0293

Browse files
authored
Address flaky tests in limit_change (#17)
1 parent c9e4643 commit 14c0293

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/qualitative_networks.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,12 @@ end
307307

308308
"""
309309
$(TYPEDSIGNATURES)
310+
311+
Returns the limited value of `next_value` which is at most 1 different than `prev_value`.
312+
313+
It is also never negative, or larger than `N`.
310314
"""
311-
function limit_change(prev_value, next_value, N::Integer)
315+
function limit_change(prev_value::Integer, next_value::Integer, N::Integer)
312316
if next_value > prev_value
313317
limited_value = min(prev_value + 1, N)
314318
elseif next_value < prev_value

test/test-qn.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ end
6868
end
6969

7070
@testset "Async QN" begin
71-
for i = 1:100
72-
async_qn = aqn(network, N + i)
73-
step!(async_qn, 10)
74-
@test all(get_state(async_qn.model) .<= N + i)
71+
for N = 2:5 # a few different levels of N
72+
for _ = 1:100 # 100 different initializations
73+
async_qn = aqn(network, N)
74+
step!(async_qn, 100)
75+
@test all(get_state(async_qn.model) .<= N)
76+
end
7577
end
78+
7679
end
7780

7881
@testset "Get attractors" begin

0 commit comments

Comments
 (0)