Skip to content

Commit

Permalink
Drop compat code for argmin and argmax from #470, #472, and #622
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 8, 2019
1 parent 4338acb commit e4752e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 29 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ Currently, the `@compat` macro supports the following syntaxes:

* `findin(a, b)` is now `findall(in(b), a)` ([#24673]).

* `indmin` and `indmax` are now `argmin` and `argmax`, respectively ([#25654]).

* `Compat.indexin` accepts any iterable as first argument, returns `nothing` (rather than `0`)
for entries with no match and gives the index of the first (rather than the last) match
([#25662], [#25998]).
Expand Down
17 changes: 0 additions & 17 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,6 @@ end
end
end

@static if !isdefined(Base, :argmin)
if VERSION >= v"0.7.0-DEV.1660" # indmin/indmax return key
const argmin = indmin
const argmax = indmax
else
argmin(x::AbstractArray) = CartesianIndex(ind2sub(x, indmin(x)))
argmin(x::AbstractVector) = indmin(x)
argmin(x::Associative) = first(Iterators.drop(keys(x), indmin(values(x))-1))
argmin(x::Tuple) = indmin(x)
argmax(x::AbstractArray) = CartesianIndex(ind2sub(x, indmax(x)))
argmax(x::AbstractVector) = indmax(x)
argmax(x::Associative) = first(Iterators.drop(keys(x), indmax(values(x))-1))
argmax(x::Tuple) = indmax(x)
end
export argmin, argmax
end

@static if !isdefined(Base, :parentmodule)
parentmodule(m::Module) = Base.module_parent(m)
parentmodule(f::Function) = Base.function_module(f)
Expand Down
10 changes: 10 additions & 0 deletions test/old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,13 @@ end

# 0.7.0-DEV.3415
@test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5]

# 0.7.0-DEV.3516
@test argmax([10,12,9,11]) == 2
@test argmax([10 12; 9 11]) == CartesianIndex(1, 2)
@test argmax(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :y
@test argmax((-5, 6, 10)) == 3
@test argmin([10,12,9,11]) == 3
@test argmin([10 12; 9 11]) == CartesianIndex(2, 1)
@test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x
@test argmin((1.0, -3, 0.f0)) == 2
10 changes: 0 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,6 @@ end
@test nameof(Float64) == :Float64
@test nameof(Array) == :Array

# 0.7.0-DEV.3516
@test argmax([10,12,9,11]) == 2
@test argmax([10 12; 9 11]) == CartesianIndex(1, 2)
@test argmax(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :y
@test argmax((-5, 6, 10)) == 3
@test argmin([10,12,9,11]) == 3
@test argmin([10 12; 9 11]) == CartesianIndex(2, 1)
@test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x
@test argmin((1.0, -3, 0.f0)) == 2

module TestPkg
using Compat
using Compat.Pkg
Expand Down

0 comments on commit e4752e4

Please sign in to comment.