Skip to content

Commit daf94da

Browse files
committed
Add/modify permute
1 parent 7c9df49 commit daf94da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/TupleTools.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __precompile__(true)
22
module TupleTools
33

44
using Base: tuple_type_head, tuple_type_tail, tuple_type_cons, tail, front, setindex
5-
import Base: permute # TODO: this can disappear when Sparse moves out of Base
5+
# import Base: permute # TODO: this can disappear when Sparse moves out of Base
66

77
"""
88
struct StaticLength{N} end
@@ -258,8 +258,8 @@ Get the indices `t[i] for i in I`, again as tuple.
258258
259259
Permute the elements of tuple `t` according to the permutation in `p`.
260260
"""
261-
@inline permute(t::NTuple{N}, p::NTuple{N,Int}) where {N} = isperm(p) ? getindices(t, p) : throw(ArgumentError("not a valid permutation: $p"))
262-
@inline permute(t::NTuple{N}, p) where {N} = isperm(p) && length(p) == N ? ntuple(n->t[p[n]], StaticLength(N)) : throw(ArgumentError("not a valid permutation: $p"))
261+
@inline permute(t::NTuple{N,Any}, p::NTuple{N,Int}) where {N} = isperm(p) ? getindices(t, p) : throw(ArgumentError("not a valid permutation: $p"))
262+
@inline permute(t::NTuple{N,Any}, p) where {N} = isperm(p) && length(p) == N ? ntuple(n->t[p[n]], StaticLength(N)) : throw(ArgumentError("not a valid permutation: $p"))
263263

264264
"""
265265
invperm(p::NTuple{N,Int}) -> ::NTuple{N,Int}

0 commit comments

Comments
 (0)