Skip to content

Commit

Permalink
Allow int seed for clugen rng parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nunofachada committed Jun 2, 2024
1 parent 5e1dcb8 commit 6230b20
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down Expand Up @@ -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

# ############### #
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6230b20

Please sign in to comment.