Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RandomExtensions"
uuid = "fb686558-2515-59ef-acaa-46db3789a887"
authors = ["Rafael Fourquet <fourquet.rafael@gmail.com>"]
version = "0.4.3"
version = "0.4.4"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
17 changes: 15 additions & 2 deletions src/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ rand(rng::AbstractRNG, sp::SamplerTag{Cont{T}}) where {T<:Union{Pair,Complex}} =
#### additional convenience methods

# rand(Pair{A,B}) => rand(make(Pair{A,B}, A, B))
Sampler(::Type{RNG}, ::Type{Pair{A,B}}, n::Repetition) where {RNG<:AbstractRNG,A,B} =
Sampler(RNG, make(Pair{A,B}, A, B), n)
if VERSION < v"1.11.0-DEV.618" # now implemented in `Random`
Sampler(::Type{RNG}, ::Type{Pair{A,B}}, n::Repetition) where {RNG<:AbstractRNG,A,B} =
Sampler(RNG, make(Pair{A,B}, A, B), n)
end

# rand(make(Complex, x)) => rand(make(Complex, x, x))
Sampler(::Type{RNG}, u::Make1{T}, n::Repetition) where {RNG<:AbstractRNG,T<:Complex} =
Expand All @@ -226,6 +228,17 @@ Sampler(::Type{RNG}, ::Type{T}, n::Repetition
) where {RNG<:AbstractRNG,T<:Union{Tuple,NamedTuple}} =
Sampler(RNG, make(T), n)

if VERSION >= v"1.11.0-DEV.573"
# now `Random` implements `rand(Tuple{...})`, so be more specific for
# special stuff still not implemented by `Random`
# TODO: we should probably remove this
Sampler(::Type{RNG}, ::Type{Tuple}, n::Repetition) where {RNG <: AbstractRNG} =
Sampler(RNG, make(Tuple), n)

Sampler(::Type{RNG}, ::Type{NTuple{N}}, n::Repetition) where {RNG <: AbstractRNG, N} =
Sampler(RNG, make(NTuple{N}), n)
end

#### make

# implement make(Tuple, S1, S2...), e.g. for rand(make(Tuple, Int, 1:3)),
Expand Down