Skip to content

Commit 5f14f11

Browse files
authored
deprecate ipermute! in favor of invpermute! (#25168)
1 parent da52b79 commit 5f14f11

File tree

8 files changed

+20
-15
lines changed

8 files changed

+20
-15
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ Deprecated or removed
880880
(i.e. `Void <: T`). `isnull(x)` can be replaced with `x === nothing`
881881
and `unsafe_get`/`get` can be dropped or replaced with `coalesce`.
882882

883+
* `ipermute!` has been deprecated in favor of `invpermute!` ([#25168]).
884+
883885
* `CartesianRange` has been renamed `CartesianIndices` ([#24715]).
884886

885887
* `sub2ind` and `ind2sub` are deprecated in favor of using `CartesianIndices` and `LinearIndices` ([#24715]).

base/combinatorics.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ to verify that `p` is a permutation.
101101
To return a new permutation, use `v[p]`. Note that this is generally faster than
102102
`permute!(v,p)` for large vectors.
103103
104-
See also [`ipermute!`](@ref).
104+
See also [`invpermute!`](@ref).
105105
106106
# Examples
107107
```jldoctest
@@ -121,7 +121,7 @@ julia> A
121121
"""
122122
permute!(a, p::AbstractVector) = permute!!(a, copymutable(p))
123123

124-
function ipermute!!(a, p::AbstractVector{<:Integer})
124+
function invpermute!!(a, p::AbstractVector{<:Integer})
125125
count = 0
126126
start = 0
127127
while count < length(a)
@@ -145,7 +145,7 @@ function ipermute!!(a, p::AbstractVector{<:Integer})
145145
end
146146

147147
"""
148-
ipermute!(v, p)
148+
invpermute!(v, p)
149149
150150
Like [`permute!`](@ref), but the inverse of the given permutation is applied.
151151
@@ -155,7 +155,7 @@ julia> A = [1, 1, 3, 4];
155155
156156
julia> perm = [2, 4, 3, 1];
157157
158-
julia> ipermute!(A, perm);
158+
julia> invpermute!(A, perm);
159159
160160
julia> A
161161
4-element Array{Int64,1}:
@@ -165,7 +165,7 @@ julia> A
165165
1
166166
```
167167
"""
168-
ipermute!(a, p::AbstractVector) = ipermute!!(a, copymutable(p))
168+
invpermute!(a, p::AbstractVector) = invpermute!!(a, copymutable(p))
169169

170170
"""
171171
invperm(v)

base/deprecated.jl

+3
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ end
363363

364364
@deprecate ipermutedims(A::AbstractArray,p) permutedims(A, invperm(p))
365365

366+
# PR #25168
367+
@deprecate ipermute!(a, p::AbstractVector) invpermute!(a, p)
368+
366369
# 18696
367370
function ($)(x, y)
368371
depwarn("`x \$ y` is deprecated. use `xor(x, y)` or `x ⊻ y` instead.", :$)

base/exports.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ export
459459
indmax,
460460
indmin,
461461
invperm,
462-
ipermute!,
462+
invpermute!,
463463
isassigned,
464464
isperm,
465465
issorted,

base/linalg/cholesky.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ end
445445

446446
function ldiv!(C::CholeskyPivoted{T}, B::StridedVector{T}) where T<:BlasFloat
447447
chkfullrank(C)
448-
ipermute!(LAPACK.potrs!(C.uplo, C.factors, permute!(B, C.piv)), C.piv)
448+
invpermute!(LAPACK.potrs!(C.uplo, C.factors, permute!(B, C.piv)), C.piv)
449449
end
450450
function ldiv!(C::CholeskyPivoted{T}, B::StridedMatrix{T}) where T<:BlasFloat
451451
chkfullrank(C)
@@ -455,7 +455,7 @@ function ldiv!(C::CholeskyPivoted{T}, B::StridedMatrix{T}) where T<:BlasFloat
455455
end
456456
LAPACK.potrs!(C.uplo, C.factors, B)
457457
for i=1:size(B, 2)
458-
ipermute!(view(B, 1:n, i), C.piv)
458+
invpermute!(view(B, 1:n, i), C.piv)
459459
end
460460
B
461461
end

doc/src/stdlib/arrays.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Base.Random.randperm!
169169
Base.invperm
170170
Base.isperm
171171
Base.permute!(::Any, ::AbstractVector)
172-
Base.ipermute!
172+
Base.invpermute!
173173
Base.Random.randcycle
174174
Base.Random.randcycle!
175175
Base.Random.shuffle

test/combinatorics.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ end
3737
@test !isperm(p)
3838

3939
a = randcycle(10)
40-
@test ipermute!(permute!([1:10;], a),a) == [1:10;]
40+
@test invpermute!(permute!([1:10;], a),a) == [1:10;]
4141

4242
# PR 12785
4343
let ai = 2:-1:1
44-
@test ipermute!(permute!([1, 2], ai), ai) == [1, 2]
44+
@test invpermute!(permute!([1, 2], ai), ai) == [1, 2]
4545
end
4646
end
4747

test/sorting.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Base.step(r::ConstantRange) = 0
172172
permute!(c, ix)
173173
@test c == b
174174

175-
ipermute!(c, ix)
175+
invpermute!(c, ix)
176176
@test c == a
177177

178178
c = sort(a, alg=alg, lt=(>))
@@ -245,7 +245,7 @@ end
245245
c = copy(v)
246246
permute!(c, pi)
247247
@test c == si
248-
ipermute!(c, pi)
248+
invpermute!(c, pi)
249249
@test c == v
250250

251251
# stable algorithms
@@ -256,7 +256,7 @@ end
256256
s = copy(v)
257257
permute!(s, p)
258258
@test s == si
259-
ipermute!(s, p)
259+
invpermute!(s, p)
260260
@test s == v
261261
end
262262

@@ -269,7 +269,7 @@ end
269269
s = copy(v)
270270
permute!(s, p)
271271
@test s == si
272-
ipermute!(s, p)
272+
invpermute!(s, p)
273273
@test s == v
274274
end
275275
end

0 commit comments

Comments
 (0)