diff --git a/REQUIRE b/REQUIRE index e6fa8e9a..f0e6ec4b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,3 @@ julia 0.5 StatsBase +Compat 0.18 diff --git a/src/UnicodePlots.jl b/src/UnicodePlots.jl index b4240c58..9db1931b 100644 --- a/src/UnicodePlots.jl +++ b/src/UnicodePlots.jl @@ -1,7 +1,8 @@ -isdefined(Base, :__precompile__) && __precompile__() +__precompile__() module UnicodePlots using Base.Dates +using Compat import StatsBase: Histogram, fit export diff --git a/src/canvas.jl b/src/canvas.jl index 02c6fe2e..c3ce8589 100644 --- a/src/canvas.jl +++ b/src/canvas.jl @@ -1,5 +1,5 @@ -abstract GraphicsArea -abstract Canvas <: GraphicsArea +@compat abstract type GraphicsArea end +@compat abstract type Canvas <: GraphicsArea end origin(c::Canvas) = (origin_x(c), origin_y(c)) Base.size(c::Canvas) = (width(c), height(c)) diff --git a/src/graphics/asciicanvas.jl b/src/graphics/asciicanvas.jl index 45a1fa47..bb050d29 100644 --- a/src/graphics/asciicanvas.jl +++ b/src/graphics/asciicanvas.jl @@ -3,7 +3,7 @@ const ascii_signs = [0b100_000_000 0b000_100_000 0b000_000_100; 0b001_000_000 0b000_001_000 0b000_000_001] const ascii_lookup = Dict{UInt16,Char}() -const ascii_decode = Array(Char, 512) +const ascii_decode = Vector{Char}(512) ascii_lookup[0b101_000_000] = '"' ascii_lookup[0b111_111_111] = '@' ascii_lookup[0b011_110_011] = '$' diff --git a/src/graphics/bargraphics.jl b/src/graphics/bargraphics.jl index e4561838..4331b68d 100644 --- a/src/graphics/bargraphics.jl +++ b/src/graphics/bargraphics.jl @@ -1,3 +1,5 @@ +if VERSION < v"0.6-" + _type_string = """ type BarplotGraphics{R<:Real} <: GraphicsArea bars::Vector{R} color::Symbol @@ -17,6 +19,31 @@ type BarplotGraphics{R<:Real} <: GraphicsArea new(bars, color, width, max_freq, max_len, symb) end end +""" +else + _type_string = """ +type BarplotGraphics{R<:Real} <: GraphicsArea + bars::Vector{R} + color::Symbol + width::Int + max_freq::R + max_len::R + symb::AbstractString + + function BarplotGraphics{R}( + bars::Vector{R}, + width::Int, + color::Symbol, + symb) where R + width = max(width, 5) + max_freq = maximum(bars) + max_len = length(string(max_freq)) + new(bars, color, width, max_freq, max_len, symb) + end +end +""" +end +include_string(_type_string) nrows(c::BarplotGraphics) = length(c.bars) ncols(c::BarplotGraphics) = c.width diff --git a/src/graphics/blockcanvas.jl b/src/graphics/blockcanvas.jl index dcccaae2..1aee1d89 100644 --- a/src/graphics/blockcanvas.jl +++ b/src/graphics/blockcanvas.jl @@ -1,7 +1,7 @@ const block_signs = [0b1000 0b0010; 0b0100 0b0001] -const block_decode = Array(Char, 16) +const block_decode = Vector{Char}(16) block_decode[0b0000 + 1] = ' ' block_decode[0b0001 + 1] = '▗' block_decode[0b0010 + 1] = '▖' diff --git a/src/graphics/dotcanvas.jl b/src/graphics/dotcanvas.jl index 2eceb7b1..00ba1935 100644 --- a/src/graphics/dotcanvas.jl +++ b/src/graphics/dotcanvas.jl @@ -1,6 +1,6 @@ const dot_signs = [0b10 0b01] -const dot_decode = Array(Char, 5) +const dot_decode = Array{Char}(5) dot_decode[0b00 + 1] = ' ' dot_decode[0b01 + 1] = '.' dot_decode[0b10 + 1] = '\'' diff --git a/src/graphics/lookupcanvas.jl b/src/graphics/lookupcanvas.jl index 5e93afea..f0a34289 100644 --- a/src/graphics/lookupcanvas.jl +++ b/src/graphics/lookupcanvas.jl @@ -1,4 +1,4 @@ -abstract LookupCanvas <: Canvas +@compat abstract type LookupCanvas <: Canvas end lookup_encode(::LookupCanvas) = error() lookup_decode(::LookupCanvas) = error() diff --git a/src/interface/histogram.jl b/src/interface/histogram.jl index f1322ca8..4752c025 100644 --- a/src/interface/histogram.jl +++ b/src/interface/histogram.jl @@ -82,8 +82,12 @@ See also function histogram(v, bins::Int; symb = "▇", args...) result = fit(Histogram, v; nbins = bins) edges, counts = result.edges[1], result.weights - labels = Array(String, length(counts)) - binwidth = edges.step / edges.divisor + labels = Vector{String}(length(counts)) + @static if VERSION < v"0.6.0-dev.2390" + binwidth = edges.step / edges.divisor + else + binwidth = edges.step.hi + end @inbounds for i in 1:length(counts) val = float_round_log10(edges[i], binwidth) labels[i] = string("(", val, ",", float_round_log10(val+binwidth, binwidth), "]") diff --git a/src/interface/lineplot.jl b/src/interface/lineplot.jl index 68c20ab0..f40a38b3 100644 --- a/src/interface/lineplot.jl +++ b/src/interface/lineplot.jl @@ -289,7 +289,7 @@ function lineplot{D<:TimeType, R<:Real}( X::AbstractVector{D}, Y::AbstractVector{R}; args...) - d = convert(Vector{Float64}, X) + d = convert(Vector{Float64}, Dates.value.(X)) new_plot = lineplot(d, Y; args...) annotate!(new_plot, :bl, string(first(X))) annotate!(new_plot, :br, string(last(X))) diff --git a/src/interface/spy.jl b/src/interface/spy.jl index a9517e0a..0974b60b 100644 --- a/src/interface/spy.jl +++ b/src/interface/spy.jl @@ -176,7 +176,7 @@ function spy{T<:Canvas}( color) else pos_idx = vals .> 0 - neg_idx = !pos_idx + neg_idx = (!).(pos_idx) pos_cols = cols[pos_idx] pos_rows = rows[pos_idx] neg_cols = cols[neg_idx]