Skip to content

Commit f4c4c33

Browse files
authoredOct 20, 2022
reword error when rng sampler is fed empty array (#47104)
1 parent 82bd71b commit f4c4c33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎stdlib/Random/src/generation.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ SamplerRangeFast(r::AbstractUnitRange{T}) where T<:BitInteger =
210210
SamplerRangeFast(r, uint_sup(T))
211211

212212
function SamplerRangeFast(r::AbstractUnitRange{T}, ::Type{U}) where {T,U}
213-
isempty(r) && throw(ArgumentError("range must be non-empty"))
213+
isempty(r) && throw(ArgumentError("collection must be non-empty"))
214214
m = (last(r) - first(r)) % unsigned(T) % U # % unsigned(T) to not propagate sign bit
215215
bw = (sizeof(U) << 3 - leading_zeros(m)) % UInt # bit-width
216216
mask = ((1 % U) << bw) - (1 % U)
@@ -284,7 +284,7 @@ SamplerRangeInt(r::AbstractUnitRange{T}) where T<:BitInteger =
284284
SamplerRangeInt(r, uint_sup(T))
285285

286286
function SamplerRangeInt(r::AbstractUnitRange{T}, ::Type{U}) where {T,U}
287-
isempty(r) && throw(ArgumentError("range must be non-empty"))
287+
isempty(r) && throw(ArgumentError("collection must be non-empty"))
288288
a = first(r)
289289
m = (last(r) - first(r)) % unsigned(T) % U
290290
k = m + one(U)
@@ -330,7 +330,7 @@ struct SamplerRangeNDL{U<:Unsigned,T} <: Sampler{T}
330330
end
331331

332332
function SamplerRangeNDL(r::AbstractUnitRange{T}) where {T}
333-
isempty(r) && throw(ArgumentError("range must be non-empty"))
333+
isempty(r) && throw(ArgumentError("collection must be non-empty"))
334334
a = first(r)
335335
U = uint_sup(T)
336336
s = (last(r) - first(r)) % unsigned(T) % U + one(U) # overflow ok
@@ -369,7 +369,7 @@ end
369369
function SamplerBigInt(::Type{RNG}, r::AbstractUnitRange{BigInt}, N::Repetition=Val(Inf)
370370
) where {RNG<:AbstractRNG}
371371
m = last(r) - first(r)
372-
m.size < 0 && throw(ArgumentError("range must be non-empty"))
372+
m.size < 0 && throw(ArgumentError("collection must be non-empty"))
373373
nlimbs = Int(m.size)
374374
hm = nlimbs == 0 ? Limb(0) : GC.@preserve m unsafe_load(m.d, nlimbs)
375375
highsp = Sampler(RNG, Limb(0):hm, N)

2 commit comments

Comments
 (2)

nanosoldier commented on Oct 20, 2022

@nanosoldier
Collaborator

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true, configuration=(rr=true,))

nanosoldier commented on Oct 21, 2022

@nanosoldier
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

Please sign in to comment.