Skip to content

Commit

Permalink
use rng also for pop!
Browse files Browse the repository at this point in the history
  • Loading branch information
stecrotti committed Mar 4, 2024
1 parent 432eb88 commit 36b494c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MatrixProductBP"
uuid = "3d39929c-b583-45fa-b331-3f50b693a38a"
authors = ["stecrotti <[email protected]>"]
version = "0.2.0"
version = "0.3.0"

[deps]
CavityTools = "217fe2f1-7e3d-419f-9934-cd6900c2759a"
Expand All @@ -28,7 +28,7 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d"

[compat]
CavityTools = "0.2.1"
CavityTools = "0.3 - 1"
Distributions = "0.25"
IndexedGraphs = "0.3, 0.4"
InvertedIndices = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function simulate_queue_sis!(x, g, P0, λ, μ, T;
end
end
while !isempty(Q)
i, Δt = pop!(Q)
i, Δt = pop!(Q; rng)
t += Δt
t > T && break
x[i] ⊻= true
Expand Down
9 changes: 5 additions & 4 deletions test/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
@test all(all(all(-1 x.val 1 for x in cit) for cit in ci) for ci in c)
end

# just check that it runs without errors
@testset "sampling - Gillespie" begin
@testset "sampling - Gillespie - reproducibility" begin
av, va = continuous_sis_sampler(sis, T, λ, ρ; nsamples = 10^4, sites=1,
discard_dead_epidemics=true)
@test true
discard_dead_epidemics=true, rng = MersenneTwister(0))
av2, va2 = continuous_sis_sampler(sis, T, λ, ρ; nsamples = 10^4, sites=1,
discard_dead_epidemics=true, rng = MersenneTwister(0))
@test av2 == av && va2 == va
end
end

2 comments on commit 36b494c

@stecrotti
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 created: JuliaRegistries/General/102260

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.3.0 -m "<description of version>" 36b494c4c008f2d62469a3e6172c52b8277a1fd8
git push origin v0.3.0

Please sign in to comment.