From 5307ffcb547771a788cd176da6264e306bcb362d Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Sun, 2 Jun 2024 22:51:20 +0100 Subject: [PATCH] Add test for using Integer seed in clugen() --- test/clugen.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/clugen.jl b/test/clugen.jl index a18155e..98885af 100644 --- a/test/clugen.jl +++ b/test/clugen.jl @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 Nuno Fachada and contributors +# Copyright (c) 2020-2024 Nuno Fachada and contributors # Distributed under the MIT License (See accompanying file LICENSE or copy # at http://opensource.org/licenses/MIT) @@ -224,16 +224,15 @@ end @testset """Reproducibility: - seed=$(Int(rng.seed[1])) - """ for rng in rngs[1:(end - 1)] - # Get a seed - seed = Int(rng.seed[1]) - # Reseed PRNG, run clugen and get results - Random.seed!(seed) - r1 = @test_nowarn clugen(2, 4, 100, [1, 1], 0.01, [10, 10], 5, 1, 0.1) + seed=$(seed) + """ for seed in seeds[1:2], use_rng in (true, false) + local seed_or_rng::Union{Integer,AbstractRNG} + # Create a PRNG with the specified seed, run clugen and get results + seed_or_rng = use_rng ? MersenneTwister(seed) : seed + r1 = @test_nowarn clugen(2, 4, 100, [1, 1], 0.01, [10, 10], 5, 1, 0.1, rng=seed_or_rng) # Do it again - Random.seed!(seed) - r2 = @test_nowarn clugen(2, 4, 100, [1, 1], 0.01, [10, 10], 5, 1, 0.1) + seed_or_rng = use_rng ? MersenneTwister(seed) : seed + r2 = @test_nowarn clugen(2, 4, 100, [1, 1], 0.01, [10, 10], 5, 1, 0.1, rng=seed_or_rng) # Check that results are exactly the same @test all(r1.points .== r2.points) @test all(r1.clusters .== r2.clusters)