From e383450eb69410a89f4b15fd2ceddab50891abb5 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Mon, 9 Oct 2023 14:12:37 +0200 Subject: [PATCH 1/2] `rand(Pair{X, Y})` is now implemented in `Random` --- src/sampling.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sampling.jl b/src/sampling.jl index c0c3f4c..e3743fa 100644 --- a/src/sampling.jl +++ b/src/sampling.jl @@ -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} = From 552420f3e1aa50f5ede6b9d4483679abb5d7129e Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Mon, 9 Oct 2023 14:50:52 +0200 Subject: [PATCH 2/2] `rand(Tuple{...})` is now implemented in `Random` --- Project.toml | 2 +- src/sampling.jl | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4dee948..e6f7a0b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RandomExtensions" uuid = "fb686558-2515-59ef-acaa-46db3789a887" authors = ["Rafael Fourquet "] -version = "0.4.3" +version = "0.4.4" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/sampling.jl b/src/sampling.jl index e3743fa..3070eee 100644 --- a/src/sampling.jl +++ b/src/sampling.jl @@ -228,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)),