From b3c0c03c2dbfcf97a822a20ea43cd6ba79fcb84d Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Sun, 26 Aug 2018 09:44:09 -0400 Subject: [PATCH 01/11] drop support for julia 0.6 --- .travis.yml | 14 +++++--------- REQUIRE | 2 +- docs/make.jl | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b1789fbf..63eaee07f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: julia os: - linux julia: - - 0.6 - 0.7 + - 1.0 - nightly matrix: fast_finish: true @@ -11,12 +11,8 @@ matrix: - julia: nightly notifications: email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone(pwd()); Pkg.build("Gadfly");' - - julia -e 'Pkg.checkout("Compose")' - - julia --check-bounds=yes -e 'Pkg.test("Gadfly", coverage=true)' +before_script: + - julia -e 'using Pkg; Pkg.add(PackageSpec(name="Compose", rev="master"))' after_success: - - julia -e 'cd(Pkg.dir("Gadfly")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' - - julia -e 'Pkg.checkout("Compose")' - - if [[ "$TRAVIS_JULIA_VERSION" == "0.6" ]]; then julia -e 'cd(Pkg.dir("Gadfly")); map(x->Pkg.add(strip(x)), readlines(open(joinpath("docs", "REQUIRE")))); include(joinpath("docs", "make.jl"))'; fi + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' + - julia -e 'using Pkg; foreach(x->Pkg.add(strip(x)), readlines(open(joinpath("docs", "REQUIRE")))); include(joinpath("docs", "make.jl"))' diff --git a/REQUIRE b/REQUIRE index 73614b045..ff9309939 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.6.3 +julia 0.7 Colors 0.3.4 Compat 0.18.0 Compose 0.5.2 diff --git a/docs/make.jl b/docs/make.jl index d670fe128..52c45ff7f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -41,7 +41,7 @@ makedocs( deploydocs( repo = "github.com/GiovineItalia/Gadfly.jl.git", - julia = "0.6", + julia = "1.0", osname = "linux", deps = nothing, make = nothing, From 2d4f5916fa4088c5931ca734f747d16bb2b67bee Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Sun, 26 Aug 2018 09:52:48 -0400 Subject: [PATCH 02/11] femtocleaner --- src/Gadfly.jl | 24 +++++++------- src/aesthetics.jl | 14 ++++----- src/coord.jl | 2 +- src/geom/hvabline.jl | 18 +++++------ src/geom/label.jl | 4 +-- src/geom/line.jl | 2 +- src/geom/polygon.jl | 2 +- src/geom/ribbon.jl | 4 +-- src/geom/segment.jl | 2 +- src/geom/subplot.jl | 4 +-- src/geometry.jl | 4 +-- src/guide.jl | 20 ++++++------ src/misc.jl | 12 +++---- src/open_file.jl | 6 ++-- src/scale.jl | 14 ++++----- src/statistics.jl | 38 +++++++++++------------ test/compare_examples.jl | 4 +-- test/runtests.jl | 6 ++-- test/testscripts/Guide_colorkey.jl | 2 +- test/testscripts/Guide_shapekey.jl | 2 +- test/testscripts/contour_matrix.jl | 4 +-- test/testscripts/date_bar.jl | 4 +-- test/testscripts/density_dark.jl | 2 +- test/testscripts/discrete_color_hue.jl | 2 +- test/testscripts/discrete_color_manual.jl | 2 +- test/testscripts/ellipse.jl | 2 +- test/testscripts/hvabline_dates.jl | 2 +- test/testscripts/percent.jl | 2 +- test/testscripts/single_datetime.jl | 2 +- test/testscripts/stat_qq.jl | 2 +- test/testscripts/subplot_grid_free_y_1.jl | 2 +- test/testscripts/timeseries_colorful.jl | 2 +- test/testscripts/timeseries_day.jl | 2 +- test/testscripts/timeseries_month.jl | 2 +- test/testscripts/timeseries_year_1.jl | 2 +- test/testscripts/timeseries_year_2.jl | 2 +- test/testscripts/timeseries_year_3.jl | 2 +- test/testscripts/vector.jl | 2 +- 38 files changed, 111 insertions(+), 113 deletions(-) diff --git a/src/Gadfly.jl b/src/Gadfly.jl index 23dfbb387..0de779964 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -1,5 +1,3 @@ -__precompile__() - module Gadfly using Colors @@ -59,7 +57,7 @@ function __init__() end -const ColorOrNothing = Union{Colorant, (Void)} +const ColorOrNothing = Union{Colorant, (Nothing)} element_aesthetics(::Any) = [] input_aesthetics(::Any) = [] @@ -132,11 +130,11 @@ set_default_plot_format(fmt::Symbol) = Compose.set_default_graphic_format(fmt) # A plot has zero or more layers. Layers have a particular geometry and their # own data, which is inherited from the plot if not given. mutable struct Layer <: Element - data_source::Union{Void, MeltedData, AbstractArray, AbstractDataFrame} + data_source::Union{Nothing, MeltedData, AbstractArray, AbstractDataFrame} mapping::Dict statistics::Vector{StatisticElement} geom::GeometryElement - theme::Union{Void, Theme} + theme::Union{Nothing, Theme} order::Int end Layer() = Layer(nothing, Dict(), StatisticElement[], Geom.nil(), nothing, 0) @@ -161,7 +159,7 @@ append!(ls, layer(y=[3,2,1], Geom.point)) plot(ls..., Guide.title("layer example")) ``` """ -function layer(data_source::Union{AbstractDataFrame, Void}, +function layer(data_source::Union{AbstractDataFrame, Nothing}, elements::ElementOrFunction...; mapping...) mapping = Dict{Symbol, Any}(mapping) lyr = Layer() @@ -211,11 +209,11 @@ add_plot_element!(lyrs::Vector{Layer}, arg::Theme) = [lyr.theme = arg for lyr in # A full plot specification. mutable struct Plot layers::Vector{Layer} - data_source::Union{Void, MeltedData, AbstractArray, AbstractDataFrame} + data_source::Union{Nothing, MeltedData, AbstractArray, AbstractDataFrame} data::Data scales::Vector{ScaleElement} statistics::Vector{StatisticElement} - coord::Union{Void, CoordinateElement} + coord::Union{Nothing, CoordinateElement} guides::Vector{GuideElement} theme::Theme mapping::Dict @@ -314,7 +312,7 @@ The old fashioned (pre-named arguments) version of plot. This version takes an explicit mapping dictionary, mapping aesthetics symbols to expressions or columns in the data frame. """ -function plot(data_source::Union{Void, AbstractArray, AbstractDataFrame}, +function plot(data_source::Union{Nothing, AbstractArray, AbstractDataFrame}, mapping::Dict, elements::ElementOrFunctionOrLayers...) mapping = cleanmapping(mapping) p = Plot() @@ -456,9 +454,9 @@ function render_prepare(plot::Plot) if mapreduce(x->in(x,layer_needed_aes),|,[:x,:xmax,:xmin]) && mapreduce(y->in(y,layer_needed_aes),|,[:y,:ymax,:ymin]) if !mapreduce(x->in(x,layer_defined_aes),|,[:x,:xmax,:xmin]) - unshift!(layer_stats[i], Stat.x_enumerate) + pushfirst!(layer_stats[i], Stat.x_enumerate) elseif !mapreduce(y->in(y,layer_defined_aes),|,[:y,:ymax,:ymin]) - unshift!(layer_stats[i], Stat.y_enumerate) + pushfirst!(layer_stats[i], Stat.y_enumerate) end end end @@ -1059,10 +1057,10 @@ function display(d::REPLDisplay, ::MIME"text/html", p::Union{Plot,Compose.Contex $(plotsvg) diff --git a/src/aesthetics.jl b/src/aesthetics.jl index b932f5123..38e7136da 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -1,11 +1,11 @@ const NumericalOrCategoricalAesthetic = - Union{(Void), Vector, DataArray, IndirectArray} + Union{(Nothing), Vector, DataArray, IndirectArray} const CategoricalAesthetic = - Union{(Void), IndirectArray} + Union{(Nothing), IndirectArray} const NumericalAesthetic = - Union{(Void), Matrix, Vector, DataArray} + Union{(Nothing), Matrix, Vector, DataArray} @varset Aesthetics begin @@ -247,10 +247,10 @@ function concat(aess::Aesthetics...) end -cat_aes_var!(a::(Void), b::(Void)) = a -cat_aes_var!(a::(Void), b::Union{Function,AbstractString}) = b -cat_aes_var!(a::(Void), b) = copy(b) -cat_aes_var!(a, b::(Void)) = a +cat_aes_var!(a::(Nothing), b::(Nothing)) = a +cat_aes_var!(a::(Nothing), b::Union{Function,AbstractString}) = b +cat_aes_var!(a::(Nothing), b) = copy(b) +cat_aes_var!(a, b::(Nothing)) = a cat_aes_var!(a::Function, b::Function) = a === string || a == showoff ? b : a function cat_aes_var!(a::Dict, b::Dict) diff --git a/src/coord.jl b/src/coord.jl index 834cb7e18..4549d0b77 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -18,7 +18,7 @@ struct Cartesian <: Gadfly.CoordinateElement xflip::Bool yflip::Bool fixed::Bool - aspect_ratio::Union{(Void), Float64} + aspect_ratio::Union{(Nothing), Float64} raster::Bool Cartesian(xvars, yvars, xmin, xmax, ymin, ymax, xflip, yflip, fixed, aspect_ratio, raster) = diff --git a/src/geom/hvabline.jl b/src/geom/hvabline.jl index 83ae67f9c..76cd4f2e2 100755 --- a/src/geom/hvabline.jl +++ b/src/geom/hvabline.jl @@ -12,9 +12,9 @@ check_arguments(arg, len) = fill(arg, len) struct HLineGeometry <: Gadfly.GeometryElement - color::Union{Vector, Color, (Void)} - size::Union{Vector, Measure, (Void)} - style::Union{Vector, Symbol, (Void)} + color::Union{Vector, Color, (Nothing)} + size::Union{Vector, Measure, (Nothing)} + style::Union{Vector, Symbol, (Nothing)} tag::Symbol HLineGeometry(color, size, style, tag) = @@ -59,9 +59,9 @@ end struct VLineGeometry <: Gadfly.GeometryElement - color::Union{Vector, Color, (Void)} - size::Union{Vector, Measure, (Void)} - style::Union{Vector, Symbol, (Void)} + color::Union{Vector, Color, (Nothing)} + size::Union{Vector, Measure, (Nothing)} + style::Union{Vector, Symbol, (Nothing)} tag::Symbol VLineGeometry(color, size, style, tag) = @@ -106,9 +106,9 @@ end struct ABLineGeometry <: Gadfly.GeometryElement - color::Union{Vector, Color, (Void)} - size::Union{Vector, Measure, (Void)} - style::Union{Vector, Symbol, (Void)} + color::Union{Vector, Color, (Nothing)} + size::Union{Vector, Measure, (Nothing)} + style::Union{Vector, Symbol, (Nothing)} tag::Symbol ABLineGeometry(color, size, style, tag) = diff --git a/src/geom/label.jl b/src/geom/label.jl index 30191b6cf..a26ee82e7 100644 --- a/src/geom/label.jl +++ b/src/geom/label.jl @@ -56,7 +56,7 @@ function deferred_label_context(geom::LabelGeometry, padding = aes.size .+ theme.label_padding end - point_positions = Array{AbsoluteVec2}(0) + point_positions = Array{AbsoluteVec2}(undef, 0) for (x, y) in zip(aes.x, aes.y) x = Compose.resolve_position(parent_box, units, parent_transform, Compose.x_measure(x)) y = Compose.resolve_position(parent_box, units, parent_transform, Compose.y_measure(y)) @@ -98,7 +98,7 @@ function deferred_label_context(geom::LabelGeometry, # Checking for label overlaps is O(n^2). To mitigate these costs, we build a # sparse overlap matrix. This also costs O(n^2), but we only have to do it # once, rather than every iteration of annealing. - possible_overlaps = [Array{Int}(0) for _ in 1:length(label_point_boxes)] + possible_overlaps = [Array{Int}(undef, 0) for _ in 1:length(label_point_boxes)] # TODO: this whole thing would be much more effecient if we forbid from # the start labels that overlap points. We should be able to precompute diff --git a/src/geom/line.jl b/src/geom/line.jl index b5ffac514..63845b997 100644 --- a/src/geom/line.jl +++ b/src/geom/line.jl @@ -119,7 +119,7 @@ function Gadfly.Geom.render(geom::LineGeometry, theme::Gadfly.Theme, aes::Gadfly # Find the aesthetic with the most levels: aesv = [aes_g, aes_color, aes_linestyle] - i1 = indmax([length(unique(a)) for a in aesv]) + i1 = argmax([length(unique(a)) for a in aesv]) aes_maxlvls = aesv[i1] # Concrete values?: diff --git a/src/geom/polygon.jl b/src/geom/polygon.jl index af1ef8b25..47aaac300 100644 --- a/src/geom/polygon.jl +++ b/src/geom/polygon.jl @@ -46,7 +46,7 @@ function polygon_points(xs, ys, preserve_order) return T[(x, y) for (x, y) in zip(xs, ys)] else centroid_x, centroid_y = mean(xs), mean(ys) - θ = atan2(xs - centroid_x, ys - centroid_y) + θ = atan(xs - centroid_x, ys - centroid_y) perm = sortperm(θ) return T[(x, y) for (x, y) in zip(xs[perm], ys[perm])] end diff --git a/src/geom/ribbon.jl b/src/geom/ribbon.jl index 0c8ff7f8d..1bd7bf722 100644 --- a/src/geom/ribbon.jl +++ b/src/geom/ribbon.jl @@ -45,7 +45,7 @@ function render(geom::RibbonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetic max_points = Dict{RGB{Float32}, Vector{(Tuple{XT, YT})}}() for (x, y, c) in zip(aes_x, aes_ymax, aes.color) if !haskey(max_points, c) - max_points[c] = Array{Tuple{XT, YT}}(0) + max_points[c] = Array{Tuple{XT, YT}}(undef, 0) end push!(max_points[c], (x, y)) end @@ -53,7 +53,7 @@ function render(geom::RibbonGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetic min_points = Dict{RGB{Float32}, Vector{(Tuple{XT, YT})}}() for (x, y, c) in zip(aes.x, aes.ymin, aes.color) if !haskey(min_points, c) - min_points[c] = Array{Tuple{XT, YT}}(0) + min_points[c] = Array{Tuple{XT, YT}}(undef, 0) end push!(min_points[c], (x, y)) end diff --git a/src/geom/segment.jl b/src/geom/segment.jl index 414ffb09c..499763686 100755 --- a/src/geom/segment.jl +++ b/src/geom/segment.jl @@ -63,7 +63,7 @@ function render(geom::SegmentGeometry, theme::Gadfly.Theme, aes::Gadfly.Aestheti dx = xmax-x dy = ymax-y vl = 0.225*hypot(dy/xyrange[2], dx/xyrange[1]) - θ = atan2(dy/xyrange[2], dx/xyrange[1]) + θ = atan(dy/xyrange[2], dx/xyrange[1]) ϕ = pi/15 xr = -vl*xyrange[1]*[cos(θ+ϕ), cos(θ-ϕ)] yr = -vl*xyrange[2]*[sin(θ+ϕ), sin(θ-ϕ)] diff --git a/src/geom/subplot.jl b/src/geom/subplot.jl index 6044efca9..c73b9dab3 100644 --- a/src/geom/subplot.jl +++ b/src/geom/subplot.jl @@ -289,9 +289,9 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, subplot_padding = 2mm # This assumes non of the layers themselves are subplot geometries - layer_subplot_aess = Vector{Gadfly.Aesthetics}[Array{Gadfly.Aesthetics}(0) + layer_subplot_aess = Vector{Gadfly.Aesthetics}[Array{Gadfly.Aesthetics}(undef, 0) for _ in 1:length(geom.layers)] - layer_subplot_datas = Vector{Gadfly.Data}[Array{Gadfly.Data}(0) + layer_subplot_datas = Vector{Gadfly.Data}[Array{Gadfly.Data}(undef, 0) for _ in 1:length(geom.layers)] for i in 1:n, j in 1:m diff --git a/src/geometry.jl b/src/geometry.jl index a814e6c23..17e9c9bea 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -42,8 +42,8 @@ render(geom::Nil, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, # Subplot geometries require some more arguments to render. A simpler render # function is defined and passed through to here for non-subplot geometries. render(geom::Gadfly.GeometryElement, theme::Gadfly.Theme, aes::Gadfly.Aesthetics, - subplot_layer_aess::Union{(Void), Vector{Gadfly.Aesthetics}}, - subplot_layer_datas::Union{(Void), Vector{Gadfly.Data}}, + subplot_layer_aess::Union{(Nothing), Vector{Gadfly.Aesthetics}}, + subplot_layer_datas::Union{(Nothing), Vector{Gadfly.Data}}, scales::Dict{Symbol, ScaleElement}) = render(geom, theme, aes) diff --git a/src/guide.jl b/src/guide.jl index 6acdf79c3..77eb5938b 100644 --- a/src/guide.jl +++ b/src/guide.jl @@ -156,9 +156,9 @@ end struct ColorKey <: Gadfly.GuideElement - title::Union{AbstractString, (Void)} - labels::Union{Vector{String}, (Void)} - pos::Union{Vector, (Void)} + title::Union{AbstractString, (Nothing)} + labels::Union{Vector{String}, (Nothing)} + pos::Union{Vector, (Nothing)} end ColorKey(;title=nothing, labels=nothing, pos=nothing) = ColorKey(title, labels, pos) @@ -402,7 +402,7 @@ function render(guide::ColorKey, theme::Gadfly.Theme, (theme.key_position == :inside && gpos === nothing) && (gpos = [0.7w, 0.25h]) used_colors = Set{Color}() - colors = Array{Color}(0) # to preserve ordering + colors = Array{Color}(undef, 0) # to preserve ordering labels = OrderedDict{Color, Set{AbstractString}}() continuous_guide = false @@ -491,7 +491,7 @@ end struct ManualColorKey{C<:Color} <: Gadfly.GuideElement - title::Union{AbstractString, (Void)} + title::Union{AbstractString, (Nothing)} labels::OrderedDict{C, AbstractString} end function ManualColorKey(title, labels, colors::Vector{C}) where {C<:Color} @@ -550,7 +550,7 @@ end struct XTicks <: Gadfly.GuideElement label::Bool - ticks::Union{(Void), Symbol, AbstractArray} + ticks::Union{(Nothing), Symbol, AbstractArray} orientation::Symbol function XTicks(label, ticks, orientation) @@ -721,7 +721,7 @@ end struct YTicks <: Gadfly.GuideElement label::Bool - ticks::Union{(Void), Symbol, AbstractArray} + ticks::Union{(Nothing), Symbol, AbstractArray} orientation::Symbol function YTicks(label, ticks, orientation) @@ -908,7 +908,7 @@ end # X-axis label Guide struct XLabel <: Gadfly.GuideElement - label::Union{(Void), AbstractString} + label::Union{(Nothing), AbstractString} orientation::Symbol end XLabel(label; orientation=:auto) = XLabel(label, orientation) @@ -975,7 +975,7 @@ end # Y-axis label Guide struct YLabel <: Gadfly.GuideElement - label::Union{(Void), AbstractString} + label::Union{(Nothing), AbstractString} orientation::Symbol end YLabel(label; orientation=:auto) = YLabel(label, orientation) @@ -1036,7 +1036,7 @@ end # Title Guide struct Title <: Gadfly.GuideElement - label::Union{(Void), AbstractString} + label::Union{(Nothing), AbstractString} end """ diff --git a/src/misc.jl b/src/misc.jl index 77e1d7927..5e5290314 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -247,7 +247,7 @@ function has(xs::AbstractArray{T,N}, y::T) where {T,N} return false end -Maybe(T) = Union{T, (Void)} +Maybe(T) = Union{T, (Nothing)} lerp(x::Float64, a, b) = a + (b - a) * max(min(x, 1.0), 0.0) @@ -330,7 +330,7 @@ end svg_color_class_from_label(label::AbstractString) = @sprintf("color_%s", escape_id(label)) -using Base.Dates +using Dates # Arbitrarily order colors color_isless(a::Color, b::Color) = @@ -395,17 +395,17 @@ end discretize_make_ia(values::AbstractVector, levels) = IndirectArray(Array{UInt8}(indexin(values, levels)), levels) discretize_make_ia(values::AbstractVector) = discretize_make_ia(values, unique(values)) -discretize_make_ia(values::AbstractVector, ::Void) = discretize_make_ia(values) +discretize_make_ia(values::AbstractVector, ::Nothing) = discretize_make_ia(values) discretize_make_ia(values::IndirectArray) = values -discretize_make_ia(values::IndirectArray, ::Void) = values +discretize_make_ia(values::IndirectArray, ::Nothing) = values discretize_make_ia(values::CategoricalArray) = discretize_make_ia(values, intersect(push!(levels(values), missing), unique(values))) -discretize_make_ia(values::CategoricalArray, ::Void) = discretize_make_ia(values) +discretize_make_ia(values::CategoricalArray, ::Nothing) = discretize_make_ia(values) function discretize_make_ia(values::CategoricalArray{T}, levels::Vector) where {T} mapping = coalesce.(indexin(CategoricalArrays.index(values.pool), levels), 0) - unshift!(mapping, coalesce(findfirst(ismissing, levels), 0)) + pushfirst!(mapping, coalesce(findfirst(ismissing, levels), 0)) index = [mapping[x+1] for x in values.refs] any(iszero, index) && throw(ArgumentError("values not in levels encountered")) return IndirectArray(index, convert(Vector{T},levels)) diff --git a/src/open_file.jl b/src/open_file.jl index a20fe1ed9..8f134ab48 100644 --- a/src/open_file.jl +++ b/src/open_file.jl @@ -1,9 +1,9 @@ function open_file(filename) - if is_apple() + if Sys.isapple() run(`open $(filename)`) - elseif is_linux() || is_bsd() + elseif Sys.islinux() || Sys.isbsd() run(`xdg-open $(filename)`) - elseif is_windows() + elseif Sys.iswindows() run(`$(ENV["COMSPEC"]) /c start $(filename)`) else warn("Showing plots is not supported on OS $(string(Compat.KERNEL))") diff --git a/src/scale.jl b/src/scale.jl index 977a59ac0..51b612e56 100644 --- a/src/scale.jl +++ b/src/scale.jl @@ -78,7 +78,7 @@ struct ContinuousScale <: Gadfly.ScaleElement maxvalue minticks maxticks - labels::Union{(Void), Function} + labels::Union{(Nothing), Function} format scalable @@ -275,9 +275,9 @@ end struct DiscreteScale <: Gadfly.ScaleElement vars::Vector{Symbol} - labels::Union{(Void), Function} - levels::Union{(Void), AbstractVector} - order::Union{(Void), AbstractVector} + labels::Union{(Nothing), Function} + levels::Union{(Nothing), AbstractVector} + order::Union{(Nothing), AbstractVector} end DiscreteScale(vals; labels=nothing, levels=nothing, order=nothing) = DiscreteScale(vals, labels, levels, order) @@ -411,8 +411,8 @@ end struct DiscreteColorScale <: Gadfly.ScaleElement f::Function - levels::Union{(Void), AbstractVector} - order::Union{(Void), AbstractVector} + levels::Union{(Nothing), AbstractVector} + order::Union{(Nothing), AbstractVector} preserve_order::Bool end DiscreteColorScale(f; levels=nothing, order=nothing, preserve_order=true) = @@ -426,7 +426,7 @@ default_discrete_colors(n) = convert(Vector{Color}, transform=c -> deuteranopic(c, 0.5), lchoices=Float64[65, 70, 75, 80], cchoices=Float64[0, 50, 60, 70], - hchoices=linspace(0, 330, 24))) + hchoices=range(0, stop=330, length=24))) """ color_discrete_hue[(f; levels=nothing, order=nothing, preserve_order=true)] diff --git a/src/statistics.jl b/src/statistics.jl index ab9e68a06..94acfdf0f 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -546,9 +546,9 @@ function apply_statistic(stat::DensityStatistic, end end - colors = Array{RGB{Float32}}(0) - aes.x = Array{Float64}(0) - aes.y = Array{Float64}(0) + colors = Array{RGB{Float32}}(undef, 0) + aes.x = Array{Float64}(undef, 0) + aes.y = Array{Float64}(undef, 0) for (c, xs) in groups window = stat.bw <= 0.0 ? KernelDensity.default_bandwidth(xs) : stat.bw f = KernelDensity.kde(xs, bandwidth=window, npoints=stat.n) @@ -1348,10 +1348,10 @@ function apply_statistic(stat::StepStatistic, aes.group != nothing && permute!(aes.group, p) end - x_step = Array{eltype(aes.x)}(0) - y_step = Array{eltype(aes.y)}(0) - color_step = aes.color == nothing ? nothing : Array{eltype(aes.color)}(0) - group_step = aes.group == nothing ? nothing : Array{eltype(aes.group)}(0) + 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) i = 1 i_offset = 1 @@ -1415,7 +1415,7 @@ function apply_statistic(stat::FunctionStatistic, i = 1 for (f, xmin, xmax) in zip(aes.y, cycle(aes.xmin), cycle(aes.xmax)) - for x in linspace(xmin, xmax, stat.num_samples) + for x in range(xmin, stop=xmax, length=stat.num_samples) aes.x[i] = x ys[i] = f(x) i += 1 @@ -1488,11 +1488,11 @@ function apply_statistic(stat::ContourStatistic, if typeof(aes.z) <: Function if xs == nothing && aes.xmin != nothing && aes.xmax != nothing - xs = linspace(aes.xmin[1], aes.xmax[1], stat.samples) + xs = range(aes.xmin[1], stop=aes.xmax[1], length=stat.samples) end if ys == nothing && aes.ymin != nothing && aes.ymax != nothing - ys = linspace(aes.ymin[1], aes.ymax[1], stat.samples) + ys = range(aes.ymin[1], stop=aes.ymax[1], length=stat.samples) end zs = Float64[aes.z(x, y) for x in xs, y in ys] @@ -1511,7 +1511,7 @@ function apply_statistic(stat::ContourStatistic, elseif typeof(aes.z) <: Vector z = Vector{Float64}(aes.z) a = [xs ys z] - as = sortrows(a, by=x->(x[2],x[1])) + as = sortslices(a, dims=1, by=x->(x[2],x[1])) xs = unique(as[:,1]) ys = unique(as[:,2]) zs = Array{Float64}(length(xs), length(ys)) @@ -1659,9 +1659,9 @@ function apply_statistic(stat::ViolinStatistic, grouped_color = (colorflag ? Dict(x=>first(aes.color[aes.x.==x]) for x in ux) : uxflag && Dict(x=>nothing for x in ux) ) - aes.x = Array{Float64}(0) - aes.y = Array{Float64}(0) - aes.width = Array{Float64}(0) + aes.x = Array{Float64}(undef, 0) + aes.y = Array{Float64}(undef, 0) + aes.width = Array{Float64}(undef, 0) colors = eltype(aes.color)[] for (x, ys) in grouped_y @@ -1787,9 +1787,9 @@ function apply_statistic(stat::BinMeanStatistic, push!(groups[c][2], y) end end - colors = Array{RGB{Float32}}(0) - aes.x = Array{Tx}(0) - aes.y = Array{Ty}(0) + colors = Array{RGB{Float32}}(undef, 0) + aes.x = Array{Tx}(undef, 0) + aes.y = Array{Ty}(undef, 0) for (c, v) in groups (fx, fy) = mean_by_group(v[1], v[2], breaks) append!(aes.x, fx) @@ -1892,10 +1892,10 @@ function apply_statistic(stat::VecFieldStatistic, if isa(aes.z, Function) if xs == nothing && aes.xmin != nothing && aes.xmax != nothing - xs = linspace(aes.xmin[1], aes.xmax[1], stat.samples) + xs = range(aes.xmin[1], stop=aes.xmax[1], length=stat.samples) end if ys == nothing && aes.ymin != nothing && aes.ymax != nothing - ys = linspace(aes.ymin[1], aes.ymax[1], stat.samples) + ys = range(aes.ymin[1], stop=aes.ymax[1], length=stat.samples) end zs = Float64[aes.z(x, y) for x in xs, y in ys] diff --git a/test/compare_examples.jl b/test/compare_examples.jl index bdced56fc..669ccfec2 100644 --- a/test/compare_examples.jl +++ b/test/compare_examples.jl @@ -59,7 +59,7 @@ diffedout = joinpath((@__DIR__), "diffed-output") ndifferentfiles = 0 const creator_producer = r"(Creator|Producer)" filter_mkdir_git(x) = !mapreduce(y->x==y,|,[".mkdir","git.log","git.status"]) -filter_regex(x) = ismatch(Regex(args["filter"]), x) +filter_regex(x) = occursin(Regex(args["filter"]), x) master_files = filter(x->filter_mkdir_git(x) && filter_regex(x), readdir(masterout)) devel_files = filter(x->filter_mkdir_git(x) && filter_regex(x), readdir(develout)) cached_notin_genned = setdiff(master_files, devel_files) @@ -76,7 +76,7 @@ for file in intersect(master_files,devel_files) if same lsame = Bool[cached[i] == genned[i] for i = 1:length(cached)] if !all(lsame) - for idx in find(lsame.==false) + for idx in findall(lsame.==false) # Don't worry about lines that are due to # Creator/Producer (e.g., Cairo versions) if !isempty(search(cached[idx], creator_producer)) diff --git a/test/runtests.jl b/test/runtests.jl index 6e1d1a886..b087661c1 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,7 @@ if haskey(ENV, "GADFLY_THEME") pop!(ENV, "GADFLY_THEME") end -using Base.Test, Gadfly, Compat +using Test, Gadfly, Compat repo = LibGit2.GitRepo(dirname(@__DIR__)) branch = LibGit2.headname(repo) @@ -75,11 +75,11 @@ testfiles = isempty(ARGS) ? @testset "Gadfly" begin for filename in testfiles, (backend_name, backend) in backends info(filename,'.',backend_name) - srand(1) + Random.seed!(1) p = evalfile(joinpath(testdir, "$(filename).jl")) @test typeof(p) in [Plot,Compose.Context] r = draw(backend(filename), p) - @test typeof(r) in [Bool,Void] + @test typeof(r) in [Bool,Nothing] end end diff --git a/test/testscripts/Guide_colorkey.jl b/test/testscripts/Guide_colorkey.jl index 6c4125376..134cd10e9 100644 --- a/test/testscripts/Guide_colorkey.jl +++ b/test/testscripts/Guide_colorkey.jl @@ -2,7 +2,7 @@ using Compose, Gadfly set_default_plot_size(6inch, 3inch) -srand(123) +Random.seed!(123) plot(x=rand(20), y=rand(20), color=repeat(["A","B"], inner=10), Guide.colorkey(title="Species", labels=["Name1","Name2"], pos=[0.85w,-0.3h]) ) diff --git a/test/testscripts/Guide_shapekey.jl b/test/testscripts/Guide_shapekey.jl index 8994f6f00..7e17f5343 100644 --- a/test/testscripts/Guide_shapekey.jl +++ b/test/testscripts/Guide_shapekey.jl @@ -2,7 +2,7 @@ using Compose, DataFrames, Gadfly set_default_plot_size(9inch, 3.3inch) -srand(123) +Random.seed!(123) theme1 = Theme(point_size=3mm) coord1 = Coord.cartesian(xmin=0.0, xmax=6.0) D = DataFrame(x=1:5, y=rand(5), V1=["A","A","B","B","D"], V2 = string.([1,2,2,3,3]) ) diff --git a/test/testscripts/contour_matrix.jl b/test/testscripts/contour_matrix.jl index 971e3139b..a0620496a 100644 --- a/test/testscripts/contour_matrix.jl +++ b/test/testscripts/contour_matrix.jl @@ -3,8 +3,8 @@ using Gadfly, Compat set_default_plot_size(6inch, 3inch) f(x,y) = x*exp(-(x-(round(Int, x)))^2-y^2) -M = Array{Float64}(200, 200) -for (i, x) in enumerate(linspace(-8., 8., 200)), (j, y) in enumerate(linspace(-2., 2., 200)) +M = Array{Float64}(undef, 200, 200) +for (i, x) in enumerate(range(-8., stop=8., length=200)), (j, y) in enumerate(range(-2., stop=2., length=200)) M[i, j] = f(x, y) end diff --git a/test/testscripts/date_bar.jl b/test/testscripts/date_bar.jl index ee1789f8c..52342b887 100644 --- a/test/testscripts/date_bar.jl +++ b/test/testscripts/date_bar.jl @@ -1,8 +1,8 @@ -using Gadfly, Base.Dates +using Gadfly, Dates set_default_plot_size(6inch, 3inch) -dates = Array{Date}(40) +dates = Array{Date}(undef, 40) dates[1] = today() for i=2:length(dates) dates[i] = today()+Day(i) diff --git a/test/testscripts/density_dark.jl b/test/testscripts/density_dark.jl index d8a450ea3..e9c3fb162 100644 --- a/test/testscripts/density_dark.jl +++ b/test/testscripts/density_dark.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Distributions, Base.Test +using Gadfly, DataArrays, RDatasets, Distributions, Test set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/discrete_color_hue.jl b/test/testscripts/discrete_color_hue.jl index 7a7a2aa6e..7b6e1453a 100644 --- a/test/testscripts/discrete_color_hue.jl +++ b/test/testscripts/discrete_color_hue.jl @@ -1,4 +1,4 @@ using Gadfly, Colors plot(ones(10,3).*[1 2 3], x=Row.index, y=Col.value, color=Col.index, - Geom.line, Scale.color_discrete_hue(x->linspace(RGB(1,0,0),RGB(0,0,1),x))) + Geom.line, Scale.color_discrete_hue(x->range(RGB(1,0,0), stop=RGB(0,0,1), length=x))) diff --git a/test/testscripts/discrete_color_manual.jl b/test/testscripts/discrete_color_manual.jl index 868a9a68c..654cafbcd 100644 --- a/test/testscripts/discrete_color_manual.jl +++ b/test/testscripts/discrete_color_manual.jl @@ -1,4 +1,4 @@ -using Gadfly, Colors, Base.Test +using Gadfly, Colors, Test set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/ellipse.jl b/test/testscripts/ellipse.jl index 53bba3d2f..494a57c43 100644 --- a/test/testscripts/ellipse.jl +++ b/test/testscripts/ellipse.jl @@ -1,7 +1,7 @@ using Distributions, Gadfly set_default_plot_size(6.6inch, 3.3inch) -srand(123) +Random.seed!(123) d = rand(MvNormal([2, 2],[1.0 0.7; 0.7 1.0]), 50)' pa= plot(x=d[:,1], y=d[:,2], Geom.point, layer(Stat.ellipse, Geom.polygon(preserve_order=true))) diff --git a/test/testscripts/hvabline_dates.jl b/test/testscripts/hvabline_dates.jl index 148205461..6b310c781 100644 --- a/test/testscripts/hvabline_dates.jl +++ b/test/testscripts/hvabline_dates.jl @@ -1,4 +1,4 @@ -using Gadfly, Base.Dates +using Gadfly, Dates dates = [Date("2017-08-07"), Date("2017-08-08"), Date("2017-08-09")] date = [Date("2017-08-08")] diff --git a/test/testscripts/percent.jl b/test/testscripts/percent.jl index a162927ee..48d3a79c2 100644 --- a/test/testscripts/percent.jl +++ b/test/testscripts/percent.jl @@ -23,7 +23,7 @@ isless(a::Percent, b::Percent) = isless(a.value, b.value) one(::Type{Percent}) = Percent(0.01) zero(::Type{Percent}) = Percent(0.0) isfinite(a::Percent) = isfinite(a.value) -show(io::IO, p::Percent) = print(io, round(100 * p.value, 4), "%") +show(io::IO, p::Percent) = print(io, round(100 * p.value, digits=4), "%") y=[Percent(0.1), Percent(0.2), Percent(0.3)] plot(x=collect(1:length(y)), y=y) diff --git a/test/testscripts/single_datetime.jl b/test/testscripts/single_datetime.jl index b4586cac0..295de6734 100644 --- a/test/testscripts/single_datetime.jl +++ b/test/testscripts/single_datetime.jl @@ -1,6 +1,6 @@ # issue 462 -using Gadfly, Base.Dates +using Gadfly, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/stat_qq.jl b/test/testscripts/stat_qq.jl index 39ce94015..93775e87d 100644 --- a/test/testscripts/stat_qq.jl +++ b/test/testscripts/stat_qq.jl @@ -2,7 +2,7 @@ using Gadfly, Distributions set_default_plot_size(6inch, 16inch) -srand(1234) +Random.seed!(1234) x = rand(Normal(), 100) y = rand(Normal(10), 100) diff --git a/test/testscripts/subplot_grid_free_y_1.jl b/test/testscripts/subplot_grid_free_y_1.jl index a0f71c68c..a45576280 100644 --- a/test/testscripts/subplot_grid_free_y_1.jl +++ b/test/testscripts/subplot_grid_free_y_1.jl @@ -3,7 +3,7 @@ using Gadfly, RDatasets, Compat set_default_plot_size(15cm, 15cm) d = dataset("mlmRev", "Chem97") -idx = find((d[:Score] .> 4) .& (d[:Age] .> 0)) +idx = findall((d[:Score] .> 4) .& (d[:Age] .> 0)) plot(d[idx[1:4:end], :], x=:GCSEScore, ygroup=:Gender, diff --git a/test/testscripts/timeseries_colorful.jl b/test/testscripts/timeseries_colorful.jl index ce887d90c..992e29bc8 100755 --- a/test/testscripts/timeseries_colorful.jl +++ b/test/testscripts/timeseries_colorful.jl @@ -1,4 +1,4 @@ -using Gadfly, DataFrames, Base.Dates +using Gadfly, DataFrames, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_day.jl b/test/testscripts/timeseries_day.jl index 87f90e05b..056e1533c 100644 --- a/test/testscripts/timeseries_day.jl +++ b/test/testscripts/timeseries_day.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, DataFrames, RDatasets, Base.Dates +using Gadfly, DataArrays, DataFrames, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_month.jl b/test/testscripts/timeseries_month.jl index 2d92e69fc..bb312e97e 100644 --- a/test/testscripts/timeseries_month.jl +++ b/test/testscripts/timeseries_month.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Base.Dates +using Gadfly, DataArrays, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_1.jl b/test/testscripts/timeseries_year_1.jl index 78a53d68b..ebdc60398 100644 --- a/test/testscripts/timeseries_year_1.jl +++ b/test/testscripts/timeseries_year_1.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Base.Dates +using Gadfly, DataArrays, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_2.jl b/test/testscripts/timeseries_year_2.jl index af77daf9f..c8bd3b4ef 100644 --- a/test/testscripts/timeseries_year_2.jl +++ b/test/testscripts/timeseries_year_2.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Base.Dates +using Gadfly, DataArrays, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_3.jl b/test/testscripts/timeseries_year_3.jl index b65b2b25a..9590f3ea8 100644 --- a/test/testscripts/timeseries_year_3.jl +++ b/test/testscripts/timeseries_year_3.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Base.Dates +using Gadfly, DataArrays, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/vector.jl b/test/testscripts/vector.jl index 2c2e38bde..0ce541e7e 100644 --- a/test/testscripts/vector.jl +++ b/test/testscripts/vector.jl @@ -2,7 +2,7 @@ using DataFrames, Gadfly set_default_plot_size(2*3.3inch, 2*3.3inch) -srand(123) +Random.seed!(123) D = convert(DataFrame, 99*rand(4, 4)+0.5) xsc = Scale.x_continuous(minvalue=0.0, maxvalue=100) From 6f591d83eebec99c7a9e2bd52da0c88f1ca8d9d7 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Mon, 27 Aug 2018 07:45:59 -0400 Subject: [PATCH 03/11] excise DataArrays and Missing --- REQUIRE | 2 -- src/Gadfly.jl | 1 - src/aesthetics.jl | 12 ++++++------ src/coord.jl | 1 - src/geometry.jl | 1 - src/mapping.jl | 2 +- src/misc.jl | 6 +++--- src/scale.jl | 3 +-- src/statistics.jl | 7 +++---- test/testscripts/array_aesthetics.jl | 4 ++-- test/testscripts/boxplot.jl | 2 +- test/testscripts/boxplot_nonstandard.jl | 2 +- test/testscripts/colored_points.jl | 2 +- test/testscripts/colorful_density.jl | 2 +- test/testscripts/colorful_hist.jl | 2 +- test/testscripts/custom_themes.jl | 2 +- test/testscripts/density.jl | 2 +- test/testscripts/density_dark.jl | 2 +- test/testscripts/discrete_bar.jl | 2 +- test/testscripts/discrete_bar_horizontal.jl | 2 +- test/testscripts/discrete_bar_horizontal_spacing.jl | 2 +- test/testscripts/dodged_discrete_histogram.jl | 2 +- .../dodged_discrete_histogram_horizontal.jl | 2 +- test/testscripts/function_layers.jl | 2 +- test/testscripts/grid_line_style.jl | 2 +- test/testscripts/histogram2d.jl | 2 +- test/testscripts/histogram2d_discrete.jl | 2 +- test/testscripts/histogram2d_explicit_bins.jl | 2 +- test/testscripts/histogram_errorbar.jl | 2 +- test/testscripts/histogram_explicit_bins.jl | 2 +- test/testscripts/hstack.jl | 2 +- test/testscripts/issue82.jl | 2 +- test/testscripts/jitter.jl | 2 +- test/testscripts/labels.jl | 2 +- test/testscripts/line_histogram.jl | 2 +- test/testscripts/points.jl | 2 +- test/testscripts/raster.jl | 2 +- test/testscripts/spy.jl | 2 +- test/testscripts/stacked_continuous_histogram.jl | 2 +- test/testscripts/stacked_discrete_histogram.jl | 2 +- .../stacked_discrete_histogram_horizontal.jl | 2 +- test/testscripts/subplot_grid.jl | 2 +- test/testscripts/subplot_grid_free_axis.jl | 2 +- test/testscripts/subplot_grid_histogram.jl | 2 +- test/testscripts/timeseries_day.jl | 2 +- test/testscripts/timeseries_month.jl | 2 +- test/testscripts/timeseries_year_1.jl | 2 +- test/testscripts/timeseries_year_2.jl | 2 +- test/testscripts/timeseries_year_3.jl | 2 +- test/testscripts/violin.jl | 2 +- test/testscripts/vstack.jl | 2 +- 51 files changed, 57 insertions(+), 64 deletions(-) diff --git a/REQUIRE b/REQUIRE index ff9309939..8097e3482 100644 --- a/REQUIRE +++ b/REQUIRE @@ -5,7 +5,6 @@ Compose 0.5.2 Contour 0.1.1 CoupledFields DataFrames 0.11.4 -DataArrays DataStructures Distributions DocStringExtensions @@ -18,4 +17,3 @@ Showoff 0.0.3 StatsBase Juno IndirectArrays 0.4.2 -Missings diff --git a/src/Gadfly.jl b/src/Gadfly.jl index 0de779964..eac16e868 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -3,7 +3,6 @@ module Gadfly using Colors using Compat using Compose -using DataArrays using DataFrames using DataStructures using JSON diff --git a/src/aesthetics.jl b/src/aesthetics.jl index 38e7136da..cb0281683 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -1,11 +1,11 @@ const NumericalOrCategoricalAesthetic = - Union{(Nothing), Vector, DataArray, IndirectArray} + Union{Nothing, Vector, Array, IndirectArray} const CategoricalAesthetic = - Union{(Nothing), IndirectArray} + Union{Nothing, IndirectArray} const NumericalAesthetic = - Union{(Nothing), Matrix, Vector, DataArray} + Union{Nothing, Matrix, Vector, Array} @varset Aesthetics begin @@ -272,8 +272,8 @@ cat_aes_var!(a, b) = a function cat_aes_var!(a::AbstractArray{T}, b::AbstractArray{U}) where {T, U} V = promote_type(T, U) - if isa(a, DataArray) || isa(b, DataArray) - ab = DataArray(V, length(a) + length(b)) + if isa(a, Array{Union{Missing,T}}) || isa(b, Array{Union{Missing,U}}) + ab = Array{Union{Missing,V}}(length(a) + length(b)) else ab = Array{V}(length(a) + length(b)) end @@ -370,7 +370,7 @@ function by_xy_group(aes::T, xgroup, ygroup, if !applicable(convert, typeof(vals), staging[i, j]) T2 = eltype(vals) if T2 <: Color T2 = Color end - da = DataArray(T2, length(staging[i, j])) + da = Array{Union{Missing,T2}}(length(staging[i, j])) copy!(da, staging[i, j]) setfield!(aes_grid[i, j], var, da) else diff --git a/src/coord.jl b/src/coord.jl index 4549d0b77..23cb90c3f 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -3,7 +3,6 @@ module Coord using Gadfly using Compat using Compose -using DataArrays import Gadfly.Maybe export cartesian diff --git a/src/geometry.jl b/src/geometry.jl index 17e9c9bea..125410f34 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -3,7 +3,6 @@ module Geom using Colors using Compat using Compose -using DataArrays using DataStructures using Distributions using Gadfly diff --git a/src/mapping.jl b/src/mapping.jl index 33ccce924..df105c5b1 100644 --- a/src/mapping.jl +++ b/src/mapping.jl @@ -135,7 +135,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) end end - push!(V, eltyp == Vector ? Array{eltyp}(vm) : DataArray(eltyp, vm)) + push!(V, eltyp == Vector ? Array{eltyp}(vm) : Array{Union{Missing,eltyp}}(vm)) name = gensym() push!(vnames, name) colmap[colgroup] = j diff --git a/src/misc.jl b/src/misc.jl index 5e5290314..5cbc19da7 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -68,7 +68,7 @@ function concrete_length(xs) n end -function concrete_length(xs::DataArray{T}) where T +function concrete_length(xs::Array{Union{Missing,T}}) where T n = 0 for i = 1:length(xs) if !xs.na[i] && isconcrete(xs.data[i]::T) @@ -150,7 +150,7 @@ function concrete_minmax(xs, xmin::T, xmax::T) where T<:Real end -function concrete_minmax(xs::DataArray{TA}, xmin::T, xmax::T) where {T<:Real, TA} +function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T<:Real, TA} for i = 1:length(xs) if !xs.na[i] x = xs.data[i]::TA @@ -183,7 +183,7 @@ function concrete_minmax(xs, xmin::T, xmax::T) where T end -function concrete_minmax(xs::DataArray{TA}, xmin::T, xmax::T) where {T, TA} +function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T, TA} for i = 1:length(xs) if !xs.na[i] x = xs.data[i]::TA diff --git a/src/scale.jl b/src/scale.jl index 51b612e56..c17939f3f 100644 --- a/src/scale.jl +++ b/src/scale.jl @@ -3,7 +3,6 @@ module Scale using Colors using Compat using Compose -using DataArrays using DataStructures using Gadfly using Showoff @@ -198,7 +197,7 @@ function apply_scale(scale::ContinuousScale, T = Measure end - ds = any(ismissing, vals) ? DataArray(T, length(vals)) : Array{T}(length(vals)) + ds = any(ismissing, vals) ? Array{Union{Missing,T}}(length(vals)) : Array{T}(length(vals)) apply_scale_typed!(ds, vals, scale) if var == :xviewmin || var == :xviewmax || diff --git a/src/statistics.jl b/src/statistics.jl index 94acfdf0f..e115d0c64 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -6,7 +6,6 @@ import Contour using Colors using Compat using Compose -using DataArrays using DataStructures using Distributions using Hexagons @@ -964,7 +963,7 @@ function apply_statistic_typed(minval::T, maxval::T, vals, size, dsize) where T minval, maxval end -function apply_statistic_typed(minval::T, maxval::T, vals::DataArray{T}, size, dsize) where T +function apply_statistic_typed(minval::T, maxval::T, vals::Array{Union{Missing,T}}, size, dsize) where T lensize = length(size) lendsize = length(dsize) for i = 1:length(vals) @@ -1426,7 +1425,7 @@ function apply_statistic(stat::FunctionStatistic, if aes.color != nothing func_color = aes.color aes.color = Array{eltype(aes.color)}(length(aes.y) * stat.num_samples) - groups = DataArray(Int, length(aes.y) * stat.num_samples) + groups = Array{Union{Missing,Int}}(length(aes.y) * stat.num_samples) for i in 1:length(aes.y) aes.color[1+(i-1)*stat.num_samples:i*stat.num_samples] = func_color[i] groups[1+(i-1)*stat.num_samples:i*stat.num_samples] = i @@ -1435,7 +1434,7 @@ function apply_statistic(stat::FunctionStatistic, elseif length(aes.y) > 1 && haskey(scales, :color) data = Gadfly.Data() data.color = Array{AbstractString}(length(aes.y) * stat.num_samples) - groups = DataArray(Int, length(aes.y) * stat.num_samples) + groups = Array{Union{Missing,Int}}(length(aes.y) * stat.num_samples) for i in 1:length(aes.y) fname = "f$(i)" data.color[1+(i-1)*stat.num_samples:i*stat.num_samples] = fname diff --git a/test/testscripts/array_aesthetics.jl b/test/testscripts/array_aesthetics.jl index 64c249de1..550184eb8 100644 --- a/test/testscripts/array_aesthetics.jl +++ b/test/testscripts/array_aesthetics.jl @@ -1,6 +1,6 @@ -# Test mapping arrays directly to aesthetics without a data fram. +# Test mapping arrays directly to aesthetics without a data frame. -using Gadfly, DataArrays, DataFrames +using Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/boxplot.jl b/test/testscripts/boxplot.jl index 57084c117..3f1845ecf 100644 --- a/test/testscripts/boxplot.jl +++ b/test/testscripts/boxplot.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/boxplot_nonstandard.jl b/test/testscripts/boxplot_nonstandard.jl index 9c46f27be..4ff3b954b 100644 --- a/test/testscripts/boxplot_nonstandard.jl +++ b/test/testscripts/boxplot_nonstandard.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/colored_points.jl b/test/testscripts/colored_points.jl index 4bc1c4855..29923e07e 100644 --- a/test/testscripts/colored_points.jl +++ b/test/testscripts/colored_points.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/colorful_density.jl b/test/testscripts/colorful_density.jl index f32b885fa..34ad9d539 100644 --- a/test/testscripts/colorful_density.jl +++ b/test/testscripts/colorful_density.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/colorful_hist.jl b/test/testscripts/colorful_hist.jl index 3b5dd1c17..e837335d4 100644 --- a/test/testscripts/colorful_hist.jl +++ b/test/testscripts/colorful_hist.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/custom_themes.jl b/test/testscripts/custom_themes.jl index abc154097..b3c2466d6 100644 --- a/test/testscripts/custom_themes.jl +++ b/test/testscripts/custom_themes.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/density.jl b/test/testscripts/density.jl index 75fdd1f63..71364288e 100644 --- a/test/testscripts/density.jl +++ b/test/testscripts/density.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Distributions +using Gadfly, RDatasets, Distributions set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/density_dark.jl b/test/testscripts/density_dark.jl index e9c3fb162..bb3a94de6 100644 --- a/test/testscripts/density_dark.jl +++ b/test/testscripts/density_dark.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Distributions, Test +using Gadfly, RDatasets, Distributions, Test set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/discrete_bar.jl b/test/testscripts/discrete_bar.jl index 98a78ab64..49611ac2a 100644 --- a/test/testscripts/discrete_bar.jl +++ b/test/testscripts/discrete_bar.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/discrete_bar_horizontal.jl b/test/testscripts/discrete_bar_horizontal.jl index f1f43224e..1e581233e 100644 --- a/test/testscripts/discrete_bar_horizontal.jl +++ b/test/testscripts/discrete_bar_horizontal.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/discrete_bar_horizontal_spacing.jl b/test/testscripts/discrete_bar_horizontal_spacing.jl index 2cfc63a4f..21996df5b 100644 --- a/test/testscripts/discrete_bar_horizontal_spacing.jl +++ b/test/testscripts/discrete_bar_horizontal_spacing.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/dodged_discrete_histogram.jl b/test/testscripts/dodged_discrete_histogram.jl index 5812db50c..09393e295 100644 --- a/test/testscripts/dodged_discrete_histogram.jl +++ b/test/testscripts/dodged_discrete_histogram.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/dodged_discrete_histogram_horizontal.jl b/test/testscripts/dodged_discrete_histogram_horizontal.jl index 825677fae..836ad2a99 100644 --- a/test/testscripts/dodged_discrete_histogram_horizontal.jl +++ b/test/testscripts/dodged_discrete_histogram_horizontal.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/function_layers.jl b/test/testscripts/function_layers.jl index 1281f8729..0d4018f7c 100644 --- a/test/testscripts/function_layers.jl +++ b/test/testscripts/function_layers.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/grid_line_style.jl b/test/testscripts/grid_line_style.jl index 5c4183a08..35acef1cc 100644 --- a/test/testscripts/grid_line_style.jl +++ b/test/testscripts/grid_line_style.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/histogram2d.jl b/test/testscripts/histogram2d.jl index 14b9f7de0..3a098be26 100644 --- a/test/testscripts/histogram2d.jl +++ b/test/testscripts/histogram2d.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/histogram2d_discrete.jl b/test/testscripts/histogram2d_discrete.jl index 1dcfca6dc..6b73b52ba 100644 --- a/test/testscripts/histogram2d_discrete.jl +++ b/test/testscripts/histogram2d_discrete.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/histogram2d_explicit_bins.jl b/test/testscripts/histogram2d_explicit_bins.jl index ef00c84eb..dbb0a78a3 100644 --- a/test/testscripts/histogram2d_explicit_bins.jl +++ b/test/testscripts/histogram2d_explicit_bins.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/histogram_errorbar.jl b/test/testscripts/histogram_errorbar.jl index 06bf9bb31..5406b7495 100644 --- a/test/testscripts/histogram_errorbar.jl +++ b/test/testscripts/histogram_errorbar.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, DataFrames, Gadfly +using RDatasets, DataFrames, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/histogram_explicit_bins.jl b/test/testscripts/histogram_explicit_bins.jl index 9d47b2566..d3bba4618 100644 --- a/test/testscripts/histogram_explicit_bins.jl +++ b/test/testscripts/histogram_explicit_bins.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/hstack.jl b/test/testscripts/hstack.jl index 851b3aae6..33c72336c 100644 --- a/test/testscripts/hstack.jl +++ b/test/testscripts/hstack.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, DataFrames +using Gadfly, RDatasets, DataFrames set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/issue82.jl b/test/testscripts/issue82.jl index a19412773..c146da0c8 100644 --- a/test/testscripts/issue82.jl +++ b/test/testscripts/issue82.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, DataFrames +using Gadfly, DataFrames set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/jitter.jl b/test/testscripts/jitter.jl index 3eff99e4d..08542e41b 100644 --- a/test/testscripts/jitter.jl +++ b/test/testscripts/jitter.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/labels.jl b/test/testscripts/labels.jl index 63c6263fb..0975a4761 100644 --- a/test/testscripts/labels.jl +++ b/test/testscripts/labels.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 6inch) diff --git a/test/testscripts/line_histogram.jl b/test/testscripts/line_histogram.jl index 218205a1f..1129aa833 100644 --- a/test/testscripts/line_histogram.jl +++ b/test/testscripts/line_histogram.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/points.jl b/test/testscripts/points.jl index 4207cbf36..68f65fa4a 100644 --- a/test/testscripts/points.jl +++ b/test/testscripts/points.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/raster.jl b/test/testscripts/raster.jl index 7228adcfc..4a6c8fd0e 100644 --- a/test/testscripts/raster.jl +++ b/test/testscripts/raster.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/spy.jl b/test/testscripts/spy.jl index 6f7c5981e..12eb24b2e 100644 --- a/test/testscripts/spy.jl +++ b/test/testscripts/spy.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays +using Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/stacked_continuous_histogram.jl b/test/testscripts/stacked_continuous_histogram.jl index b4448c312..ac08dee69 100644 --- a/test/testscripts/stacked_continuous_histogram.jl +++ b/test/testscripts/stacked_continuous_histogram.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/stacked_discrete_histogram.jl b/test/testscripts/stacked_discrete_histogram.jl index f308427da..00015c1f7 100644 --- a/test/testscripts/stacked_discrete_histogram.jl +++ b/test/testscripts/stacked_discrete_histogram.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/stacked_discrete_histogram_horizontal.jl b/test/testscripts/stacked_discrete_histogram_horizontal.jl index 3b2c69704..cd445c5db 100644 --- a/test/testscripts/stacked_discrete_histogram_horizontal.jl +++ b/test/testscripts/stacked_discrete_histogram_horizontal.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/subplot_grid.jl b/test/testscripts/subplot_grid.jl index 5d462300b..1595dba03 100644 --- a/test/testscripts/subplot_grid.jl +++ b/test/testscripts/subplot_grid.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, DataFrames, Gadfly +using RDatasets, DataFrames, Gadfly set_default_plot_size(10inch, 10inch) diff --git a/test/testscripts/subplot_grid_free_axis.jl b/test/testscripts/subplot_grid_free_axis.jl index 7af4a7fcb..3af7289f4 100644 --- a/test/testscripts/subplot_grid_free_axis.jl +++ b/test/testscripts/subplot_grid_free_axis.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, DataFrames, Gadfly +using RDatasets, DataFrames, Gadfly set_default_plot_size(10inch, 10inch) diff --git a/test/testscripts/subplot_grid_histogram.jl b/test/testscripts/subplot_grid_histogram.jl index 197f79f27..f6fd0da93 100644 --- a/test/testscripts/subplot_grid_histogram.jl +++ b/test/testscripts/subplot_grid_histogram.jl @@ -1,4 +1,4 @@ -using RDatasets, DataArrays, Gadfly +using RDatasets, Gadfly set_default_plot_size(10inch, 3inch) diff --git a/test/testscripts/timeseries_day.jl b/test/testscripts/timeseries_day.jl index 056e1533c..cce467236 100644 --- a/test/testscripts/timeseries_day.jl +++ b/test/testscripts/timeseries_day.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, DataFrames, RDatasets, Dates +using Gadfly, DataFrames, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_month.jl b/test/testscripts/timeseries_month.jl index bb312e97e..916a7fe92 100644 --- a/test/testscripts/timeseries_month.jl +++ b/test/testscripts/timeseries_month.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Dates +using Gadfly, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_1.jl b/test/testscripts/timeseries_year_1.jl index ebdc60398..f6cc3eb4e 100644 --- a/test/testscripts/timeseries_year_1.jl +++ b/test/testscripts/timeseries_year_1.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Dates +using Gadfly, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_2.jl b/test/testscripts/timeseries_year_2.jl index c8bd3b4ef..2a459eb9e 100644 --- a/test/testscripts/timeseries_year_2.jl +++ b/test/testscripts/timeseries_year_2.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Dates +using Gadfly, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/timeseries_year_3.jl b/test/testscripts/timeseries_year_3.jl index 9590f3ea8..457b3e421 100644 --- a/test/testscripts/timeseries_year_3.jl +++ b/test/testscripts/timeseries_year_3.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, Dates +using Gadfly, RDatasets, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/violin.jl b/test/testscripts/violin.jl index 08b827755..a33e13e6f 100644 --- a/test/testscripts/violin.jl +++ b/test/testscripts/violin.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets +using Gadfly, RDatasets set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/vstack.jl b/test/testscripts/vstack.jl index 833a5046b..8f884e8da 100644 --- a/test/testscripts/vstack.jl +++ b/test/testscripts/vstack.jl @@ -1,4 +1,4 @@ -using Gadfly, DataArrays, RDatasets, DataFrames +using Gadfly, RDatasets, DataFrames set_default_plot_size(6inch, 6inch) From 254e3a9ee6c7b8345bc314012a6cedaf1187714e Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Wed, 29 Aug 2018 12:15:06 -0400 Subject: [PATCH 04/11] fix depwarns --- REQUIRE | 2 + src/Gadfly.jl | 28 +++--- src/aesthetics.jl | 28 +++--- src/bincount.jl | 2 +- src/coord.jl | 20 ++--- src/geom/bar.jl | 4 +- src/geom/beeswarm.jl | 8 +- src/geom/line.jl | 6 +- src/geom/polygon.jl | 2 +- src/geom/rectbin.jl | 2 +- src/geom/subplot.jl | 8 +- src/guide.jl | 24 +++--- src/guide/keys.jl | 6 +- src/mapping.jl | 69 ++++++++------- src/misc.jl | 20 ++--- src/poetry.jl | 3 +- src/scale.jl | 10 ++- src/shapes.jl | 22 ++--- src/statistics.jl | 109 ++++++++++++------------ src/theme.jl | 4 +- src/ticks.jl | 4 +- src/varset.jl | 2 +- test/REQUIRE | 1 - test/compare_examples.jl | 20 +++-- test/runtests.jl | 12 ++- test/testscripts/Guide_colorkey.jl | 2 +- test/testscripts/Guide_shapekey.jl | 2 +- test/testscripts/boxplot_no_aesy.jl | 10 +-- test/testscripts/colored_smooth_lm.jl | 4 +- test/testscripts/density_dark.jl | 16 ++-- test/testscripts/ellipse.jl | 4 +- test/testscripts/issue177.jl | 4 +- test/testscripts/issue961.jl | 4 +- test/testscripts/issue975.jl | 2 +- test/testscripts/line_linestyle.jl | 2 +- test/testscripts/log10_scale_range.jl | 2 +- test/testscripts/matrix_lines.jl | 4 +- test/testscripts/scale_color_log.jl | 2 +- test/testscripts/scale_color_log10.jl | 2 +- test/testscripts/scale_color_log2.jl | 2 +- test/testscripts/smooth_lm.jl | 2 +- test/testscripts/stat_qq.jl | 2 +- test/testscripts/static_label_layout.jl | 2 +- test/testscripts/timeseries_year_2.jl | 7 -- test/testscripts/vector.jl | 6 +- 45 files changed, 254 insertions(+), 243 deletions(-) diff --git a/REQUIRE b/REQUIRE index 8097e3482..1cd55a52c 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,5 @@ julia 0.7 +CategoricalArrays # might be able to remove Colors 0.3.4 Compat 0.18.0 Compose 0.5.2 @@ -13,6 +14,7 @@ IterTools JSON KernelDensity Loess +Measures Showoff 0.0.3 StatsBase Juno diff --git a/src/Gadfly.jl b/src/Gadfly.jl index eac16e868..1094a5c0c 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -9,10 +9,12 @@ using JSON using Showoff using IndirectArrays using CategoricalArrays +using Printf +using Base64 import IterTools import IterTools: distinct, drop, chain -import Compose: draw, hstack, vstack, gridstack, isinstalled, parse_colorant +import Compose: draw, hstack, vstack, gridstack, parse_colorant import Base: +, -, /, *, copy, push!, start, next, done, show, getindex, cat, show, isfinite, display @@ -378,7 +380,7 @@ function render_prepare(plot::Plot) # Process layers, filling inheriting mappings or data from the Plot where # they are missing. - datas = Array{Data}(length(plot.layers)) + datas = Array{Data}(undef, length(plot.layers)) for (i, layer) in enumerate(plot.layers) if layer.data_source === nothing && isempty(layer.mapping) layer.data_source = plot.data_source @@ -434,7 +436,7 @@ function render_prepare(plot::Plot) end # Add default statistics for geometries. - layer_stats = Array{Vector{StatisticElement}}(length(plot.layers)) + layer_stats = Array{Vector{StatisticElement}}(undef, length(plot.layers)) for (i, layer) in enumerate(plot.layers) layer_stats[i] = isempty(layer.statistics) ? ( isa(layer.geom, Geom.SubplotGeometry) ? default_statistic(layer.geom) : [default_statistic(layer.geom)] ) : layer.statistics @@ -550,7 +552,7 @@ function render_prepare(plot::Plot) (haskey(plot.mapping, var) || haskey(scales, var)) && continue t = :categorical - for data in chain(datas, subplot_datas) + for data in Iterators.flatten((datas, subplot_datas)) val = getfield(data, var) if val != nothing && val != :categorical t = classify_data(val) @@ -692,7 +694,7 @@ function render_prepare(plot::Plot) keytypes = [Guide.ColorKey, Guide.ShapeKey] supress_keys = false for layer in plot.layers - if isa(layer.geom, Geom.SubplotGeometry) && any(haskey.(layer.geom.guides, keytypes)) + if isa(layer.geom, Geom.SubplotGeometry) && any(haskey.((layer.geom.guides,), keytypes)) supress_keys = true break end @@ -711,8 +713,8 @@ function render_prepare(plot::Plot) end # build arrays of scaled aesthetics for layers within subplots - layer_subplot_aess = Array{Vector{Aesthetics}}(length(plot.layers)) - layer_subplot_datas = Array{Vector{Data}}(length(plot.layers)) + layer_subplot_aess = Array{Vector{Aesthetics}}(undef, length(plot.layers)) + layer_subplot_datas = Array{Vector{Data}}(undef, length(plot.layers)) j = 1 for (i, layer) in enumerate(plot.layers) layer_subplot_aess[i] = Aesthetics[] @@ -988,7 +990,7 @@ function default_mime() end end -import Base.REPL: REPLDisplay +import REPL: REPLDisplay """ display(p::Plot) @@ -998,19 +1000,19 @@ This function is handy when rendering by `plot` has been suppressed with either trailing semi-colon or by calling it within a function. """ function display(d::REPLDisplay, p::Union{Plot,Compose.Context}) - if mimewritable("text/html", p) + if showable("text/html", p) display(d,"text/html", p) return - elseif mimewritable("image/png", p) + elseif showable("image/png", p) display(d,"image/png", p) return - elseif mimewritable("application/pdf", p) + elseif showable("application/pdf", p) display(d,"application/pdf", p) return - elseif mimewritable("image/svg+xml", p) + elseif showable("image/svg+xml", p) display(d,"image/svg+xml", p) return - elseif mimewritable("application/postscript", p) + elseif showable("application/postscript", p) display(d,"application/postscript", p) return end diff --git a/src/aesthetics.jl b/src/aesthetics.jl index cb0281683..4086dbc37 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -11,14 +11,14 @@ const NumericalAesthetic = @varset Aesthetics begin x, Union{NumericalOrCategoricalAesthetic, Distribution} y, Union{NumericalOrCategoricalAesthetic, Distribution} - z, Union{(Void), Function, NumericalAesthetic} + z, Union{Nothing, Function, NumericalAesthetic} xend, NumericalAesthetic yend, NumericalAesthetic - size, Union{CategoricalAesthetic,Vector,Void} - shape, Union{CategoricalAesthetic,Vector,Void} - color, Union{CategoricalAesthetic,Vector,Void} - linestyle, Union{CategoricalAesthetic,Vector,Void} + size, Union{CategoricalAesthetic,Vector,Nothing} + shape, Union{CategoricalAesthetic,Vector,Nothing} + color, Union{CategoricalAesthetic,Vector,Nothing} + linestyle, Union{CategoricalAesthetic,Vector,Nothing} label, CategoricalAesthetic group, CategoricalAesthetic @@ -56,7 +56,7 @@ const NumericalAesthetic = ytick, NumericalAesthetic xgrid, NumericalAesthetic ygrid, NumericalAesthetic - color_key_colors, Maybe(Associative) + color_key_colors, Maybe(AbstractDict) color_key_title, Maybe(AbstractString) color_key_continuous, Maybe(Bool) color_function, Maybe(Function) @@ -88,8 +88,8 @@ const NumericalAesthetic = shape_label, Function, showoff # pseudo-aesthetics - pad_categorical_x, Nullable{Bool}, Nullable{Bool}() - pad_categorical_y, Nullable{Bool}, Nullable{Bool}() + pad_categorical_x, Union{Missing,Bool}, missing + pad_categorical_y, Union{Missing,Bool}, missing end @@ -273,9 +273,9 @@ cat_aes_var!(a, b) = a function cat_aes_var!(a::AbstractArray{T}, b::AbstractArray{U}) where {T, U} V = promote_type(T, U) if isa(a, Array{Union{Missing,T}}) || isa(b, Array{Union{Missing,U}}) - ab = Array{Union{Missing,V}}(length(a) + length(b)) + ab = Array{Union{Missing,V}}(undef, length(a) + length(b)) else - ab = Array{V}(length(a) + length(b)) + ab = Array{V}(undef, length(a) + length(b)) end i = 1 for x in a @@ -320,8 +320,8 @@ function by_xy_group(aes::T, xgroup, ygroup, xrefs = xgroup === nothing ? [1] : xgroup yrefs = ygroup === nothing ? [1] : ygroup - aes_grid = Array{T}(n, m) - staging = Array{AbstractArray}(n, m) + aes_grid = Array{T}(undef, n, m) + staging = Array{AbstractArray}(undef, n, m) for i in 1:n, j in 1:m aes_grid[i, j] = T() end @@ -370,7 +370,7 @@ function by_xy_group(aes::T, xgroup, ygroup, if !applicable(convert, typeof(vals), staging[i, j]) T2 = eltype(vals) if T2 <: Color T2 = Color end - da = Array{Union{Missing,T2}}(length(staging[i, j])) + da = Array{Union{Missing,T2}}(undef, length(staging[i, j])) copy!(da, staging[i, j]) setfield!(aes_grid[i, j], var, da) else @@ -404,7 +404,7 @@ function inherit!(a::Aesthetics, b::Aesthetics; bval = getfield(b, field) if field in clobber_set setfield!(a, field, bval) - elseif 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) diff --git a/src/bincount.jl b/src/bincount.jl index 75e7bd43b..f13d90349 100644 --- a/src/bincount.jl +++ b/src/bincount.jl @@ -69,7 +69,7 @@ end # numbins: number of bins # function bin!(bincounts::Vector, xs, x_min, binwidth, numbins) - bincounts[1:numbins] = 0 + bincounts[1:numbins] .= 0 for x in xs if !isconcrete(x) continue diff --git a/src/coord.jl b/src/coord.jl index 23cb90c3f..5358591a1 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -132,21 +132,21 @@ end # function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics}, scales::Dict{Symbol, Gadfly.ScaleElement}) - pad_categorical_x = Nullable{Bool}() - pad_categorical_y = Nullable{Bool}() + pad_categorical_x = missing + pad_categorical_y = missing for aes in aess - if !isnull(aes.pad_categorical_x) - if isnull(pad_categorical_x) + if aes.pad_categorical_x !== missing + if pad_categorical_x === missing pad_categorical_x = aes.pad_categorical_x else - pad_categorical_x = Nullable(get(pad_categorical_x) || get(aes.pad_categorical_x)) + pad_categorical_x = pad_categorical_x || aes.pad_categorical_x end end - if !isnull(aes.pad_categorical_y) - if isnull(pad_categorical_y) + if aes.pad_categorical_y !== missing + if pad_categorical_y === missing pad_categorical_y = aes.pad_categorical_y else - pad_categorical_y = Nullable(get(pad_categorical_y) || get(aes.pad_categorical_y)) + pad_categorical_y = pad_categorical_y || aes.pad_categorical_y end end end @@ -237,12 +237,12 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics}, xpadding = Scale.iscategorical(scales, :x) ? 0mm : 2mm ypadding = Scale.iscategorical(scales, :y) ? 0mm : 2mm - if Scale.iscategorical(scales, :x) && (isnull(pad_categorical_x) || get(pad_categorical_x)) + if Scale.iscategorical(scales, :x) && (pad_categorical_x===missing || pad_categorical_x) xmin -= 0.5 xmax += 0.5 end - if Scale.iscategorical(scales, :y) && (isnull(pad_categorical_y) || get(pad_categorical_y)) + if Scale.iscategorical(scales, :y) && (pad_categorical_y===missing || pad_categorical_y) ymin -= 0.5 ymax += 0.5 end diff --git a/src/geom/bar.jl b/src/geom/bar.jl index 3a7b5efc6..ad9d5e3fc 100644 --- a/src/geom/bar.jl +++ b/src/geom/bar.jl @@ -190,7 +190,7 @@ function render_dodged_bar(geom::BarGeometry, dodge_pos_dict[aes.ymin[i]] = aes.ymin[i]*cy end - dodge_pos = Array{Measure}(length(idxs)) + dodge_pos = Array{Measure}(undef, length(idxs)) for (i, j) in enumerate(idxs) dodge_pos[i] = dodge_pos_dict[aes.ymin[j]] + theme.bar_spacing/2 dodge_pos_dict[aes.ymin[j]] += dodge_height[aes.ymin[j]] @@ -220,7 +220,7 @@ function render_dodged_bar(geom::BarGeometry, dodge_pos_dict[aes.xmin[i]] = aes.xmin[i]*cx end - dodge_pos = Array{Measure}(length(idxs)) + dodge_pos = Array{Measure}(undef, length(idxs)) for (i, j) in enumerate(idxs) dodge_pos[i] = dodge_pos_dict[aes.xmin[j]] + theme.bar_spacing/2 dodge_pos_dict[aes.xmin[j]] += dodge_width[aes.xmin[j]] diff --git a/src/geom/beeswarm.jl b/src/geom/beeswarm.jl index f74066db4..797c3beb0 100644 --- a/src/geom/beeswarm.jl +++ b/src/geom/beeswarm.jl @@ -51,12 +51,12 @@ function render(geom::BeeswarmGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthet point_dist = (2*theme.point_size + geom.padding).value point_dist += eps(point_dist) - offsets = Array{Length{:mm}}(length(val)) - positions = Array{Compose.Measure}(length(val)) + offsets = Array{Length{:mm}}(undef, length(val)) + positions = Array{Compose.Measure}(undef, length(val)) n = length(val) - overlaps = Array{Bool}(n) - absvals = Array{Float64}(n) + overlaps = Array{Bool}(undef, n) + absvals = Array{Float64}(undef, n) for (i, v) in enumerate(val) absvals[i] = Compose.resolve_position( draw_context.box, diff --git a/src/geom/line.jl b/src/geom/line.jl index 63845b997..a0b435c45 100644 --- a/src/geom/line.jl +++ b/src/geom/line.jl @@ -142,9 +142,9 @@ function Gadfly.Geom.render(geom::LineGeometry, theme::Gadfly.Theme, aes::Gadfly ug = unique(groups) n = length(ug) - lines = Vector{Vector{Tuple{XT,YT}}}(n) - line_colors = Vector{CT}(n) - line_styles = Vector{LST}(n) + lines = Vector{Vector{Tuple{XT,YT}}}(undef, n) + line_colors = Vector{CT}(undef, n) + line_styles = Vector{LST}(undef, n) linestyle_palette_length = length(theme.line_style) for (k,g) in enumerate(ug) i = groups.==[g] diff --git a/src/geom/polygon.jl b/src/geom/polygon.jl index 47aaac300..a2c223ed4 100644 --- a/src/geom/polygon.jl +++ b/src/geom/polygon.jl @@ -46,7 +46,7 @@ function polygon_points(xs, ys, preserve_order) return T[(x, y) for (x, y) in zip(xs, ys)] else centroid_x, centroid_y = mean(xs), mean(ys) - θ = atan(xs - centroid_x, ys - centroid_y) + θ = atan.(xs - centroid_x, ys - centroid_y) perm = sortperm(θ) return T[(x, y) for (x, y) in zip(xs[perm], ys[perm])] end diff --git a/src/geom/rectbin.jl b/src/geom/rectbin.jl index 94869a5f7..9b64363ff 100644 --- a/src/geom/rectbin.jl +++ b/src/geom/rectbin.jl @@ -86,7 +86,7 @@ function render(geom::RectangularBinGeometry, theme::Gadfly.Theme, aes::Gadfly.A if length(aes.color) == n cs = aes.color else - cs = Array{RGBA{Float32}}(n) + cs = Array{RGBA{Float32}}(undef, n) for i in 1:n cs[i] = aes.color[((i - 1) % length(aes.color)) + 1] end diff --git a/src/geom/subplot.jl b/src/geom/subplot.jl index c73b9dab3..e21f87dc2 100644 --- a/src/geom/subplot.jl +++ b/src/geom/subplot.jl @@ -159,12 +159,12 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, end end - layer_aes_grid = Array{Matrix{Gadfly.Aesthetics}}(length(geom.layers)) + layer_aes_grid = Array{Matrix{Gadfly.Aesthetics}}(undef, length(geom.layers)) for (i, (layer, aes)) in enumerate(zip(geom.layers, subplot_layer_aess)) layer_aes_grid[i] = Gadfly.by_xy_group(aes, aes.xgroup, aes.ygroup, m, n) end - layer_data_grid = Array{Matrix{Gadfly.Data}}(length(geom.layers)) + layer_data_grid = Array{Matrix{Gadfly.Data}}(undef, length(geom.layers)) for (i, (layer, data, aes)) in enumerate(zip(geom.layers, subplot_layer_datas, subplot_layer_aess)) layer_data_grid[i] = Gadfly.by_xy_group(data, aes.xgroup, aes.ygroup, m, n) @@ -224,7 +224,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, Gadfly.inherit!(col_aes, geom_aes) Stat.apply_statistic(Stat.xticks(), scales, coord, col_aes) - aes_grid[:, j] = col_aes + aes_grid[:, j] .= col_aes end end @@ -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 isnull(child.units) + if child.units===nothing child.units = subtbl.units end end diff --git a/src/guide.jl b/src/guide.jl index 77eb5938b..731b0a3c8 100644 --- a/src/guide.jl +++ b/src/guide.jl @@ -204,7 +204,7 @@ function render_discrete_color_key(colors::Vector{C}, # return a context with a lyout of numcols columns function make_layout(numcols) - colrows = Array{Int}(numcols) + colrows = Array{Int}(undef, numcols) m = n for i in 1:numcols colrows[i] = min(m, ceil(Integer, (n / numcols))) @@ -212,7 +212,7 @@ function render_discrete_color_key(colors::Vector{C}, end xpad = 1mm - colwidths = Array{Measure}(numcols) + colwidths = Array{Measure}(undef, numcols) m = 0 for (i, nrows) in enumerate(colrows) if m == n @@ -1164,8 +1164,8 @@ function layout_guides(plot_context::Context, aspect_ratio = nothing if isa(coord, Gadfly.Coord.cartesian) if coord.fixed - aspect_ratio = isnull(plot_context.units) ? 1.0 : - abs(get(plot_context.units).width / get(plot_context.units).height) + 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 @@ -1176,8 +1176,8 @@ function layout_guides(plot_context::Context, i = 1 for (ctxs, order) in guides[top_guide_position] for ctx in ctxs - if isnull(ctx.units) && !isnull(plot_units) - ctx.units = UnitBox(get(plot_units), toppad=0mm, bottompad=0mm) + if ctx.units===nothing && plot_units!==nothing + ctx.units = UnitBox(plot_units, toppad=0mm, bottompad=0mm) end end @@ -1187,8 +1187,8 @@ function layout_guides(plot_context::Context, i += 1 for (ctxs, order) in guides[bottom_guide_position] for ctx in ctxs - if isnull(ctx.units) && !isnull(plot_units) - ctx.units = UnitBox(get(plot_units), toppad=0mm, bottompad=0mm) + if ctx.units===nothing && plot_units!==nothing + ctx.units = UnitBox(plot_units, toppad=0mm, bottompad=0mm) end end @@ -1199,8 +1199,8 @@ function layout_guides(plot_context::Context, j = 1 for (ctxs, order) in guides[left_guide_position] for ctx in ctxs - if isnull(ctx.units) && !isnull(plot_units) - ctx.units = UnitBox(get(plot_units), leftpad=0mm, rightpad=0mm) + if ctx.units===nothing && plot_units!==nothing + ctx.units = UnitBox(plot_units, leftpad=0mm, rightpad=0mm) end end @@ -1210,8 +1210,8 @@ function layout_guides(plot_context::Context, j += 1 for (ctxs, order) in guides[right_guide_position] for ctx in ctxs - if isnull(ctx.units) && !isnull(plot_units) - ctx.units = UnitBox(get(plot_units), leftpad=0mm, rightpad=0mm) + 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 988050b0c..de1216994 100644 --- a/src/guide/keys.jl +++ b/src/guide/keys.jl @@ -30,7 +30,7 @@ function Guide.render(guide::Guide.ShapeKey, theme::Gadfly.Theme, aes::Gadfly.Ae gpos = guide.pos (theme.key_position == :inside) && (gpos == Float64[]) && (gpos = [0.7w, 0.25h]) - # Aesthetics for keys: shape_key_title, shape_label (Function), shape_key_shapes (Associative) + # 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 shape_key_labels = !(guide.labels==[""]) ? guide.labels : aes.shape_label(1:nshapes) @@ -88,7 +88,7 @@ function render_discrete_key(labels::Vector{String}, title_ctx::Context, title_w # return a context with a lyout of numcols columns function make_layout(numcols) - colrows = Array{Int}(numcols) + colrows = Array{Int}(undef, numcols) m = n for i in 1:numcols colrows[i] = min(m, ceil(Integer, (n / numcols))) @@ -96,7 +96,7 @@ function render_discrete_key(labels::Vector{String}, title_ctx::Context, title_w end xpad = 1mm - colwidths = Array{Measure}(numcols) + colwidths = Array{Measure}(undef, numcols) m = 0 for (i, nrows) in enumerate(colrows) if m == n diff --git a/src/mapping.jl b/src/mapping.jl index df105c5b1..c0aa21906 100644 --- a/src/mapping.jl +++ b/src/mapping.jl @@ -2,35 +2,34 @@ module Col using Compat using DataFrames -import IterTools import Base: == struct GroupedColumn - columns::Nullable{Vector} + columns::Union{Nothing,Vector} end Base.hash(colgroup::GroupedColumn, h::UInt64) = hash(colgroup.columns, h) function ==(a::GroupedColumn, b::GroupedColumn) - return (isnull(a.columns) && isnull(b.columns)) || - (!isnull(a.columns) && !isnull(b.columns) && get(a.columns) == get(b.columns)) + return (a.columns===nothing && b.columns===nothing) || + (a.columns!==nothing && b.columns!==nothing && a.columns == b.columns) end Base.show(io::IO, gc::GroupedColumn) = print(io, "Column") -index() = GroupedColumn(Nullable{Vector}()) +index() = GroupedColumn(nothing) -index(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumn(Nullable(collect(T, xs))) +index(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumn(collect(Union{Nothing,T}, xs)) struct GroupedColumnValue - columns::Nullable{Vector} + columns::Union{Nothing,Vector} end Base.show(io::IO, gc::GroupedColumnValue) = print(io, "Column Value") -value() = GroupedColumnValue(Nullable{Vector}()) +value() = GroupedColumnValue(nothing) -value(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumnValue(Nullable(collect(T, xs))) +value(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumnValue(collect(Union{Nothing,T}, xs)) end # module Col @@ -41,12 +40,12 @@ using Compat # represent a row index correspondig to a set of columns struct GroupedColumnRowIndex - columns::Nullable{Vector} + columns::Union{Nothing,Vector} end -index() = GroupedColumnRowIndex(Nullable{Vector}()) +index() = GroupedColumnRowIndex(nothing) -index(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumnRowIndex(Nullable(collect(T, xs))) +index(xs::T...) where {T <: (Union{Int, Symbol})} = GroupedColumnRowIndex(collect(Union{Nothing,T}, xs)) end # module Row @@ -99,17 +98,17 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) vm = um grouped_columns = Set{Symbol}() for colgroup in colgroups - if isnull(colgroup.columns) # null => group all columns + if colgroup.columns===nothing # null => group all columns vm *= un grouped_columns = copy(allcolumns) else - for j in get(colgroup.columns) + for j in colgroup.columns if !isa(j, Symbol) error("DataFrame columns can only be grouped by (Symbol) names") end push!(grouped_columns, j) end - vm *= length(get(colgroup.columns)) + vm *= length(colgroup.columns) end end @@ -122,7 +121,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) # allocate vectors for grouped columns for (j, colgroup) in enumerate(colgroups) - cols = isnull(colgroup.columns) ? allcolumns : get(colgroup.columns) + cols = colgroup.columns===nothing ? allcolumns : colgroup.columns # figure the grouped common column type firstcol = U[first(cols)] @@ -135,7 +134,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) end end - push!(V, eltyp == Vector ? Array{eltyp}(vm) : Array{Union{Missing,eltyp}}(vm)) + push!(V, eltyp == Vector ? Array{eltyp}(undef, vm) : Array{Union{Nothing,eltyp}}(undef, vm)) name = gensym() push!(vnames, name) colmap[colgroup] = j @@ -149,15 +148,15 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) end # Indicator columns for each colgroup - col_indicators = Array{Symbol}(vm, length(colgroups)) - row_indicators = Array{Int}(vm, length(colgroups)) + col_indicators = Array{Symbol}(undef, vm, length(colgroups)) + row_indicators = Array{Int}(undef, vm, length(colgroups)) - colidxs = [isnull(colgroup.columns) ? collect(allcolumns) : get(colgroup.columns) + colidxs = [colgroup.columns===nothing ? collect(allcolumns) : colgroup.columns for colgroup in colgroups] vi = 1 for ui in 1:um - for colidx in IterTools.product(colidxs...) + for colidx in Iterators.product(colidxs...) # copy grouped columns for (vj, uj) in enumerate(colidx) V[vj][vi] = U[ui, uj] @@ -182,10 +181,10 @@ end function meltdata(U::AbstractVector, colgroups_::Vector{Col.GroupedColumn}) colgroups = Set(colgroups_) - if length(colgroups) != 1 || !isnull(first(colgroups).columns) + 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(2, U...), colgroups_) + return meltdata(cat(U..., dims=2), colgroups_) end # otherwise it doesn't make much sense @@ -195,9 +194,9 @@ function meltdata(U::AbstractVector, colgroups_::Vector{Col.GroupedColumn}) colmap = Dict{Any, Int}() colmap[colgroup] = 1 - V = cat(1, U...) - col_indicators = Array{Int}(length(V)) - row_indicators = Array{Int}(length(V)) + V = cat(U..., dims=1) + col_indicators = Array{Int}(undef, length(V)) + row_indicators = Array{Int}(undef, length(V)) k = 1 for i in 1:length(U) for j in 1:length(U[i]) @@ -217,22 +216,22 @@ function meltdata(U::AbstractMatrix, colgroups_::Vector{Col.GroupedColumn}) colgroups = Set(colgroups_) # Figure out the size of the new melted matrix - allcolumns = IntSet() + allcolumns = BitSet() for i in 1:un push!(allcolumns, i) end vm = um - grouped_columns = IntSet() + grouped_columns = BitSet() for colgroup in colgroups - if isnull(colgroup.columns) + if colgroup.columns===nothing vm *= un grouped_columns = copy(allcolumns) else - for j in get(colgroup.columns) + for j in colgroup.columns push!(grouped_columns, j) end - vm *= length(get(colgroup.columns)) + vm *= length(colgroup.columns) end end @@ -241,14 +240,14 @@ function meltdata(U::AbstractMatrix, colgroups_::Vector{Col.GroupedColumn}) V = similar(U, (vm, vn)) # Indicator columns for each colgroup - col_indicators = Array{Int}((vm, length(colgroups))) - row_indicators = Array{Int}((vm, length(colgroups))) + col_indicators = Array{Int}(undef, vm, length(colgroups)) + row_indicators = Array{Int}(undef, vm, length(colgroups)) - colidxs = [isnull(colgroup.columns) ? collect(allcolumns) : get(colgroup.columns) + colidxs = [colgroup.columns===nothing ? collect(allcolumns) : colgroup.columns for colgroup in colgroups] vi = 1 - for ui in 1:um, colidx in IterTools.product(colidxs...) + for ui in 1:um, colidx in Iterators.product(colidxs...) # copy grouped columns for (vj, uj) in enumerate(colidx) V[vi, vj] = U[ui, uj] diff --git a/src/misc.jl b/src/misc.jl index 5cbc19da7..70fc7cb36 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -71,7 +71,7 @@ end function concrete_length(xs::Array{Union{Missing,T}}) where T n = 0 for i = 1:length(xs) - if !xs.na[i] && isconcrete(xs.data[i]::T) + if !ismissing(xs[i]) && isconcrete(xs[i]) n += 1 end end @@ -87,7 +87,7 @@ function concrete_length(xs::Iterators.Flatten) end function concrete_minimum(xs) - if done(xs, start(xs)) + if isempty(xs) error("argument must not be empty") end @@ -109,7 +109,7 @@ end function concrete_maximum(xs) - if done(xs, start(xs)) + if isempty(xs) error("argument must not be empty") end @@ -152,8 +152,8 @@ end function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T<:Real, TA} for i = 1:length(xs) - if !xs.na[i] - x = xs.data[i]::TA + if !ismissing(xs[i]) + x = xs[i] xT = convert(T, x) if isnan(xmin) || xT < xmin xmin = xT @@ -185,8 +185,8 @@ end function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T, TA} for i = 1:length(xs) - if !xs.na[i] - x = xs.data[i]::TA + if !ismissing(xs[i]) + x = xs[i] xT = convert(T, x) if xT < xmin xmin = xT @@ -266,8 +266,8 @@ end # Remove any markup or whitespace from a string. function escape_id(s::AbstractString) - s = replace(s, r"<[^>]*>", "") - s = replace(s, r"\s", "_") + s = replace(s, r"<[^>]*>" => "") + s = replace(s, r"\s" => "_") s end @@ -404,7 +404,7 @@ discretize_make_ia(values::CategoricalArray) = discretize_make_ia(values, intersect(push!(levels(values), missing), unique(values))) discretize_make_ia(values::CategoricalArray, ::Nothing) = discretize_make_ia(values) function discretize_make_ia(values::CategoricalArray{T}, levels::Vector) where {T} - mapping = coalesce.(indexin(CategoricalArrays.index(values.pool), levels), 0) + mapping = Union{Nothing,Int}[coalesce.(indexin(CategoricalArrays.index(values.pool), levels), 0)...] pushfirst!(mapping, coalesce(findfirst(ismissing, levels), 0)) index = [mapping[x+1] for x in values.refs] any(iszero, index) && throw(ArgumentError("values not in levels encountered")) diff --git a/src/poetry.jl b/src/poetry.jl index b89fca040..65f571956 100644 --- a/src/poetry.jl +++ b/src/poetry.jl @@ -132,7 +132,6 @@ left blank, and an error is thrown if all elements of `M` are `NaN`. See [`Geom.rectbin`](@ref) and [`Coord.cartesian(fixed=true)...)`](@ref Gadfly.Coord.cartesian). """ - function spy(M::AbstractMatrix, elements::ElementOrFunction...; mapping...) is, js, values = _findnz(x->!isnan(x), M) n,m = size(M) @@ -160,7 +159,7 @@ function _findnz(testf::Function, A::AbstractMatrix{T}) where T N = Base.count(testf, A) is = zeros(Int, N) js = zeros(Int, N) - zs = Array{T}(N) + zs = Array{T}(undef, N) if N == 0 return (is, js, zs) end diff --git a/src/scale.jl b/src/scale.jl index c17939f3f..647bd6953 100644 --- a/src/scale.jl +++ b/src/scale.jl @@ -8,6 +8,7 @@ using Gadfly using Showoff using IndirectArrays using CategoricalArrays +using Printf import Gadfly: element_aesthetics, isconcrete, concrete_length, discretize_make_ia, aes2str import Distributions: Distribution @@ -197,7 +198,8 @@ function apply_scale(scale::ContinuousScale, T = Measure end - ds = any(ismissing, vals) ? Array{Union{Missing,T}}(length(vals)) : Array{T}(length(vals)) + ds = any(ismissing, vals) ? Array{Union{Missing,T}}(undef,length(vals)) : + Array{T}(undef,length(vals)) apply_scale_typed!(ds, vals, scale) if var == :xviewmin || var == :xviewmax || @@ -215,7 +217,7 @@ function apply_scale(scale::ContinuousScale, label_var = Symbol(var, "_label") end - if in(label_var, Set(fieldnames(aes))) + if in(label_var, Set(fieldnames(typeof(aes)))) setfield!(aes, label_var, make_labeler(scale)) end end @@ -361,7 +363,7 @@ function apply_scale(scale::DiscreteScale, aess::Vector{Gadfly.Aesthetics}, data labeler = explicit_labeler end - in(label_var, Set(fieldnames(aes))) && setfield!(aes, label_var, labeler) + in(label_var, Set(fieldnames(typeof(aes)))) && setfield!(aes, label_var, labeler) end end end @@ -635,7 +637,7 @@ function apply_scale(scale::ContinuousColorScale, for (aes, data) in zip(aess, datas) data.color === nothing && continue - aes.color = Array{RGB{Float32}}(length(data.color)) + aes.color = Array{RGB{Float32}}(undef, length(data.color)) apply_scale_typed!(aes.color, data.color, scale, cmin, cspan) color_key_colors = Dict{Color, Float64}() diff --git a/src/shapes.jl b/src/shapes.jl index 5eb039ce6..081e529f3 100755 --- a/src/shapes.jl +++ b/src/shapes.jl @@ -17,7 +17,7 @@ function square(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) s = 1/sqrt(2) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) @@ -37,7 +37,7 @@ $(shape_docstr("diamonds")) function diamond(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[1 + i % length(xs)]) y = y_measure(ys[1 + i % length(ys)]) @@ -55,7 +55,7 @@ $(shape_docstr("crosses")) """ function cross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) y = y_measure(ys[mod1(i, length(ys))]) @@ -85,7 +85,7 @@ $(shape_docstr("rotated crosses")) """ function xcross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) s = 1/sqrt(5) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) @@ -110,7 +110,7 @@ $(shape_docstr("upward-pointing triangles")) """ function utriangle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) @@ -143,7 +143,7 @@ $(shape_docstr("five-pointed stars")) """ function star1(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) # some magic scalars sx = 0.7 @@ -172,7 +172,7 @@ $(shape_docstr("four-pointed stars")) """ function star2(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) y = y_measure(ys[mod1(i, length(ys))]) @@ -197,7 +197,7 @@ $(shape_docstr("hexagons")) function hexagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) y = y_measure(ys[mod1(i, length(ys))]) @@ -223,7 +223,7 @@ $(shape_docstr("octagons")) function octagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - polys = Vector{Vector{Tuple{Measure, Measure}}}(n) + polys = Vector{Vector{Tuple{Measure, Measure}}}(undef, n) for i in 1:n x = x_measure(xs[mod1(i, length(xs))]) y = y_measure(ys[mod1(i, length(ys))]) @@ -249,7 +249,7 @@ $(shape_docstr("horizontal lines")) function hline(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - line_ps = Vector{Vector{Tuple{Measure,Measure}}}(n) + line_ps = Vector{Vector{Tuple{Measure,Measure}}}(undef, n) for i in 1:n x = x_measure(xs[1 + i % length(xs)]) y = y_measure(ys[1 + i % length(ys)]) @@ -268,7 +268,7 @@ $(shape_docstr("vertical lines")) function vline(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) n = max(length(xs), length(ys), length(rs)) - line_ps = Vector{Vector{Tuple{Measure,Measure}}}(n) + line_ps = Vector{Vector{Tuple{Measure,Measure}}}(undef, n) for i in 1:n x = x_measure(xs[1 + i % length(xs)]) y = y_measure(ys[1 + i % length(ys)]) diff --git a/src/statistics.jl b/src/statistics.jl index e115d0c64..c9b01b985 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -1,17 +1,20 @@ module Stat import Gadfly -import StatsBase import Contour using Colors using Compat using Compose using DataStructures +using Dates using Distributions using Hexagons using Loess using CoupledFields # It is registered in METADATA.jl using IndirectArrays +using Statistics +using LinearAlgebra +using Random import Gadfly: Scale, Coord, input_aesthetics, output_aesthetics, default_scales, isconcrete, setfield!, discretize_make_ia, aes2str @@ -73,8 +76,8 @@ function barminmax(vals, iscontinuous::Bool) barspan = minspan end position_type = promote_type(typeof(barspan/2.0), eltype(vals)) - minvals = Array{position_type}(length(vals)) - maxvals = Array{position_type}(length(vals)) + minvals = Array{position_type}(undef, length(vals)) + maxvals = Array{position_type}(undef, length(vals)) for (i, x) in enumerate(vals) minvals[i] = x - barspan/2.0 @@ -116,10 +119,10 @@ function apply_statistic(stat::RectbinStatistic, aes.ymax = ymaxvals if !isxcontinuous - aes.pad_categorical_x = Nullable(false) + aes.pad_categorical_x = false end if !isycontinuous - aes.pad_categorical_y = Nullable(false) + aes.pad_categorical_y = false end end @@ -222,9 +225,9 @@ function apply_statistic(stat::BarStatistic, if !iscontinuous if stat.orientation == :horizontal - aes.pad_categorical_y = Nullable(false) + aes.pad_categorical_y = false else - aes.pad_categorical_x = Nullable(false) + aes.pad_categorical_x = false end end end @@ -341,10 +344,10 @@ function apply_statistic(stat::HistogramStatistic, if aes.color === nothing T = typeof(x_min + 1*binwidth) - setfield!(aes, othervar, Array{Float64}(d)) - setfield!(aes, minvar, Array{T}(d)) - setfield!(aes, maxvar, Array{T}(d)) - setfield!(aes, var, Array{T}(d)) + setfield!(aes, othervar, Array{Float64}(undef, d)) + setfield!(aes, minvar, Array{T}(undef, d)) + setfield!(aes, maxvar, Array{T}(undef, d)) + setfield!(aes, var, Array{T}(undef, d)) for j in 1:d getfield(aes, minvar)[j] = x_min + (j - 1) * binwidth getfield(aes, maxvar)[j] = x_min + j * binwidth @@ -363,12 +366,12 @@ function apply_statistic(stat::HistogramStatistic, end end T = typeof(x_min + 1*binwidth) - setfield!(aes, minvar, Array{T}(d * length(groups))) - setfield!(aes, maxvar, Array{T}(d * length(groups))) - setfield!(aes, var, Array{T}(d * length(groups))) + setfield!(aes, minvar, Array{T}(undef, d * length(groups))) + setfield!(aes, maxvar, Array{T}(undef, d * length(groups))) + setfield!(aes, var, Array{T}(undef, d * length(groups))) - setfield!(aes, othervar, Array{Float64}(d * length(groups))) - colors = Array{RGB{Float32}}(d * length(groups)) + setfield!(aes, othervar, Array{Float64}(undef, d * length(groups))) + colors = Array{RGB{Float32}}(undef, d * length(groups)) x_span = x_max - x_min stack_height = zeros(Int, d) @@ -651,17 +654,17 @@ function apply_statistic(stat::Histogram2DStatistic, end if x_categorial - aes.x = Array{Int64}(n) + aes.x = Array{Int64}(undef, n) else - aes.xmin = Array{Float64}(n) - aes.xmax = Array{Float64}(n) + aes.xmin = Array{Float64}(undef, n) + aes.xmax = Array{Float64}(undef, n) end if y_categorial - aes.y = Array{Int64}(n) + aes.y = Array{Int64}(undef, n) else - aes.ymin = Array{Float64}(n) - aes.ymax = Array{Float64}(n) + aes.ymin = Array{Float64}(undef, n) + aes.ymax = Array{Float64}(undef, n) end k = 1 @@ -694,7 +697,7 @@ function apply_statistic(stat::Histogram2DStatistic, aes.color_key_title = "Count" data = Gadfly.Data() - data.color = Array{Int}(n) + data.color = Array{Int}(undef, n) k = 1 for cnt in transpose(bincounts) if cnt > 0 @@ -706,13 +709,13 @@ function apply_statistic(stat::Histogram2DStatistic, if x_categorial aes.xmin, aes.xmax = barminmax(aes.x, false) aes.x = discretize_make_ia(aes.x) - aes.pad_categorical_x = Nullable(false) + aes.pad_categorical_x = false end if y_categorial aes.ymin, aes.ymax = barminmax(aes.y, false) aes.y = discretize_make_ia(aes.y) - aes.pad_categorical_y = Nullable(false) + aes.pad_categorical_y = false end Scale.apply_scale(color_scale, [aes], data) @@ -908,8 +911,8 @@ function apply_statistic(stat::TickStatistic, multiticks = Gadfly.multilevel_ticks(viewmin - (viewmax - viewmin), viewmax + (viewmax - viewmin)) tickcount = length(ticks) + sum([length(ts) for ts in values(multiticks)]) - tickvisible = Array{Bool}(tickcount) - tickscale = Array{Float64}(tickcount) + tickvisible = Array{Bool}(undef, tickcount) + tickscale = Array{Float64}(undef, tickcount) i = 1 for t in ticks tickscale[i] = 1.0 @@ -967,9 +970,9 @@ function apply_statistic_typed(minval::T, maxval::T, vals::Array{Union{Missing,T lensize = length(size) lendsize = length(dsize) for i = 1:length(vals) - vals.na[i] && continue + ismissing(vals[i]) && continue - val::T = vals.data[i] + val = vals[i] s = size[mod1(i, lensize)] ds = dsize[mod1(i, lendsize)] @@ -1063,12 +1066,12 @@ function apply_statistic(stat::BoxplotStatistic, end m = length(groups) - aes.x = Array{eltype(aes.x)}(m) - aes.middle = Array{T}(m) - aes.lower_hinge = Array{T}(m) - aes.upper_hinge = Array{T}(m) - aes.lower_fence = Array{T}(m) - aes.upper_fence = Array{T}(m) + aes.x = Array{eltype(aes.x)}(undef, m) + aes.middle = Array{T}(undef, m) + aes.lower_hinge = Array{T}(undef, m) + aes.upper_hinge = Array{T}(undef, m) + aes.lower_fence = Array{T}(undef, m) + aes.upper_fence = Array{T}(undef, m) aes.outliers = Vector{T}[] for (i, ((x, c), ys)) in enumerate(groups) @@ -1207,7 +1210,7 @@ function apply_statistic(stat::SmoothStatistic, if stat.method == :loess smoothys = Loess.predict(loess(xs, ys, span=stat.smoothing), xsp) elseif stat.method == :lm - lmcoeff = linreg(xs,ys) + lmcoeff = hcat(fill!(similar(xs), 1), xs) \ ys smoothys = lmcoeff[2].*xsp .+ lmcoeff[1] end @@ -1267,10 +1270,10 @@ function apply_statistic(stat::HexBinStatistic, end N = length(counts) - aes.x = Array{Float64}(N) - aes.y = Array{Float64}(N) + aes.x = Array{Float64}(undef, N) + aes.y = Array{Float64}(undef, N) data = Gadfly.Data() - data.color = Array{Int}(N) + data.color = Array{Int}(undef, N) k = 1 for (idx, cnt) in counts x, y = center(HexagonOffsetOddR(idx[1], idx[2]), xsize, ysize, @@ -1409,8 +1412,8 @@ function apply_statistic(stat::FunctionStatistic, Gadfly.assert_aesthetics_defined("FunctionStatistic", aes, :xmax) Gadfly.assert_aesthetics_equal_length("FunctionStatistic", aes, :xmin, :xmax) - aes.x = Array{Float64}(length(aes.y) * stat.num_samples) - ys = Array{Float64}(length(aes.y) * stat.num_samples) + aes.x = Array{Float64}(undef, length(aes.y) * stat.num_samples) + ys = Array{Float64}(undef, length(aes.y) * stat.num_samples) i = 1 for (f, xmin, xmax) in zip(aes.y, cycle(aes.xmin), cycle(aes.xmax)) @@ -1424,21 +1427,21 @@ function apply_statistic(stat::FunctionStatistic, # color was bound explicitly if aes.color != nothing func_color = aes.color - aes.color = Array{eltype(aes.color)}(length(aes.y) * stat.num_samples) - groups = Array{Union{Missing,Int}}(length(aes.y) * stat.num_samples) + aes.color = Array{eltype(aes.color)}(undef, length(aes.y) * stat.num_samples) + groups = Array{Union{Missing,Int}}(undef, length(aes.y) * stat.num_samples) for i in 1:length(aes.y) - aes.color[1+(i-1)*stat.num_samples:i*stat.num_samples] = func_color[i] - groups[1+(i-1)*stat.num_samples:i*stat.num_samples] = i + aes.color[1+(i-1)*stat.num_samples:i*stat.num_samples] .= func_color[i] + groups[1+(i-1)*stat.num_samples:i*stat.num_samples] .= i end aes.group = discretize_make_ia(groups) elseif length(aes.y) > 1 && haskey(scales, :color) data = Gadfly.Data() - data.color = Array{AbstractString}(length(aes.y) * stat.num_samples) - groups = Array{Union{Missing,Int}}(length(aes.y) * stat.num_samples) + data.color = Array{AbstractString}(undef, length(aes.y) * stat.num_samples) + groups = Array{Union{Missing,Int}}(undef, length(aes.y) * stat.num_samples) for i in 1:length(aes.y) fname = "f$(i)" - data.color[1+(i-1)*stat.num_samples:i*stat.num_samples] = fname - groups[1+(i-1)*stat.num_samples:i*stat.num_samples] = i + data.color[1+(i-1)*stat.num_samples:i*stat.num_samples] .= fname + groups[1+(i-1)*stat.num_samples:i*stat.num_samples] .= i end Scale.apply_scale(scales[:color], [aes], data) aes.group = discretize_make_ia(groups) @@ -1513,7 +1516,7 @@ function apply_statistic(stat::ContourStatistic, as = sortslices(a, dims=1, by=x->(x[2],x[1])) xs = unique(as[:,1]) ys = unique(as[:,2]) - zs = Array{Float64}(length(xs), length(ys)) + zs = Array{Float64}(undef, length(xs), length(ys)) zs[:,:] = as[:,3] else error("Stat.contour requires either a matrix, function or dataframe") @@ -1736,8 +1739,8 @@ function apply_statistic(stat::JitterStatistic, rng = MersenneTwister(stat.seed) for var in stat.vars data = getfield(aes, var) - outdata = Array{Float64}(size(data)) - broadcast!(+, outdata, data, stat.range * (rand(rng, length(data)) - 0.5) .* span) + outdata = Array{Float64}(undef, size(data)) + broadcast!(+, outdata, data, stat.range * (rand(rng, length(data)) .- 0.5) .* span) setfield!(aes, var, outdata) end end @@ -2020,7 +2023,7 @@ function Gadfly.Stat.apply_statistic(stat::EllipseStatistic, for (g, data) in grouped_xy dfd = size(data,1)-1 dhat = fit(stat.distribution, data') - Σ½ = chol(cov(dhat)) + Σ½ = cholesky(cov(dhat)).U rv = sqrt.(dfn*[quantile(FDist(dfn,dfd), p) for p in stat.levels]) ellxy = [cos.(θ) sin.(θ)] * Σ½ μ = mean(dhat) diff --git a/src/theme.jl b/src/theme.jl index 936f8b8a0..67c10d0d6 100755 --- a/src/theme.jl +++ b/src/theme.jl @@ -44,7 +44,7 @@ end default_middle_color(fill_color::TransparentColor) = RGBA{Float32}( default_middle_color(color(fill_color)), fill_color.alpha) -get_stroke_vector(::Void) = [] +get_stroke_vector(::Nothing) = [] get_stroke_vector(vec::AbstractVector) = vec function get_stroke_vector(linestyle::Symbol) ldash = 6 * Compose.mm @@ -206,7 +206,7 @@ $(FIELDS) key_position, Symbol, :right "Color used to stroke bars in bar plots. If a function is given, it's used to transform the fill color of the bars to obtain a stroke color. (Function, Color, or Nothing)", - bar_highlight, Union{(Void), Function, Color}, nothing + bar_highlight, Union{Nothing, Function, Color}, nothing rug_size, Measure, 2.0mm diff --git a/src/ticks.jl b/src/ticks.jl index 36dffa85f..3eee01765 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -145,13 +145,13 @@ function optimize_ticks_typed(x_min::T, x_max::T, extend_ticks, span = q_best * 10.0^z_best * one_t if extend_ticks - S = Array{typeof(1.0 * one_t)}(Int(3 * k_best)) + S = Array{typeof(1.0 * one_t)}(undef, Int(3 * k_best)) for i in 0:(3*k_best - 1) S[i+1] = (r_best + i - k_best) * span end viewmin, viewmax = S[k_best + 1], S[2 * k_best] else - S = Array{typeof(1.0 * one_t)}(k_best) + S = Array{typeof(1.0 * one_t)}(undef, k_best) for i in 0:(k_best - 1) S[i+1] = (r_best + i) * span end diff --git a/src/varset.jl b/src/varset.jl index b4d017c47..7773a18ce 100644 --- a/src/varset.jl +++ b/src/varset.jl @@ -17,7 +17,7 @@ macro varset(name::Symbol, table) inherit_parameters_expr = Expr(:parameters) for row in table - isa(row, Expr) && row.head == :line && continue + isa(row, LineNumberNode) && continue hasdocstr = false if isa(row, Symbol) diff --git a/test/REQUIRE b/test/REQUIRE index c793fa8d3..81ce90c58 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,3 +1,2 @@ RDatasets Cairo -Fontconfig diff --git a/test/compare_examples.jl b/test/compare_examples.jl index 669ccfec2..a418284f7 100644 --- a/test/compare_examples.jl +++ b/test/compare_examples.jl @@ -1,6 +1,6 @@ include(joinpath(@__DIR__,"..","src","open_file.jl")) -using ArgParse +using ArgParse, LibGit2 s = ArgParseSettings() @add_arg_table s begin @@ -44,6 +44,7 @@ options = LibGit2.StatusOptions(flags=LibGit2.Consts.STATUS_OPT_INCLUDE_IGNORED status = LibGit2.GitStatus(repo, status_opts=options) for i in 1:length(status) entry = status[i] + entry.index_to_workdir == C_NULL && continue index_to_workdir = unsafe_load(entry.index_to_workdir) if index_to_workdir.status == Int(LibGit2.Consts.DELTA_IGNORED) filepath = unsafe_string(index_to_workdir.new_file.path) @@ -64,10 +65,10 @@ master_files = filter(x->filter_mkdir_git(x) && filter_regex(x), readdir(mastero devel_files = filter(x->filter_mkdir_git(x) && filter_regex(x), readdir(develout)) cached_notin_genned = setdiff(master_files, devel_files) isempty(cached_notin_genned) || - warn("files in master-output/ but not in devel-output/: ", join(cached_notin_genned,", ")) + @warn string("files in master-output/ but not in devel-output/: ", join(cached_notin_genned,", ")) genned_notin_cached = setdiff(devel_files, master_files) isempty(genned_notin_cached) || - warn("files in devel-output/ but not in master-output/: ", join(genned_notin_cached,", ")) + @warn string("files in devel-output/ but not in master-output/: ", join(genned_notin_cached,", ")) for file in intersect(master_files,devel_files) print("Comparing ", file, " ... ") cached = open(readlines, joinpath(masterout, file)) @@ -79,7 +80,7 @@ for file in intersect(master_files,devel_files) for idx in findall(lsame.==false) # Don't worry about lines that are due to # Creator/Producer (e.g., Cairo versions) - if !isempty(search(cached[idx], creator_producer)) + if findfirst(creator_producer, cached[idx]) !== nothing lsame[idx] = true end end @@ -89,6 +90,7 @@ for file in intersect(master_files,devel_files) if same println("same!") else + global ndifferentfiles ndifferentfiles +=1 println("different :(") if args["diff"] @@ -129,5 +131,11 @@ for file in intersect(master_files,devel_files) end end -infoorwarn = ndifferentfiles==0 ? info : warn -infoorwarn("# different images = ",ndifferentfiles) +result = string("# different images = ",ndifferentfiles) +if ndifferentfiles==0 + @info result +else + @warn result +end + +repo = options = status = 0; GC.gc() # see https://github.com/JuliaLang/julia/issues/28306 diff --git a/test/runtests.jl b/test/runtests.jl index b087661c1..d132cbaea 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,9 +5,9 @@ if haskey(ENV, "GADFLY_THEME") pop!(ENV, "GADFLY_THEME") end -using Test, Gadfly, Compat +using Test, Gadfly, Compat, LibGit2, Dates, Random, Compose, Cairo -repo = LibGit2.GitRepo(dirname(@__DIR__)) +repo = GitRepo(dirname(@__DIR__)) branch = LibGit2.headname(repo) outputdir = joinpath(@__DIR__, mapreduce(x->startswith(branch,x), |, ["master","(detac"]) ? "master-output" : "devel-output") @@ -30,9 +30,10 @@ function mimic_git_log_n1(io::IO, head) commit = LibGit2.GitCommit(repo, hash) author = LibGit2.author(commit) println(io, "Author: ",author.name," <",author.email,">") - datetime = Dates.unix2datetime(author.time + 60*author.time_offset) + datetime = unix2datetime(author.time + 60*author.time_offset) println(io, "Date: ",Dates.format(datetime, "e u d HH:MM:SS YYYY")) println(io, " ",LibGit2.message(commit)) + hash = commit = author = 0; GC.gc() # see https://github.com/JuliaLang/julia/issues/28306 end function mimic_git_status(io::IO, head) println(io, "On branch ",LibGit2.shortname(head)) @@ -53,6 +54,7 @@ function mimic_git_status(io::IO, head) println(io, " ", unsafe_string(index_to_workdir.new_file.path)) end end + status = 0; GC.gc() # see https://github.com/JuliaLang/julia/issues/28306 end head = LibGit2.head(repo) open(io->mimic_git_log_n1(io,head), joinpath(outputdir,"git.log"), "w") @@ -74,7 +76,7 @@ testfiles = isempty(ARGS) ? @testset "Gadfly" begin for filename in testfiles, (backend_name, backend) in backends - info(filename,'.',backend_name) + @info string(filename,'.',backend_name) Random.seed!(1) p = evalfile(joinpath(testdir, "$(filename).jl")) @test typeof(p) in [Plot,Compose.Context] @@ -116,3 +118,5 @@ close(output) if prev_theme !== nothing ENV["GADFLY_THEME"] = prev_theme end + +repo = branch = options = status = head = 0; GC.gc() # see https://github.com/JuliaLang/julia/issues/28306 diff --git a/test/testscripts/Guide_colorkey.jl b/test/testscripts/Guide_colorkey.jl index 134cd10e9..d4e7e5455 100644 --- a/test/testscripts/Guide_colorkey.jl +++ b/test/testscripts/Guide_colorkey.jl @@ -1,4 +1,4 @@ -using Compose, Gadfly +using Compose, Gadfly, Random set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/Guide_shapekey.jl b/test/testscripts/Guide_shapekey.jl index 7e17f5343..6850ea27b 100644 --- a/test/testscripts/Guide_shapekey.jl +++ b/test/testscripts/Guide_shapekey.jl @@ -1,4 +1,4 @@ -using Compose, DataFrames, Gadfly +using Compose, DataFrames, Gadfly, Random set_default_plot_size(9inch, 3.3inch) diff --git a/test/testscripts/boxplot_no_aesy.jl b/test/testscripts/boxplot_no_aesy.jl index bd439a688..3b7985088 100644 --- a/test/testscripts/boxplot_no_aesy.jl +++ b/test/testscripts/boxplot_no_aesy.jl @@ -1,11 +1,11 @@ using Gadfly, DataFrames x = collect(11:20) -a = x.*3+4 -b = a-1 -c = a-2 -d = a-3 +a = x .* 3 .+ 4 +b = a .- 1 +c = a .- 2 +d = a .- 3 -df = DataFrame(x = x,a=a,b=b,c=c,d=d,s = repmat(["A"],10)) +df = DataFrame(x=x, a=a, b=b, c=c, d=d, s=repeat(["A"],inner=10)) plot(df, x="x", upper_fence="a", upper_hinge="b", lower_hinge="c", lower_fence="d", Geom.boxplot) diff --git a/test/testscripts/colored_smooth_lm.jl b/test/testscripts/colored_smooth_lm.jl index db35550b9..987270c10 100644 --- a/test/testscripts/colored_smooth_lm.jl +++ b/test/testscripts/colored_smooth_lm.jl @@ -3,9 +3,9 @@ using Gadfly set_default_plot_size(6inch, 8inch) x1 = rand(40) -y1 = 4.*x1 .+ 2 .+randn(40) +y1 = 4 .* x1 .+ 2 .+ randn(40) x2 = rand(40) -y2 = -6.*x2 .+ 3 .+ randn(40) +y2 = -6 .* x2 .+ 3 .+ randn(40) x = [x1;x2] y = [y1;y2] col = [fill("Slope 4",40); fill("Slope -6",40)] diff --git a/test/testscripts/density_dark.jl b/test/testscripts/density_dark.jl index bb3a94de6..808176d0a 100644 --- a/test/testscripts/density_dark.jl +++ b/test/testscripts/density_dark.jl @@ -1,4 +1,4 @@ -using Gadfly, RDatasets, Distributions, Test +using Gadfly, RDatasets, Test, Base64 set_default_plot_size(6inch, 3inch) @@ -9,18 +9,18 @@ p = Gadfly.with_theme(:dark) do end # prevent these tests from running more than once -if !isdefined(:density_dark_tested) +if ! @isdefined density_dark_tested svg_str_dark = stringmime(MIME("image/svg+xml"), p) - @test contains(svg_str_dark, hex(Gadfly.dark_theme.default_color)) - @test contains(svg_str_dark, hex(Gadfly.dark_theme.background_color)) - @test contains(svg_str_dark, hex(Gadfly.dark_theme.panel_fill)) + @test occursin(hex(Gadfly.dark_theme.default_color), svg_str_dark) + @test occursin(hex(Gadfly.dark_theme.background_color), svg_str_dark) + @test occursin(hex(Gadfly.dark_theme.panel_fill), svg_str_dark) # Test reset. p2 = plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut", Geom.density) svg_str_light = stringmime(MIME("image/svg+xml"), p2) - @test !contains(svg_str_light, hex(Gadfly.dark_theme.default_color)) - @test !contains(svg_str_light, hex(Gadfly.dark_theme.background_color)) - @test !contains(svg_str_light, hex(Gadfly.dark_theme.panel_fill)) + @test !occursin(hex(Gadfly.dark_theme.default_color), svg_str_light) + @test !occursin(hex(Gadfly.dark_theme.background_color), svg_str_light) + @test !occursin(hex(Gadfly.dark_theme.panel_fill), svg_str_light) density_dark_tested=true end diff --git a/test/testscripts/ellipse.jl b/test/testscripts/ellipse.jl index 494a57c43..28535ffb8 100644 --- a/test/testscripts/ellipse.jl +++ b/test/testscripts/ellipse.jl @@ -1,4 +1,4 @@ -using Distributions, Gadfly +using Distributions, Gadfly, Random set_default_plot_size(6.6inch, 3.3inch) Random.seed!(123) @@ -6,4 +6,4 @@ d = rand(MvNormal([2, 2],[1.0 0.7; 0.7 1.0]), 50)' pa= plot(x=d[:,1], y=d[:,2], Geom.point, layer(Stat.ellipse, Geom.polygon(preserve_order=true))) pb= plot(x=d[:,1], y=d[:,2], Geom.point, Geom.ellipse(levels=[0.95, 0.99])) -hstack(pa,pb) \ No newline at end of file +hstack(pa,pb) diff --git a/test/testscripts/issue177.jl b/test/testscripts/issue177.jl index 25dfa88c3..1504bec14 100644 --- a/test/testscripts/issue177.jl +++ b/test/testscripts/issue177.jl @@ -14,8 +14,8 @@ x = [2400:1:2500;] WiFiPlots = [2.0 * gaussian(ix, iy, 40.0) for ix=x, iy=WiFiFreqs] -BLEValues = [ ((findfirst(BLEFreqs, ix) > 0) ? 0.127 : 0/0) for ix=x] -BLEChannels = [findfirst(BLEFreqs, ix) for ix=x] +BLEValues = [ (findfirst(isequal(ix), BLEFreqs) !== nothing ? 0.127 : 0/0) for ix=x] +BLEChannels = [something(findfirst(isequal(ix), BLEFreqs),0) for ix=x] BLEChannelStrs = [(ix < 10) ? "0$ix" : "$ix" for ix=BLEChannels] df = DataFrame(frequency=x, value=BLEValues, channel=BLEChannels) diff --git a/test/testscripts/issue961.jl b/test/testscripts/issue961.jl index f60f1e7bc..82acfacb2 100644 --- a/test/testscripts/issue961.jl +++ b/test/testscripts/issue961.jl @@ -1,8 +1,8 @@ -using Gadfly, RDatasets +using Gadfly, RDatasets, Dates day = collect(Date("1960-01-01"):Dates.Day(1):Date("1999-12-31")) t = Dates.value.(day) w = 2π/365.25 -D1 = DataFrame(Day=day, y=2*rand(length(day)).*(1+sin.(w*t))) +D1 = DataFrame(Day=day, y=2*rand(length(day)) .* (1 .+ sin.(w*t))) hline = Geom.hline(color="red") plot(D1, x=:Day, y=:y, yintercept=[3.9], Geom.line, hline) diff --git a/test/testscripts/issue975.jl b/test/testscripts/issue975.jl index 19809ea3d..0253790e0 100644 --- a/test/testscripts/issue975.jl +++ b/test/testscripts/issue975.jl @@ -1,4 +1,4 @@ -using DataFrames, Gadfly +using DataFrames, Gadfly, Dates set_default_plot_size(6inch, 3inch) diff --git a/test/testscripts/line_linestyle.jl b/test/testscripts/line_linestyle.jl index 7b0b7221c..327204b85 100644 --- a/test/testscripts/line_linestyle.jl +++ b/test/testscripts/line_linestyle.jl @@ -3,7 +3,7 @@ using StatsBase: winsor set_default_plot_size(6inch, 3inch) labs = [ "exp", "sqrt", "log", "winsor", "linear"] -funcs = [ x->60*(1-exp.(-0.2*x)), x->sqrt.(x)*10, x->log.(x)*10, x->winsor(x, prop=0.15), x->x*0.6 ] +funcs = [ x->60*(1 .- exp.(-0.2*x)), x->sqrt.(x)*10, x->log.(x)*10, x->winsor(x, prop=0.15), x->x*0.6 ] x = [1.0:30;] D = vcat([DataFrame(x=x, y=f(x), linev=l) for (f,l) in zip(funcs, labs)]...) diff --git a/test/testscripts/log10_scale_range.jl b/test/testscripts/log10_scale_range.jl index 3bc9d4be4..66b4c61bc 100644 --- a/test/testscripts/log10_scale_range.jl +++ b/test/testscripts/log10_scale_range.jl @@ -3,6 +3,6 @@ using Gadfly set_default_plot_size(6inch, 3inch) n = 10 -plot(x=1+rand(n), y=1+rand(n), +plot(x=1 .+ rand(n), y=1 .+ rand(n), Scale.x_log10(minvalue=1.0, maxvalue=10), Scale.y_log10(minvalue=1.0, maxvalue=10)) diff --git a/test/testscripts/matrix_lines.jl b/test/testscripts/matrix_lines.jl index dda92b8cc..fec2833cb 100644 --- a/test/testscripts/matrix_lines.jl +++ b/test/testscripts/matrix_lines.jl @@ -1,4 +1,4 @@ -using Gadfly +using Gadfly, LinearAlgebra # wide-form plotting of matrices @@ -6,6 +6,6 @@ set_default_plot_size(6inch, 4inch) n = 20 m = 40 -X = randn(m, n) * diagm(1:n) +X = randn(m, n) * Matrix(Diagonal(1:n)) plot(X, x=Row.index, y=Col.value, color=Col.index, Geom.line) diff --git a/test/testscripts/scale_color_log.jl b/test/testscripts/scale_color_log.jl index 7b578d40c..b4749ca0f 100644 --- a/test/testscripts/scale_color_log.jl +++ b/test/testscripts/scale_color_log.jl @@ -3,5 +3,5 @@ using Gadfly set_default_plot_size(6inch, 3inch) n = 10 -plot(x=rand(n), y=rand(n), color=e.^rand(n), +plot(x=rand(n), y=rand(n), color=ℯ.^rand(n), Scale.color_log(minvalue=1)) diff --git a/test/testscripts/scale_color_log10.jl b/test/testscripts/scale_color_log10.jl index 4e1ff76d6..7cec2d84b 100644 --- a/test/testscripts/scale_color_log10.jl +++ b/test/testscripts/scale_color_log10.jl @@ -3,5 +3,5 @@ using Gadfly set_default_plot_size(6inch, 3inch) n = 10 -plot(x=rand(n), y=rand(n), color=1000.^rand(n), +plot(x=rand(n), y=rand(n), color=1000 .^ rand(n), Scale.color_log10(minvalue=1, maxvalue=1e3)) diff --git a/test/testscripts/scale_color_log2.jl b/test/testscripts/scale_color_log2.jl index aafc58d7d..928649d45 100644 --- a/test/testscripts/scale_color_log2.jl +++ b/test/testscripts/scale_color_log2.jl @@ -3,5 +3,5 @@ using Gadfly set_default_plot_size(6inch, 3inch) n = 10 -plot(x=rand(n), y=rand(n), color=8.^rand(n), +plot(x=rand(n), y=rand(n), color=8 .^ rand(n), Scale.color_log2(minvalue=1, maxvalue=8)) diff --git a/test/testscripts/smooth_lm.jl b/test/testscripts/smooth_lm.jl index a96faa89f..d37cf63d3 100644 --- a/test/testscripts/smooth_lm.jl +++ b/test/testscripts/smooth_lm.jl @@ -3,7 +3,7 @@ using Gadfly set_default_plot_size(6inch, 8inch) x = rand(40) -y = 4.*x .+ 2 .+randn(40) +y = 4 .* x .+ 2 .+ randn(40) plot(x=x,y=y, Geom.point, Geom.smooth(method=:lm)) diff --git a/test/testscripts/stat_qq.jl b/test/testscripts/stat_qq.jl index 93775e87d..cd5e40383 100644 --- a/test/testscripts/stat_qq.jl +++ b/test/testscripts/stat_qq.jl @@ -1,4 +1,4 @@ -using Gadfly, Distributions +using Gadfly, Distributions, Random set_default_plot_size(6inch, 16inch) diff --git a/test/testscripts/static_label_layout.jl b/test/testscripts/static_label_layout.jl index a18bb04cc..081c3f41c 100644 --- a/test/testscripts/static_label_layout.jl +++ b/test/testscripts/static_label_layout.jl @@ -1,4 +1,4 @@ -using Gadfly +using Gadfly, Random set_default_plot_size(6inch, 16inch) diff --git a/test/testscripts/timeseries_year_2.jl b/test/testscripts/timeseries_year_2.jl index 2a459eb9e..e0341201a 100644 --- a/test/testscripts/timeseries_year_2.jl +++ b/test/testscripts/timeseries_year_2.jl @@ -3,11 +3,4 @@ using Gadfly, RDatasets, Dates set_default_plot_size(6inch, 3inch) economics = dataset("HistData", "Prostitutes") - -if Pkg.installed("RData") < v"0.4.0" - # NOTE: I know these aren't unix times, but I'm not sure what they are, and this - # is just a test so it doesn't matter. - economics[:Date] = DateTime[unix2datetime(d) for d in economics[:Date]] -end - p = plot(economics, x=:Date, y=:Count, Geom.line) diff --git a/test/testscripts/vector.jl b/test/testscripts/vector.jl index 0ce541e7e..72f53a1c0 100644 --- a/test/testscripts/vector.jl +++ b/test/testscripts/vector.jl @@ -1,9 +1,9 @@ -using DataFrames, Gadfly +using DataFrames, Gadfly, Random set_default_plot_size(2*3.3inch, 2*3.3inch) Random.seed!(123) -D = convert(DataFrame, 99*rand(4, 4)+0.5) +D = convert(DataFrame, 99 * rand(4,4) .+ 0.5) xsc = Scale.x_continuous(minvalue=0.0, maxvalue=100) ysc = Scale.y_continuous(minvalue=0.0, maxvalue=100) @@ -19,7 +19,7 @@ p3 = plot(z=(x,y)->x*exp(-(x^2+y^2)), Guide.xlabel("x"), Guide.ylabel("y"), Guide.colorkey(title="z")); Z = fill(1.0, 5, 5) -Z[2:4, 2:4] = 2.0 +Z[2:4, 2:4] .= 2.0 Z[3,3] = 3.0 p4 = plot(z=Z, From 57f45994b3d2e4686b3b6248c13e1b84fdb8a7d0 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Sat, 1 Sep 2018 12:58:21 -0400 Subject: [PATCH 05/11] hard code small random sequences in tests for easier regression --- test/testscripts/Guide_colorkey.jl | 10 +++++----- test/testscripts/Guide_shapekey.jl | 9 +++++---- test/testscripts/array_of_arrays.jl | 6 +++--- test/testscripts/auto_enumerate.jl | 5 ++++- .../continuous_color_scale_range.jl | 5 +++-- test/testscripts/continuous_scale_range.jl | 4 ++-- test/testscripts/date_bar.jl | 4 +++- test/testscripts/errorbar.jl | 19 ++++++++----------- test/testscripts/explicit_number_format.jl | 4 ++-- test/testscripts/explicit_subplot_titles.jl | 4 +++- test/testscripts/explicit_xy_ticks.jl | 4 ++-- test/testscripts/histogram_errorbar.jl | 4 ++-- test/testscripts/issue1004.jl | 4 +++- test/testscripts/issue1005.jl | 9 ++++++--- test/testscripts/issue509.jl | 5 +++-- test/testscripts/issue98.jl | 4 +++- test/testscripts/log10_scale_range.jl | 4 ++-- test/testscripts/noticks.jl | 5 ++++- test/testscripts/rug.jl | 4 +++- test/testscripts/scale_color_asinh.jl | 6 ++++-- test/testscripts/scale_color_log.jl | 5 +++-- test/testscripts/scale_color_log10.jl | 5 +++-- test/testscripts/scale_color_log2.jl | 5 +++-- test/testscripts/scale_color_sqrt.jl | 6 ++++-- test/testscripts/static_label_layout.jl | 7 ++++--- test/testscripts/step.jl | 3 ++- test/testscripts/subplot_categorical_bar.jl | 6 +++--- test/testscripts/subplot_scales.jl | 3 ++- test/testscripts/vector.jl | 8 +++++--- 29 files changed, 99 insertions(+), 68 deletions(-) diff --git a/test/testscripts/Guide_colorkey.jl b/test/testscripts/Guide_colorkey.jl index d4e7e5455..64d05fac3 100644 --- a/test/testscripts/Guide_colorkey.jl +++ b/test/testscripts/Guide_colorkey.jl @@ -1,8 +1,8 @@ -using Compose, Gadfly, Random +using Compose, Gadfly set_default_plot_size(6inch, 3inch) -Random.seed!(123) -plot(x=rand(20), y=rand(20), color=repeat(["A","B"], inner=10), - Guide.colorkey(title="Species", labels=["Name1","Name2"], pos=[0.85w,-0.3h]) - ) +plot(x=[0.768448, 0.940515, 0.673959, 0.395453, 0.313244, 0.662555, 0.586022, 0.0521332, 0.26864, 0.108871, 0.163666, 0.473017, 0.865412, 0.617492, 0.285698, 0.463847, 0.275819, 0.446568, 0.582318, 0.255981], + y=[0.70586, 0.291978, 0.281066, 0.792931, 0.20923, 0.918165, 0.614255, 0.802665, 0.555668, 0.940782, 0.48, 0.790201, 0.356221, 0.900925, 0.529253, 0.031831, 0.900681, 0.940299, 0.621379, 0.348173], + color=repeat(["A","B"], inner=10), + Guide.colorkey(title="Species", labels=["Name1","Name2"], pos=[0.85w,-0.3h])) diff --git a/test/testscripts/Guide_shapekey.jl b/test/testscripts/Guide_shapekey.jl index 6850ea27b..21713f8fb 100644 --- a/test/testscripts/Guide_shapekey.jl +++ b/test/testscripts/Guide_shapekey.jl @@ -1,12 +1,13 @@ -using Compose, DataFrames, Gadfly, Random +using Compose, DataFrames, Gadfly set_default_plot_size(9inch, 3.3inch) -Random.seed!(123) theme1 = Theme(point_size=3mm) coord1 = Coord.cartesian(xmin=0.0, xmax=6.0) -D = DataFrame(x=1:5, y=rand(5), V1=["A","A","B","B","D"], V2 = string.([1,2,2,3,3]) ) - +D = DataFrame(x=1:5, + y=[0.768448, 0.940515, 0.673959, 0.395453, 0.313244], + V1=["A","A","B","B","D"], + V2 = string.([1,2,2,3,3]) ) pa = plot(x=1:5, y=[0.77, 0.94, 0.67, 0.39, 0.31], shape=["A","A","B","B","D"], theme1, coord1, Guide.shapekey(title="Key",labels=["α","β","δ"]), diff --git a/test/testscripts/array_of_arrays.jl b/test/testscripts/array_of_arrays.jl index 6c26e515e..e3958ec49 100644 --- a/test/testscripts/array_of_arrays.jl +++ b/test/testscripts/array_of_arrays.jl @@ -4,7 +4,7 @@ using Gadfly set_default_plot_size(4inch, 4inch) -xs = [ rand(Float32, 10), - rand(Float64, 15), - rand(Float32, 5) ] +xs = Any[Float32[0.547994, 0.819285, 0.567737, 0.557336, 0.27934, 0.777828, 0.8135, 0.00389743, 0.699683, 0.0958536], + [0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512, 0.0769509], + Float32[0.625995, 0.902331, 0.10869, 0.735902, 0.908017]] plot(xs, x=Row.index, y=Col.value, color=Col.index, Scale.color_discrete, Geom.line) diff --git a/test/testscripts/auto_enumerate.jl b/test/testscripts/auto_enumerate.jl index 07090de4d..99ecde792 100644 --- a/test/testscripts/auto_enumerate.jl +++ b/test/testscripts/auto_enumerate.jl @@ -2,4 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(layer(y=20*rand(20), Geom.bar), layer(x=20*rand(20), Geom.line)) +plot(layer(y=[4.72067, 6.93034, 6.25414, 0.158186, 9.77226, 4.21936, 19.0383, 19.9981, 5.03324, 19.7333, 11.115, 8.74216, 8.49436, 15.4645, 5.6238, 4.18945, 5.02758, 0.407497, 5.75403, 17.1902], + Geom.bar), + layer(x=[1.53902, 12.8079, 17.4709, 5.57165, 15.0263, 12.8977, 1.55653, 16.9637, 1.7127, 11.0641, 9.267, 3.71643, 2.23962, 19.5262, 1.03229, 10.7606, 9.11384, 5.5879, 3.56492, 10.9797], + Geom.line)) diff --git a/test/testscripts/continuous_color_scale_range.jl b/test/testscripts/continuous_color_scale_range.jl index 3df2a9913..d82e885c5 100644 --- a/test/testscripts/continuous_color_scale_range.jl +++ b/test/testscripts/continuous_color_scale_range.jl @@ -2,6 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206], Scale.color_continuous(minvalue=-10, maxvalue=10)) diff --git a/test/testscripts/continuous_scale_range.jl b/test/testscripts/continuous_scale_range.jl index 61ef89462..caff8938f 100644 --- a/test/testscripts/continuous_scale_range.jl +++ b/test/testscripts/continuous_scale_range.jl @@ -2,7 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], Scale.x_continuous(minvalue=-10, maxvalue=10), Scale.y_continuous(minvalue=-10, maxvalue=10)) diff --git a/test/testscripts/date_bar.jl b/test/testscripts/date_bar.jl index 52342b887..3b2e3e3e6 100644 --- a/test/testscripts/date_bar.jl +++ b/test/testscripts/date_bar.jl @@ -8,4 +8,6 @@ for i=2:length(dates) dates[i] = today()+Day(i) end -plot(x=dates,y=sort(rand(40)*40),Geom.bar) +plot(x=dates, + y=[0.316371, 0.814995, 2.06458, 3.07804, 3.11306, 3.42541, 4.47924, 7.12984, 7.43285, 8.37889, 8.43873, 9.44133, 10.0552, 10.0665, 11.1433, 11.1758, 11.2476, 11.5081, 12.5083, 13.8607, 16.9887, 17.4843, 18.2277, 18.534, 19.5445, 21.5212, 21.9593, 22.1282, 22.23, 25.6158, 25.7953, 30.0525, 30.9289, 33.9274, 34.3805, 34.9418, 38.0767, 39.0525, 39.4667, 39.9962], + Geom.bar) diff --git a/test/testscripts/errorbar.jl b/test/testscripts/errorbar.jl index 22ac5ed79..d1f1dd3ec 100644 --- a/test/testscripts/errorbar.jl +++ b/test/testscripts/errorbar.jl @@ -1,15 +1,12 @@ -using Gadfly, RDatasets, Distributions +using Gadfly set_default_plot_size(6inch, 3inch) -sds = [1, 1/2, 1/4, 1/8, 1/16, 1/32] -n = 10 -ys = [mean(rand(Normal(0, sd), n)) for sd in sds] -ymins = ys .- (1.96 * sds / sqrt(n)) -ymaxs = ys .+ (1.96 * sds / sqrt(n)) -cs = [string(i) for i in 1:length(sds)] - -plot(x=ys, xmin=ymins, xmax=ymaxs, - y=ys, ymin=ymins, ymax=ymaxs, - color=cs, +plot(x=[0.0533077, -0.0631488, -0.0132793, -0.0316036, 0.00812427, -0.00512818], + xmin=[-0.566499, -0.373052, -0.168231, -0.109079, -0.0306136, -0.0244971], + xmax=[0.673114, 0.246754, 0.141672, 0.0458722, 0.0468622, 0.0142408], + y=[0.0533077, -0.0631488, -0.0132793, -0.0316036, 0.00812427, -0.00512818], + ymin=[-0.566499, -0.373052, -0.168231, -0.109079, -0.0306136, -0.0244971], + ymax=[0.673114, 0.246754, 0.141672, 0.0458722, 0.0468622, 0.0142408], + color=String["1", "2", "3", "4", "5", "6"], Geom.point, Geom.errorbar) diff --git a/test/testscripts/explicit_number_format.jl b/test/testscripts/explicit_number_format.jl index 4ded10f42..0f33ca766 100644 --- a/test/testscripts/explicit_number_format.jl +++ b/test/testscripts/explicit_number_format.jl @@ -2,7 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], Scale.x_continuous(format=:scientific), Scale.y_continuous(format=:plain)) diff --git a/test/testscripts/explicit_subplot_titles.jl b/test/testscripts/explicit_subplot_titles.jl index f1ce3028b..998e2cbcb 100644 --- a/test/testscripts/explicit_subplot_titles.jl +++ b/test/testscripts/explicit_subplot_titles.jl @@ -2,7 +2,9 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(x=rand(20), y=rand(20), xgroup=vcat(fill("A", 10), fill("B", 10)), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + y=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206, 0.46335, 0.185821, 0.111981, 0.976312, 0.0516146, 0.53803, 0.455692, 0.279395, 0.178246, 0.548983], + xgroup=vcat(fill("A", 10), fill("B", 10)), Geom.subplot_grid(Geom.point), Guide.xlabel("Species"), Guide.ylabel("Important Measurements"), diff --git a/test/testscripts/explicit_xy_ticks.jl b/test/testscripts/explicit_xy_ticks.jl index 294add7c4..4e723b338 100644 --- a/test/testscripts/explicit_xy_ticks.jl +++ b/test/testscripts/explicit_xy_ticks.jl @@ -2,7 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], Guide.xticks(ticks=[0.0, 0.1, 0.9, 1.0]), Guide.yticks(ticks=[0.4, 0.5, 0.6])) diff --git a/test/testscripts/histogram_errorbar.jl b/test/testscripts/histogram_errorbar.jl index 5406b7495..218aeb2ea 100644 --- a/test/testscripts/histogram_errorbar.jl +++ b/test/testscripts/histogram_errorbar.jl @@ -4,8 +4,8 @@ set_default_plot_size(6inch, 3inch) df = dataset("plm", "Cigar") df = df[df[:State] .== 1, :] -ymin = df[:Sales] .- 20*rand() -ymax = df[:Sales] .+ 20*rand() +ymin = df[:Sales] .- 20*0.23603334566204692 +ymax = df[:Sales] .+ 20*0.34651701419196046 plot(df, x="Year", y="Sales", ymin=ymin, ymax=ymax, Geom.bar, Geom.errorbar) diff --git a/test/testscripts/issue1004.jl b/test/testscripts/issue1004.jl index 371149f9c..816b1f89f 100644 --- a/test/testscripts/issue1004.jl +++ b/test/testscripts/issue1004.jl @@ -2,5 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(x=rand(12), y=rand(12), color=repeat(["a","b","c"], outer=[4]), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108], + y=[0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512, 0.0769509, 0.640396, 0.873544, 0.278582], + color=repeat(["a","b","c"], outer=[4]), Scale.color_discrete_manual("red","purple","green")) diff --git a/test/testscripts/issue1005.jl b/test/testscripts/issue1005.jl index ccf44d840..3ef259a5d 100644 --- a/test/testscripts/issue1005.jl +++ b/test/testscripts/issue1005.jl @@ -2,8 +2,11 @@ using Gadfly, DataFrames set_default_plot_size(6inch, 3inch) -points = DataFrame(index=rand(0:10,30), val=rand(1:10,30)) -line = DataFrame(val=rand(1:10,11), index = collect(0:10)) +points = DataFrame( + index=[2,10,7,3,10,0,1,10,4,5,4,0,3,7,7,8,5,7,2,3,3,6,4,8,4,10,5,9,5,8], + val=[6,10,4,2,4,9,1,1,7,4,8,2,2,2,7,9,1,3,7,10,2,3,10,7,8,9,2,6,6,10]) +line = DataFrame(val=[4,3,10,6,10,2,3,2,4,7,4], index=collect(0:10)) pointLayer = layer(points, x="index", y="val", Geom.point,Theme(default_color="green")) lineLayer = layer(line, x="index", y="val", Geom.line) -plot(pointLayer, lineLayer, Guide.manual_color_key("Legend", ["Points", "Line"], ["green", "deepskyblue"])) +plot(pointLayer, lineLayer, + Guide.manual_color_key("Legend", ["Points", "Line"], ["green", "deepskyblue"])) diff --git a/test/testscripts/issue509.jl b/test/testscripts/issue509.jl index 35ee3a640..4e06339fd 100644 --- a/test/testscripts/issue509.jl +++ b/test/testscripts/issue509.jl @@ -2,5 +2,6 @@ using Gadfly set_default_plot_size(6inch, 3inch) -x = rand(10);y=rand(10); -plot(x=x,y=y,Guide.manual_color_key("Title", ["One", "Two"], ["green","blue"])) +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + Guide.manual_color_key("Title", ["One", "Two"], ["green","blue"])) diff --git a/test/testscripts/issue98.jl b/test/testscripts/issue98.jl index 15ca0b438..fff11e02d 100644 --- a/test/testscripts/issue98.jl +++ b/test/testscripts/issue98.jl @@ -3,4 +3,6 @@ using Gadfly set_default_plot_size(6inch, 3inch) n = 10 -plot(x=fill(1, n), y=rand(n), Geom.bar) +plot(x=fill(1, n), + y=[0.905597, 0.941418, 0.545107, 0.0393329, 0.355558, 0.0472913, 0.360985, 0.438887, 0.273428, 0.984925], + Geom.bar) diff --git a/test/testscripts/log10_scale_range.jl b/test/testscripts/log10_scale_range.jl index 66b4c61bc..8ab0bf516 100644 --- a/test/testscripts/log10_scale_range.jl +++ b/test/testscripts/log10_scale_range.jl @@ -2,7 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=1 .+ rand(n), y=1 .+ rand(n), +plot(x=[1.23603, 1.34652, 1.31271, 1.00791, 1.48861, 1.21097, 1.95192, 1.9999, 1.25166, 1.98667], + y=[1.55575, 1.43711, 1.42472, 1.77322, 1.28119, 1.20947, 1.25138, 1.02037, 1.2877, 1.85951], Scale.x_log10(minvalue=1.0, maxvalue=10), Scale.y_log10(minvalue=1.0, maxvalue=10)) diff --git a/test/testscripts/noticks.jl b/test/testscripts/noticks.jl index b6acb46df..1c258f3b9 100644 --- a/test/testscripts/noticks.jl +++ b/test/testscripts/noticks.jl @@ -2,4 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(x=rand(10), y=rand(10), Guide.xticks(ticks=nothing), Guide.yticks(ticks=nothing)) +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + Guide.xticks(ticks=nothing), + Guide.yticks(ticks=nothing)) diff --git a/test/testscripts/rug.jl b/test/testscripts/rug.jl index 26759f008..55adecf2f 100644 --- a/test/testscripts/rug.jl +++ b/test/testscripts/rug.jl @@ -2,4 +2,6 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(x=rand(20), y=rand(20), Guide.xrug, Guide.yrug) +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + y=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206, 0.46335, 0.185821, 0.111981, 0.976312, 0.0516146, 0.53803, 0.455692, 0.279395, 0.178246, 0.548983], + Guide.xrug, Guide.yrug) diff --git a/test/testscripts/scale_color_asinh.jl b/test/testscripts/scale_color_asinh.jl index a9d21f5d0..b3e1956f0 100644 --- a/test/testscripts/scale_color_asinh.jl +++ b/test/testscripts/scale_color_asinh.jl @@ -2,5 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=sinh.(rand(n)), Scale.color_asinh) +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[0.0770269, 0.685074, 0.988958, 0.2822, 0.824017, 0.69052, 0.077905, 0.953607, 0.0857399, 0.581857], + Scale.color_asinh) diff --git a/test/testscripts/scale_color_log.jl b/test/testscripts/scale_color_log.jl index b4749ca0f..0a04bf287 100644 --- a/test/testscripts/scale_color_log.jl +++ b/test/testscripts/scale_color_log.jl @@ -2,6 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=ℯ.^rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[1.07999, 1.89723, 2.39539, 1.32126, 2.11978, 1.90576, 1.08094, 2.33541, 1.08941, 1.73882], Scale.color_log(minvalue=1)) diff --git a/test/testscripts/scale_color_log10.jl b/test/testscripts/scale_color_log10.jl index 7cec2d84b..1be15921b 100644 --- a/test/testscripts/scale_color_log10.jl +++ b/test/testscripts/scale_color_log10.jl @@ -2,6 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=1000 .^ rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[1.70158, 83.4044, 417.477, 6.85089, 179.448, 86.03, 1.7119, 350.394, 1.80678, 45.6685], Scale.color_log10(minvalue=1, maxvalue=1e3)) diff --git a/test/testscripts/scale_color_log2.jl b/test/testscripts/scale_color_log2.jl index 928649d45..024f6b34f 100644 --- a/test/testscripts/scale_color_log2.jl +++ b/test/testscripts/scale_color_log2.jl @@ -2,6 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=8 .^ rand(n), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[1.17353, 3.78735, 6.1502, 1.78478, 4.76983, 3.82285, 1.17567, 5.83429, 1.19491, 3.15933], Scale.color_log2(minvalue=1, maxvalue=8)) diff --git a/test/testscripts/scale_color_sqrt.jl b/test/testscripts/scale_color_sqrt.jl index e40262b2c..a1889de53 100644 --- a/test/testscripts/scale_color_sqrt.jl +++ b/test/testscripts/scale_color_sqrt.jl @@ -2,5 +2,7 @@ using Gadfly set_default_plot_size(6inch, 3inch) -n = 10 -plot(x=rand(n), y=rand(n), color=sqrt.(rand(n)), Scale.color_sqrt) +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666], + y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + color=[0.2774, 0.800248, 0.934636, 0.527809, 0.866783, 0.803046, 0.278974, 0.92097, 0.292635, 0.743778], + Scale.color_sqrt) diff --git a/test/testscripts/static_label_layout.jl b/test/testscripts/static_label_layout.jl index 081c3f41c..cc2727f1a 100644 --- a/test/testscripts/static_label_layout.jl +++ b/test/testscripts/static_label_layout.jl @@ -1,9 +1,10 @@ -using Gadfly, Random +using Gadfly set_default_plot_size(6inch, 16inch) -n = 10 -xs, ys, labels = rand(n), rand(n), [randstring(6) for _ in 1:n] +xs = [0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666] +ys = [0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512] +labels = String["mxhEmy", "9APlX1", "P17KC2", "2zNjTz", "g4mUef", "rcfI9s", "Bjd19K", "V1jjSR", "DEBHJk", "0J7d2j"] l = plot(x=xs, y=ys, label=labels, Geom.point, Geom.label(position=:left)) r = plot(x=xs, y=ys, label=labels, Geom.point, Geom.label(position=:right)) diff --git a/test/testscripts/step.jl b/test/testscripts/step.jl index 59e193886..907d444fa 100644 --- a/test/testscripts/step.jl +++ b/test/testscripts/step.jl @@ -2,6 +2,7 @@ using Gadfly, DataFrames set_default_plot_size(6inch, 3inch) -df = DataFrame(x=vcat(rand(10), rand(10)), y=rand(20), +df = DataFrame(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + y=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206, 0.46335, 0.185821, 0.111981, 0.976312, 0.0516146, 0.53803, 0.455692, 0.279395, 0.178246, 0.548983], grouping=vcat(fill("A", 10), fill("B", 10))) plot(df, x=:x, y=:y, color=:grouping, Geom.line, Stat.step) diff --git a/test/testscripts/subplot_categorical_bar.jl b/test/testscripts/subplot_categorical_bar.jl index 32580c89b..770b7ab8f 100644 --- a/test/testscripts/subplot_categorical_bar.jl +++ b/test/testscripts/subplot_categorical_bar.jl @@ -4,11 +4,11 @@ set_default_plot_size(6inch, 3inch) plot(xgroup=["A", "A", "B", "B"], x=["X", "Y", "X", "Y"], - y=rand(4), + y=[0.236033, 0.346517, 0.312707, 0.00790928], Geom.subplot_grid(Geom.bar)) -plot(x=rand(3), - y=rand(3), +plot(x=[0.488613, 0.210968, 0.951916], + y=[0.999905, 0.251662, 0.986666], xgroup=["A", "A", "B"], ygroup=["X", "Y", "Y"], Geom.subplot_grid(Geom.bar)) diff --git a/test/testscripts/subplot_scales.jl b/test/testscripts/subplot_scales.jl index 02c44ea8f..9e7cd4ff9 100644 --- a/test/testscripts/subplot_scales.jl +++ b/test/testscripts/subplot_scales.jl @@ -2,7 +2,8 @@ using Gadfly set_default_plot_size(6inch, 3inch) -plot(x=rand(20), y=rand(20), +plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666, 0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512], + y=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206, 0.46335, 0.185821, 0.111981, 0.976312, 0.0516146, 0.53803, 0.455692, 0.279395, 0.178246, 0.548983], color=vcat(fill("A", 5), fill("B", 5), fill("C", 5), fill("D", 5)), ygroup=vcat(fill("U", 10), fill("V", 10)), Geom.subplot_grid(Scale.color_discrete, Geom.line)) diff --git a/test/testscripts/vector.jl b/test/testscripts/vector.jl index 72f53a1c0..0c4560820 100644 --- a/test/testscripts/vector.jl +++ b/test/testscripts/vector.jl @@ -1,9 +1,11 @@ -using DataFrames, Gadfly, Random +using DataFrames, Gadfly set_default_plot_size(2*3.3inch, 2*3.3inch) -Random.seed!(123) -D = convert(DataFrame, 99 * rand(4,4) .+ 0.5) +D = DataFrame(x1=[76.5763, 93.611, 67.2219, 39.6499], + x2=[31.5112, 66.0929, 58.5162, 5.66118], + x3=[27.0953, 11.2782, 16.7029, 47.3287], + x4=[86.1758, 61.6317, 28.7841, 46.4209]) xsc = Scale.x_continuous(minvalue=0.0, maxvalue=100) ysc = Scale.y_continuous(minvalue=0.0, maxvalue=100) From 21430b1389fadf026fd047c4d93475644235f36a Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Fri, 7 Sep 2018 22:14:26 -0400 Subject: [PATCH 06/11] stop testing on julia 0.7 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63eaee07f..0e5a31695 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: julia os: - linux julia: - - 0.7 - 1.0 - nightly matrix: From 02db312cc149d48dd4d2c326d4850757af2a1762 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Fri, 7 Sep 2018 23:23:28 -0400 Subject: [PATCH 07/11] fixes for julia 1.0 --- src/Gadfly.jl | 2 +- src/aesthetics.jl | 3 ++- src/geom/subplot.jl | 2 +- test/REQUIRE | 1 + test/testscripts/density_dark.jl | 12 ++++++------ 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Gadfly.jl b/src/Gadfly.jl index 1094a5c0c..2cebdda34 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -16,7 +16,7 @@ import IterTools import IterTools: distinct, drop, chain import Compose: draw, hstack, vstack, gridstack, parse_colorant import Base: +, -, /, *, - copy, push!, start, next, done, show, getindex, cat, + copy, push!, show, getindex, cat, show, isfinite, display import Distributions: Distribution diff --git a/src/aesthetics.jl b/src/aesthetics.jl index 4086dbc37..6291888b8 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -97,7 +97,8 @@ function show(io::IO, data::Aesthetics) maxlen = 0 print(io, "Aesthetics(") for name in fieldnames(Aesthetics) - if getfield(data, name) != nothing + val = getfield(data, name) + if !ismissing(val) && val != nothing print(io, "\n ", string(name), "=") show(io, getfield(data, name)) end diff --git a/src/geom/subplot.jl b/src/geom/subplot.jl index e21f87dc2..08bc4b113 100644 --- a/src/geom/subplot.jl +++ b/src/geom/subplot.jl @@ -224,7 +224,7 @@ function render(geom::SubplotGrid, theme::Gadfly.Theme, Gadfly.inherit!(col_aes, geom_aes) Stat.apply_statistic(Stat.xticks(), scales, coord, col_aes) - aes_grid[:, j] .= col_aes + aes_grid[:, j] .= [col_aes] end end diff --git a/test/REQUIRE b/test/REQUIRE index 81ce90c58..2e674a029 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,2 +1,3 @@ RDatasets Cairo +CSV diff --git a/test/testscripts/density_dark.jl b/test/testscripts/density_dark.jl index 808176d0a..59727ae77 100644 --- a/test/testscripts/density_dark.jl +++ b/test/testscripts/density_dark.jl @@ -11,16 +11,16 @@ end # prevent these tests from running more than once if ! @isdefined density_dark_tested svg_str_dark = stringmime(MIME("image/svg+xml"), p) - @test occursin(hex(Gadfly.dark_theme.default_color), svg_str_dark) - @test occursin(hex(Gadfly.dark_theme.background_color), svg_str_dark) - @test occursin(hex(Gadfly.dark_theme.panel_fill), svg_str_dark) + @test occursin(Base.hex(Gadfly.dark_theme.default_color), svg_str_dark) + @test occursin(Base.hex(Gadfly.dark_theme.background_color), svg_str_dark) + @test occursin(Base.hex(Gadfly.dark_theme.panel_fill), svg_str_dark) # Test reset. p2 = plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut", Geom.density) svg_str_light = stringmime(MIME("image/svg+xml"), p2) - @test !occursin(hex(Gadfly.dark_theme.default_color), svg_str_light) - @test !occursin(hex(Gadfly.dark_theme.background_color), svg_str_light) - @test !occursin(hex(Gadfly.dark_theme.panel_fill), svg_str_light) + @test !occursin(Base.hex(Gadfly.dark_theme.default_color), svg_str_light) + @test !occursin(Base.hex(Gadfly.dark_theme.background_color), svg_str_light) + @test !occursin(Base.hex(Gadfly.dark_theme.panel_fill), svg_str_light) density_dark_tested=true end From 0186e38553880546b04cf5042ca0a26575e0ac34 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Sat, 8 Sep 2018 11:50:50 -0400 Subject: [PATCH 08/11] add feature to regression testing script --- test/compare_examples.jl | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/compare_examples.jl b/test/compare_examples.jl index a418284f7..92108b1c8 100644 --- a/test/compare_examples.jl +++ b/test/compare_examples.jl @@ -8,7 +8,7 @@ s = ArgParseSettings() help = "print to STDOUT the output of `diff`" action = :store_true "--two" - help = "open and display both files" + help = "display both files" action = :store_true "--bw" help = "generate, save and display a B&W difference image for PNG and SVG files. requires Rsvg, Cairo, and Images" @@ -53,6 +53,11 @@ for i in 1:length(status) end end +function display_two(master,devel) + open_file(master) + open_file(devel) +end + # Compare with cached output masterout = joinpath((@__DIR__), "master-output") develout = joinpath((@__DIR__), "devel-output") @@ -97,10 +102,7 @@ for file in intersect(master_files,devel_files) diffcmd = `diff $(joinpath(masterout, file)) $(joinpath(develout, file))` run(ignorestatus(diffcmd)) end - if args["two"] - open_file("$(joinpath(masterout,file))") - open_file("$(joinpath(develout,file))") - end + args["two"] && display_two(joinpath(masterout,file), joinpath(develout,file)) if args["bw"] && (endswith(file,".svg") || endswith(file,".png")) wait_for_user = false if endswith(file,".svg") @@ -125,9 +127,14 @@ for file in intersect(master_files,devel_files) println("PNGs are different sizes :(") end end - args["diff"] || args["two"] || (args["bw"] && wait_for_user) || continue - println("Press ENTER to continue, CTRL-C to quit") - readline() + args["diff"] || args["two"] || (args["bw"] && + (endswith(file,".svg") || endswith(file,".png")) && wait_for_user) || continue + println("Enter 'two' to display both files, nothing to continue, or press CTRL-C to quit") + while true + resp = readline() + resp=="" && break + resp=="two" && display_two(joinpath(masterout,file), joinpath(develout,file)) + end end end From 677f96ace48c5f5348cd9a51e6483e05bd8a71f8 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Sat, 8 Sep 2018 14:01:55 -0400 Subject: [PATCH 09/11] fix regression testing problem with Theme stack --- test/testscripts/Theme_plot_padding.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/testscripts/Theme_plot_padding.jl b/test/testscripts/Theme_plot_padding.jl index 46b250855..56a9cf7db 100644 --- a/test/testscripts/Theme_plot_padding.jl +++ b/test/testscripts/Theme_plot_padding.jl @@ -14,4 +14,7 @@ pa = plot(D, x=:x, y=:y, gp, xscale, style(plot_padding=[10mm,10mm,5mm,5mm])) pb = plot(D, x=:x, y=:y, gp, xscale, style(plot_padding=[0.05w,0.05w,0.2h,0.2h])) # 1mm padding on all sides, note x-axis right label gets cut deliberately pc = plot(D, x=:x, y=:y, gp, xscale, style(plot_padding=[1mm])) -hstack(pa,pb,pc) +p = hstack(pa,pb,pc) + +Gadfly.pop_theme() +return p From 58794f59b3ee4003011b495e58645445bac731dd Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Mon, 10 Sep 2018 22:29:20 -0400 Subject: [PATCH 10/11] fix some uses of missing and nothing --- src/aesthetics.jl | 10 +++------ src/mapping.jl | 5 +---- src/misc.jl | 54 +++++------------------------------------------ src/statistics.jl | 19 ++--------------- 4 files changed, 11 insertions(+), 77 deletions(-) diff --git a/src/aesthetics.jl b/src/aesthetics.jl index 6291888b8..0cefe5c4e 100755 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -1,11 +1,11 @@ const NumericalOrCategoricalAesthetic = - Union{Nothing, Vector, Array, IndirectArray} + Union{Nothing, Vector, IndirectArray} const CategoricalAesthetic = Union{Nothing, IndirectArray} const NumericalAesthetic = - Union{Nothing, Matrix, Vector, Array} + Union{Nothing, Matrix, Vector} @varset Aesthetics begin @@ -273,11 +273,7 @@ cat_aes_var!(a, b) = a function cat_aes_var!(a::AbstractArray{T}, b::AbstractArray{U}) where {T, U} V = promote_type(T, U) - if isa(a, Array{Union{Missing,T}}) || isa(b, Array{Union{Missing,U}}) - ab = Array{Union{Missing,V}}(undef, length(a) + length(b)) - else - ab = Array{V}(undef, length(a) + length(b)) - end + ab = Array{V}(undef, length(a) + length(b)) i = 1 for x in a ab[i] = x diff --git a/src/mapping.jl b/src/mapping.jl index c0aa21906..7ded47cca 100644 --- a/src/mapping.jl +++ b/src/mapping.jl @@ -10,10 +10,7 @@ end Base.hash(colgroup::GroupedColumn, h::UInt64) = hash(colgroup.columns, h) -function ==(a::GroupedColumn, b::GroupedColumn) - return (a.columns===nothing && b.columns===nothing) || - (a.columns!==nothing && b.columns!==nothing && a.columns == b.columns) -end +==(a::GroupedColumn, b::GroupedColumn) = a.columns==b.columns Base.show(io::IO, gc::GroupedColumn) = print(io, "Column") diff --git a/src/misc.jl b/src/misc.jl index 70fc7cb36..14f44ce42 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -61,17 +61,7 @@ end function concrete_length(xs) n = 0 for x in xs - if isconcrete(x) - n += 1 - end - end - n -end - -function concrete_length(xs::Array{Union{Missing,T}}) where T - n = 0 - for i = 1:length(xs) - if !ismissing(xs[i]) && isconcrete(xs[i]) + if !ismissing(x) && isconcrete(x) n += 1 end end @@ -136,24 +126,7 @@ function concrete_minmax(xs, xmin::T, xmax::T) where T<:Real end for x in xs - if isconcrete(x) - xT = convert(T, x) - if isnan(xmin) || xT < xmin - xmin = xT - end - if isnan(xmax) || xT > xmax - xmax = xT - end - end - end - xmin, xmax -end - - -function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T<:Real, TA} - for i = 1:length(xs) - if !ismissing(xs[i]) - x = xs[i] + if !ismissing(x) && isconcrete(x) xT = convert(T, x) if isnan(xmin) || xT < xmin xmin = xT @@ -169,24 +142,7 @@ end function concrete_minmax(xs, xmin::T, xmax::T) where T for x in xs - if isconcrete(x) - xT = convert(T, x) - if xT < xmin - xmin = xT - end - if xT > xmax - xmax = xT - end - end - end - xmin, xmax -end - - -function concrete_minmax(xs::Array{Union{Missing,TA}}, xmin::T, xmax::T) where {T, TA} - for i = 1:length(xs) - if !ismissing(xs[i]) - x = xs[i] + if !ismissing(x) && isconcrete(x) xT = convert(T, x) if xT < xmin xmin = xT @@ -404,8 +360,8 @@ discretize_make_ia(values::CategoricalArray) = discretize_make_ia(values, intersect(push!(levels(values), missing), unique(values))) discretize_make_ia(values::CategoricalArray, ::Nothing) = discretize_make_ia(values) function discretize_make_ia(values::CategoricalArray{T}, levels::Vector) where {T} - mapping = Union{Nothing,Int}[coalesce.(indexin(CategoricalArrays.index(values.pool), levels), 0)...] - pushfirst!(mapping, coalesce(findfirst(ismissing, levels), 0)) + mapping = something.(indexin(CategoricalArrays.index(values.pool), levels), 0) + pushfirst!(mapping, something(findfirst(ismissing, levels), 0)) index = [mapping[x+1] for x in values.refs] any(iszero, index) && throw(ArgumentError("values not in levels encountered")) return IndirectArray(index, convert(Vector{T},levels)) diff --git a/src/statistics.jl b/src/statistics.jl index c9b01b985..50b108b97 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -956,7 +956,7 @@ function apply_statistic_typed(minval::T, maxval::T, vals, size, dsize) where T lensize = length(size) lendsize = length(dsize) for (i, val) in enumerate(vals) - (!Gadfly.isconcrete(val) || !isfinite(val)) && continue + (ismissing(val) || !Gadfly.isconcrete(val) || !isfinite(val)) && continue s = size[mod1(i, lensize)] ds = dsize[mod1(i, lendsize)] @@ -966,21 +966,6 @@ function apply_statistic_typed(minval::T, maxval::T, vals, size, dsize) where T minval, maxval end -function apply_statistic_typed(minval::T, maxval::T, vals::Array{Union{Missing,T}}, size, dsize) where T - lensize = length(size) - lendsize = length(dsize) - for i = 1:length(vals) - ismissing(vals[i]) && continue - - val = vals[i] - s = size[mod1(i, lensize)] - ds = dsize[mod1(i, lendsize)] - - minval, maxval = minvalmaxval(minval, maxval, val, s, ds) - end - minval, maxval -end - function minvalmaxval(minval::T, maxval::T, val, s, ds) where T if val < minval || !isfinite(minval) minval = val @@ -1428,7 +1413,7 @@ function apply_statistic(stat::FunctionStatistic, if aes.color != nothing func_color = aes.color aes.color = Array{eltype(aes.color)}(undef, length(aes.y) * stat.num_samples) - groups = Array{Union{Missing,Int}}(undef, length(aes.y) * stat.num_samples) + groups = Array{Int}(undef, length(aes.y) * stat.num_samples) for i in 1:length(aes.y) aes.color[1+(i-1)*stat.num_samples:i*stat.num_samples] .= func_color[i] groups[1+(i-1)*stat.num_samples:i*stat.num_samples] .= i From bc6bdedac1c2abf7053201bb0a560e676e540e61 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Thu, 13 Sep 2018 07:15:44 -0400 Subject: [PATCH 11/11] fix support for Juno --- src/Gadfly.jl | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/Gadfly.jl b/src/Gadfly.jl index 2cebdda34..a79f3e9a8 100755 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -53,8 +53,9 @@ function __init__() show(err) end else - push_theme(Juno.isactive() ? :dark : :default) + push_theme(:default) end + pushdisplay(GadflyDisplay()) end @@ -950,6 +951,14 @@ function show(io::IO, m::MIME"image/svg+xml", p::Plot) show(io, m, svg) end +function show(io::IO, m::MIME"application/juno+plotpane", p::Plot) + buf = IOBuffer() + svg = SVGJS(buf, Compose.default_graphic_width, + Compose.default_graphic_height, false) + draw(svg, p) + show(io, "text/html", svg) +end + try getfield(Compose, :Cairo) # throws if Cairo isn't being used global show @@ -990,7 +999,7 @@ function default_mime() end end -import REPL: REPLDisplay +struct GadflyDisplay <: AbstractDisplay end """ display(p::Plot) @@ -999,7 +1008,7 @@ Render `p` to a multimedia display, typically an internet browser. This function is handy when rendering by `plot` has been suppressed with either trailing semi-colon or by calling it within a function. """ -function display(d::REPLDisplay, p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, p::Union{Plot,Compose.Context}) if showable("text/html", p) display(d,"text/html", p) return @@ -1021,7 +1030,7 @@ end # Fallback display method. When there isn't a better option, we write to a # temporary file and try to open it. -function display(d::REPLDisplay, ::MIME"image/png", p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, ::MIME"image/png", p::Union{Plot,Compose.Context}) filename = string(tempname(), ".png") output = open(filename, "w") draw(PNG(output, Compose.default_graphic_width, @@ -1030,7 +1039,7 @@ function display(d::REPLDisplay, ::MIME"image/png", p::Union{Plot,Compose.Contex open_file(filename) end -function display(d::REPLDisplay, ::MIME"image/svg+xml", p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, ::MIME"image/svg+xml", p::Union{Plot,Compose.Context}) filename = string(tempname(), ".svg") output = open(filename, "w") draw(SVG(output, Compose.default_graphic_width, @@ -1039,7 +1048,7 @@ function display(d::REPLDisplay, ::MIME"image/svg+xml", p::Union{Plot,Compose.Co open_file(filename) end -function display(d::REPLDisplay, ::MIME"text/html", p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, ::MIME"text/html", p::Union{Plot,Compose.Context}) filename = string(tempname(), ".html") output = open(filename, "w") @@ -1072,7 +1081,7 @@ function display(d::REPLDisplay, ::MIME"text/html", p::Union{Plot,Compose.Contex open_file(filename) end -function display(d::REPLDisplay, ::MIME"application/postscript", p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, ::MIME"application/postscript", p::Union{Plot,Compose.Context}) filename = string(tempname(), ".ps") output = open(filename, "w") draw(PS(output, Compose.default_graphic_width, @@ -1081,7 +1090,7 @@ function display(d::REPLDisplay, ::MIME"application/postscript", p::Union{Plot,C open_file(filename) end -function display(d::REPLDisplay, ::MIME"application/pdf", p::Union{Plot,Compose.Context}) +function display(d::GadflyDisplay, ::MIME"application/pdf", p::Union{Plot,Compose.Context}) filename = string(tempname(), ".pdf") output = open(filename, "w") draw(PDF(output, Compose.default_graphic_width, @@ -1090,22 +1099,6 @@ function display(d::REPLDisplay, ::MIME"application/pdf", p::Union{Plot,Compose. open_file(filename) end -# Display in Juno - -import Juno: Juno, @render, media, Media - -media(Plot, Media.Plot) - -@render Juno.PlotPane p::Plot begin - x, y = Juno.plotsize() - set_default_plot_size(x*Gadfly.px, y*Gadfly.px) - HTML(stringmime("text/html", p)) -end - -@render Juno.Editor p::Gadfly.Plot begin - Juno.icon("graph") -end - include("coord.jl") include("geometry.jl") include("guide.jl")