diff --git a/Project.toml b/Project.toml index ce84fa85c..b7663da4d 100644 --- a/Project.toml +++ b/Project.toml @@ -34,7 +34,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] CategoricalArrays = "0.5" Colors = "0.9" -Compat = "2" +Compat = "2.1" Compose = "0.7" Contour = "0.5" CoupledFields = "0.1" diff --git a/src/Gadfly.jl b/src/Gadfly.jl index b517bc2af..06edc7630 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -503,7 +503,7 @@ function render_prepare(plot::Plot) unscaled_aesthetics = setdiff(used_aesthetics, scaled_aesthetics) - _theme(plt, lyr) = lyr.theme == nothing ? plt.theme : lyr.theme + _theme(plt, lyr) = lyr.theme === nothing ? plt.theme : lyr.theme # Add default scales for statistics. layer_stats_with_theme = map(plot.layers, layer_stats) do l, stats @@ -532,17 +532,17 @@ function render_prepare(plot::Plot) in(var, mapped_aesthetics) || continue var_data = getfield(plot.data, var) - if var_data == nothing + if var_data === nothing for data in datas var_layer_data = getfield(data, var) - if var_layer_data != nothing + if var_layer_data !== nothing var_data = var_layer_data break end end end - var_data == nothing && continue + var_data === nothing && continue t = classify_data(var_data) if scale_exists(t, var) @@ -560,7 +560,7 @@ function render_prepare(plot::Plot) t = :categorical for data in Iterators.flatten((datas, subplot_datas)) val = getfield(data, var) - if val != nothing && val != :categorical + if val !== nothing && val != :categorical t = classify_data(val) end end @@ -653,30 +653,33 @@ function render_prepare(plot::Plot) # I. Scales layer_aess = Scale.apply_scales(IterTools.distinct(values(scales)), - datas..., subplot_datas...) + vcat(datas, subplot_datas)) # set defaults for key titles keyvars = [:color, :shape] for (i, layer) in enumerate(plot.layers) for kv in keyvars - fflag = (getfield(layer_aess[i], Symbol(kv,"_key_title")) == nothing) && haskey(layer.mapping, kv) && !isa(layer.mapping[kv], AbstractArray) + fflag = (getfield(layer_aess[i], Symbol(kv,"_key_title")) === nothing) && + haskey(layer.mapping, kv) && + !isa(layer.mapping[kv], AbstractArray) fflag && setfield!(layer_aess[i], Symbol(kv,"_key_title"), string(layer.mapping[kv])) end end for kv in keyvars - fflag = (getfield(layer_aess[1], Symbol(kv,"_key_title")) == nothing) && haskey(plot.mapping, kv) && !isa(plot.mapping[kv], AbstractArray) + fflag = (getfield(layer_aess[1], Symbol(kv,"_key_title")) === nothing) && + haskey(plot.mapping, kv) && !isa(plot.mapping[kv], AbstractArray) fflag && setfield!(layer_aess[1], Symbol(kv,"_key_title"), string(plot.mapping[kv])) end # Auto-update color scale if shape==color catdatas = vcat(datas, subplot_datas) shapev = getfield.(catdatas, :shape) - di = (shapev.!=nothing) .& (shapev.== getfield.(catdatas, :color)) + di = @. (shapev !== nothing) & (shapev == getfield(catdatas, :color)) supress_colorkey = false for (aes, data) in zip(layer_aess[di], catdatas[di]) - aes.shape_key_title==nothing && (aes.shape_key_title=aes.color_key_title="Shape") + aes.shape_key_title === nothing && (aes.shape_key_title=aes.color_key_title="Shape") colorf = scales[:color].f scales[:color] = Scale.color_discrete(colorf, levels=scales[:shape].levels, order=scales[:shape].order) Scale.apply_scale(scales[:color], [aes], Gadfly.Data(color=getfield(data,:color)) ) @@ -692,7 +695,7 @@ function render_prepare(plot::Plot) end # IIb. Plot-wise Statistics - plot_aes = concat(layer_aess...) + plot_aes = concat(layer_aess) statistics = collect(statistics) Stat.apply_statistics(statistics, scales, coord, plot_aes) @@ -713,7 +716,7 @@ function render_prepare(plot::Plot) if !supress_keys for (KT, kv) in zip(keytypes, keyvars) - fflag = !all([getfield(aes, kv)==nothing for aes in [plot_aes, layer_aess...]]) + fflag = !all([getfield(aes, kv) === nothing for aes in [plot_aes, layer_aess...]]) fflag && !in(KT, explicit_guide_types) && push!(guides, KT()) end end @@ -756,7 +759,7 @@ function render(plot::Plot) ctx = pad_inner(root_context, plot.theme.plot_padding...) - if plot.theme.background_color != nothing + if plot.theme.background_color !== nothing compose!(ctx, (context(order=-1000000), fill(plot.theme.background_color), stroke(nothing), rectangle())) @@ -809,28 +812,24 @@ function render_prepared(plot::Plot, # IV. Geometries themes = Theme[layer.theme === nothing ? plot.theme : layer.theme for layer in plot.layers] - zips = trim_zip(plot.layers, layer_aess, - layer_subplot_aess, - layer_subplot_datas, - themes) - - compose!(plot_context, - [compose(context(order=layer.order), render(layer.geom, theme, aes, - subplot_aes, subplot_data, - scales)) - for (layer, aes, subplot_aes, subplot_data, theme) in zips]...) + zips = trim_zip(plot.layers, layer_aess, layer_subplot_aess, + layer_subplot_datas, themes) + for (layer, aes, subplot_aes, subplot_data, theme) in zips + r = render(layer.geom, theme, aes, subplot_aes, subplot_data, scales) + compose!(plot_context, (context(order=layer.order), r)) + end#for # V. Guides - guide_contexts = Any[] + guide_contexts = Guide.PositionedGuide[] for guide in guides guide_context = render(guide, plot.theme, plot_aes, dynamic) - if guide_context != nothing + if guide_context !== nothing append!(guide_contexts, guide_context) end end tbl = Guide.layout_guides(plot_context, coord, - plot.theme, guide_contexts...) + plot.theme, guide_contexts) if table_only return tbl end diff --git a/src/aesthetics.jl b/src/aesthetics.jl index 0ac515231..2617831a1 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -102,7 +102,7 @@ function show(io::IO, data::Aesthetics) print(io, "Aesthetics(") for name in valid_aesthetics val = getfield(data, name) - if !ismissing(val) && val != nothing + if !ismissing(val) && val !== nothing print(io, "\n ", string(name), "=") show(io, getfield(data, name)) end @@ -172,7 +172,7 @@ function assert_aesthetics_undefined(who::AbstractString, aes::Aesthetics, vars: end function assert_aesthetics_equal_length(who::AbstractString, aes::Aesthetics, vars::Symbol...) - defined_vars = Compat.Iterators.filter(var -> !(getfield(aes, var) === nothing), vars) + defined_vars = Compat.Iterators.filter(var -> getfield(aes, var) !== nothing, vars) if !isempty(defined_vars) n = length(getfield(aes, first(defined_vars))) @@ -198,7 +198,7 @@ end # function update!(a::Aesthetics, b::Aesthetics) for name in valid_aesthetics - issomething(getfield(b, name)) && setfield(a, name, getfield(b, name)) + getfield(b, name) !== nothing && setfield(a, name, getfield(b, name)) end nothing end @@ -226,26 +226,21 @@ json(a::Aesthetics) = join([string(a, ":", json(getfield(a, var))) for var in ae # Returns: # A new Aesthetics instance with vectors concatenated. # -function concat(aess::Aesthetics...) +function concat(aess) cataes = Aesthetics() for aes in aess for var in valid_aesthetics - if var in [:xviewmin, :yviewmin] - mu, mv = getfield(cataes, var), getfield(aes, var) - setfield!(cataes, var, - mu === nothing ? mv : - mv == nothing ? mu : - min(mu, mv)) - elseif var in [:xviewmax, :yviewmax] - mu, mv = getfield(cataes, var), getfield(aes, var) - setfield!(cataes, var, - mu === nothing ? mv : - mv == nothing ? mu : - max(mu, mv)) + mu, mv = getfield(cataes, var), getfield(aes, var) + isviewmin = var in (:xviewmin, :yviewmin) + isviewmax = var in (:xviewmax, :yviewmax) + mumv = if isviewmin + mu === nothing ? mv : mv === nothing ? mu : min(mu, mv) + elseif isviewmax + mu === nothing ? mv : mv === nothing ? mu : max(mu, mv) else - setfield!(cataes, var, - cat_aes_var!(getfield(cataes, var), getfield(aes, var))) - end + cat_aes_var!(mu, mv) + end#if + setfield!(cataes, var, mumv) end end cataes @@ -405,12 +400,12 @@ function inherit!(a::Aesthetics, b::Aesthetics; bval = getfield(b, field) if field in clobber_set setfield!(a, field, bval) - elseif aval === missing || aval === nothing || aval === string || aval == showoff + elseif aval === missing || aval === nothing || aval === string || aval === showoff setfield!(a, field, bval) - elseif field == :xviewmin || field == :yviewmin - bval != nothing && (aval == nothing || aval > bval) && setfield!(a, field, bval) - elseif field == :xviewmax || field == :yviewmax - bval != nothing && (aval == nothing || aval < bval) && setfield!(a, field, bval) + elseif field in (:xviewmin, :yviewmin) && bval !== nothing + (aval === nothing || aval > bval) && setfield!(a, field, bval) + elseif field in (:xviewmax, :yviewmax) && bval !== nothing + (aval === nothing || aval < bval) && setfield!(a, field, bval) elseif typeof(aval) <: Dict && typeof(bval) <: Dict merge!(aval, getfield(b, field)) end diff --git a/src/coord.jl b/src/coord.jl index 5358591a1..9d3c1784a 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -153,7 +153,7 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics}, xmin = xmax = first_concrete_aesthetic_value(aess, coord.xvars) - if xmin != nothing + if xmin !== nothing for var in coord.xvars for aes in aess vals = getfield(aes, var) @@ -169,7 +169,7 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics}, end ymin = ymax = first_concrete_aesthetic_value(aess, coord.yvars) - if ymin != nothing + if ymin !== nothing for var in coord.yvars for aes in aess vals = getfield(aes, var) @@ -196,19 +196,19 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics}, # viewmin/max that is set explicitly should override min/max for aes in aess - if aes.xviewmin != nothing + if aes.xviewmin !== nothing xviewmin = xviewmin === nothing ? aes.xviewmin : min(xviewmin, aes.xviewmin) end - if aes.xviewmax != nothing + if aes.xviewmax !== nothing xviewmax = xviewmax === nothing ? aes.xviewmax : max(xviewmax, aes.xviewmax) end - if aes.yviewmin != nothing + if aes.yviewmin !== nothing yviewmin = yviewmin === nothing ? aes.yviewmin : min(yviewmin, aes.yviewmin) end - if aes.yviewmax != nothing + if aes.yviewmax !== nothing yviewmax = yviewmax === nothing ? aes.yviewmax : max(yviewmax, aes.yviewmax) end end diff --git a/src/data.jl b/src/data.jl index d8334b016..4c63cae71 100644 --- a/src/data.jl +++ b/src/data.jl @@ -62,7 +62,7 @@ function chain(ds::Data...) chained_data = Data() for name in data_fields vs = Any[getfield(d, name) for d in ds] - vs = Any[v for v in filter(issomething, vs)] + vs = Any[v for v in filter(!isnothing, vs)] if isempty(vs) setfield!(chained_data, name, nothing) else @@ -78,7 +78,7 @@ function show(io::IO, data::Data) maxlen = 0 print(io, "Data(") for name in data_fields - if getfield(data, name) != nothing + if getfield(data, name) !== nothing print(io, "\n ", string(name), "=") show(io, getfield(data, name)) end diff --git a/src/dataframes.jl b/src/dataframes.jl index 622237fd4..eeb4e76ba 100644 --- a/src/dataframes.jl +++ b/src/dataframes.jl @@ -11,7 +11,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) vm = um grouped_columns = Set{Symbol}() for colgroup in colgroups - if colgroup.columns===nothing # null => group all columns + if colgroup.columns === nothing # null => group all columns vm *= un grouped_columns = copy(allcolumns) else @@ -34,7 +34,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) # allocate vectors for grouped columns for (j, colgroup) in enumerate(colgroups) - cols = colgroup.columns===nothing ? allcolumns : colgroup.columns + cols = colgroup.columns === nothing ? allcolumns : colgroup.columns # figure the grouped common column type firstcol = U[first(cols)] @@ -64,7 +64,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) col_indicators = Array{Symbol}(undef, vm, length(colgroups)) row_indicators = Array{Int}(undef, vm, length(colgroups)) - colidxs = [colgroup.columns===nothing ? collect(allcolumns) : colgroup.columns + colidxs = [colgroup.columns === nothing ? collect(allcolumns) : colgroup.columns for colgroup in colgroups] vi = 1 diff --git a/src/geom/boxplot.jl b/src/geom/boxplot.jl index 0fc6222f2..c56a8bcb4 100644 --- a/src/geom/boxplot.jl +++ b/src/geom/boxplot.jl @@ -123,7 +123,7 @@ function render(geom::BoxplotGeometry, theme::Gadfly.Theme, aes::Gadfly.Aestheti svgclass("geometry")) # Outliers - if !geom.suppress_outliers && aes.outliers != nothing && !isempty(aes.outliers) + if !geom.suppress_outliers && aes.outliers !== nothing && !isempty(aes.outliers) xys = collect(Iterators.flatten(zip(cycle([x]), ys, cycle([c])) for (x, ys, c) in zip(xs, aes.outliers, cs))) compose!(ctx, (context(), @@ -133,7 +133,7 @@ function render(geom::BoxplotGeometry, theme::Gadfly.Theme, aes::Gadfly.Aestheti end # Middle - if aes.middle != nothing + if aes.middle !== nothing compose!(ctx, ( context(order=1), Compose.line([[(x - fw/2, mid), (x + fw/2, mid)] diff --git a/src/geom/errorbar.jl b/src/geom/errorbar.jl index 65dafa47b..2e5bfb4a0 100644 --- a/src/geom/errorbar.jl +++ b/src/geom/errorbar.jl @@ -110,7 +110,7 @@ function render(geom::YErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthe stroke([theme.stroke_color(c) for c in aes.color]), linewidth(theme.line_width)) - (aes.color_key_continuous == true || aes.color == nothing) || compose!(ctx, + (aes.color_key_continuous == true || aes.color === nothing) || compose!(ctx, svgclass([svg_color_class_from_label(aes.color_label([c])[1]) for c in aes.color])) return ctx @@ -148,7 +148,7 @@ function render(geom::XErrorBarGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthe stroke([theme.stroke_color(c) for c in aes.color]), linewidth(theme.line_width)) - (aes.color_key_continuous == true || aes.color == nothing) || compose!(ctx, + (aes.color_key_continuous == true || aes.color === nothing) || compose!(ctx, svgclass([svg_color_class_from_label(aes.color_label([c])[1]) for c in aes.color])) diff --git a/src/geom/hvabline.jl b/src/geom/hvabline.jl index 70f5248a1..ca8e86000 100755 --- a/src/geom/hvabline.jl +++ b/src/geom/hvabline.jl @@ -131,12 +131,12 @@ const abline = ABLineGeometry element_aesthetics(geom::ABLineGeometry) = [:intercept, :slope] function render(geom::ABLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) - if aes.intercept == nothing && aes.slope == nothing + if aes.intercept === nothing && aes.slope === nothing aes.intercept = [0] aes.slope = [1] - elseif aes.intercept == nothing + elseif aes.intercept === nothing aes.intercept = fill(0,length(aes.slope)) - elseif aes.slope == nothing + elseif aes.slope === nothing aes.slope = fill(1,length(aes.intercept)) end Gadfly.assert_aesthetics_equal_length("Geom.line", aes, element_aesthetics(geom)...) diff --git a/src/geom/label.jl b/src/geom/label.jl index a26ee82e7..94a277c60 100644 --- a/src/geom/label.jl +++ b/src/geom/label.jl @@ -50,7 +50,7 @@ function deferred_label_context(geom::LabelGeometry, num_labels = length(aes.label) - if aes.size == nothing + if aes.size === nothing padding = fill(theme.point_size, num_labels) .+ theme.label_padding else padding = aes.size .+ theme.label_padding @@ -279,7 +279,7 @@ function render(geom::LabelGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics end hpos, vpos, xoff, yoff = label_layouts[geom.position] - if aes.size == nothing + if aes.size === nothing offsets = [(xoff*(theme.point_size + theme.label_padding), yoff*(theme.point_size + theme.label_padding))] else diff --git a/src/geom/point.jl b/src/geom/point.jl index dd35ab2a0..a98e4fc95 100644 --- a/src/geom/point.jl +++ b/src/geom/point.jl @@ -67,7 +67,7 @@ function render(geom::PointGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics for (x, y, color, size, shape, alpha) in Compose.cyclezip(aes.x, aes.y, aes.color, aes.size, aes.shape, aes_alpha) shapefun = typeof(shape) <: Function ? shape : theme.point_shapes[shape] sizeval = typeof(size) <: Int ? interpolate_size(size) : size - strokecolor = aes.color_key_continuous != nothing && aes.color_key_continuous ? + strokecolor = aes.color_key_continuous !== nothing && aes.color_key_continuous ? theme.continuous_highlight_color(color) : theme.discrete_highlight_color(color) class = svg_color_class_from_label(aes.color_label([color])[1]) diff --git a/src/geom/rectbin.jl b/src/geom/rectbin.jl index 9b64363ff..8a2ae0c81 100644 --- a/src/geom/rectbin.jl +++ b/src/geom/rectbin.jl @@ -94,14 +94,14 @@ function render(geom::RectangularBinGeometry, theme::Gadfly.Theme, aes::Gadfly.A allvisible = true for c in cs - if c == nothing + if c === nothing allvisible = false break end end if !allvisible - visibility = cs .!= nothing + visibility = (!isnothing).(cs) cs = cs[visibility] xmin = xmin[visibility] xmax = xmax[visibility] diff --git a/src/geom/segment.jl b/src/geom/segment.jl index 499763686..a7fc70ae7 100755 --- a/src/geom/segment.jl +++ b/src/geom/segment.jl @@ -82,7 +82,7 @@ function render(geom::SegmentGeometry, theme::Gadfly.Theme, aes::Gadfly.Aestheti if geom.arrow check = [aes.xviewmin, aes.xviewmax, aes.yviewmin, aes.yviewmax ] - if any( map(x -> x === nothing, check) ) + if any(map(isnothing, check)) error("For Geom.vector, Scale minvalue and maxvalue must be manually provided for both axes") end xyrange = [aes.xviewmax-aes.xviewmin, aes.yviewmax-aes.yviewmin] diff --git a/src/geom/subplot.jl b/src/geom/subplot.jl index 08bc4b113..abd4955f7 100644 --- a/src/geom/subplot.jl +++ b/src/geom/subplot.jl @@ -144,17 +144,17 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, # z for (layer_data, layer_aes) in zip(subplot_layer_datas, subplot_layer_aess) z = getfield(layer_data, :z) - (z != nothing) && setfield!(layer_aes, :z, z) + (z !== nothing) && setfield!(layer_aes, :z, z) end # work out the grid size m = 1 n = 1 for layer_aes in subplot_layer_aess - if layer_aes.xgroup != nothing + if layer_aes.xgroup !== nothing m = max(m, maximum(layer_aes.xgroup)) end - if layer_aes.ygroup != nothing + if layer_aes.ygroup !== nothing n = max(n, maximum(layer_aes.ygroup)) end end @@ -181,7 +181,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, Gadfly.Aesthetics[layer_aes_grid[k][i, j] for k in 1:length(geom.layers)], Gadfly.Data[layer_data_grid[k][i, j] - for k in 1:length(geom.layers)]...) + for k in 1:length(geom.layers)]) for (k, stats) in enumerate(layer_stats) Stat.apply_statistics(stats, scales, coord, layer_aes_grid[k][i, j]) @@ -190,7 +190,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, # apply geom-wide statistics geom_aes = Gadfly.concat([layer_aes_grid[k][i,j] - for i in 1:n, j in 1:m, k in 1:length(geom.layers)]...) + for i in 1:n, j in 1:m, k in 1:length(geom.layers)]) geom_stats = Gadfly.StatisticElement[] has_stat_xticks = false @@ -220,7 +220,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, if geom.free_x_axis for j in 1:m col_aes = Gadfly.concat([layer_aes_grid[k][i, j] - for i in 1:n, k in 1:length(geom.layers)]...) + for i in 1:n, k in 1:length(geom.layers)]) Gadfly.inherit!(col_aes, geom_aes) Stat.apply_statistic(Stat.xticks(), scales, coord, col_aes) @@ -231,7 +231,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, if geom.free_y_axis for i in 1:n row_aes = Gadfly.concat([layer_aes_grid[k][i, j] - for j in 1:m, k in 1:length(geom.layers)]...) + for j in 1:m, k in 1:length(geom.layers)]) Gadfly.inherit!(row_aes, geom_aes) Stat.apply_statistic(Stat.yticks(), scales, coord, row_aes) @@ -349,7 +349,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, # copy over the correct units, since we are reparenting the children for u in 1:size(subtbl, 1), v in 1:size(subtbl, 2) for child in subtbl[u, v] - if child.units===nothing + if child.units === nothing child.units = subtbl.units end end diff --git a/src/guide.jl b/src/guide.jl index 5e13b7c4c..ab64e060f 100644 --- a/src/guide.jl +++ b/src/guide.jl @@ -35,7 +35,7 @@ const questionmark = QuestionMark function render(guide::QuestionMark, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) - text_color = theme.background_color == nothing ? + text_color = theme.background_color === nothing ? colorant"black" : distinguishable_colors(2,theme.background_color)[2] text_box = compose!( context(), text(1w,0h+2px,"?",hright,vtop), @@ -64,7 +64,7 @@ const helpscreen = HelpScreen function render(guide::HelpScreen, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) - box_color = theme.background_color == nothing ? + box_color = theme.background_color === nothing ? colorant"black" : distinguishable_colors(2,theme.background_color)[2] text_color = distinguishable_colors(2,box_color)[2] text_strings = ["h,j,k,l,arrows,drag to pan", @@ -104,7 +104,7 @@ const crosshair = CrossHair function render(guide::CrossHair, theme::Gadfly.Theme, aes::Gadfly.Aesthetics) - text_color = theme.background_color == nothing ? + text_color = theme.background_color === nothing ? colorant"black" : distinguishable_colors(2,theme.background_color)[2] text_box = compose!( context(), @@ -262,7 +262,7 @@ function render_discrete_color_key(colors::Vector{C}, fill(theme.key_label_color)) col = compose!(context(xpos, yoff), swatches, swatch_labels) - if aes_color_label != nothing + if aes_color_label !== nothing classes = [svg_color_class_from_label(aes_color_label([c])[1]) for c in cs] #class_jscalls = ["data(\"color_class\", \"$(c)\")" #for c in classes] @@ -408,14 +408,14 @@ function render(guide::ColorKey, theme::Gadfly.Theme, guide_title = aes.color_key_title end - if aes.color_key_colors != nothing && - aes.color_key_continuous != nothing && + if aes.color_key_colors !== nothing && + aes.color_key_continuous !== nothing && aes.color_key_continuous continuous_guide = true end color_key_labels = aes.color_label(keys(aes.color_key_colors)) - if !continuous_guide && (guide.labels != nothing) + if !continuous_guide && guide.labels !== nothing color_key_labels = guide.labels end @@ -457,7 +457,7 @@ function render(guide::ColorKey, theme::Gadfly.Theme, title_width, theme) end - if aes.shape != nothing + if aes.shape !== nothing # TODO: Draw key for shapes. We need to think about how to make this # work. Do we need to optimize number of columns for shape and size # keys? I'm guessing it's not worth it. @@ -469,7 +469,7 @@ function render(guide::ColorKey, theme::Gadfly.Theme, end position = right_guide_position - if gpos != nothing + if gpos !== nothing position = over_guide_position ctxs = [compose(context(), (context(gpos[1],gpos[2]), ctxs[1]))] elseif theme.key_position == :left @@ -569,13 +569,13 @@ visibility. `ticks` can also be an array of locations, or `nothing`. const xticks = XTicks default_statistic(guide::XTicks) = - guide.ticks == nothing ? Stat.identity() : Stat.xticks(ticks=guide.ticks) + guide.ticks === nothing ? Stat.identity() : Stat.xticks(ticks=guide.ticks) function render(guide::XTicks, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool=true) - guide.ticks == nothing && return PositionedGuide[] + guide.ticks === nothing && return PositionedGuide[] - if Gadfly.issomething(aes.xtick) + if aes.xtick !== nothing ticks = aes.xtick tickvisibility = aes.xtickvisible scale = aes.xtickscale @@ -592,7 +592,7 @@ function render(guide::XTicks, theme::Gadfly.Theme, scale = Any[] end - if Gadfly.issomething(aes.xgrid) + if aes.xgrid !== nothing grids = aes.xgrid gridvisibility = length(grids) < length(ticks) ? tickvisibility[2:end] : tickvisibility else @@ -740,7 +740,7 @@ visibility. `ticks` can also be an array of locations, or `nothing`. const yticks = YTicks function default_statistic(guide::YTicks) - if guide.ticks == nothing + if guide.ticks === nothing return Stat.identity() else return Stat.yticks(ticks=guide.ticks) @@ -749,11 +749,11 @@ end function render(guide::YTicks, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, dynamic::Bool=true) - if guide.ticks == nothing + if guide.ticks === nothing return PositionedGuide[] end - if Gadfly.issomething(aes.ytick) + if aes.ytick !== nothing ticks = aes.ytick tickvisibility = aes.ytickvisible scale = aes.ytickscale @@ -769,7 +769,7 @@ function render(guide::YTicks, theme::Gadfly.Theme, scale = Any[] end - if Gadfly.issomething(aes.ygrid) + if aes.ygrid !== nothing grids = aes.ygrid if length(grids) < length(ticks) gridvisibility = tickvisibility[2:end] @@ -1129,7 +1129,7 @@ end function layout_guides(plot_context::Context, coord::Gadfly.CoordinateElement, theme::Gadfly.Theme, - positioned_guides::PositionedGuide...) + positioned_guides::Vector{PositionedGuide}) # Organize guides by position guides = DefaultDict(() -> (Tuple{Vector{Context}, Int})[]) for positioned_guide in positioned_guides @@ -1160,9 +1160,9 @@ function layout_guides(plot_context::Context, aspect_ratio = nothing if isa(coord, Gadfly.Coord.cartesian) if coord.fixed - aspect_ratio = plot_context.units===nothing ? 1.0 : - abs(plot_context.units.width / plot_context.units.height) - elseif coord.aspect_ratio != nothing + aspect_ratio = (plot_context.units === nothing) ? 1.0 : + abs(plot_context.units.width / plot_context.units.height) + elseif coord.aspect_ratio !== nothing aspect_ratio = coord.aspect_ratio end end @@ -1172,7 +1172,7 @@ function layout_guides(plot_context::Context, i = 1 for (ctxs, order) in guides[top_guide_position] for ctx in ctxs - if ctx.units===nothing && plot_units!==nothing + if ctx.units === nothing && plot_units !== nothing ctx.units = UnitBox(plot_units, toppad=0mm, bottompad=0mm) end end @@ -1183,7 +1183,7 @@ function layout_guides(plot_context::Context, i += 1 for (ctxs, order) in guides[bottom_guide_position] for ctx in ctxs - if ctx.units===nothing && plot_units!==nothing + if ctx.units === nothing && plot_units !== nothing ctx.units = UnitBox(plot_units, toppad=0mm, bottompad=0mm) end end @@ -1195,7 +1195,7 @@ function layout_guides(plot_context::Context, j = 1 for (ctxs, order) in guides[left_guide_position] for ctx in ctxs - if ctx.units===nothing && plot_units!==nothing + if ctx.units === nothing && plot_units !== nothing ctx.units = UnitBox(plot_units, leftpad=0mm, rightpad=0mm) end end @@ -1206,7 +1206,7 @@ function layout_guides(plot_context::Context, j += 1 for (ctxs, order) in guides[right_guide_position] for ctx in ctxs - if ctx.units===nothing && plot_units!==nothing + if ctx.units === nothing && plot_units !== nothing ctx.units = UnitBox(plot_units, leftpad=0mm, rightpad=0mm) end end diff --git a/src/guide/keys.jl b/src/guide/keys.jl index ac3943033..f62568d00 100644 --- a/src/guide/keys.jl +++ b/src/guide/keys.jl @@ -32,11 +32,11 @@ function Guide.render(guide::Guide.ShapeKey, theme::Gadfly.Theme, aes::Gadfly.Ae # Aesthetics for keys: shape_key_title, shape_label (Function), shape_key_shapes (AbstractDict) nshapes = length(unique(aes.shape)) - guide_title = (guide.title!="Shape" || aes.shape_key_title==nothing) ? guide.title : aes.shape_key_title + guide_title = (guide.title!="Shape" || aes.shape_key_title === nothing) ? guide.title : aes.shape_key_title shape_key_labels = !(guide.labels==[""]) ? guide.labels : aes.shape_label(1:nshapes) colors = [nothing] - if (aes.shape_key_title !=nothing) && (aes.color_key_title==aes.shape_key_title) + if aes.shape_key_title !== nothing && (aes.color_key_title==aes.shape_key_title) colors = collect(keys(aes.color_key_colors)) end @@ -70,8 +70,8 @@ function render_discrete_key(labels::Vector{String}, title_ctx::Context, title_w n = max(length(colors), length(shapes)) shape1 = shapes[1] - shapes = (shape1==nothing) ? fill(theme.key_swatch_shape, n) : theme.point_shapes[shapes] - (colors[1]==nothing) && (colors = fill((theme.key_swatch_color==nothing) ? theme.default_color : theme.key_swatch_color, n)) + shapes = shape1 === nothing ? fill(theme.key_swatch_shape, n) : theme.point_shapes[shapes] + (colors[1] === nothing) && (colors = fill((theme.key_swatch_color === nothing) ? theme.default_color : theme.key_swatch_color, n)) # only consider layouts with a reasonable number of columns maxcols = theme.key_max_columns < 1 ? 1 : theme.key_max_columns @@ -144,7 +144,7 @@ function render_discrete_key(labels::Vector{String}, title_ctx::Context, title_w fill(theme.key_label_color)) col = compose!(context(xpos, yoff), swatches, swatch_labels) - if aes_color_label != nothing + if aes_color_label !== nothing classes = [svg_color_class_from_label(aes_color_label([c])[1]) for c in clrs] #class_jscalls = ["data(\"color_class\", \"$(c)\")" for c in classes] compose!(col, diff --git a/src/mapping.jl b/src/mapping.jl index 12d625a58..072f76696 100644 --- a/src/mapping.jl +++ b/src/mapping.jl @@ -87,7 +87,7 @@ end function meltdata(U::AbstractVector, colgroups_::Vector{Col.GroupedColumn}) colgroups = Set(colgroups_) - if length(colgroups) != 1 || first(colgroups).columns!==nothing + if length(colgroups) != 1 || first(colgroups).columns !== nothing # if every column is of the same length, treat it as a matrix if length(Set([length(u for u in U)])) == 1 return meltdata(cat(U..., dims=2), colgroups_) @@ -130,7 +130,7 @@ function meltdata(U::AbstractMatrix, colgroups_::Vector{Col.GroupedColumn}) vm = um grouped_columns = BitSet() for colgroup in colgroups - if colgroup.columns===nothing + if colgroup.columns === nothing vm *= un grouped_columns = copy(allcolumns) else @@ -149,7 +149,7 @@ function meltdata(U::AbstractMatrix, colgroups_::Vector{Col.GroupedColumn}) col_indicators = Array{Int}(undef, vm, length(colgroups)) row_indicators = Array{Int}(undef, vm, length(colgroups)) - colidxs = [colgroup.columns===nothing ? collect(allcolumns) : colgroup.columns + colidxs = [colgroup.columns === nothing ? collect(allcolumns) : colgroup.columns for colgroup in colgroups] vi = 1 diff --git a/src/misc.jl b/src/misc.jl index 4a3591600..b1583a9f8 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -188,9 +188,6 @@ function inherit!(a::T, b::T) where T end -isnothing(u) = u === nothing -issomething(u) = !isnothing(u) - negate(f) = x -> !f(x) diff --git a/src/scale.jl b/src/scale.jl index 6972591c4..555806bc6 100644 --- a/src/scale.jl +++ b/src/scale.jl @@ -19,9 +19,9 @@ include("color_misc.jl") iscategorical(scales::Dict{Symbol, Gadfly.ScaleElement}, var::Symbol) = haskey(scales, var) && isa(scales[var], DiscreteScale) -function apply_scales(scales, aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) +function apply_scales(scales, aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for scale in scales - apply_scale(scale, aess, datas...) + apply_scale(scale, aess, datas) end for (aes, data) in zip(aess, datas) @@ -29,9 +29,9 @@ function apply_scales(scales, aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Dat end end -function apply_scales(scales, datas::Gadfly.Data...) +function apply_scales(scales, datas::Vector{Gadfly.Data}) aess = Gadfly.Aesthetics[Gadfly.Aesthetics() for _ in datas] - apply_scales(scales, aess, datas...) + apply_scales(scales, aess, datas) aess end @@ -86,7 +86,7 @@ struct ContinuousScale <: Gadfly.ScaleElement function ContinuousScale(vars, trans, minvalue, maxvalue, minticks, maxticks, labels, format, scalable) - minvalue != nothing && maxvalue != nothing && minvalue > maxvalue && + minvalue !== nothing && maxvalue !== nothing && minvalue > maxvalue && error("Cannot construct a ContinuousScale with minvalue > maxvalue") new(vars, trans, minvalue, maxvalue, minticks, maxticks, labels, format, scalable) end @@ -100,9 +100,9 @@ function ContinuousScale(vars, trans; end function make_labeler(scale::ContinuousScale) - if scale.labels != nothing + if scale.labels !== nothing xs -> [scale.labels(x) for x in xs] - elseif scale.format == nothing + elseif scale.format === nothing scale.trans.label else xs -> scale.trans.label(xs, scale.format) @@ -178,9 +178,12 @@ alpha_continuous(; minvalue=0.0, maxvalue=1.0, labels=nothing, format=nothing, m ContinuousScale([:alpha], identity_transform, minvalue=minvalue, maxvalue=maxvalue, labels=labels, format=format, minticks=minticks, maxticks=maxticks, scalable=scalable) +# Need to wrap Gadfly.Data in array for apply_scale methods +apply_scale(scale::Gadfly.ScaleElement, aess::Vector{Gadfly.Aesthetics}, data::Gadfly.Data) = + apply_scale(scale, aess, Gadfly.Data[data]) function apply_scale(scale::ContinuousScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for (aes, data) in zip(aess, datas) for var in scale.vars vals = getfield(data, var) @@ -242,7 +245,7 @@ function apply_scale(scale::ContinuousScale, end end - if scale.minvalue != nothing + if scale.minvalue !== nothing if scale.vars === x_vars aes.xviewmin = scale.trans.f(scale.minvalue) elseif scale.vars === y_vars @@ -250,7 +253,7 @@ function apply_scale(scale::ContinuousScale, end end - if scale.maxvalue != nothing + if scale.maxvalue !== nothing if scale.vars === x_vars aes.xviewmax = scale.trans.f(scale.maxvalue) elseif scale.vars === y_vars @@ -269,7 +272,7 @@ end function discretize(values, levels=nothing, order=nothing, preserve_order=true) - if levels == nothing + if levels === nothing if preserve_order levels = OrderedSet() for value in values @@ -283,7 +286,7 @@ function discretize(values, levels=nothing, order=nothing, preserve_order=true) da = discretize_make_ia(values, levels) end - if order != nothing + if order !== nothing return discretize_make_ia(da, da.values[order]) else return da @@ -363,7 +366,7 @@ alpha_discrete(; labels=nothing, levels=nothing, order=nothing) = DiscreteScale([:linestyle], labels=labels, levels=levels, order=order) -function apply_scale(scale::DiscreteScale, aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) +function apply_scale(scale::DiscreteScale, aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for (aes, data) in zip(aess, datas) for var in scale.vars label_var = Symbol(var, "_label") @@ -412,7 +415,7 @@ const color_none = NoneColorScale element_aesthetics(scale::NoneColorScale) = [:color] function apply_scale(scale::NoneColorScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for aes in aess aes.color = nothing end @@ -430,7 +433,7 @@ const color_identity = IdentityColorScale element_aesthetics(scale::IdentityColorScale) = [:color] function apply_scale(scale::IdentityColorScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for (aes, data) in zip(aess, datas) data.color === nothing && continue aes.color = discretize_make_ia(data.color) @@ -513,7 +516,7 @@ end @deprecate discrete_color_manual(colors...; levels=nothing, order=nothing) color_discrete_manual(colors...; levels=levels, order=order) function apply_scale(scale::DiscreteColorScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) levelset = OrderedSet() for (aes, data) in zip(aess, datas) data.color === nothing && continue @@ -524,13 +527,13 @@ function apply_scale(scale::DiscreteColorScale, end end - if scale.levels == nothing + if scale.levels === nothing scale_levels = [levelset...] scale.preserve_order || sort!(scale_levels) else scale_levels = scale.levels end - scale.order == nothing || permute!(scale_levels, scale.order) + scale.order === nothing || permute!(scale_levels, scale.order) colors = convert(Vector{RGB{Float32}}, scale.f(length(scale_levels))) color_map = Dict([(color, string(label)) @@ -621,8 +624,8 @@ const color_continuous_gradient = color_continuous ### WHY HAVE THIS ALIAS? @deprecate continuous_color(;minvalue=nothing, maxvalue=nothing) color_continuous(;minvalue=nothing, maxvalue=nothing) function apply_scale(scale::ContinuousColorScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) - cdata = skipmissing(Iterators.flatten(i.color for i in datas if i.color != nothing)) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) + cdata = skipmissing(Iterators.flatten(i.color for i in datas if i.color !== nothing)) if !isempty(cdata) cmin, cmax = extrema(cdata) else @@ -630,9 +633,9 @@ function apply_scale(scale::ContinuousColorScale, end strict_span = false - scale.minvalue != nothing && scale.maxvalue != nothing && (strict_span=true) - scale.minvalue != nothing && (cmin=scale.minvalue) - scale.maxvalue != nothing && (cmax=scale.maxvalue) + scale.minvalue !== nothing && scale.maxvalue !== nothing && (strict_span=true) + scale.minvalue !== nothing && (cmin=scale.minvalue) + scale.maxvalue !== nothing && (cmax=scale.maxvalue) cmin, cmax = promote(cmin, cmax) @@ -693,7 +696,7 @@ struct LabelScale <: Gadfly.ScaleElement end function apply_scale(scale::LabelScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for (aes, data) in zip(aess, datas) data.label === nothing && continue aes.label = discretize(data.label) @@ -733,7 +736,7 @@ end element_aesthetics(scale::IdentityScale) = [scale.var] function apply_scale(scale::IdentityScale, - aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...) + aess::Vector{Gadfly.Aesthetics}, datas::Vector{Gadfly.Data}) for (aes, data) in zip(aess, datas) getfield(data, scale.var) === nothing && continue setfield!(aes, scale.var, getfield(data, scale.var)) diff --git a/src/statistics.jl b/src/statistics.jl index a55415ea5..49ad28a88 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -17,7 +17,7 @@ using LinearAlgebra using Random import Gadfly: Scale, Coord, input_aesthetics, output_aesthetics, - default_scales, isconcrete, setfield!, discretize_make_ia, aes2str + default_scales, isconcrete, setfield!, discretize_make_ia, aes2str import KernelDensity # import Distributions: Uniform, Distribution, qqbuild import IterTools: distinct @@ -186,7 +186,7 @@ function apply_statistic(stat::BarStatistic, iscontinuous = haskey(scales, var) && isa(scales[var], Scale.ContinuousScale) - if getfield(aes, minvar) == nothing || getfield(aes, maxvar) == nothing + if getfield(aes, minvar) === nothing || getfield(aes, maxvar) === nothing minvals, maxvals = barminmax(vals, iscontinuous) setfield!(aes, minvar, minvals) @@ -194,9 +194,9 @@ function apply_statistic(stat::BarStatistic, end z = zero(eltype(getfield(aes, othervar))) - if getfield(aes, viewminvar) == nothing && z < minimum(getfield(aes, othervar)) + if getfield(aes, viewminvar) === nothing && z < minimum(getfield(aes, othervar)) setfield!(aes, viewminvar, z) - elseif getfield(aes, viewmaxvar) == nothing && z > maximum(getfield(aes, othervar)) + elseif getfield(aes, viewmaxvar) === nothing && z > maximum(getfield(aes, othervar)) setfield!(aes, viewmaxvar, z) end @@ -249,7 +249,7 @@ function HistogramStatistic(; bincount=nothing, orientation=:vertical, density=false, limits=NamedTuple()) - if bincount != nothing + if bincount !== nothing HistogramStatistic(bincount, bincount, position, orientation, density, limits) else HistogramStatistic(minbincount, maxbincount, position, orientation, density, limits) @@ -417,7 +417,7 @@ function apply_statistic(stat::HistogramStatistic, # See issue #560. Stacked histograms on a non-linear y scale are a strange # thing. After some discussion, the least confusing thing is to make the stack # partitioned linearly. Here we make that adjustment. - if stat.position == :stack && aes.color != nothing + if stat.position == :stack && aes.color !== nothing # A little trickery to figure out the scale stack height. data = Gadfly.Data() setfield!(data, othervar, stack_height) @@ -561,12 +561,12 @@ function Histogram2DStatistic(; xbincount=nothing, ybincount=nothing, yminbincount=3, ymaxbincount=150) - if xbincount != nothing + if xbincount !== nothing xminbincount = xbincount xmaxbincount = xbincount end - if ybincount != nothing + if ybincount !== nothing yminbincount = ybincount ymaxbincount = ybincount end @@ -770,7 +770,7 @@ function apply_statistic(stat::TickStatistic, error("TickStatistic cannot be applied to subplot coordinates.") # don't clobber existing ticks - getfield(aes, Symbol(stat.axis, "tick")) == nothing || return + getfield(aes, Symbol(stat.axis, "tick")) === nothing || return in_group_var = Symbol(stat.axis, "group") minval, maxval = nothing, nothing @@ -781,11 +781,11 @@ function apply_statistic(stat::TickStatistic, for var in in_vars categorical && !in(var,[:x,:y]) && continue vals = getfield(aes, var) - if vals != nothing && eltype(vals) != Function - if minval == nothing + if vals !== nothing && eltype(vals) != Function + if minval === nothing minval = first(vals) end - if maxval == nothing + if maxval === nothing maxval = first(vals) end T = promote_type(typeof(minval), typeof(maxval)) @@ -824,17 +824,17 @@ function apply_statistic(stat::TickStatistic, # check the x/yviewmin/max pesudo-aesthetics if stat.axis == "x" - if aes.xviewmin != nothing + if aes.xviewmin !== nothing minval = min(minval, aes.xviewmin) end - if aes.xviewmax != nothing + if aes.xviewmax !== nothing maxval = max(maxval, aes.xviewmax) end elseif stat.axis == "y" - if aes.yviewmin != nothing + if aes.yviewmin !== nothing minval = min(minval, aes.yviewmin) end - if aes.yviewmax != nothing + if aes.yviewmax !== nothing maxval = max(maxval, aes.yviewmax) end end @@ -959,12 +959,12 @@ function minvalmaxval(minval::T, maxval::T, val, s, ds) where T maxval = val end - if s != nothing && typeof(s) <: AbstractFloat + if s !== nothing && typeof(s) <: AbstractFloat minval = min(minval, val - s)::T maxval = max(maxval, val + s)::T end - if ds != nothing + if ds !== nothing minval = min(minval, val - ds)::T maxval = max(maxval, val + ds)::T end @@ -999,7 +999,7 @@ function apply_statistic(stat::BoxplotStatistic, coord::Gadfly.CoordinateElement, aes::Gadfly.Aesthetics) - xflag = aes.x != nothing + xflag = aes.x !== nothing aes_x = (xflag ? eltype(aes.x) : Int)[] if xflag aes_x = aes.x @@ -1007,10 +1007,10 @@ function apply_statistic(stat::BoxplotStatistic, aes_x = ones(Int, length(aes.y)) aes.x_label = x -> fill("", length(x)) end - colorflag = aes.color != nothing + colorflag = aes.color !== nothing aes_color = colorflag ? aes.color : fill(nothing, length(aes_x)) - if aes.y == nothing + if aes.y === nothing groups = Any[] for (x, c) in zip(aes.x, cycle(aes_color)) push!(groups, (x, c)) @@ -1150,7 +1150,7 @@ function Stat.apply_statistic(stat::SmoothStatistic, error("Stat.loess and Stat.lm require that x and y be bound to arrays of plain numbers.") end - colorflag = aes.color != nothing + colorflag = aes.color !== nothing aes_color = colorflag ? aes.color : fill(nothing, length(aes.x)) uc = unique(aes_color) @@ -1308,18 +1308,18 @@ function apply_statistic(stat::StepStatistic, p = sortperm(aes.x, alg=MergeSort) permute!(aes.x, p) permute!(aes.y, p) - aes.group != nothing && permute!(aes.group, p) - aes.color != nothing && permute!(aes.color, p) + aes.group !== nothing && permute!(aes.group, p) + aes.color !== nothing && permute!(aes.color, p) - if aes.group != nothing + if aes.group !== nothing Gadfly.assert_aesthetics_equal_length("StepStatistic", aes, :x, :group) permute!(aes.x, p) permute!(aes.y, p) permute!(aes.group, p) - aes.color != nothing && permute!(aes.color, p) + aes.color !== nothing && permute!(aes.color, p) end - if aes.color != nothing + if aes.color !== nothing Gadfly.assert_aesthetics_equal_length("StepStatistic", aes, :x, :color) # TODO: use this when we switch to 0.4 # sortperm!(p, aes.color, alg=MergeSort, lt=Gadfly.color_isless) @@ -1327,13 +1327,13 @@ function apply_statistic(stat::StepStatistic, permute!(aes.x, p) permute!(aes.y, p) permute!(aes.color, p) - aes.group != nothing && permute!(aes.group, p) + aes.group !== nothing && permute!(aes.group, p) end x_step = Array{eltype(aes.x)}(undef, 0) y_step = Array{eltype(aes.y)}(undef, 0) - color_step = aes.color == nothing ? nothing : Array{eltype(aes.color)}(undef, 0) - group_step = aes.group == nothing ? nothing : Array{eltype(aes.group)}(undef, 0) + color_step = aes.color === nothing ? nothing : Array{eltype(aes.color)}(undef, 0) + group_step = aes.group === nothing ? nothing : Array{eltype(aes.group)}(undef, 0) i = 1 i_offset = 1 @@ -1343,17 +1343,17 @@ function apply_statistic(stat::StepStatistic, (u > length(aes.x) || v > length(aes.y)) && break - if (aes.color != nothing && + if (aes.color !== nothing && (aes.color[u] != aes.color[i_offset] || aes.color[v] != aes.color[i_offset])) || - (aes.group != nothing && + (aes.group !== nothing && (aes.group[u] != aes.color[i_offset] || aes.color[v] != aes.group[i_offset])) i_offset = max(u, v) i = 1 else push!(x_step, aes.x[u]) push!(y_step, aes.y[v]) - aes.color != nothing && push!(color_step, aes.color[i_offset]) - aes.group != nothing && push!(group_step, aes.group[i_offset]) + aes.color !== nothing && push!(color_step, aes.color[i_offset]) + aes.group !== nothing && push!(group_step, aes.group[i_offset]) i += 1 end end @@ -1405,7 +1405,7 @@ function apply_statistic(stat::FunctionStatistic, end # color was bound explicitly - if aes.color != nothing + if aes.color !== nothing func_color = aes.color aes.color = Array{eltype(aes.color)}(undef, length(aes.y) * stat.num_samples) groups = Array{Int}(undef, length(aes.y) * stat.num_samples) @@ -1469,11 +1469,11 @@ function apply_statistic(stat::ContourStatistic, ys = aes.y === nothing ? nothing : convert(Vector{Float64}, aes.y) if typeof(aes.z) <: Function - if xs == nothing && aes.xmin != nothing && aes.xmax != nothing + if xs === nothing && aes.xmin !== nothing && aes.xmax !== nothing xs = range(aes.xmin[1], stop=aes.xmax[1], length=stat.samples) end - if ys == nothing && aes.ymin != nothing && aes.ymax != nothing + if ys === nothing && aes.ymin !== nothing && aes.ymax !== nothing ys = range(aes.ymin[1], stop=aes.ymax[1], length=stat.samples) end @@ -1482,10 +1482,10 @@ function apply_statistic(stat::ContourStatistic, elseif typeof(aes.z) <: Matrix zs = convert(Matrix{Float64}, aes.z) - if xs == nothing + if xs === nothing xs = collect(Float64, 1:size(zs)[1]) end - if ys == nothing + if ys === nothing ys = collect(Float64, 1:size(zs)[2]) end size(zs) != (length(xs), length(ys)) && @@ -1634,7 +1634,7 @@ function apply_statistic(stat::ViolinStatistic, grouped_color = Dict{Int, Gadfly.ColorOrNothing}(1=>nothing) ux = unique(aes.x) uxflag = length(ux) < length(aes.x) - colorflag = aes.color != nothing + colorflag = aes.color !== nothing uxflag && (grouped_y = Dict(x=>aes.y[aes.x.==x] for x in ux)) @@ -1701,7 +1701,7 @@ function minimum_span(vars::Vector{Symbol}, aes::Gadfly.Aesthetics) end end - if span == nothing || (dataspan != nothing && dataspan < span) + if span === nothing || (dataspan !== nothing && dataspan < span) span = dataspan end end @@ -1714,7 +1714,7 @@ function apply_statistic(stat::JitterStatistic, coord::Gadfly.CoordinateElement, aes::Gadfly.Aesthetics) span = minimum_span(stat.vars, aes) - span == nothing && return + span === nothing && return rng = MersenneTwister(stat.seed) for var in stat.vars @@ -1827,8 +1827,8 @@ function apply_statistic(stat::EnumerateStatistic, scales::Dict{Symbol, Gadfly.ScaleElement}, coord::Gadfly.CoordinateElement, aes::Gadfly.Aesthetics) - has_x = aes.x != nothing - has_y = aes.y != nothing + has_x = aes.x !== nothing + has_y = aes.y !== nothing if stat.var == :x && !has_x && has_y aes.x = collect(1:length(aes.y)) @@ -1873,10 +1873,10 @@ function apply_statistic(stat::VecFieldStatistic, ys = aes.y === nothing ? nothing : Float64.(aes.y) if isa(aes.z, Function) - if xs == nothing && aes.xmin != nothing && aes.xmax != nothing + if xs === nothing && aes.xmin !== nothing && aes.xmax !== nothing xs = range(aes.xmin[1], stop=aes.xmax[1], length=stat.samples) end - if ys == nothing && aes.ymin != nothing && aes.ymax != nothing + if ys === nothing && aes.ymin !== nothing && aes.ymax !== nothing ys = range(aes.ymin[1], stop=aes.ymax[1], length=stat.samples) end @@ -1885,10 +1885,10 @@ function apply_statistic(stat::VecFieldStatistic, elseif isa(aes.z, Matrix) zs = Float64.(aes.z) - if xs == nothing + if xs === nothing xs = collect(Float64, 1:size(zs)[1]) end - if ys == nothing + if ys === nothing ys = collect(Float64, 1:size(zs)[2]) end if size(zs) != (length(xs), length(ys)) @@ -1981,8 +1981,8 @@ function apply_statistic(stat::EllipseStatistic, aes::Gadfly.Aesthetics) Dat = [aes.x aes.y] - colorflag = aes.color != nothing - groupflag = aes.group != nothing + colorflag = aes.color !== nothing + groupflag = aes.group !== nothing aes_color = colorflag ? aes.color : fill(nothing, length(aes.x)) aes_group = groupflag ? aes.group : fill(nothing, length(aes.x)) CT, GT = eltype(aes_color), eltype(aes_group) @@ -2053,7 +2053,7 @@ function apply_statistic(stat::DodgeStatistic, coord::Gadfly.CoordinateElement, aes::Gadfly.Aesthetics) - aes.color==nothing && return + aes.color === nothing && return nbars = length(unique(aes.color)) othervar = (stat.axis == :x) ? :y : :x vals = getfield(aes, stat.axis) diff --git a/src/varset.jl b/src/varset.jl index 7773a18ce..ce909e502 100644 --- a/src/varset.jl +++ b/src/varset.jl @@ -45,7 +45,7 @@ macro varset(name::Symbol, table) push!(parameters, Expr(:kw, var, default)) push!(inherit_parameters, Expr(:kw, var, :(b.$var))) if typ==:ColorOrNothing - push!(parsed_vars, :($(var)==nothing ? nothing : parse_colorant($(var)))) + push!(parsed_vars, :($(var) === nothing ? nothing : parse_colorant($(var)))) else push!(parsed_vars, :($(var))) end