@@ -297,13 +297,16 @@ randperm(r::AbstractRNG, n::T) where {T <: Integer} = randperm!(r, Vector{T}(und
297297randperm (n:: Integer ) = randperm (default_rng (), n)
298298
299299"""
300- randperm!([rng=default_rng(),] A::Array {<:Integer})
300+ randperm!([rng=default_rng(),] A::AbstractArray {<:Integer})
301301
302302Construct in `A` a random permutation of length `length(A)`. The
303303optional `rng` argument specifies a random number generator (see
304304[Random Numbers](@ref)). To randomly permute an arbitrary vector, see
305305[`shuffle`](@ref) or [`shuffle!`](@ref).
306306
307+ !!! compat "Julia 1.13"
308+ `A isa Array` was required prior to Julia v1.13.
309+
307310# Examples
308311```jldoctest
309312julia> randperm!(Xoshiro(123), Vector{Int}(undef, 4))
@@ -314,8 +317,9 @@ julia> randperm!(Xoshiro(123), Vector{Int}(undef, 4))
314317 3
315318```
316319"""
317- function randperm! (r:: AbstractRNG , a:: Array {<:Integer} )
320+ function randperm! (r:: AbstractRNG , a:: AbstractArray {<:Integer} )
318321 # keep it consistent with `shuffle!` and `randcycle!` if possible
322+ Base. require_one_based_indexing (a)
319323 n = length (a)
320324 @assert n <= Int64 (2 )^ 52
321325 n == 0 && return a
@@ -332,7 +336,7 @@ function randperm!(r::AbstractRNG, a::Array{<:Integer})
332336 return a
333337end
334338
335- randperm! (a:: Array {<:Integer} ) = randperm! (default_rng (), a)
339+ randperm! (a:: AbstractArray {<:Integer} ) = randperm! (default_rng (), a)
336340
337341
338342# # randcycle & randcycle!
@@ -370,7 +374,7 @@ randcycle(r::AbstractRNG, n::T) where {T <: Integer} = randcycle!(r, Vector{T}(u
370374randcycle (n:: Integer ) = randcycle (default_rng (), n)
371375
372376"""
373- randcycle!([rng=default_rng(),] A::Array {<:Integer})
377+ randcycle!([rng=default_rng(),] A::AbstractArray {<:Integer})
374378
375379Construct in `A` a random cyclic permutation of length `n = length(A)`.
376380The optional `rng` argument specifies a random number generator, see
@@ -382,6 +386,9 @@ which are sampled uniformly. If `A` is empty, `randcycle!` leaves it unchanged.
382386
383387[`randcycle`](@ref) is a variant of this function that allocates a new vector.
384388
389+ !!! compat "Julia 1.13"
390+ `A isa Array` was required prior to Julia v1.13.
391+
385392# Examples
386393```jldoctest
387394julia> randcycle!(Xoshiro(123), Vector{Int}(undef, 6))
@@ -394,8 +401,9 @@ julia> randcycle!(Xoshiro(123), Vector{Int}(undef, 6))
394401 1
395402```
396403"""
397- function randcycle! (r:: AbstractRNG , a:: Array {<:Integer} )
404+ function randcycle! (r:: AbstractRNG , a:: AbstractArray {<:Integer} )
398405 # keep it consistent with `shuffle!` and `randperm!` if possible
406+ Base. require_one_based_indexing (a)
399407 n = length (a)
400408 @assert n <= Int64 (2 )^ 52
401409 n == 0 && return a
@@ -411,4 +419,4 @@ function randcycle!(r::AbstractRNG, a::Array{<:Integer})
411419 return a
412420end
413421
414- randcycle! (a:: Array {<:Integer} ) = randcycle! (default_rng (), a)
422+ randcycle! (a:: AbstractArray {<:Integer} ) = randcycle! (default_rng (), a)
0 commit comments