Skip to content

Commit da8e83a

Browse files
authored
Use StableRNGs.jl in tests (#294)
1 parent 648d3c6 commit da8e83a

12 files changed

+29
-29
lines changed

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
PairPlots = "43a3c2be-4208-490b-832a-a21dcd55d7da"
1212
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1313
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
14+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
1415
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1516
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1617
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

test/data/eigenanalysis-1.png

-45.7 KB
Loading

test/data/eigenanalysis-2.png

-73.1 KB
Loading

test/data/projectionpursuit-1.png

-65.8 KB
Loading

test/data/projectionpursuit-2.png

-134 KB
Loading

test/data/projectionpursuit-3.png

-53 KB
Loading

test/runtests.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ using StatsBase
1010
using Statistics
1111
using DelimitedFiles
1212
using ReferenceTests
13+
using StableRNGs
1314
using PairPlots
1415
using ImageIO
15-
using Random
1616
using Test
1717

1818
import CairoMakie as Mke
@@ -30,9 +30,8 @@ islinux = Sys.islinux()
3030
visualtests = !isCI || (isCI && islinux)
3131
datadir = joinpath(@__DIR__, "data")
3232

33-
# using MersenneTwister for backward
34-
# compatibility with old Julia versions
35-
rng = MersenneTwister(42)
33+
# using StableRNG for compatibility between Julia versions
34+
rng = StableRNG(42)
3635

3736
# for functor tests in Functional testset
3837
struct Polynomial{T<:Real}

test/shows.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
├─ weights: nothing
144144
├─ replace: false
145145
├─ ordered: true
146-
└─ rng: TaskLocalRNG()"""
146+
└─ rng: Random.TaskLocalRNG()"""
147147
end
148148

149149
@testset "Filter" begin

test/transforms/eigenanalysis.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
@test TT.parameters(EigenAnalysis(:V)) == (proj=:V, maxdim=nothing, pratio=1.0)
33

44
# PCA test
5-
x = rand(Normal(0, 10), 1500)
6-
y = x + rand(Normal(0, 2), 1500)
5+
x = rand(rng, Normal(0, 10), 1500)
6+
y = x + rand(rng, Normal(0, 2), 1500)
77
t = Table(; x, y)
88
T = EigenAnalysis(:V)
99
n, c = apply(T, t)
@@ -16,8 +16,8 @@
1616
@test Tables.matrix(t) Tables.matrix(tₒ)
1717

1818
# DRS test
19-
x = rand(Normal(0, 10), 1500)
20-
y = x + rand(Normal(0, 2), 1500)
19+
x = rand(rng, Normal(0, 10), 1500)
20+
y = x + rand(rng, Normal(0, 2), 1500)
2121
t = Table(; x, y)
2222
T = EigenAnalysis(:VD)
2323
n, c = apply(T, t)
@@ -30,8 +30,8 @@
3030
@test Tables.matrix(t) Tables.matrix(tₒ)
3131

3232
# SDS test
33-
x = rand(Normal(0, 10), 1500)
34-
y = x + rand(Normal(0, 2), 1500)
33+
x = rand(rng, Normal(0, 10), 1500)
34+
y = x + rand(rng, Normal(0, 2), 1500)
3535
t = Table(; x, y)
3636
T = EigenAnalysis(:VDV)
3737
n, c = apply(T, t)
@@ -73,8 +73,8 @@
7373
end
7474

7575
# row table
76-
x = rand(Normal(0, 10), 1500)
77-
y = x + rand(Normal(0, 2), 1500)
76+
x = rand(rng, Normal(0, 10), 1500)
77+
y = x + rand(rng, Normal(0, 2), 1500)
7878
t = Table(; x, y)
7979
rt = Tables.rowtable(t)
8080
T = EigenAnalysis(:V)
@@ -84,9 +84,9 @@
8484
@test Tables.matrix(rt) Tables.matrix(rtₒ)
8585

8686
# maxdim
87-
x = randn(1000)
88-
y = x + randn(1000)
89-
z = 2x - y + randn(1000)
87+
x = randn(rng, 1000)
88+
y = x + randn(rng, 1000)
89+
z = 2x - y + randn(rng, 1000)
9090
t = Table(; x, y, z)
9191

9292
# PCA

test/transforms/filter.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
@test Tables.isrowtable(n)
105105

106106
# performance tests
107-
trng = MersenneTwister(2) # test rng
107+
trng = StableRNG(2) # test rng
108108
x = rand(trng, 100_000)
109109
y = rand(trng, 100_000)
110110
c = CoDaArray((a=rand(trng, 100_000), b=rand(trng, 100_000), c=rand(trng, 100_000)))

0 commit comments

Comments
 (0)