Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate ipermutedims #18891

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,43 +283,6 @@ function cumsum_kbn{T<:AbstractFloat}(A::AbstractArray{T}, axis::Integer=1)
return B + C
end

## ipermutedims in terms of permutedims ##

"""
ipermutedims(A, perm)

Like [`permutedims`](:func:`permutedims`), except the inverse of the given permutation is applied.

```jldoctest
julia> A = reshape(collect(1:8), (2,2,2))
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 3
2 4
<BLANKLINE>
[:, :, 2] =
5 7
6 8

julia> ipermutedims(A, [3, 2, 1])
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 3
5 7
<BLANKLINE>
[:, :, 2] =
2 4
6 8
```
"""
function ipermutedims(A::AbstractArray,perm)
iperm = Array{Int}(length(perm))
for (i,p) = enumerate(perm)
iperm[p] = i
end
return permutedims(A,iperm)
end

## Other array functions ##

"""
Expand Down
2 changes: 2 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1019,4 +1019,6 @@ eval(Multimedia, :(macro textmime(mime)
end
end))

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

# End deprecations scheduled for 0.6
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ export
indmin,
invperm,
ipermute!,
ipermutedims,
isassigned,
isperm,
issorted,
Expand Down
2 changes: 1 addition & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ function sort(A::AbstractArray, dim::Integer;
Ap = permutedims(A, pdims)
Av = vec(Ap)
sort_chunks!(Av, n, alg, order)
ipermutedims(Ap, pdims)
permutedims(Ap, invperm(pdims))
else
Av = A[:]
sort_chunks!(Av, n, alg, order)
Expand Down
28 changes: 0 additions & 28 deletions doc/stdlib/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1354,34 +1354,6 @@ Indexing, Assignment, and Concatenation
2 4
6 8

.. function:: ipermutedims(A, perm)

.. Docstring generated from Julia source

Like :func:`permutedims`\ , except the inverse of the given permutation is applied.

.. doctest::

julia> A = reshape(collect(1:8), (2,2,2))
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 3
2 4
<BLANKLINE>
[:, :, 2] =
5 7
6 8

julia> ipermutedims(A, [3, 2, 1])
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 3
5 7
<BLANKLINE>
[:, :, 2] =
2 4
6 8

.. function:: permutedims!(dest, src, perm)

.. Docstring generated from Julia source
Expand Down
9 changes: 3 additions & 6 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,11 @@ end
@test_throws ArgumentError permutedims(s, (1,1,1))
@test_throws ArgumentError Base.PermutedDimsArrays.PermutedDimsArray(a, (1,1,1))
@test_throws ArgumentError Base.PermutedDimsArrays.PermutedDimsArray(s, (1,1,1))
end

@testset "ipermutedims" begin
tensors = Any[rand(1,2,3,4),rand(2,2,2,2),rand(5,6,5,6),rand(1,1,1,1)]
for i = tensors
for A in [rand(1,2,3,4),rand(2,2,2,2),rand(5,6,5,6),rand(1,1,1,1)]
perm = randperm(4)
@test isequal(i,ipermutedims(permutedims(i,perm),perm))
@test isequal(i,permutedims(ipermutedims(i,perm),perm))
@test isequal(A,permutedims(permutedims(A,perm),invperm(perm)))
@test isequal(A,permutedims(permutedims(A,invperm(perm)),perm))
end
end

Expand Down