From 0484ff50e8bf80d4181c03fa2a64b643a4c089a3 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Fri, 7 Apr 2017 16:58:15 -0400 Subject: [PATCH] update for julia 0.6 --- src/Gadfly.jl | 61 +++++++++++++------------ src/aesthetics.jl | 18 ++++---- src/coord.jl | 2 +- src/format.jl | 8 ++-- src/geom/point.jl | 8 ++-- src/geom/segment.jl | 2 +- src/geom/subplot.jl | 2 +- src/geometry.jl | 4 +- src/guide.jl | 10 ++-- src/mapping.jl | 6 +-- src/misc.jl | 8 ++-- src/poetry.jl | 2 +- src/scale.jl | 6 +-- src/statistics.jl | 109 ++++++++++++++++++++++---------------------- src/ticks.jl | 4 +- 15 files changed, 127 insertions(+), 123 deletions(-) diff --git a/src/Gadfly.jl b/src/Gadfly.jl index d61eb1005..a7195a3ac 100644 --- a/src/Gadfly.jl +++ b/src/Gadfly.jl @@ -44,7 +44,7 @@ function __init__() end -typealias ColorOrNothing @compat(Union{Colorant, (@compat Void)}) +const ColorOrNothing = @compat(Union{Colorant, (@compat Void)}) element_aesthetics(::Any) = [] input_aesthetics(::Any) = [] @@ -55,12 +55,12 @@ default_statistic(::Any) = Stat.identity() element_coordinate_type(::Any) = Coord.cartesian -abstract Element -abstract ScaleElement <: Element -abstract CoordinateElement <: Element -abstract GeometryElement <: Element -abstract GuideElement <: Element -abstract StatisticElement <: Element +abstract type Element end +abstract type ScaleElement <: Element end +abstract type CoordinateElement <: Element end +abstract type GeometryElement <: Element end +abstract type GuideElement <: Element end +abstract type StatisticElement <: Element end include("misc.jl") @@ -77,7 +77,7 @@ include("theme.jl") # The layer and plot functions can also take functions that are evaluated with # no arguments and are expected to produce an element. -typealias ElementOrFunction{T <: Element} @compat(Union{Element, Base.Callable, Theme}) +@compat const ElementOrFunction{T <: Element} = @compat(Union{Element, Base.Callable, Theme}) const gadflyjs = joinpath(dirname(Base.source_path()), "gadfly.js") @@ -313,7 +313,7 @@ end # because a call to layer() expands to a vector of layers (one for each Geom # supplied), we need to allow Vector{Layer} to count as an Element for the # purposes of plot(). -typealias ElementOrFunctionOrLayers @compat(Union{ElementOrFunction, Vector{Layer}}) +const ElementOrFunctionOrLayers = @compat(Union{ElementOrFunction, Vector{Layer}}) """ @@ -452,7 +452,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}(length(plot.layers)) for (i, layer) in enumerate(plot.layers) if layer.data_source === nothing && isempty(layer.mapping) layer.data_source = plot.data_source @@ -507,7 +507,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}}(length(plot.layers)) for (i, layer) in enumerate(plot.layers) layer_stats[i] = isempty(layer.statistics) ? [default_statistic(layer.geom)] : layer.statistics @@ -783,8 +783,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}}(length(plot.layers)) + layer_subplot_datas = Array{Vector{Data}}(length(plot.layers)) j = 1 for (i, layer) in enumerate(plot.layers) layer_subplot_aess[i] = Aesthetics[] @@ -1046,7 +1046,6 @@ function default_mime() end end -import Base.Multimedia: @try_display, xdisplayable import Base.REPL: REPLDisplay """ @@ -1057,22 +1056,26 @@ 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(p::Union{Plot,Compose.Context}) - displays = Base.Multimedia.displays - for i = length(displays):-1:1 - m = default_mime() - if xdisplayable(displays[i], m, p) - @try_display return display(displays[i], m, p) - end - - if xdisplayable(displays[i], p) - @try_display return display(displays[i], p) - end +function display(d::REPLDisplay, p::Union{Plot,Compose.Context}) + if mimewritable("text/html", p) + display(d,"text/html", p) + return + elseif mimewritable("image/svg+xml", p) + display(d,"image/svg+xml", p) + return + elseif mimewritable("image/png", p) + display(d,"image/png", p) + return + elseif mimewritable("application/postscript", p) + display(d,"application/postscript", p) + return + elseif mimewritable("application/pdf", p) + display(d,"application/pdf", p) + return end - invoke(display, Tuple{Any}, p) + throw(MethodError) end - function open_file(filename) if is_apple() run(`open $(filename)`) @@ -1112,7 +1115,7 @@ function display(d::REPLDisplay, ::MIME"text/html", p::Union{Plot,Compose.Contex plot_output = IOBuffer() draw(SVGJS(plot_output, Compose.default_graphic_width, Compose.default_graphic_height, false), p) - plotsvg = takebuf_string(plot_output) + plotsvg = String(take!(plot_output)) write(output, """ @@ -1262,7 +1265,7 @@ end # Determine whether the input is categorical or numerical -typealias CategoricalType @compat(Union{AbstractString, Bool, Symbol}) +const CategoricalType = @compat(Union{AbstractString, Bool, Symbol}) function classify_data{N, T <: CategoricalType}(data::AbstractArray{T, N}) diff --git a/src/aesthetics.jl b/src/aesthetics.jl index 0fdd3cf50..a7deb1b90 100644 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -1,12 +1,12 @@ -typealias NumericalOrCategoricalAesthetic +const NumericalOrCategoricalAesthetic = @compat(Union{(@compat Void), Vector, DataArray, PooledDataArray}) -typealias CategoricalAesthetic +const CategoricalAesthetic = @compat(Union{(@compat Void), PooledDataArray}) -typealias NumericalAesthetic +const NumericalAesthetic = @compat(Union{(@compat Void), Matrix, Vector, DataArray}) @@ -135,7 +135,7 @@ end function defined_aesthetics(aes::Aesthetics) vars = Set{Symbol}() for name in fieldnames(Aesthetics) - if !is(getfield(aes, name), nothing) + if getfield(aes, name) !== nothing push!(vars, name) end end @@ -177,7 +177,7 @@ end function assert_aesthetics_equal_length(who::AbstractString, aes::Aesthetics, vars::Symbol...) - defined_vars = filter(var -> !(getfield(aes, var) === nothing), vars) + defined_vars = Base.Iterators.filter(var -> !(getfield(aes, var) === nothing), vars) if !isempty(defined_vars) n = length(getfield(aes, first(defined_vars))) @@ -309,7 +309,7 @@ function cat_aes_var!{T, U}(a::AbstractArray{T}, b::AbstractArray{U}) if isa(a, DataArray) || isa(b, DataArray) ab = DataArray(V, length(a) + length(b)) else - ab = Array(V, length(a) + length(b)) + ab = Array{V}(length(a) + length(b)) end i = 1 for x in a @@ -370,8 +370,8 @@ function by_xy_group{T <: @compat(Union{Data, Aesthetics})}(aes::T, xgroup, ygro 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}(n, m) + staging = Array{AbstractArray}(n, m) for i in 1:n, j in 1:m aes_grid[i, j] = T() end @@ -410,7 +410,7 @@ function by_xy_group{T <: @compat(Union{Data, Aesthetics})}(aes::T, xgroup, ygro staging[i, j] = similar(vals, 0) end - for (i, j, v) in zip(Iterators.cycle(yrefs), Iterators.cycle(xrefs), vals) + for (i, j, v) in zip(Base.Iterators.cycle(yrefs), Base.Iterators.cycle(xrefs), vals) push!(staging[i, j], v) end diff --git a/src/coord.jl b/src/coord.jl index 0fa33396d..572eab7e4 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -6,7 +6,7 @@ using Compat using Compose using DataArrays import Gadfly.Maybe -import Iterators: cycle +import Base.Iterators: cycle export cartesian diff --git a/src/format.jl b/src/format.jl index 2c23759c7..b92073551 100644 --- a/src/format.jl +++ b/src/format.jl @@ -208,7 +208,7 @@ function formatter{T<:Date}(ds::AbstractArray{T}; fmt=nothing) function format(d) buf = IOBuffer() print(buf, year(d)) - takebuf_string(buf) + String(take!(buf)) end elseif day_all_1 # label months and years @@ -219,7 +219,7 @@ function formatter{T<:Date}(ds::AbstractArray{T}; fmt=nothing) else print(buf, month_abbrevs[month(d)]) end - takebuf_string(buf) + String(take!(buf)) end else function format(d) @@ -231,7 +231,7 @@ function formatter{T<:Date}(ds::AbstractArray{T}; fmt=nothing) else print(buf, day(d)) end - takebuf_string(buf) + String(take!(buf)) end end end @@ -242,7 +242,7 @@ function formatter(xs::AbstractArray; fmt=nothing) function format(x) buf = IOBuffer() print(buf, x) - takebuf_string(buf) + String(take!(buf)) end format diff --git a/src/geom/point.jl b/src/geom/point.jl index 5efb3b8f9..f02ce323a 100644 --- a/src/geom/point.jl +++ b/src/geom/point.jl @@ -44,10 +44,10 @@ function render(geom::PointGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics ctx = context() if aes.shape != nothing - xs = Array(eltype(aes_x), 0) - ys = Array(eltype(aes_y), 0) - cs = Array(eltype(aes.color), 0) - size = Array(eltype(aes.size), 0) + xs = Array{eltype(aes_x)}(0) + ys = Array{eltype(aes_y)}(0) + cs = Array{eltype(aes.color)}(0) + size = Array{eltype(aes.size)}(0) shape_max = maximum(aes.shape) if shape_max > length(theme.shapes) error("Too many values for the shape aesthetic. Define more shapes in Theme.shapes") diff --git a/src/geom/segment.jl b/src/geom/segment.jl index 9043c4ad7..c8c44e741 100755 --- a/src/geom/segment.jl +++ b/src/geom/segment.jl @@ -1,5 +1,5 @@ -abstract SegmentGeometry <: Gadfly.GeometryElement +abstract type SegmentGeometry <: Gadfly.GeometryElement end # Geometry for vectors/arrows/segments immutable SegmentGeom <: SegmentGeometry diff --git a/src/geom/subplot.jl b/src/geom/subplot.jl index 8114fd463..a2d3ed296 100644 --- a/src/geom/subplot.jl +++ b/src/geom/subplot.jl @@ -2,7 +2,7 @@ # Subplot geometries -abstract SubplotGeometry <: Gadfly.GeometryElement +abstract type SubplotGeometry <: Gadfly.GeometryElement end # Adding elements to subplots in a generic way. diff --git a/src/geometry.jl b/src/geometry.jl index 9e6235469..2bc3c6422 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -14,8 +14,8 @@ import Gadfly: render, layers, element_aesthetics, inherit, escape_id, default_statistic, default_scales, element_coordinate_type, ScaleElement, svg_color_class_from_label, isconcrete, concretize -import Iterators -import Iterators: cycle, product, distinct, takestrict, chain, repeated +import Iterators: chain, distinct, takestrict +import Base.Iterators: cycle, product, repeated const empty_tag = Symbol("") diff --git a/src/guide.jl b/src/guide.jl index e5f865253..b10ef7cf1 100644 --- a/src/guide.jl +++ b/src/guide.jl @@ -14,7 +14,7 @@ import Gadfly: render, escape_id, default_statistic, jsdata, jsplotdata, # Where the guide should be placed in relation to the plot. -abstract GuidePosition +abstract type GuidePosition end immutable TopGuidePosition <: GuidePosition end immutable RightGuidePosition <: GuidePosition end immutable BottomGuidePosition <: GuidePosition end @@ -208,7 +208,7 @@ function render_discrete_color_key{C<:Color}(colors::Vector{C}, # return a context with a lyout of numcols columns function make_layout(numcols) - colrows = Array(Int, numcols) + colrows = Array{Int}(numcols) m = n for i in 1:numcols colrows[i] = min(m, ceil(Integer, (n / numcols))) @@ -216,7 +216,7 @@ function render_discrete_color_key{C<:Color}(colors::Vector{C}, end xpad = 1mm - colwidths = Array(Measure, numcols) + colwidths = Array{Measure}(numcols) m = 0 for (i, nrows) in enumerate(colrows) if m == n @@ -406,13 +406,13 @@ function render(guide::ColorKey, theme::Gadfly.Theme, end used_colors = Set{Color}() - colors = Array(Color, 0) # to preserve ordering + colors = Array{Color}(0) # to preserve ordering labels = OrderedDict{Color, Set{AbstractString}}() continuous_guide = false guide_title = guide.title - if guide_title === nothing && !is(aes.color_key_title, nothing) + if guide_title === nothing && aes.color_key_title !== nothing guide_title = aes.color_key_title end diff --git a/src/mapping.jl b/src/mapping.jl index ff7d5cd60..f0ab6139a 100644 --- a/src/mapping.jl +++ b/src/mapping.jl @@ -145,7 +145,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) : DataArray(eltyp, vm)) name = gensym() push!(vnames, name) colmap[colgroup] = j @@ -159,7 +159,7 @@ function meltdata(U::AbstractDataFrame, colgroups_::Vector{Col.GroupedColumn}) end # Indicator columns for each colgroup - indicators = Array(Symbol, (vm, length(colgroups))) + indicators = Array{Symbol}((vm, length(colgroups))) colidxs = [isnull(colgroup.columns) ? collect(allcolumns) : get(colgroup.columns) for colgroup in colgroups] @@ -219,7 +219,7 @@ function meltdata(U::AbstractMatrix, colgroups_::Vector{Col.GroupedColumn}) V = similar(U, (vm, vn)) # Indicator columns for each colgroup - indicators = Array(Int, (vm, length(colgroups))) + indicators = Array{Int}((vm, length(colgroups))) colidxs = [isnull(colgroup.columns) ? collect(allcolumns) : get(colgroup.columns) for colgroup in colgroups] diff --git a/src/misc.jl b/src/misc.jl index 6cc4e72be..46007e0b0 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -59,9 +59,9 @@ function concretize(xss::AbstractVector...) @label next_j1 end - yss = Array(AbstractVector, length(xss)) + yss = Array{AbstractVector}(length(xss)) for (i, xs) in enumerate(xss) - yss[i] = Array(eltype(xs), count) + yss[i] = Array{eltype(xs)}(count) end k = 1 @@ -271,7 +271,7 @@ function inherit!{T}(a::T, b::T) end -isnothing(u) = is(u, nothing) +isnothing(u) = u === nothing issomething(u) = !isnothing(u) negate(f) = x -> !f(x) @@ -334,7 +334,7 @@ function evalfunc(f::Function, a, b, n) @assert n > 1 step = (b - a) / (n - 1) - xs = Array(typeof(a + step), n) + xs = Array{typeof(a + step)}(n) for i in 1:n xs[i] = a + (i-1) * step end diff --git a/src/poetry.jl b/src/poetry.jl index 1a0dd1025..1461c164b 100644 --- a/src/poetry.jl +++ b/src/poetry.jl @@ -186,7 +186,7 @@ function _findnz{T}(testf::Function, A::AbstractMatrix{T}) N = Base.count(testf, A) is = zeros(Int, N) js = zeros(Int, N) - zs = Array(T, N) + zs = Array{T}(N) if N == 0 return (is, js, zs) end diff --git a/src/scale.jl b/src/scale.jl index cc0f13a21..968b45fb5 100644 --- a/src/scale.jl +++ b/src/scale.jl @@ -246,7 +246,7 @@ function apply_scale(scale::ContinuousScale, T = Measure end - ds = Gadfly.hasna(vals) ? DataArray(T, length(vals)) : Array(T, length(vals)) + ds = Gadfly.hasna(vals) ? DataArray(T, length(vals)) : Array{T}(length(vals)) apply_scale_typed!(ds, vals, scale) if var == :xviewmin || var == :xviewmax || @@ -430,7 +430,7 @@ function apply_scale(scale::DiscreteScale, aess::Vector{Gadfly.Aesthetics}, disc_data = discretize(getfield(data, var), scale.levels, scale.order) - setfield!(aes, var, PooledDataArray(round(Int64, disc_data.refs))) + setfield!(aes, var, PooledDataArray(round.(Int64, disc_data.refs))) # The leveler for discrete scales is a closure over the discretized data. if scale.labels === nothing @@ -591,7 +591,7 @@ function apply_scale(scale::DiscreteColorScale, continue end ds = discretize(data.color, scale_levels) - colorvals = Array(RGB{Float32}, nonzero_length(ds.refs)) + colorvals = Array{RGB{Float32}}(nonzero_length(ds.refs)) i = 1 for k in ds.refs if k != 0 diff --git a/src/statistics.jl b/src/statistics.jl index d7e2716a2..07ff0e6c7 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -15,7 +15,8 @@ import Gadfly: Scale, Coord, input_aesthetics, output_aesthetics, default_scales, isconcrete, nonzero_length, setfield! import KernelDensity import Distributions: Uniform, Distribution, qqbuild -import Iterators: chain, cycle, product, partition, distinct +import Iterators: chain, distinct +import Base.Iterators: cycle, product, partition include("bincount.jl") @@ -78,8 +79,8 @@ function barminmax(values, iscontinuous::Bool) barspan = minspan end position_type = promote_type(typeof(barspan/2.0), eltype(values)) - minvals = Array(position_type, length(values)) - maxvals = Array(position_type, length(values)) + minvals = Array{position_type}(length(values)) + maxvals = Array{position_type}(length(values)) for (i, x) in enumerate(values) minvals[i] = x - barspan/2.0 @@ -346,10 +347,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}(d)) + setfield!(aes, minvar, Array{T}(d)) + setfield!(aes, maxvar, Array{T}(d)) + setfield!(aes, var, Array{T}(d)) for j in 1:d getfield(aes, minvar)[j] = x_min + (j - 1) * binwidth getfield(aes, maxvar)[j] = x_min + j * binwidth @@ -370,12 +371,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}(d * length(groups))) + setfield!(aes, maxvar, Array{T}(d * length(groups))) + setfield!(aes, var, Array{T}(d * length(groups))) - setfield!(aes, othervar, Array(Float64, d * length(groups))) - colors = Array(RGB{Float32}, d * length(groups)) + setfield!(aes, othervar, Array{Float64}(d * length(groups))) + colors = Array{RGB{Float32}}(d * length(groups)) x_span = x_max - x_min stack_height = zeros(Int, d) @@ -567,9 +568,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}}(0) + aes.x = Array{Float64}(0) + aes.y = Array{Float64}(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) @@ -674,17 +675,17 @@ function apply_statistic(stat::Histogram2DStatistic, end if x_categorial - aes.x = Array(Int64, n) + aes.x = Array{Int64}(n) else - aes.xmin = Array(Float64, n) - aes.xmax = Array(Float64, n) + aes.xmin = Array{Float64}(n) + aes.xmax = Array{Float64}(n) end if y_categorial - aes.y = Array(Int64, n) + aes.y = Array{Int64}(n) else - aes.ymin = Array(Float64, n) - aes.ymax = Array(Float64, n) + aes.ymin = Array{Float64}(n) + aes.ymax = Array{Float64}(n) end k = 1 @@ -720,7 +721,7 @@ function apply_statistic(stat::Histogram2DStatistic, aes.color_key_title = "Count" data = Gadfly.Data() - data.color = Array(Int, n) + data.color = Array{Int}(n) k = 1 for cnt in transpose(bincounts) if cnt > 0 @@ -892,20 +893,20 @@ function apply_statistic(stat::TickStatistic, strict_span = false if typeof(coord) == Coord.Cartesian if stat.out_var == "x" - if !is(coord.xmin, nothing) + if coord.xmin !== nothing minval = coord.xmin strict_span = true end - if !is(coord.xmax, nothing) + if coord.xmax !== nothing maxval = coord.xmax strict_span = true end elseif stat.out_var == "y" - if !is(coord.ymin, nothing) + if coord.ymin !== nothing minval = coord.ymin strict_span = true end - if !is(coord.ymax, nothing) + if coord.ymax !== nothing maxval = coord.ymax strict_span = true end @@ -947,8 +948,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}(tickcount) + tickscale = Array{Float64}(tickcount) i = 1 for t in ticks tickscale[i] = 1.0 @@ -1103,12 +1104,12 @@ function apply_statistic(stat::BoxplotStatistic, if aes.y != nothing 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)}(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.outliers = Vector{T}[] for (i, ((x, c), ys)) in enumerate(groups) @@ -1240,9 +1241,9 @@ function apply_statistic(stat::SmoothStatistic, end end - aes.x = Array(Float64, length(groups) * num_steps) - aes.y = Array(Float64, length(groups) * num_steps) - colors = Array(RGB{Float32}, length(groups) * num_steps) + aes.x = Array{Float64}(length(groups) * num_steps) + aes.y = Array{Float64}(length(groups) * num_steps) + colors = Array{RGB{Float32}}(length(groups) * num_steps) for (i, (c, (xs, ys))) in enumerate(groups) x_min, x_max = minimum(xs), maximum(xs) @@ -1308,10 +1309,10 @@ function apply_statistic(stat::HexBinStatistic, end N = length(counts) - aes.x = Array(Float64, N) - aes.y = Array(Float64, N) + aes.x = Array{Float64}(N) + aes.y = Array{Float64}(N) data = Gadfly.Data() - data.color = Array(Int, N) + data.color = Array{Int}(N) k = 1 for (idx, cnt) in counts x, y = center(HexagonOffsetOddR(idx[1], idx[2]), xsize, ysize, @@ -1394,10 +1395,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)}(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) i = 1 i_offset = 1 @@ -1468,8 +1469,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}(length(aes.y) * stat.num_samples) + ys = Array{Float64}(length(aes.y) * stat.num_samples) i = 1 for (f, xmin, xmax) in zip(aes.y, cycle(aes.xmin), cycle(aes.xmax)) @@ -1492,7 +1493,7 @@ function apply_statistic(stat::FunctionStatistic, aes.group = PooledDataArray(groups) elseif length(aes.y) > 1 && haskey(scales, :color) data = Gadfly.Data() - data.color = Array(AbstractString, length(aes.y) * stat.num_samples) + data.color = Array{AbstractString}(length(aes.y) * stat.num_samples) groups = DataArray(Int, length(aes.y) * stat.num_samples) for i in 1:length(aes.y) fname = "f$(i)" @@ -1720,9 +1721,9 @@ function apply_statistic(stat::ViolinStatistic, push!(grouped_y[x], y) end - aes.x = Array(Float64, 0) - aes.y = Array(Float64, 0) - aes.width = Array(Float64, 0) + aes.x = Array{Float64}(0) + aes.y = Array{Float64}(0) + aes.width = Array{Float64}(0) for (x, ys) in grouped_y window = stat.n > 1 ? KernelDensity.default_bandwidth(ys) : 0.1 @@ -1806,7 +1807,7 @@ function apply_statistic(stat::JitterStatistic, rng = MersenneTwister(stat.seed) for var in stat.vars data = getfield(aes, var) - outdata = Array(Float64, size(data)) + outdata = Array{Float64}(size(data)) broadcast!(+, outdata, data, stat.range * (rand(rng, length(data)) - 0.5) .* span) setfield!(aes, var, outdata) end @@ -1864,9 +1865,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}}(0) + aes.x = Array{Tx}(0) + aes.y = Array{Ty}(0) for (c, v) in groups (fx, fy) = mean_by_group(v[1], v[2], breaks) append!(aes.x, fx) diff --git a/src/ticks.jl b/src/ticks.jl index 1acb0c22e..9070c3631 100644 --- a/src/ticks.jl +++ b/src/ticks.jl @@ -147,13 +147,13 @@ function optimize_ticks_typed{T}(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), (@compat Int(3 * k_best))) + S = Array{typeof(1.0 * one_t)}(@compat 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)}(k_best) for i in 0:(k_best - 1) S[i+1] = (r_best + i) * span end