Skip to content

Commit daf1235

Browse files
authored
remove scalarmin, scalarmax, and corresponding deprecations (#25401)
1 parent 9ca03c6 commit daf1235

File tree

7 files changed

+14
-40
lines changed

7 files changed

+14
-40
lines changed

base/operators.jl

-10
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,6 @@ julia> minmax('c','b')
391391
"""
392392
minmax(x,y) = isless(y, x) ? (y, x) : (x, y)
393393

394-
scalarmax(x,y) = max(x,y)
395-
scalarmax(x::AbstractArray, y::AbstractArray) = throw(ArgumentError("ordering is not well-defined for arrays"))
396-
scalarmax(x , y::AbstractArray) = throw(ArgumentError("ordering is not well-defined for arrays"))
397-
scalarmax(x::AbstractArray, y ) = throw(ArgumentError("ordering is not well-defined for arrays"))
398-
399-
scalarmin(x,y) = min(x,y)
400-
scalarmin(x::AbstractArray, y::AbstractArray) = throw(ArgumentError("ordering is not well-defined for arrays"))
401-
scalarmin(x , y::AbstractArray) = throw(ArgumentError("ordering is not well-defined for arrays"))
402-
scalarmin(x::AbstractArray, y ) = throw(ArgumentError("ordering is not well-defined for arrays"))
403-
404394
## definitions providing basic traits of arithmetic operators ##
405395

406396
"""

base/precompile.jl

-2
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,6 @@ precompile(Tuple{typeof(Base.LineEdit.common_prefix), Array{String, 1}})
617617
precompile(Tuple{typeof(Base.LineEdit.show_completions), Base.LineEdit.PromptState, Array{String, 1}})
618618
precompile(Tuple{typeof(Base.collect_to!), Array{Int64, 1}, Base.Generator{Array{String, 1}, typeof(Base.length)}, Int64, Int64})
619619
precompile(Tuple{typeof(Base._collect), Array{String, 1}, Base.Generator{Array{String, 1}, typeof(Base.length)}, Base.EltypeUnknown, Base.HasShape})
620-
precompile(Tuple{typeof(Base.mapreduce_impl), typeof(Base.identity), typeof(Base.scalarmax), Array{Int64, 1}, Int64, Int64})
621-
precompile(Tuple{typeof(Base._mapreduce), typeof(Base.identity), typeof(Base.scalarmax), Base.IndexLinear, Array{Int64, 1}})
622620
precompile(Tuple{typeof(Base.Terminals.cmove_down), Base.Terminals.TTYTerminal, Int64})
623621
precompile(Tuple{typeof(Base.Terminals.cmove_col), Base.Terminals.TTYTerminal, Int64})
624622
precompile(Tuple{typeof(Base.Terminals.cmove_right), Base.Terminals.TTYTerminal, Int64})

base/reduce.jl

+7-10
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ mapreduce_empty(::typeof(identity), op, T) = reduce_empty(op, T)
284284
mapreduce_empty(::typeof(abs), op, T) = abs(reduce_empty(op, T))
285285
mapreduce_empty(::typeof(abs2), op, T) = abs2(reduce_empty(op, T))
286286

287-
mapreduce_empty(f::typeof(abs), ::Union{typeof(scalarmax), typeof(max)}, T) = abs(zero(T))
288-
mapreduce_empty(f::typeof(abs2), ::Union{typeof(scalarmax), typeof(max)}, T) = abs2(zero(T))
287+
mapreduce_empty(f::typeof(abs), ::typeof(max), T) = abs(zero(T))
288+
mapreduce_empty(f::typeof(abs2), ::typeof(max), T) = abs2(zero(T))
289289

290290
mapreduce_empty_iter(f, op, itr, ::HasEltype) = mapreduce_empty(f, op, eltype(itr))
291291
mapreduce_empty_iter(f, op::typeof(&), itr, ::EltypeUnknown) = true
@@ -488,10 +488,7 @@ prod(a) = mapreduce(identity, mul_prod, a)
488488

489489
## maximum & minimum
490490

491-
function mapreduce_impl(f, op::Union{typeof(scalarmax),
492-
typeof(scalarmin),
493-
typeof(max),
494-
typeof(min)},
491+
function mapreduce_impl(f, op::Union{typeof(max), typeof(min)},
495492
A::AbstractArray, first::Int, last::Int)
496493
# locate the first non NaN number
497494
@inbounds a1 = A[first]
@@ -505,8 +502,8 @@ function mapreduce_impl(f, op::Union{typeof(scalarmax),
505502
v
506503
end
507504

508-
maximum(f::Callable, a) = mapreduce(f, scalarmax, a)
509-
minimum(f::Callable, a) = mapreduce(f, scalarmin, a)
505+
maximum(f::Callable, a) = mapreduce(f, max, a)
506+
minimum(f::Callable, a) = mapreduce(f, min, a)
510507

511508
"""
512509
maximum(itr)
@@ -521,7 +518,7 @@ julia> maximum([1,2,3])
521518
3
522519
```
523520
"""
524-
maximum(a) = mapreduce(identity, scalarmax, a)
521+
maximum(a) = mapreduce(identity, max, a)
525522

526523
"""
527524
minimum(itr)
@@ -536,7 +533,7 @@ julia> minimum([1,2,3])
536533
1
537534
```
538535
"""
539-
minimum(a) = mapreduce(identity, scalarmin, a)
536+
minimum(a) = mapreduce(identity, min, a)
540537

541538
## extrema
542539

base/reducedim.jl

+5-9
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ for (Op, initfun) in ((:(typeof(add_sum)), :zero), (:(typeof(mul_prod)), :one))
6767
@eval initarray!(a::AbstractArray{T}, ::$(Op), init::Bool, src::AbstractArray) where {T} = (init && fill!(a, $(initfun)(T)); a)
6868
end
6969

70-
for Op in (:(typeof(scalarmax)), :(typeof(scalarmin)), :(typeof(max)), :(typeof(min)))
70+
for Op in (:(typeof(max)), :(typeof(min)))
7171
@eval initarray!(a::AbstractArray{T}, ::$(Op), init::Bool, src::AbstractArray) where {T} = (init && copyfirst!(a, src); a)
7272
end
7373

@@ -124,13 +124,9 @@ function _reducedim_init(f, op, fv, fop, A, region)
124124
return reducedim_initarray(A, region, z, Tr)
125125
end
126126

127-
reducedim_init(f, op::typeof(max), A::AbstractArray, region) = reducedim_init(f, scalarmax, A, region)
128-
reducedim_init(f, op::typeof(min), A::AbstractArray, region) = reducedim_init(f, scalarmin, A, region)
129-
reducedim_init(f::Union{typeof(abs),typeof(abs2)}, op::typeof(max), A::AbstractArray, region) = reducedim_init(f, scalarmax, A, region)
130-
131-
reducedim_init(f, op::typeof(scalarmax), A::AbstractArray{T}, region) where {T} = reducedim_initarray0(A, region, f, maximum)
132-
reducedim_init(f, op::typeof(scalarmin), A::AbstractArray{T}, region) where {T} = reducedim_initarray0(A, region, f, minimum)
133-
reducedim_init(f::Union{typeof(abs),typeof(abs2)}, op::typeof(scalarmax), A::AbstractArray{T}, region) where {T} =
127+
reducedim_init(f, op::typeof(max), A::AbstractArray{T}, region) where {T} = reducedim_initarray0(A, region, f, maximum)
128+
reducedim_init(f, op::typeof(min), A::AbstractArray{T}, region) where {T} = reducedim_initarray0(A, region, f, minimum)
129+
reducedim_init(f::Union{typeof(abs),typeof(abs2)}, op::typeof(max), A::AbstractArray{T}, region) where {T} =
134130
reducedim_initarray(A, region, zero(f(zero(T))))
135131

136132
reducedim_init(f, op::typeof(&), A::AbstractArray, region) = reducedim_initarray(A, region, true)
@@ -605,7 +601,7 @@ julia> any!([1 1], A)
605601
any!(r, A)
606602

607603
for (fname, op) in [(:sum, :add_sum), (:prod, :mul_prod),
608-
(:maximum, :scalarmax), (:minimum, :scalarmin),
604+
(:maximum, :max), (:minimum, :min),
609605
(:all, :&), (:any, :|)]
610606
fname! = Symbol(fname, '!')
611607
@eval begin

base/sparse/sparsevector.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Common definitions
44

5-
import Base: scalarmax, scalarmin, sort, find, findnz
5+
import Base: sort, find, findnz
66
import Base.LinAlg: promote_to_array_type, promote_to_arrays_
77

88
### The SparseVector

test/operators.jl

-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ p = 1=>:foo
5252
@test xor(2) == 2
5353
@test ()(2) == 2
5454

55-
@test_throws ArgumentError Base.scalarmin(['a','b'],['c','d'])
56-
@test_throws ArgumentError Base.scalarmin('a',['c','d'])
57-
@test_throws ArgumentError Base.scalarmin(['a','b'],'c')
58-
@test_throws ArgumentError Base.scalarmax(['a','b'],['c','d'])
59-
@test_throws ArgumentError Base.scalarmax('a',['c','d'])
60-
@test_throws ArgumentError Base.scalarmax(['a','b'],'c')
61-
6255
@test_throws MethodError min(Set([1]), Set([2]))
6356
@test_throws MethodError max(Set([1]), Set([2]))
6457
@test_throws MethodError minmax(Set([1]), Set([2]))

test/reduce.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
@test mapreduce(-, +, Vector(linspace(1.0, 10000.0, 10000))) == -50005000.0
4747
# empty mr
4848
@test mapreduce(abs2, +, Float64[]) === 0.0
49-
@test mapreduce(abs2, Base.scalarmax, Float64[]) === 0.0
49+
@test mapreduce(abs2, max, Float64[]) === 0.0
5050
@test mapreduce(abs, max, Float64[]) === 0.0
5151
@test_throws ArgumentError mapreduce(abs2, &, Float64[])
5252
@test_throws ArgumentError mapreduce(abs2, |, Float64[])

0 commit comments

Comments
 (0)