diff --git a/src/onset.jl b/src/onset.jl index 5e7d364a..29530fce 100644 --- a/src/onset.jl +++ b/src/onset.jl @@ -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 diff --git a/test/onset.jl b/test/onset.jl index 7d46908f..9865a32c 100644 --- a/test/onset.jl +++ b/test/onset.jl @@ -46,7 +46,7 @@ @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( @@ -54,7 +54,11 @@ 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