Skip to content

Commit

Permalink
Use StableRNGs to get inputs for calculus tests
Browse files Browse the repository at this point in the history
Should prevent test failures due to changed random inputs between Julia
versions.
  • Loading branch information
johnomotani committed Feb 5, 2025
1 parent 0b45e3e commit df8adc7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions moment_kinetics/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
Expand All @@ -51,6 +52,7 @@ manufactured_solns_ext = ["Symbolics", "IfElse"]

[compat]
julia = "1.9.0"
StableRNGs = "1"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
1 change: 1 addition & 0 deletions moment_kinetics/src/moment_kinetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module moment_kinetics
export run_moment_kinetics

using MPI
using StableRNGs # Included so it can be imported conveniently into tests. Not used within moment_kinetics.
using StatsBase

# Include submodules from other source files
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/test/calculus_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function runtests()
end
end

rng = MersenneTwister(42)
rng = StableRNG(48)

@testset "finite_difference derivatives (4 argument), periodic" verbose=false begin
@testset "$nelement $ngrid" for nelement (1:5), ngrid (9:33)
Expand Down
1 change: 1 addition & 0 deletions moment_kinetics/test/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Included in test files as `include("setup.jl")`
##########################
using Test: @testset, @test
using moment_kinetics
using moment_kinetics.StableRNGs

module MKTestUtilities

Expand Down

0 comments on commit df8adc7

Please sign in to comment.