From 6230b20ff09d2e5fc122d8479d790e862cab675c Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Sun, 2 Jun 2024 20:13:38 +0100 Subject: [PATCH] Allow int seed for clugen rng parameter --- src/main.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.jl b/src/main.jl index daea2e0..36ee2f4 100644 --- a/src/main.jl +++ b/src/main.jl @@ -111,7 +111,7 @@ arguments, described next. This parameter allows the user to specify a custom function for this purpose, which must follow [`CluGen.angle_deltas()`](@ref)'s signature. Alternatively, the user can specify an array of angle deltas directly. -- `rng`: A concrete instance of +- `rng`: The seed for the random number generator or an instance of [`AbstractRNG`](https://docs.julialang.org/en/v1/stdlib/Random/#Random.AbstractRNG) for reproducible runs. Alternatively, the user can set the global RNG seed with [`Random.seed!()`](https://docs.julialang.org/en/v1/stdlib/Random/#Random.seed!) @@ -184,7 +184,7 @@ function clugen( clucenters_fn::Union{<:Function,AbstractArray{<:Real}}=clucenters, llengths_fn::Union{<:Function,AbstractArray{<:Real,1}}=llengths, angle_deltas_fn::Union{<:Function,AbstractArray{<:Real,1}}=angle_deltas, - rng::AbstractRNG=Random.GLOBAL_RNG, + rng::Union{Integer,AbstractRNG}=Random.GLOBAL_RNG, )::NamedTuple # ############### # @@ -284,6 +284,11 @@ function clugen( ) end + # If the user specified rng as an int, create a proper rng object + if typeof(rng) <: Integer + rng = MersenneTwister(rng) + end + # Check that proj_dist_fn specifies a valid way for projecting points along # cluster-supporting lines i.e., either "norm" (default), "unif" or a # user-defined function