@@ -26,6 +26,7 @@ rand(rng::AbstractRNG, s::Sampleable, dim1::Int, moredims::Int...) =
2626
2727# default fallback (redefined for univariate distributions)
2828function rand (rng:: AbstractRNG , s:: Sampleable{<:ArrayLikeVariate} )
29+ Base. depwarn (" Please implement `rand(rng::AbstractRNG, s::$(typeof (s)) )`. The default fallback will be removed" , :rand )
2930 return @inbounds rand! (rng, s, Array {eltype(s)} (undef, size (s)))
3031end
3132
4546
4647# this is a workaround for sampleables that incorrectly base `eltype` on the parameters
4748function rand (rng:: AbstractRNG , s:: Sampleable{<:ArrayLikeVariate,Continuous} )
48- return @inbounds rand! (rng, sampler (s), Array {float(eltype(s))} (undef, size (s)))
49+ Base. depwarn (" Please implement `rand(rng::AbstractRNG, s::$(typeof (s)) `. The default fallback will be removed" , :rand )
50+ return @inbounds rand! (rng, s, Array {float(eltype(s))} (undef, size (s)))
4951end
5052
5153"""
@@ -63,16 +65,14 @@ form as specified above. The rules are summarized as below:
6365"""
6466function rand! end
6567Base. @propagate_inbounds rand! (s:: Sampleable , X:: AbstractArray ) = rand! (default_rng (), s, X)
66- Base. @propagate_inbounds function rand! (rng:: AbstractRNG , s:: Sampleable , X:: AbstractArray )
67- return _rand! (rng, s, X)
68- end
6968
7069# default definitions for arraylike variates
7170@inline function rand! (
7271 rng:: AbstractRNG ,
7372 s:: Sampleable{ArrayLikeVariate{N}} ,
7473 x:: AbstractArray{<:Real,N} ,
7574) where {N}
75+ Base. depwarn (" Please implement `Random.rand!(rng::Random.AbstractRNG, s::$(typeof (s)) , x::AbstractArray{<:Real,$N })`, the default fallback will be removed." , :rand! )
7676 @boundscheck begin
7777 size (x) == size (s) || throw (DimensionMismatch (" inconsistent array dimensions" ))
7878 end
9393 throw (DimensionMismatch (" inconsistent array dimensions" ))
9494 end
9595 # the function barrier fixes performance issues if `sampler(s)` is type unstable
96- return _rand! (rng, sampler (s), x)
96+ _rand! (rng, sampler (s), x)
97+ return x
9798end
9899
99100function _rand! (
0 commit comments