diff --git a/Project.toml b/Project.toml index 0b90562..2f11b82 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "PooledArrays" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -version = "1.4.2" +version = "1.4.3" [deps] DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" @@ -12,7 +12,8 @@ julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" [targets] -test = ["OffsetArrays", "Test"] +test = ["OffsetArrays", "Random", "Test"] diff --git a/src/PooledArrays.jl b/src/PooledArrays.jl index 7daf2b9..ce58ff8 100644 --- a/src/PooledArrays.jl +++ b/src/PooledArrays.jl @@ -297,13 +297,13 @@ function Base.reverse(x::PooledArray) PooledArray(RefArray(reverse(x.refs)), x.invpool, x.pool, x.refcount) end -function Base.permute!!(x::PooledArray, p::AbstractVector{T}) where T<:Integer - Base.permute!!(x.refs, p) +function Base.permute!(x::PooledArray, p::AbstractVector{T}) where T<:Integer + permute!(x.refs, p) return x end -function Base.invpermute!!(x::PooledArray, p::AbstractVector{T}) where T<:Integer - Base.invpermute!!(x.refs, p) +function Base.invpermute!(x::PooledArray, p::AbstractVector{T}) where T<:Integer + invpermute!(x.refs, p) return x end diff --git a/test/runtests.jl b/test/runtests.jl index 105a708..f205d73 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,6 +2,8 @@ using Test, OffsetArrays using PooledArrays using DataAPI: refarray, refvalue, refpool, invrefpool using PooledArrays: refcount +using Random: randperm + import Future.copy! if Threads.nthreads() < 2 @@ -35,6 +37,17 @@ end @test sort(pc) == sort(c) @test sortperm(pc) == sortperm(c) + perm = randperm(length(pc)) + pc2 = copy(pc) + pc3 = permute!(pc2, perm) + @test pc2 === pc3 + @test pc2 == pc[perm] + + pc2 = copy(pc) + pc3 = invpermute!(pc2, perm) + @test pc2 === pc3 + @test pc2[perm] == pc + push!(pc, -10) push!(c, -10) @test pc == c