Skip to content

Commit

Permalink
Set minimum for first onset to 1 (not 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschepers committed Feb 26, 2024
1 parent 5b65d98 commit 5128e3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/onset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function simulate_onsets(rng, onset::AbstractOnset, simulation::Simulation)
onsets = simulate_interonset_distances(rng, onset, simulation.design)

# accumulate them
onsets_accum = accumulate(+, onsets, dims = 1)
onsets_accum = accumulate(+, onsets, dims = 1, init = 1)

return onsets_accum
end
6 changes: 5 additions & 1 deletion test/onset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@
@test minimum(rand_vec) >= 0
end
@testset "sim_onsets" begin
# test accumulate always increasing

uniform_onset = UniformOnset(; offset = 0, width = 50)

accumulated_onset = UnfoldSim.simulate_onsets(
StableRNG(1),
uniform_onset,
gen_debug_simulation(onset = uniform_onset),
)
# test accumulate always increasing
@test all(diff(accumulated_onset, dims = 1) .>= 0)

# test that the first onset is at >=1 (not 0)
@test accumulated_onset[1] >= 1
end

end

0 comments on commit 5128e3f

Please sign in to comment.