Skip to content

Commit 93d8ae5

Browse files
authored
Ensure stability of rand between Julia versions (#196)
1 parent dfae9eb commit 93d8ae5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

test/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
33
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
44
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
55
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
6+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
67
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
78
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using TestParticle, OrdinaryDiffEq, StaticArrays, Random
1+
using TestParticle, OrdinaryDiffEq, StaticArrays
22
using TestParticle: Field, qᵢ, mᵢ, qₑ, mₑ, c, guiding_center
33
using Meshes: CartesianGrid
4+
using Random, StableRNGs
45
using Test
56

67
"Initial state perturbation for EnsembleProblem."
78
function prob_func(prob, i, repeat)
8-
remake(prob, u0=rand(MersenneTwister(i))*prob.u0)
9+
remake(prob, u0=rand(StableRNG(i))*prob.u0)
910
end
1011

1112
function prob_func_boris_mutable(prob, i, repeat)
@@ -127,7 +128,7 @@ end
127128

128129
x = getindex.(sol.u[10].u, 1)
129130

130-
@test x[7] 0.09615629718624641 rtol=1e-6
131+
@test x[7] 0.08230289216655486 rtol=1e-6
131132

132133
stateinit = SA[x0..., u0...]
133134
tspan = (0.0, 1.0)

0 commit comments

Comments
 (0)