replace min and max with _min and _max

This commit is contained in:
Michael K. Borregaard 2017-05-30 21:58:04 +02:00
parent 172805bcf9
commit 74ad9fb880
8 changed files with 30 additions and 30 deletions

View File

@ -260,8 +260,8 @@ end
function expand_extrema!(ex::Extrema, v::Number)
ex.emin = min(v, ex.emin)
ex.emax = max(v, ex.emax)
ex.emin = _min(v, ex.emin)
ex.emax = _max(v, ex.emax)
ex
end
@ -276,8 +276,8 @@ expand_extrema!(axis::Axis, ::Bool) = axis[:extrema]
function expand_extrema!{MIN<:Number,MAX<:Number}(axis::Axis, v::Tuple{MIN,MAX})
ex = axis[:extrema]
ex.emin = min(v[1], ex.emin)
ex.emax = max(v[2], ex.emax)
ex.emin = _min(v[1], ex.emin)
ex.emax = _max(v[2], ex.emax)
ex
end
function expand_extrema!{N<:Number}(axis::Axis, v::AVec{N})
@ -368,8 +368,8 @@ end
# push the limits out slightly
function widen(lmin, lmax)
span = lmax - lmin
# eps = max(1e-16, min(1e-2span, 1e-10))
eps = max(1e-16, 0.03span)
# eps = _max(1e-16, min(1e-2span, 1e-10))
eps = _max(1e-16, 0.03span)
lmin-eps, lmax+eps
end
@ -425,7 +425,7 @@ function discrete_value!(axis::Axis, dv)
# @show axis[:discrete_map], axis[:discrete_values], dv
if cv_idx == -1
ex = axis[:extrema]
cv = max(0.5, ex.emax + 1.0)
cv = _max(0.5, ex.emax + 1.0)
expand_extrema!(axis, cv)
push!(axis[:discrete_values], dv)
push!(axis[:continuous_values], cv)

View File

@ -410,14 +410,14 @@ end
dist(a, b) = abs(a-b)
mindist(x, a, b) = min(dist(a, x), dist(b, x))
mindist(x, a, b) = _min(dist(a, x), dist(b, x))
function gappy(x, ps)
n = length(ps)
x <= first(ps) && return first(ps) - x
for j=1:(n-1)
p0 = ps[j]
p1 = ps[min(j+1, n)]
p1 = ps[_min(j+1, n)]
if p0 <= x && p1 >= x
return mindist(x, p0, p1) * (isodd(j) ? 1 : -1)
end

View File

@ -338,7 +338,7 @@ end
function gr_set_line(lw, style, c) #, a)
GR.setlinetype(gr_linetype[style])
w, h = gr_plot_size
GR.setlinewidth(max(0, lw / ((w + h) * 0.001)))
GR.setlinewidth(_max(0, lw / ((w + h) * 0.001)))
gr_set_linecolor(c) #, a)
end
@ -391,7 +391,7 @@ function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, vi
viewport[4] = viewport_canvas[4] * (1.0 - top(bb) / h)
if is3d(sp)
vp = viewport[:]
extent = min(vp[2] - vp[1], vp[4] - vp[3])
extent = _min(vp[2] - vp[1], vp[4] - vp[3])
viewport[1] = 0.5 * (vp[1] + vp[2] - extent)
viewport[2] = 0.5 * (vp[1] + vp[2] + extent)
viewport[3] = 0.5 * (vp[3] + vp[4] - extent)
@ -425,7 +425,7 @@ function gr_set_viewport_polar()
ymax -= 0.05 * (xmax - xmin)
xcenter = 0.5 * (xmin + xmax)
ycenter = 0.5 * (ymin + ymax)
r = 0.5 * min(xmax - xmin, ymax - ymin)
r = 0.5 * _min(xmax - xmin, ymax - ymin)
GR.setviewport(xcenter -r, xcenter + r, ycenter - r, ycenter + r)
GR.setwindow(-1, 1, -1, 1)
r

View File

@ -349,7 +349,7 @@ function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend})
ymin, ymax = axis_limits(yaxis)
if ispolar(sp)
#Plots.jl appears to give (xmin,xmax) ≜ (Θmin,Θmax) & (ymin,ymax) ≜ (rmin,rmax)
rmax = max(abs(ymin), abs(ymax))
rmax = _max(abs(ymin), abs(ymax))
xmin, xmax = -rmax, rmax
ymin, ymax = -rmax, rmax
end

View File

@ -926,14 +926,14 @@ function py_compute_axis_minval(axis::Axis)
for series in series_list(sp)
v = series.d[axis[:letter]]
if !isempty(v)
minval = min(minval, _minimum(abs(v)))
minval = _min(minval, _minimum(abs(v)))
end
end
end
# now if the axis limits go to a smaller abs value, use that instead
vmin, vmax = axis_limits(axis)
minval = min(minval, abs(vmin), abs(vmax))
minval = _min(minval, abs(vmin), abs(vmax))
minval
end
@ -954,7 +954,7 @@ function py_set_scale(ax, axis::Axis)
elseif scale == :log10
10
end
kw[Symbol(:linthresh,letter)] = max(1e-16, py_compute_axis_minval(axis))
kw[Symbol(:linthresh,letter)] = _max(1e-16, py_compute_axis_minval(axis))
"symlog"
end
func(arg; kw...)
@ -1096,10 +1096,10 @@ function _update_min_padding!(sp::Subplot{PyPlotBackend})
bottompad = 0mm
for bb in (py_bbox_axis(ax, "x"), py_bbox_axis(ax, "y"), py_bbox_title(ax))
if ispositive(width(bb)) && ispositive(height(bb))
leftpad = max(leftpad, left(plotbb) - left(bb))
toppad = max(toppad, top(plotbb) - top(bb))
rightpad = max(rightpad, right(bb) - right(plotbb))
bottompad = max(bottompad, bottom(bb) - bottom(plotbb))
leftpad = _max(leftpad, left(plotbb) - left(bb))
toppad = _max(toppad, top(plotbb) - top(bb))
rightpad = _max(rightpad, right(bb) - right(plotbb))
bottompad = _max(bottompad, bottom(bb) - bottom(plotbb))
end
end

View File

@ -55,10 +55,10 @@ function Base.:+(bb1::BoundingBox, bb2::BoundingBox)
ispositive(width(bb2)) || return bb1
ispositive(height(bb2)) || return bb1
l = min(left(bb1), left(bb2))
t = min(top(bb1), top(bb2))
r = max(right(bb1), right(bb2))
b = max(bottom(bb1), bottom(bb2))
l = _min(left(bb1), left(bb2))
t = _min(top(bb1), top(bb2))
r = _max(right(bb1), right(bb2))
b = _max(bottom(bb1), bottom(bb2))
BoundingBox(l, t, r-l, b-t)
end

View File

@ -225,7 +225,7 @@ end
fr = if yaxis[:scale] == :identity
0.0
else
min(axis_limits(yaxis)[1], _minimum(y))
_min(axis_limits(yaxis)[1], _minimum(y))
end
end
newx, newy = zeros(3n), zeros(3n)
@ -548,7 +548,7 @@ Plots.@deps stepbins path
function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode::Symbol = :auto)
_cl(x) = max(ceil(Int, x), 1)
_cl(x) = _max(ceil(Int, x), 1)
_iqr(v) = quantile(v, 0.75) - quantile(v, 0.25)
_span(v) = _maximum(v) - _minimum(v)

View File

@ -6,7 +6,7 @@ function binData(data, nbins)
lo, hi = _extrema(data)
edges = collect(linspace(lo, hi, nbins+1))
midpoints = calcMidpoints(edges)
buckets = Int[max(2, min(searchsortedfirst(edges, x), length(edges)))-1 for x in data]
buckets = Int[_max(2, _min(searchsortedfirst(edges, x), length(edges)))-1 for x in data]
counts = zeros(Int, length(midpoints))
for b in buckets
counts[b] += 1
@ -284,8 +284,8 @@ unzip{T}(xyuv::FixedSizeArrays.Vec{4,T}) = T[xyuv[1]], T[xyuv[2]], T[xyuv[
function _expand_limits(lims, x)
try
e1, e2 = _extrema(x)
lims[1] = min(lims[1], e1)
lims[2] = max(lims[2], e2)
lims[1] = _min(lims[1], e1)
lims[2] = _max(lims[2], e2)
# catch err
# warn(err)
end
@ -343,7 +343,7 @@ end
function calc_r_extrema(x, y)
xmin, xmax = _extrema(x)
ymin, ymax = _extrema(y)
r = 0.5 * min(xmax - xmin, ymax - ymin)
r = 0.5 * _min(xmax - xmin, ymax - ymin)
_extrema(r)
end