Skip to content

Commit 5f9bbbe

Browse files
committed
rename methods of min and max that do reductions to minimum and maximum
this is step 1 for #4235
1 parent df8321e commit 5f9bbbe

35 files changed

+127
-124
lines changed

base/abstractarray.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function checkbounds(sz::Int, I::AbstractVector{Bool})
7171
end
7272

7373
function checkbounds{T<:Integer}(sz::Int, I::Ranges{T})
74-
if !isempty(I) && (min(I) < 1 || max(I) > sz)
74+
if !isempty(I) && (minimum(I) < 1 || maximum(I) > sz)
7575
throw(BoundsError())
7676
end
7777
end
@@ -755,7 +755,7 @@ function cat(catdim::Integer, X...)
755755
nargs = length(X)
756756
dimsX = map((a->isa(a,AbstractArray) ? size(a) : (1,)), X)
757757
ndimsX = map((a->isa(a,AbstractArray) ? ndims(a) : 1), X)
758-
d_max = max(ndimsX)
758+
d_max = maximum(ndimsX)
759759

760760
if catdim > d_max + 1
761761
for i=1:nargs
@@ -823,7 +823,7 @@ function cat_t(catdim::Integer, typeC, A::AbstractArray...)
823823
nargs = length(A)
824824
dimsA = map(size, A)
825825
ndimsA = map(ndims, A)
826-
d_max = max(ndimsA)
826+
d_max = maximum(ndimsA)
827827

828828
if catdim > d_max + 1
829829
for i=1:nargs
@@ -1394,9 +1394,9 @@ reduced_dims0(A, region) = ntuple(ndims(A), i->(size(A,i)==0 ? 0 :
13941394
reducedim(f::Function, A, region, v0) =
13951395
reducedim(f, A, region, v0, similar(A, reduced_dims(A, region)))
13961396

1397-
max{T}(A::AbstractArray{T}, b::(), region) =
1397+
maximum{T}(A::AbstractArray{T}, region) =
13981398
isempty(A) ? similar(A,reduced_dims0(A,region)) : reducedim(max,A,region,typemin(T))
1399-
min{T}(A::AbstractArray{T}, b::(), region) =
1399+
minimum{T}(A::AbstractArray{T}, region) =
14001400
isempty(A) ? similar(A,reduced_dims0(A,region)) : reducedim(min,A,region,typemax(T))
14011401
sum{T}(A::AbstractArray{T}, region) = reducedim(+,A,region,zero(T))
14021402
prod{T}(A::AbstractArray{T}, region) = reducedim(*,A,region,one(T))
@@ -1531,8 +1531,8 @@ function prod{T}(A::AbstractArray{T})
15311531
v
15321532
end
15331533

1534-
function min{T<:Real}(A::AbstractArray{T})
1535-
if isempty(A); error("min: argument is empty"); end
1534+
function minimum{T<:Real}(A::AbstractArray{T})
1535+
if isempty(A); error("minimum: argument is empty"); end
15361536
v = A[1]
15371537
for i=2:length(A)
15381538
@inbounds x = A[i]
@@ -1543,8 +1543,8 @@ function min{T<:Real}(A::AbstractArray{T})
15431543
v
15441544
end
15451545

1546-
function max{T<:Real}(A::AbstractArray{T})
1547-
if isempty(A); error("max: argument is empty"); end
1546+
function maximum{T<:Real}(A::AbstractArray{T})
1547+
if isempty(A); error("maximum: argument is empty"); end
15481548
v = A[1]
15491549
for i=2:length(A)
15501550
@inbounds x = A[i]

base/bitarray.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1852,8 +1852,8 @@ function any(B::BitArray)
18521852
return false
18531853
end
18541854

1855-
min(B::BitArray) = isempty(B) ? error("min: argument is empty") : all(B)
1856-
max(B::BitArray) = isempty(B) ? error("max: argument is empty") : any(B)
1855+
minimum(B::BitArray) = isempty(B) ? error("minimum: argument is empty") : all(B)
1856+
maximum(B::BitArray) = isempty(B) ? error("maximum: argument is empty") : any(B)
18571857

18581858
## map over bitarrays ##
18591859

@@ -2176,7 +2176,7 @@ function cat(catdim::Integer, X::Union(BitArray, Integer)...)
21762176
end
21772177
dimsX = map((a->isa(a,BitArray) ? size(a) : (1,)), X)
21782178
ndimsX = map((a->isa(a,BitArray) ? ndims(a) : 1), X)
2179-
d_max = max(ndimsX)
2179+
d_max = maximum(ndimsX)
21802180

21812181
if catdim > d_max + 1
21822182
for i=1:nargs

base/darray.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function DArray(init, dims, procs)
4545
end
4646
DArray(init, dims, procs, defaultdist(dims,procs))
4747
end
48-
DArray(init, dims) = DArray(init, dims, workers()[1:min(nworkers(),max(dims))])
48+
DArray(init, dims) = DArray(init, dims, workers()[1:min(nworkers(),maximum(dims))])
4949

5050
# new DArray similar to an existing one
5151
DArray(init, d::DArray) = DArray(init, size(d), procs(d), [size(d.chunks)...])

base/deprecated.jl

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ export PipeString
120120
@deprecate open_any_tcp_port listenany
121121
@deprecate subtype issubtype
122122
@deprecate bsxfun broadcast
123+
@deprecate max(x) maximum(x)
124+
@deprecate min(x) minimum(x)
125+
@deprecate max(f::Function,x) maximum(f,x)
126+
@deprecate min(f::Function,x) minimum(f,x)
127+
@deprecate max(x,_::(),d) maximum(x,d)
128+
@deprecate min(x,_::(),d) minimum(x,d)
123129

124130
deprecated_ls() = run(`ls -l`)
125131
deprecated_ls(args::Cmd) = run(`ls -l $args`)

base/exports.jl

+2
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,9 @@ export
506506
logspace,
507507
mapslices,
508508
max,
509+
maximum,
509510
min,
511+
minimum,
510512
nans,
511513
ndims,
512514
nnz,

base/iterator.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Zip
2222
end
2323
zip(itrs...) = Zip(itrs...)
2424

25-
length(z::Zip) = min(length, z.itrs)
25+
length(z::Zip) = minimum(length, z.itrs)
2626
start(z::Zip) = { start(itr) for itr in z.itrs }
2727
function next(z::Zip, state)
2828
for i = 1:length(z.itrs)

base/linalg/bitarray.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gradient(F::BitVector, h::BitVector) = gradient(bitunpack(F), bitunpack(h))
7878
## diag and related
7979

8080
function diag(B::BitMatrix)
81-
n = min(size(B))
81+
n = minimum(size(B))
8282
v = similar(B, n)
8383
for i = 1:n
8484
v[i] = B[i,i]

base/linalg/blas.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function axpy!{T,Ta<:Number,Ti<:Integer}(alpha::Ta, x::Array{T}, rx::Union(Range
178178
error("Ranges should be of the same length")
179179
end
180180

181-
if min(rx) < 1 || max(rx) > length(x) || min(ry) < 1 || max(ry) > length(y)
181+
if minimum(rx) < 1 || maximum(rx) > length(x) || minimum(ry) < 1 || maximum(ry) > length(y)
182182
throw(BoundsError())
183183
end
184184
axpy!(length(rx), convert(T, alpha), pointer(x)+(first(rx)-1)*sizeof(T),
@@ -590,7 +590,7 @@ end
590590

591591
function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union(Range1{Ti},Range{Ti}),
592592
src::Array{T}, rsrc::Union(Range1{Ti},Range{Ti}))
593-
if min(rdest) < 1 || max(rdest) > length(dest) || min(rsrc) < 1 || max(rsrc) > length(src)
593+
if minimum(rdest) < 1 || maximum(rdest) > length(dest) || minimum(rsrc) < 1 || maximum(rsrc) > length(src)
594594
throw(BoundsError())
595595
end
596596
if length(rdest) != length(rsrc)

base/linalg/cholmod.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ end
987987
findnz(L::CholmodFactor) = findnz(CholmodSparse(L))
988988

989989
function diag{Tv}(A::CholmodSparse{Tv})
990-
minmn = min(size(A))
990+
minmn = minimum(size(A))
991991
res = zeros(Tv,minmn)
992992
cp0 = A.colptr0
993993
rv0 = A.rowval0

base/linalg/dense.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ isposdef(x::Number) = imag(x)==0 && real(x) > 0
2020
norm{T<:BlasFloat}(x::Vector{T}) = BLAS.nrm2(length(x), x, 1)
2121

2222
function norm{T<:BlasFloat, TI<:Integer}(x::Vector{T}, rx::Union(Range1{TI},Range{TI}))
23-
if min(rx) < 1 || max(rx) > length(x)
23+
if minimum(rx) < 1 || maximum(rx) > length(x)
2424
throw(BoundsError())
2525
end
2626
BLAS.nrm2(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx))
@@ -35,14 +35,14 @@ function norm{T<:BlasFloat}(x::Vector{T}, p::Number)
3535
elseif p == 1
3636
BLAS.asum(n, x, 1)
3737
elseif p == Inf
38-
max(abs(x))
38+
maximum(abs(x))
3939
elseif p == -Inf
40-
min(abs(x))
40+
minimum(abs(x))
4141
elseif p == 0
4242
convert(T, nnz(x))
4343
else
4444
absx = abs(x)
45-
dx = max(absx)
45+
dx = maximum(absx)
4646
if dx != zero(T)
4747
scale!(absx, 1/dx)
4848
a = dx * (sum(absx.^p).^(1/p))
@@ -135,7 +135,7 @@ function trace{T}(A::Matrix{T})
135135
error("expected square matrix")
136136
end
137137
t = zero(T)
138-
for i=1:min(size(A))
138+
for i=1:minimum(size(A))
139139
t += A[i,i]
140140
end
141141
return t
@@ -526,7 +526,7 @@ function pinv{T<:BlasFloat}(A::StridedMatrix{T})
526526
if m == 0 || n == 0 return Array(T, n, m) end
527527
SVD = svdfact(A, true)
528528
Sinv = zeros(T, length(SVD[:S]))
529-
index = SVD[:S] .> eps(real(one(T)))*max(m,n)*max(SVD[:S])
529+
index = SVD[:S] .> eps(real(one(T)))*max(m,n)*maximum(SVD[:S])
530530
Sinv[index] = 1.0 ./ SVD[:S][index]
531531
SVD[:Vt]'scale(Sinv, SVD[:U]')
532532
end
@@ -540,7 +540,7 @@ function null{T<:BlasFloat}(A::StridedMatrix{T})
540540
if m == 0 || n == 0 return eye(T, n) end
541541
SVD = svdfact(A, false)
542542
if m == 0; return eye(T, n); end
543-
indstart = sum(SVD[:S] .> max(m,n)*max(SVD[:S])*eps(eltype(SVD[:S]))) + 1
543+
indstart = sum(SVD[:S] .> max(m,n)*maximum(SVD[:S])*eps(eltype(SVD[:S]))) + 1
544544
SVD[:V][:,indstart:]
545545
end
546546
null{T<:Integer}(A::StridedMatrix{T}) = null(float(A))
@@ -549,8 +549,8 @@ null(a::StridedVector) = null(reshape(a, length(a), 1))
549549
function cond(A::StridedMatrix, p)
550550
if p == 2
551551
v = svdvals(A)
552-
maxv = max(v)
553-
return maxv == 0.0 ? Inf : maxv / min(v)
552+
maxv = maximum(v)
553+
return maxv == 0.0 ? Inf : maxv / minimum(v)
554554
elseif p == 1 || p == Inf
555555
m, n = size(A)
556556
if m != n; error("Use 2-norm for non-square matrices"); end

base/linalg/factorization.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ qr(A::Union(Number, AbstractMatrix)) = qr(A, true)
257257
size(A::QR, args::Integer...) = size(A.vs, args...)
258258

259259
function getindex(A::QR, d::Symbol)
260-
if d == :R; return triu(A.vs[1:min(size(A)),:]); end;
260+
if d == :R; return triu(A.vs[1:minimum(size(A)),:]); end;
261261
if d == :Q; return QRPackedQ(A); end
262262
error("No such type field")
263263
end
@@ -330,7 +330,7 @@ qrp(A::AbstractMatrix) = qrp(A, false)
330330
size(A::QRPivoted, args::Integer...) = size(A.hh, args...)
331331

332332
function getindex{T<:BlasFloat}(A::QRPivoted{T}, d::Symbol)
333-
if d == :R; return triu(A.hh[1:min(size(A)),:]); end;
333+
if d == :R; return triu(A.hh[1:minimum(size(A)),:]); end;
334334
if d == :Q; return QRPivotedQ(A); end
335335
if d == :p; return A.jpvt; end
336336
if d == :P
@@ -347,7 +347,7 @@ end
347347

348348
# Julia implementation similarly to xgelsy
349349
function (\){T<:BlasFloat}(A::QRPivoted{T}, B::StridedMatrix{T}, rcond::Real)
350-
nr = min(size(A.hh))
350+
nr = minimum(size(A.hh))
351351
nrhs = size(B, 2)
352352
if nr == 0 return zeros(0, nrhs), 0 end
353353
ar = abs(A.hh[1])
@@ -531,11 +531,11 @@ eigvals(x::Number) = [one(x)]
531531
#Computes maximum and minimum eigenvalue
532532
function eigmax(A::Union(Number, AbstractMatrix))
533533
v = eigvals(A)
534-
iseltype(v,Complex) ? error("Complex eigenvalues cannot be ordered") : max(v)
534+
iseltype(v,Complex) ? error("Complex eigenvalues cannot be ordered") : maximum(v)
535535
end
536536
function eigmin(A::Union(Number, AbstractMatrix))
537537
v = eigvals(A)
538-
iseltype(v,Complex) ? error("Complex eigenvalues cannot be ordered") : min(v)
538+
iseltype(v,Complex) ? error("Complex eigenvalues cannot be ordered") : minimum(v)
539539
end
540540

541541
inv(A::Eigen) = scale(A.vectors, 1.0/A.values)*A.vectors'

base/linalg/generic.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ function norm{T}(x::AbstractVector{T}, p::Number)
3636
if length(x) == 0
3737
a = zero(T)
3838
elseif p == Inf
39-
a = max(abs(x))
39+
a = maximum(abs(x))
4040
elseif p == -Inf
41-
a = min(abs(x))
41+
a = minimum(abs(x))
4242
else
4343
absx = abs(x)
44-
dx = max(absx)
44+
dx = maximum(absx)
4545
if dx != zero(T)
4646
scale!(absx, 1/dx)
4747
a = dx * (sum(absx.^p).^(1/p))
@@ -61,11 +61,11 @@ function norm(A::AbstractMatrix, p::Number)
6161
elseif m == 1 || n == 1
6262
a = norm(reshape(A, length(A)), p)
6363
elseif p == 1
64-
a = max(sum(abs(A),1))
64+
a = maximum(sum(abs(A),1))
6565
elseif p == 2
66-
a = max(svdvals(A))
66+
a = maximum(svdvals(A))
6767
elseif p == Inf
68-
a = max(sum(abs(A),2))
68+
a = maximum(sum(abs(A),2))
6969
else
7070
error("invalid parameter p given to compute matrix norm")
7171
end
@@ -85,7 +85,7 @@ function rank(A::AbstractMatrix)
8585
m,n = size(A)
8686
if m == 0 || n == 0; return 0; end
8787
sv = svdvals(A)
88-
sum(sv .> max(size(A))*eps(sv[1]))
88+
sum(sv .> maximum(size(A))*eps(sv[1]))
8989
end
9090
rank(x::Number) = x == 0 ? 0 : 1
9191

base/linalg/lapack.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ for (syev, syevr, sygvd, elty, relty) in
24572457
ccall(($(string(syev)),liblapack), Void,
24582458
(Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt},
24592459
Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}),
2460-
&jobz, &uplo, &n, A, &max(stride(A,2)), W, work, &lwork, rwork, info)
2460+
&jobz, &uplo, &n, A, &stride(A,2), W, work, &lwork, rwork, info)
24612461
if info[1] != 0 throw(LAPACKException(info[1])) end
24622462
if lwork < 0
24632463
lwork = blas_int(real(work[1]))

base/linalg/matmul.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ scale(b::Vector, A::Matrix) =
3939
dot{T<:Union(Float32, Float64)}(x::Vector{T}, y::Vector{T}) = BLAS.dot(x, y)
4040
function dot{T<:BLAS.BlasFloat, TI<:Integer}(x::Vector{T}, rx::Union(Range1{TI},Range{TI}), y::Vector{T}, ry::Union(Range1{TI},Range{TI}))
4141
length(rx) != length(ry) ? error("ranges should be of same length") : true
42-
if min(rx) < 1 || max(rx) > length(x) || min(ry) < 1 || max(ry) > length(y)
42+
if minimum(rx) < 1 || maximum(rx) > length(x) || minimum(ry) < 1 || maximum(ry) > length(y)
4343
throw(BoundsError())
4444
end
4545
BLAS.dot(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx), pointer(y)+(first(ry)-1)*sizeof(T), step(ry))

base/pkg/entry.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ function tag(pkg::String, ver::Union(Symbol,VersionNumber), commit::String, msg:
437437
sort!(existing)
438438
if isa(ver,Symbol)
439439
prv = isempty(existing) ? v"0" :
440-
isempty(ancestors) ? max(existing) : max(ancestors)
440+
isempty(ancestors) ? maximum(existing) : maximum(ancestors)
441441
ver = (ver == :bump ) ? nextbump(prv) :
442442
(ver == :patch) ? nextpatch(prv) :
443443
(ver == :minor) ? nextminor(prv) :

base/pkg/query.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function prune_versions(reqs::Requires, deps::Dict{ByteString,Dict{VersionNumber
188188
eqclassp = eq_classes[p]
189189
for cl in classes
190190
if !isempty(cl)
191-
vtop = max(cl)
191+
vtop = maximum(cl)
192192
push!(prunedp, vtop)
193193
@assert !haskey(eqclassp, vtop)
194194
eqclassp[vtop] = cl

base/pkg/read.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function installed_version(pkg::String, avail::Dict=available(pkg))
5858
ispath(pkg,".git") || return typemin(VersionNumber)
5959
head = Git.head(dir=pkg)
6060
vers = [keys(filter((ver,info)->info.sha1==head, avail))...]
61-
!isempty(vers) && return max(vers)
61+
!isempty(vers) && return maximum(vers)
6262
cache = Cache.path(pkg)
6363
cache_has_head = isdir(cache) && Git.iscommit(head, dir=cache)
6464
ancestors = VersionNumber[]
@@ -79,10 +79,10 @@ function installed_version(pkg::String, avail::Dict=available(pkg))
7979
both = sort!(intersect(ancestors,descendants))
8080
isempty(both) || warn("$pkg: some versions are both ancestors and descendants of head: $both")
8181
if !isempty(descendants)
82-
v = min(descendants)
82+
v = minimum(descendants)
8383
return VersionNumber(v.major, v.minor, v.patch, ("",), ())
8484
elseif !isempty(ancestors)
85-
v = max(ancestors)
85+
v = maximum(ancestors)
8686
return VersionNumber(v.major, v.minor, v.patch, (), ("",))
8787
else
8888
return typemin(VersionNumber)

base/pkg/resolve.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}})
6060
vers = Array((ByteString,VersionNumber,VersionNumber), 0)
6161
for (p,d) in deps, vn in keys(d)
6262
lvns = VersionNumber[filter(vn2->(vn2>vn), keys(d))...]
63-
nvn = isempty(lvns) ? typemax(VersionNumber) : min(lvns)
63+
nvn = isempty(lvns) ? typemax(VersionNumber) : minimum(lvns)
6464
push!(vers, (p,vn,nvn))
6565
end
6666
sort!(vers, by=pvn->(-ndeps[pvn[1]][pvn[2]]))

base/pkg/resolve/maxsum.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ type Messages
215215
end
216216
# normalize fields
217217
for p0 = 1:np
218-
m = max(fld[p0])
218+
m = maximum(fld[p0])
219219
for v0 = 1:spp[p0]
220220
fld[p0][v0] -= m
221221
end
@@ -303,7 +303,7 @@ function update(p0::Int, graph::Graph, msgs::Messages)
303303
# compute the new message by passing cavmsg
304304
# through the constraint encoded in the bitmask
305305
# (nearly equivalent to:
306-
# newmsg = [ max(cavmsg[bm1[:,v1]]) for v1 = 1:spp1 ]
306+
# newmsg = [ maximum(cavmsg[bm1[:,v1]]) for v1 = 1:spp1 ]
307307
# except for the gnrg term)
308308
m = FieldValue(-1)
309309
for v1 = 1:spp1
@@ -330,7 +330,7 @@ function update(p0::Int, graph::Graph, msgs::Messages)
330330
end
331331

332332
diff = newmsg - oldmsg
333-
maxdiff = max(maxdiff, max(abs(diff)))
333+
maxdiff = max(maxdiff, maximum(abs(diff)))
334334

335335
# update the field of p1
336336
fld1 = fld[p1]

0 commit comments

Comments
 (0)