Skip to content

Commit 9ae0752

Browse files
committed
updates for v0.7, rename indmin/max to argmin/max
1 parent e193e59 commit 9ae0752

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/TupleTools.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,21 @@ Returns the largest element of a tuple
141141

142142

143143
"""
144-
indmin(t::Tuple)
144+
argmin(t::Tuple)
145145
146146
Returns the index of the minimum element in a tuple. If there are multiple
147147
minimal elements, then the first one will be returned.
148148
"""
149-
indmin(t::Tuple) = findmin(t)[2]
149+
argmin(t::Tuple) = findmin(t)[2]
150150

151151

152152
"""
153-
indmax(t::Tuple)
153+
argmax(t::Tuple)
154154
155155
Returns the index of the maximum element in a tuple. If there are multiple
156156
minimal elements, then the first one will be returned.
157157
"""
158-
indmax(t::Tuple) = findmax(t)[2]
158+
argmax(t::Tuple) = findmax(t)[2]
159159

160160
"""
161161
findmin(t::Tuple)

test/runtests.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
if VERSION < v"0.7.0-DEV.2005"
22
const Test = Base.Test
33
end
4+
if VERSION >= v"0.7.0-DEV.3406"
5+
using Random
6+
end
7+
if VERSION < v"0.7.0-DEV.3516"
8+
const argmin = Base.indmin
9+
const argmax = Base.indmax
10+
end
411

512
using Test
613
using TupleTools
@@ -35,10 +42,12 @@ i = rand(1:n)
3542
@test @inferred(TupleTools.findmax(t)) == findmax(t)
3643
@test @inferred(TupleTools.minimum(t)) == minimum(t)
3744
@test @inferred(TupleTools.maximum(t)) == maximum(t)
38-
@test @inferred(TupleTools.indmin(t)) == indmin(t)
39-
@test @inferred(TupleTools.indmax(t)) == indmax(t)
45+
@test @inferred(TupleTools.argmin(t)) == argmin(t)
46+
@test @inferred(TupleTools.argmax(t)) == argmax(t)
4047

4148
@test @inferred(TupleTools.sort(t; rev = true)) == (sort(p; rev = true)...,)
4249
@test @inferred(TupleTools.sortperm(t)) == (sortperm(p)...,)
4350
@test @inferred(TupleTools.invperm(t)) == (ip...,)
51+
@test @inferred(TupleTools.isperm(t)) == true
52+
@test @inferred(TupleTools.isperm((1,2,1))) == false
4453
@test @inferred(TupleTools.permute(t, t)) == (p[p]...,)

0 commit comments

Comments
 (0)