Skip to content

Commit

Permalink
fix depwarns
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarthur committed Aug 31, 2018
1 parent ce97f6b commit 10a42c9
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 92 deletions.
3 changes: 3 additions & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,6 +14,8 @@ IterTools
JSON
KernelDensity
Loess
Measures
REPL
Showoff 0.0.3
StatsBase
Juno
Expand Down
26 changes: 14 additions & 12 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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[]
Expand Down Expand Up @@ -988,7 +990,7 @@ function default_mime()
end
end

import Base.REPL: REPLDisplay
import REPL: REPLDisplay

"""
display(p::Plot)
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/aesthetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions src/coord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/geom/subplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/guide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ 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)))
m -= colrows[i]
end

xpad = 1mm
colwidths = Array{Measure}(numcols)
colwidths = Array{Measure}(undef, numcols)
m = 0
for (i, nrows) in enumerate(colrows)
if m == n
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/guide/keys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -88,15 +88,15 @@ 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)))
m -= colrows[i]
end

xpad = 1mm
colwidths = Array{Measure}(numcols)
colwidths = Array{Measure}(undef, numcols)
m = 0
for (i, nrows) in enumerate(colrows)
if m == n
Expand Down
Loading

0 comments on commit 10a42c9

Please sign in to comment.