Skip to content

Commit

Permalink
Don't check for invariant transform when the permutation and permuted…
Browse files Browse the repository at this point in the history
… are of different lengths
  • Loading branch information
chriselrod committed Feb 9, 2021
1 parent 9d0843f commit ee80672
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ArrayInterface"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1"
version = "3.1.1"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
3 changes: 2 additions & 1 deletion src/static.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ function invariant_permutation(x::T, y::T) where {N,T<:Tuple{Vararg{StaticInt,N}
end

permute(x::Tuple, perm::Val) = permute(x, static(perm))
function permute(x::Tuple{Vararg{Any}}, perm::Tuple{Vararg{StaticInt}})
permute(x::Tuple{Vararg{Any}}, perm::Tuple{Vararg{StaticInt}}) = eachop(getindex, x, perm)
function permute(x::Tuple{Vararg{Any,K}}, perm::Tuple{Vararg{StaticInt,K}}) where {K}
if invariant_permutation(perm, perm) isa False
return eachop(getindex, x, perm)
else
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ using OffsetArrays

@test @inferred(stride_rank(@SArray(zeros(2,2,2)))) == ((1, 2, 3))
@test @inferred(stride_rank(A)) == ((1,2,3))
@test @inferred(stride_rank(view(A,:,:,1))) == ((1,2))
@test @inferred(stride_rank(view(A,:,:,1))) === ((ArrayInterface.StaticInt(1),ArrayInterface.StaticInt(2)))
@test @inferred(stride_rank(PermutedDimsArray(A,(3,1,2)))) == ((3, 1, 2))
@test @inferred(stride_rank(@view(PermutedDimsArray(A,(3,1,2))[2,1:2,:]))) == ((1, 2))
@test @inferred(stride_rank(@view(PermutedDimsArray(A,(3,1,2))[2,1:2,:])')) == ((2, 1))
Expand Down

2 comments on commit ee80672

@chriselrod
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29710

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.1.1 -m "<description of version>" ee806727383fde0bc42207771bf61b188e3574da
git push origin v3.1.1

Please sign in to comment.