use === nothing

Should decrease compile times
This commit is contained in:
Chris Rackauckas 2019-08-17 14:17:27 -04:00
parent ae4031b993
commit f12f6db310
11 changed files with 63 additions and 63 deletions

View File

@ -685,15 +685,15 @@ function processLineArg(plotattributes::KW, arg)
plotattributes[:linestyle] = arg
elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[:linewidth] = arg.width)
arg.color == nothing || (plotattributes[:linecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:linealpha] = arg.alpha)
arg.style == nothing || (plotattributes[:linestyle] = arg.style)
arg.width === nothing || (plotattributes[:linewidth] = arg.width)
arg.color === nothing || (plotattributes[:linecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[:linealpha] = arg.alpha)
arg.style === nothing || (plotattributes[:linestyle] = arg.style)
elseif typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:fillrange] = arg.size)
arg.color == nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:fillalpha] = arg.alpha)
arg.size === nothing || (plotattributes[:fillrange] = arg.size)
arg.color === nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha)
elseif typeof(arg) <: Arrow || arg in (:arrow, :arrows)
plotattributes[:arrow] = arg
@ -724,15 +724,15 @@ function processMarkerArg(plotattributes::KW, arg)
plotattributes[:markerstrokestyle] = arg
elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[:markerstrokewidth] = arg.width)
arg.color == nothing || (plotattributes[:markerstrokecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:markerstrokealpha] = arg.alpha)
arg.style == nothing || (plotattributes[:markerstrokestyle] = arg.style)
arg.width === nothing || (plotattributes[:markerstrokewidth] = arg.width)
arg.color === nothing || (plotattributes[:markerstrokecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[:markerstrokealpha] = arg.alpha)
arg.style === nothing || (plotattributes[:markerstrokestyle] = arg.style)
elseif typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:markersize] = arg.size)
arg.color == nothing || (plotattributes[:markercolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:markeralpha] = arg.alpha)
arg.size === nothing || (plotattributes[:markersize] = arg.size)
arg.color === nothing || (plotattributes[:markercolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[:markeralpha] = arg.alpha)
# linealpha
elseif allAlphas(arg)
@ -757,9 +757,9 @@ end
function processFillArg(plotattributes::KW, arg)
# fr = get(plotattributes, :fillrange, 0)
if typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:fillrange] = arg.size)
arg.color == nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:fillalpha] = arg.alpha)
arg.size === nothing || (plotattributes[:fillrange] = arg.size)
arg.color === nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha)
elseif typeof(arg) <: Bool
plotattributes[:fillrange] = arg ? 0 : nothing
@ -793,10 +793,10 @@ function processGridArg!(plotattributes::KW, arg, letter)
plotattributes[Symbol(letter, :gridstyle)] = arg
elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[Symbol(letter, :gridlinewidth)] = arg.width)
arg.color == nothing || (plotattributes[Symbol(letter, :foreground_color_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha)
arg.style == nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style)
arg.width === nothing || (plotattributes[Symbol(letter, :gridlinewidth)] = arg.width)
arg.color === nothing || (plotattributes[Symbol(letter, :foreground_color_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha)
arg.style === nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style)
# linealpha
elseif allAlphas(arg)
@ -822,10 +822,10 @@ function processMinorGridArg!(plotattributes::KW, arg, letter)
plotattributes[Symbol(letter, :minorgrid)] = true
elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width)
arg.color == nothing || (plotattributes[Symbol(letter, :foreground_color_minor_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha)
arg.style == nothing || (plotattributes[Symbol(letter, :minorgridstyle)] = arg.style)
arg.width === nothing || (plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width)
arg.color === nothing || (plotattributes[Symbol(letter, :foreground_color_minor_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha === nothing || (plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha)
arg.style === nothing || (plotattributes[Symbol(letter, :minorgridstyle)] = arg.style)
plotattributes[Symbol(letter, :minorgrid)] = true
# linealpha
@ -1237,7 +1237,7 @@ end
# v = plotattributes[k]
# plotattributes[k] = if v == :match
# match_color
# elseif v == nothing
# elseif v === nothing
# plot_color(RGBA(0,0,0,0))
# else
# v
@ -1246,7 +1246,7 @@ end
function color_or_nothing!(plotattributes::KW, k::Symbol)
v = plotattributes[k]
plotattributes[k] = if v == nothing || v == false
plotattributes[k] = if v === nothing || v == false
RGBA{Float64}(0,0,0,0)
elseif v != :match
plot_color(v)
@ -1563,11 +1563,11 @@ function _update_series_attributes!(plotattributes::KW, plt::Plot, sp::Subplot)
# update alphas
for asym in (:linealpha, :markeralpha, :fillalpha)
if plotattributes[asym] == nothing
if plotattributes[asym] === nothing
plotattributes[asym] = plotattributes[:seriesalpha]
end
end
if plotattributes[:markerstrokealpha] == nothing
if plotattributes[:markerstrokealpha] === nothing
plotattributes[:markerstrokealpha] = plotattributes[:markeralpha]
end

View File

@ -67,7 +67,7 @@ function process_axis_arg!(plotattributes::KW, arg, letter = "")
elseif T <: AVec
plotattributes[Symbol(letter,:ticks)] = arg
elseif arg == nothing
elseif arg === nothing
plotattributes[Symbol(letter,:ticks)] = []
elseif T <: Bool || arg in _allShowaxisArgs
@ -166,7 +166,7 @@ function optimal_ticks_and_labels(sp::Subplot, axis::Axis, ticks = nothing)
# or DateTime) is chosen based on the time span between amin and amax
# rather than on the input format
# TODO: maybe: non-trivial scale (:ln, :log2, :log10) for date/datetime
if ticks == nothing && scale == :identity
if ticks === nothing && scale == :identity
if axis[:formatter] == dateformatter
# optimize_datetime_ticks returns ticks and labels(!) based on
# integers/floats corresponding to the DateTime type. Thus, the axes
@ -184,7 +184,7 @@ function optimal_ticks_and_labels(sp::Subplot, axis::Axis, ticks = nothing)
end
# get a list of well-laid-out ticks
if ticks == nothing
if ticks === nothing
scaled_ticks = optimize_ticks(
sf(amin),
sf(amax);
@ -399,7 +399,7 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
# expand for fillrange
fr = plotattributes[:fillrange]
if fr == nothing && plotattributes[:seriestype] == :bar
if fr === nothing && plotattributes[:seriestype] == :bar
fr = 0.0
end
if fr != nothing && !all3D(plotattributes)
@ -419,7 +419,7 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
data = plotattributes[dsym]
bw = plotattributes[:bar_width]
if bw == nothing
if bw === nothing
bw = plotattributes[:bar_width] = _bar_width * ignorenan_minimum(filter(x->x>0,diff(sort(data))))
end
axis = sp.attr[Symbol(dsym, :axis)]

View File

@ -77,7 +77,7 @@ text_size(lab::AbstractString, sz::Number, rot::Number = 0) = text_size(length(l
# account for the size/length/rotation of tick labels
function tick_padding(sp::Subplot, axis::Axis)
ticks = get_ticks(sp, axis)
if ticks == nothing
if ticks === nothing
0mm
else
vals, labs = ticks

View File

@ -620,7 +620,7 @@ end
function gr_set_gradient(series::Series)
color = gr_get_color(series)
color !== nothing && gr_set_gradient(color)
color !=== nothing && gr_set_gradient(color)
end
function gr_get_color(series::Series)
@ -1509,7 +1509,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
lc = get_linecolor(series, clims)
gr_set_line(get_linewidth(series), get_linestyle(series), lc) #, series[:linealpha])
if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing
if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] === nothing
fc = get_fillcolor(series, clims)
gr_set_fill(fc) #, series[:fillalpha])
l, r = xpos-0.07, xpos-0.01
@ -1526,7 +1526,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if st in (:path, :straightline)
gr_set_transparency(lc, get_linealpha(series))
if series[:fillrange] == nothing || series[:ribbon] != nothing
if series[:fillrange] === nothing || series[:ribbon] != nothing
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos])
else
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos+0.4dy, ypos+0.4dy])

View File

@ -827,7 +827,7 @@ function plotly_html_head(plt::Plot)
end
function plotly_html_body(plt, style = nothing)
if style == nothing
if style === nothing
w, h = plt[:size]
style = "width:$(w)px;height:$(h)px;"
end

View File

@ -871,7 +871,7 @@ end
function py_set_ticks(ax, ticks, letter)
ticks == :auto && return
axis = getproperty(ax, Symbol(letter,"axis"))
if ticks == :none || ticks == nothing || ticks == false
if ticks == :none || ticks === nothing || ticks == false
kw = KW()
for dir in (:top,:bottom,:left,:right)
kw[dir] = kw[Symbol(:label,dir)] = false
@ -978,7 +978,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
# update subplots
for sp in plt.subplots
ax = sp.o
if ax == nothing
if ax === nothing
continue
end
@ -1186,7 +1186,7 @@ end
# to fit ticks, tick labels, guides, colorbars, etc.
function _update_min_padding!(sp::Subplot{PyPlotBackend})
ax = sp.o
ax == nothing && return sp.minpad
ax === nothing && return sp.minpad
plotbb = py_bbox(ax)
# TODO: this should initialize to the margin from sp.attr
@ -1352,7 +1352,7 @@ end
function _update_plot_object(plt::Plot{PyPlotBackend})
for sp in plt.subplots
ax = sp.o
ax == nothing && return
ax === nothing && return
figw, figh = sp.plt[:size]
figw, figh = figw*px, figh*px
pcts = bbox_to_pcts(sp.plotarea, figw, figh)

View File

@ -568,7 +568,7 @@ mutable struct EachAnn
end
function Base.iterate(ea::EachAnn, i = 1)
if ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y)
if ea.anns === nothing || isempty(ea.anns.strs) || i > length(ea.y)
return nothing
end

View File

@ -4,7 +4,7 @@ mutable struct CurrentPlot
end
const CURRENT_PLOT = CurrentPlot(nothing)
isplotnull() = CURRENT_PLOT.nullableplot == nothing
isplotnull() = CURRENT_PLOT.nullableplot === nothing
"""
current()

View File

@ -239,7 +239,7 @@ end
@recipe function f(::Type{Val{:sticks}}, x, y, z)
n = length(x)
fr = plotattributes[:fillrange]
if fr == nothing
if fr === nothing
sp = plotattributes[:subplot]
yaxis = sp[:yaxis]
fr = if yaxis[:scale] == :identity
@ -321,7 +321,7 @@ end
x := newx
y := newy
if z == nothing
if z === nothing
seriestype := :path
else
seriestype := :path3d
@ -357,7 +357,7 @@ end
# compute half-width of bars
bw = plotattributes[:bar_width]
hw = if bw == nothing
hw = if bw === nothing
if nx > 1
0.5*_bar_width*ignorenan_minimum(filter(x->x>0, diff(procx)))
else
@ -369,7 +369,7 @@ end
# make fillto a vector... default fills to 0
fillto = plotattributes[:fillrange]
if fillto == nothing
if fillto === nothing
fillto = 0
end
if (yscale in _logScales) && !all(_is_positive, fillto)
@ -491,7 +491,7 @@ end
@recipe function f(::Type{Val{:barbins}}, x, y, z)
edge, weights, xscale, yscale, baseline = _preprocess_binlike(plotattributes, x, y)
if (plotattributes[:bar_width] == nothing)
if (plotattributes[:bar_width] === nothing)
bar_width := diff(edge)
end
x := _bin_centers(edge)
@ -667,7 +667,7 @@ end
function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N
localvs = _filternans(vs)
edges = _hist_edges(localvs, binning)
h = float( weights == nothing ?
h = float( weights === nothing ?
StatsBase.fit(StatsBase.Histogram, localvs, edges, closed = :left) :
StatsBase.fit(StatsBase.Histogram, localvs, StatsBase.Weights(weights), edges, closed = :left)
)

View File

@ -26,7 +26,7 @@ function histogramHack(; kw...)
plotattributes[:x] = midpoints
plotattributes[:y] = float(counts)
plotattributes[:seriestype] = :bar
plotattributes[:fillrange] = plotattributes[:fillrange] == nothing ? 0.0 : plotattributes[:fillrange]
plotattributes[:fillrange] = plotattributes[:fillrange] === nothing ? 0.0 : plotattributes[:fillrange]
plotattributes
end
@ -38,7 +38,7 @@ function barHack(; kw...)
plotattributes = KW(kw)
midpoints = plotattributes[:x]
heights = plotattributes[:y]
fillrange = plotattributes[:fillrange] == nothing ? 0.0 : plotattributes[:fillrange]
fillrange = plotattributes[:fillrange] === nothing ? 0.0 : plotattributes[:fillrange]
# estimate the edges
dists = diff(midpoints) * 0.5
@ -81,7 +81,7 @@ function sticksHack(; kw...)
# these are the line vertices
x = Float64[]
y = Float64[]
fillrange = plotattributesLine[:fillrange] == nothing ? 0.0 : plotattributesLine[:fillrange]
fillrange = plotattributesLine[:fillrange] === nothing ? 0.0 : plotattributesLine[:fillrange]
# calculate the vertices
yScatter = plotattributesScatter[:y]
@ -194,7 +194,7 @@ end
function iter_segments(series::Series)
x, y, z = series[:x], series[:y], series[:z]
if x == nothing
if x === nothing
return UnitRange{Int}[]
elseif has_attribute_segments(series)
if series[:seriestype] in (:scatter, :scatter3d)
@ -478,7 +478,7 @@ function make_fillrange_from_ribbon(kw::KW)
rib1, rib2 = -first(rib), last(rib)
# kw[:ribbon] = nothing
kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2)
(get(kw, :fillalpha, nothing) == nothing) && (kw[:fillalpha] = 0.5)
(get(kw, :fillalpha, nothing) === nothing) && (kw[:fillalpha] = 0.5)
end
#turn tuple of fillranges to one path
@ -560,18 +560,18 @@ function colorbar_style(series::Series)
elseif iscontour(series)
cbar_lines
elseif series[:seriestype] (:heatmap,:surface) ||
any(series[z] !== nothing for z [:marker_z,:line_z,:fill_z])
any(series[z] !=== nothing for z [:marker_z,:line_z,:fill_z])
cbar_gradient
else
nothing
end
end
hascolorbar(series::Series) = colorbar_style(series) !== nothing
hascolorbar(series::Series) = colorbar_style(series) !=== nothing
hascolorbar(sp::Subplot) = sp[:colorbar] != :none && any(hascolorbar(s) for s in series_list(sp))
iscontour(series::Series) = series[:seriestype] == :contour
isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing
isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !=== nothing
function contour_levels(series::Series, clims)
iscontour(series) || error("Not a contour series")
@ -602,7 +602,7 @@ for comp in (:line, :fill, :marker)
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1)
c = series[$Symbol($compcolor)]
z = series[$Symbol($comp_z)]
if z == nothing
if z === nothing
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
else
grad = isa(c, ColorGradient) ? c : cgrad()
@ -613,7 +613,7 @@ for comp in (:line, :fill, :marker)
$get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i)
function $get_compcolor(series, i::Int = 1)
if series[$Symbol($comp_z)] == nothing
if series[$Symbol($comp_z)] === nothing
$get_compcolor(series, 0, 1, i)
else
$get_compcolor(series, get_clims(series[:subplot]), i)

View File

@ -64,7 +64,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
# now we have the fn (if any)... do the comparison
# @show reffn
if reffn == nothing
if reffn === nothing
reffn = newfn
end
# @show reffn
@ -98,7 +98,7 @@ function image_comparison_facts(pkg::Symbol;
tol = 1e-2) # acceptable error (percent)
for i in 1:length(Plots._examples)
i in skip && continue
if only == nothing || i in only
if only === nothing || i in only
@test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true
end
end