Merge pull request #2148 from JuliaPlots/nothing

use === nothing
This commit is contained in:
Christopher Rackauckas 2019-08-20 08:36:04 -04:00 committed by GitHub
commit 648f26f075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 124 additions and 124 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
@ -1121,7 +1121,7 @@ end
function _filter_input_data!(plotattributes::KW)
idxfilter = pop!(plotattributes, :idxfilter, nothing)
if idxfilter != nothing
if idxfilter !== nothing
filter_data!(plotattributes, idxfilter)
end
end
@ -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
@ -1602,13 +1602,13 @@ function _update_series_attributes!(plotattributes::KW, plt::Plot, sp::Subplot)
end
# if marker_z, fill_z or line_z are set, ensure we have a gradient
if plotattributes[:marker_z] != nothing
if plotattributes[:marker_z] !== nothing
ensure_gradient!(plotattributes, :markercolor, :markeralpha)
end
if plotattributes[:line_z] != nothing
if plotattributes[:line_z] !== nothing
ensure_gradient!(plotattributes, :linecolor, :linealpha)
end
if plotattributes[:fill_z] != nothing
if plotattributes[:fill_z] !== nothing
ensure_gradient!(plotattributes, :fillcolor, :fillalpha)
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);
@ -382,7 +382,7 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
data = plotattributes[letter] = Surface(Matrix{Float64}(data.surf))
end
expand_extrema!(axis, data)
elseif data != nothing
elseif data !== nothing
# TODO: need more here... gotta track the discrete reference value
# as well as any coord offset (think of boxplot shape coords... they all
# correspond to the same x-value)
@ -399,10 +399,10 @@ 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)
if fr !== nothing && !all3D(plotattributes)
axis = sp.attr[vert ? :yaxis : :xaxis]
if typeof(fr) <: Tuple
for fri in fr
@ -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

@ -147,7 +147,7 @@ gr_inqtext(x, y, s::Symbol) = gr_inqtext(x, y, string(s))
function gr_inqtext(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.inqmathtex(x, y, s[2:end-1])
elseif findfirst(isequal('\\'), s) != nothing || occursin("10^{", s)
elseif findfirst(isequal('\\'), s) !== nothing || occursin("10^{", s)
GR.inqtextext(x, y, s)
else
GR.inqtext(x, y, s)
@ -159,7 +159,7 @@ gr_text(x, y, s::Symbol) = gr_text(x, y, string(s))
function gr_text(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.mathtex(x, y, s[2:end-1])
elseif findfirst(isequal('\\'), s) != nothing || occursin("10^{", s)
elseif findfirst(isequal('\\'), s) !== nothing || occursin("10^{", s)
GR.textext(x, y, s)
else
GR.text(x, y, s)
@ -237,7 +237,7 @@ gr_z_axislims(sp::Subplot) = axis_limits(sp, :z)
gr_xy_axislims(sp::Subplot) = gr_x_axislims(sp)..., gr_y_axislims(sp)...
function gr_lims(sp::Subplot, axis::Axis, adjust::Bool, expand = nothing)
if expand != nothing
if expand !== nothing
expand_extrema!(axis, expand)
end
lims = axis_limits(sp, axis[:letter])
@ -629,11 +629,11 @@ function gr_get_color(series::Series)
series[:fillcolor]
elseif st in (:contour, :wireframe)
series[:linecolor]
elseif series[:marker_z] != nothing
elseif series[:marker_z] !== nothing
series[:markercolor]
elseif series[:line_z] != nothing
elseif series[:line_z] !== nothing
series[:linecolor]
elseif series[:fill_z] != nothing
elseif series[:fill_z] !== nothing
series[:fillcolor]
end
end
@ -880,7 +880,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
GR.selntran(0)
GR.setscale(0)
gr_set_font(legendfont(sp))
if sp[:legendtitle] != nothing
if sp[:legendtitle] !== nothing
tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle]))
legendw = tbx[3] - tbx[1]
legendn += 1
@ -1247,7 +1247,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if typeof(z) <: Surface
z = vec(transpose_z(series, z.surf, false))
elseif ispolar(sp)
if frng != nothing
if frng !== nothing
_, frng = convert_to_polar(x, frng, (rmin, rmax))
end
x, y = convert_to_polar(x, y, (rmin, rmax))
@ -1258,11 +1258,11 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
end
if st in (:path, :scatter, :straightline)
if x != nothing && length(x) > 1
if x !== nothing && length(x) > 1
lz = series[:line_z]
segments = iter_segments(series)
# do area fill
if frng != nothing
if frng !== nothing
GR.setfillintstyle(GR.INTSTYLE_SOLID)
fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng))
for (i, rng) in enumerate(segments)
@ -1301,7 +1301,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
plot_color(series[:linecolor]) in (black,[black])
end
h = gr_contour_levels(series, clims)
if series[:fillrange] != nothing
if series[:fillrange] !== nothing
if series[:fillcolor] != series[:linecolor] && !is_lc_black
@warn("GR: filled contour only supported with black contour lines")
end
@ -1496,7 +1496,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
gr_set_line(1, :solid, sp[:foreground_color_legend])
GR.drawrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
i = 0
if sp[:legendtitle] != nothing
if sp[:legendtitle] !== nothing
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF)
gr_set_textcolor(sp[:legendfontcolor])
gr_set_transparency(sp[:legendfontcolor])
@ -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

@ -121,9 +121,9 @@ function _create_backend_figure(plt::Plot{InspectDRBackend})
gplot = _inspectdr_getgui(plt.o)
#:overwrite_figure: want to reuse current figure
if plt[:overwrite_figure] && mplot != nothing
if plt[:overwrite_figure] && mplot !== nothing
mplot.subplots = [] #Reset
if gplot != nothing #Ensure still references current plot
if gplot !== nothing #Ensure still references current plot
gplot.src = mplot
end
else #want new one:

View File

@ -96,7 +96,7 @@ pgf_thickness_scaling(series) = pgf_thickness_scaling(series[:subplot])
function pgf_fillstyle(plotattributes, i = 1)
cstr,a = pgf_color(get_fillcolor(plotattributes, i))
fa = get_fillalpha(plotattributes, i)
if fa != nothing
if fa !== nothing
a = fa
end
"fill = $cstr, fill opacity=$a"
@ -216,12 +216,12 @@ function pgf_series(sp::Subplot, series::Series)
# add to legend?
if i == 1 && sp[:legend] != :none && should_add_to_legend(series)
if plotattributes[:fillrange] != nothing
if plotattributes[:fillrange] !== nothing
push!(style, "forget plot")
push!(series_collection, pgf_fill_legend_hack(plotattributes, args))
else
kw[:legendentry] = plotattributes[:label]
if st == :shape # || plotattributes[:fillrange] != nothing
if st == :shape # || plotattributes[:fillrange] !== nothing
push!(style, "area legend")
end
end
@ -238,7 +238,7 @@ function pgf_series(sp::Subplot, series::Series)
kw[:style] = join(style, ',')
# add fillrange
if series[:fillrange] != nothing && st != :shape
if series[:fillrange] !== nothing && st != :shape
push!(series_collection, pgf_fillrange_series(series, i, _cycle(series[:fillrange], rng), seg_args...))
end

View File

@ -403,7 +403,7 @@ end
function plotly_data(series::Series, letter::Symbol, data)
axis = series[:subplot][Symbol(letter, :axis)]
data = if axis[:ticks] == :native && data != nothing
data = if axis[:ticks] == :native && data !== nothing
plotly_native_data(axis, data)
else
data
@ -415,7 +415,7 @@ function plotly_data(series::Series, letter::Symbol, data)
plotly_data(data)
end
end
plotly_data(v) = v != nothing ? collect(v) : v
plotly_data(v) = v !== nothing ? collect(v) : v
plotly_data(surf::Surface) = surf.surf
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
@ -529,7 +529,7 @@ function plotly_series(plt::Plot, series::Series)
else
plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
plotattributes_out[:opacity] = series[:fillalpha]
if series[:fill_z] != nothing
if series[:fill_z] !== nothing
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
end
plotattributes_out[:showscale] = hascolorbar(sp)
@ -611,11 +611,11 @@ function plotly_series_shapes(plt::Plot, series::Series, clims)
plotly_hover!(plotattributes_out, _cycle(series[:hover], i))
plotattributes_outs[i] = plotattributes_out
end
if series[:fill_z] != nothing
if series[:fill_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill))
elseif series[:line_z] != nothing
elseif series[:line_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line))
elseif series[:marker_z] != nothing
elseif series[:marker_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker))
end
plotattributes_outs
@ -733,11 +733,11 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
end
end
if series[:line_z] != nothing
if series[:line_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line))
elseif series[:fill_z] != nothing
elseif series[:fill_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill))
elseif series[:marker_z] != nothing
elseif series[:marker_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker))
end
@ -782,7 +782,7 @@ function plotly_hover!(plotattributes_out::KW, hover)
# hover text
if hover in (:none, false)
plotattributes_out[:hoverinfo] = "none"
elseif hover != nothing
elseif hover !== nothing
plotattributes_out[:hoverinfo] = "text"
plotattributes_out[:text] = hover
end
@ -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

@ -216,7 +216,7 @@ end
# ---------------------------------------------------------------------------
function fix_xy_lengths!(plt::Plot{PyPlotBackend}, series::Series)
if series[:x] != nothing
if series[:x] !== nothing
x, y = series[:x], series[:y]
nx, ny = length(x), length(y)
if !isa(get(series.plotattributes, :z, nothing), Surface) && nx != ny
@ -434,7 +434,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if maximum(series[:linewidth]) > 0
segments = iter_segments(series)
# TODO: check LineCollection alternative for speed
# if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] != nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
# if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] !== nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
# # multicolored line segments
# n = length(segments)
# # segments = Array(Any,n)
@ -478,7 +478,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# end
a = series[:arrow]
if a != nothing && !is3d(st) # TODO: handle 3d later
if a !== nothing && !is3d(st) # TODO: handle 3d later
if typeof(a) != Arrow
@warn("Unexpected type for arrow: $(typeof(a))")
else
@ -508,7 +508,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if series[:markershape] != :none && st in (:path, :scatter, :path3d,
:scatter3d, :steppre, :steppost,
:bar)
markercolor = if any(typeof(series[arg]) <: AVec for arg in (:markercolor, :markeralpha)) || series[:marker_z] != nothing
markercolor = if any(typeof(series[arg]) <: AVec for arg in (:markercolor, :markeralpha)) || series[:marker_z] !== nothing
# py_color(plot_color.(get_markercolor.(series, clims, eachindex(x)), get_markeralpha.(series, eachindex(x))))
[py_color(plot_color(get_markercolor(series, clims, i), get_markeralpha(series, i))) for i in eachindex(x)]
else
@ -672,7 +672,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
push!(handles, handle)
# contour fills
if series[:fillrange] != nothing
if series[:fillrange] !== nothing
handle = ax."contourf"(x, y, z, levelargs...;
label = series[:label],
zorder = series[:series_plotindex] + 0.5,
@ -691,7 +691,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
end
z = transpose_z(series, z)
if st == :surface
if series[:fill_z] != nothing
if series[:fill_z] !== nothing
# the surface colors are different than z-value
extrakw[:facecolors] = py_shading(series[:fillcolor], transpose_z(series, series[:fill_z].surf))
extrakw[:shade] = false
@ -830,7 +830,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# handle area filling
fillrange = series[:fillrange]
if fillrange != nothing && st != :contour
if fillrange !== nothing && st != :contour
for (i, rng) in enumerate(iter_segments(series))
f, dim1, dim2 = if isvertical(series)
:fill_between, x[rng], y[rng]
@ -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
@ -1018,12 +1018,12 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
kw[:ticks] = locator
kw[:format] = formatter
kw[:boundaries] = vcat(0, kw[:values] + 0.5)
elseif any(colorbar_series[attr] != nothing for attr in (:line_z, :fill_z, :marker_z))
elseif any(colorbar_series[attr] !== nothing for attr in (:line_z, :fill_z, :marker_z))
cmin, cmax = get_clims(sp)
norm = pycolors."Normalize"(vmin = cmin, vmax = cmax)
f = if colorbar_series[:line_z] != nothing
f = if colorbar_series[:line_z] !== nothing
py_linecolormap
elseif colorbar_series[:fill_z] != nothing
elseif colorbar_series[:fill_z] !== nothing
py_fillcolormap
else
py_markercolormap
@ -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
@ -1297,7 +1297,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
for series in series_list(sp)
if should_add_to_legend(series)
# add a line/marker and a label
push!(handles, if series[:seriestype] == :shape || series[:fillrange] != nothing
push!(handles, if series[:seriestype] == :shape || series[:fillrange] !== nothing
pypatches."Patch"(
edgecolor = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
facecolor = py_color(single_color(get_fillcolor(series, clims)), get_fillalpha(series)),
@ -1335,7 +1335,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
frame = leg."get_frame"()
frame."set_linewidth"(py_thickness_scale(plt, 1))
leg."set_zorder"(1000)
sp[:legendtitle] != nothing && leg."set_title"(sp[:legendtitle])
sp[:legendtitle] !== nothing && leg."set_title"(sp[:legendtitle])
for txt in leg."get_texts"()
PyPlot.plt."setp"(txt, color = py_color(sp[:legendfontcolor]), family = sp[:legendfontfamily])
@ -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

@ -529,7 +529,7 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
# end
# @show msw msh
if anns != nothing && anns.baseshape != nothing
if anns !== nothing && anns.baseshape !== nothing
# we use baseshape to overwrite the markershape attribute
# with a list of custom shapes for each
msw,msh = anns.scalefactor
@ -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

@ -496,7 +496,7 @@ function test_examples(pkgname::Symbol; debug = false, disp = true, sleep = noth
Plots._debugMode.on = debug
plts = Dict()
for i in 1:length(_examples)
only != nothing && !(i in only) && continue
only !== nothing && !(i in only) && continue
i in skip && continue
try
plt = test_examples(pkgname, i, debug=debug, disp=disp)
@ -505,7 +505,7 @@ function test_examples(pkgname::Symbol; debug = false, disp = true, sleep = noth
# TODO: put error info into markdown?
@warn("Example $pkgname:$i:$(_examples[i].header) failed with: $ex")
end
if sleep != nothing
if sleep !== nothing
Base.sleep(sleep)
end
end

View File

@ -126,7 +126,7 @@ function _preprocess_userrecipe(kw::KW)
end
# convert a ribbon into a fillrange
if get(kw, :ribbon, nothing) != nothing
if get(kw, :ribbon, nothing) !== nothing
make_fillrange_from_ribbon(kw)
end
return
@ -136,7 +136,7 @@ function _add_errorbar_kw(kw_list::Vector{KW}, kw::KW)
# handle error bars by creating new recipedata data... these will have
# the same recipedata index as the recipedata they are copied from
for esym in (:xerror, :yerror)
if get(kw, esym, nothing) != nothing
if get(kw, esym, nothing) !== nothing
# we make a copy of the KW and apply an errorbar recipe
errkw = copy(kw)
errkw[:seriestype] = esym
@ -227,7 +227,7 @@ function _plot_setup(plt::Plot, plotattributes::KW, kw_list::Vector{KW})
# handle inset subplots
insets = plt[:inset_subplots]
if insets != nothing
if insets !== nothing
if !(typeof(insets) <: AVec)
insets = [insets]
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
@ -291,13 +291,13 @@ end
# create segmented bezier curves in place of line segments
@recipe function f(::Type{Val{:curves}}, x, y, z; npoints = 30)
args = z != nothing ? (x,y,z) : (x,y)
args = z !== nothing ? (x,y,z) : (x,y)
newx, newy = zeros(0), zeros(0)
fr = plotattributes[:fillrange]
newfr = fr != nothing ? zeros(0) : nothing
newz = z != nothing ? zeros(0) : nothing
newfr = fr !== nothing ? zeros(0) : nothing
newz = z !== nothing ? zeros(0) : nothing
# lz = plotattributes[:line_z]
# newlz = lz != nothing ? zeros(0) : nothing
# newlz = lz !== nothing ? zeros(0) : nothing
# for each line segment (point series with no NaNs), convert it into a bezier curve
# where the points are the control points of the curve
@ -306,13 +306,13 @@ end
ts = range(0, stop = 1, length = npoints)
nanappend!(newx, map(t -> bezier_value(_cycle(x,rng), t), ts))
nanappend!(newy, map(t -> bezier_value(_cycle(y,rng), t), ts))
if z != nothing
if z !== nothing
nanappend!(newz, map(t -> bezier_value(_cycle(z,rng), t), ts))
end
if fr != nothing
if fr !== nothing
nanappend!(newfr, map(t -> bezier_value(_cycle(fr,rng), t), ts))
end
# if lz != nothing
# if lz !== nothing
# lzrng = _cycle(lz, rng) # the line_z's for this segment
# push!(newlz, 0.0)
# append!(newlz, map(t -> lzrng[1+floor(Int, t * (length(rng)-1))], ts))
@ -321,16 +321,16 @@ end
x := newx
y := newy
if z == nothing
if z === nothing
seriestype := :path
else
seriestype := :path3d
z := newz
end
if fr != nothing
if fr !== nothing
fillrange := newfr
end
# if lz != nothing
# if lz !== nothing
# # line_z := newlz
# linecolor := (isa(plotattributes[:linecolor], ColorGradient) ? plotattributes[:linecolor] : cgrad())
# end
@ -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)
@ -533,7 +533,7 @@ function _stepbins_path(edge, weights, baseline::Real, xscale::Symbol, yscale::S
last_w = eltype(weights)(NaN)
while it_tuple_e != nothing && it_tuple_w != nothing
while it_tuple_e !== nothing && it_tuple_w !== nothing
b, it_state_e = it_tuple_e
w, it_state_w = it_tuple_w
@ -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

@ -22,7 +22,7 @@ function _get_defaults(s::Symbol)
:fglegend => thm.text,
:palette => thm.palette,
)
if thm.gradient != nothing
if thm.gradient !== nothing
push!(defaults, :gradient => thm.gradient)
end
return defaults

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
@ -529,7 +529,7 @@ function get_clims(sp::Subplot)
for vals in (series[:seriestype] in z_colored_series ? series[:z] : nothing, series[:line_z], series[:marker_z], series[:fill_z])
if (typeof(vals) <: AbstractSurface) && (eltype(vals.surf) <: Union{Missing, Real})
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals.surf)...)
elseif (vals != nothing) && (eltype(vals) <: Union{Missing, Real})
elseif (vals !== nothing) && (eltype(vals) <: Union{Missing, Real})
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals)...)
end
end
@ -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)
@ -650,7 +650,7 @@ function has_attribute_segments(series::Series)
for letter in (:x, :y, :z)
# If we have NaNs in the data they define the segments and
# SegmentsIterator is used
series[letter] != nothing && NaN in collect(series[letter]) && return false
series[letter] !== nothing && NaN in collect(series[letter]) && return false
end
series[:seriestype] == :shape && return false
# ... else we check relevant attributes if they have multiple inputs

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