diff --git a/src/StableRNGs.jl b/src/StableRNGs.jl index af62491..4145725 100644 --- a/src/StableRNGs.jl +++ b/src/StableRNGs.jl @@ -141,7 +141,10 @@ end # https://github.com/JuliaRandom/StableRNGs.jl/issues/10 Random.shuffle(r::StableRNG, a::AbstractArray) = Random.shuffle!(r, Base.copymutable(a)) -function Random.shuffle!(r::StableRNG, a::AbstractArray) +# Fix method ambiguity issue: https://github.com/JuliaRandom/StableRNGs.jl/issues/23 +Random.shuffle!(r::StableRNG, a::AbstractArray) = _shuffle!(r, a) +Random.shuffle!(r::StableRNG, a::AbstractArray{Bool}) = _shuffle!(r, a) +function _shuffle!(r::StableRNG, a::AbstractArray) require_one_based_indexing(a) n = length(a) n <= 1 && return a # nextpow below won't work with n == 0 diff --git a/test/runtests.jl b/test/runtests.jl index f7a9165..f1a6515 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -139,6 +139,14 @@ end b = collect(a) shuffle!(StableRNG(10), b) @test b == a_shuffled + + # https://github.com/JuliaRandom/StableRNGs.jl/issues/23 + c = [false, true, false, true, false] + c_shuffled = [false, false, false, true, true] + @test shuffle!(StableRNG(123), c) == c_shuffled + d = [false true; true false] + d_shuffled = [true true; false false] + @test shuffle(StableRNG(31), d) == d_shuffled end # https://github.com/JuliaRandom/StableRNGs.jl/issues/20