diff --git a/src/args.jl b/src/args.jl index 6f719bae..68c72455 100644 --- a/src/args.jl +++ b/src/args.jl @@ -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 diff --git a/src/axes.jl b/src/axes.jl index 8ef97f7e..66a42793 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -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)] diff --git a/src/backends.jl b/src/backends.jl index a95b2dd2..01226e78 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -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 diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 691daa83..dd21e3a6 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -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]) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index bdad392a..78df1a84 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -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 diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index eec1e6ca..5751a43f 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -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) diff --git a/src/components.jl b/src/components.jl index 097aee19..4aa27043 100644 --- a/src/components.jl +++ b/src/components.jl @@ -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 diff --git a/src/plot.jl b/src/plot.jl index 2c2ecd48..4352403a 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -4,7 +4,7 @@ mutable struct CurrentPlot end const CURRENT_PLOT = CurrentPlot(nothing) -isplotnull() = CURRENT_PLOT.nullableplot == nothing +isplotnull() = CURRENT_PLOT.nullableplot === nothing """ current() diff --git a/src/recipes.jl b/src/recipes.jl index 9227f189..1424c6e5 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -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) ) diff --git a/src/utils.jl b/src/utils.jl index 666c878d..0415664c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 206b8d50..1aa4ceee 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -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