Skip to content

Commit b7c53ed

Browse files
committed
Fixes for Julia 0.6
1 parent d60fb34 commit b7c53ed

11 files changed

+44
-11
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
julia 0.5
22
StatsBase
3+
Compat 0.18

src/UnicodePlots.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
isdefined(Base, :__precompile__) && __precompile__()
1+
__precompile__()
22
module UnicodePlots
33

44
using Base.Dates
5+
using Compat
56
import StatsBase: Histogram, fit
67

78
export

src/canvas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
abstract GraphicsArea
2-
abstract Canvas <: GraphicsArea
1+
@compat abstract type GraphicsArea end
2+
@compat abstract type Canvas <: GraphicsArea end
33

44
origin(c::Canvas) = (origin_x(c), origin_y(c))
55
Base.size(c::Canvas) = (width(c), height(c))

src/graphics/asciicanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const ascii_signs = [0b100_000_000 0b000_100_000 0b000_000_100;
33
0b001_000_000 0b000_001_000 0b000_000_001]
44

55
const ascii_lookup = Dict{UInt16,Char}()
6-
const ascii_decode = Array(Char, 512)
6+
const ascii_decode = Vector{Char}(512)
77
ascii_lookup[0b101_000_000] = '"'
88
ascii_lookup[0b111_111_111] = '@'
99
ascii_lookup[0b011_110_011] = '$'

src/graphics/bargraphics.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
if VERSION < v"0.6-"
2+
_type_string = """
13
type BarplotGraphics{R<:Real} <: GraphicsArea
24
bars::Vector{R}
35
color::Symbol
@@ -17,6 +19,31 @@ type BarplotGraphics{R<:Real} <: GraphicsArea
1719
new(bars, color, width, max_freq, max_len, symb)
1820
end
1921
end
22+
"""
23+
else
24+
_type_string = """
25+
type BarplotGraphics{R<:Real} <: GraphicsArea
26+
bars::Vector{R}
27+
color::Symbol
28+
width::Int
29+
max_freq::R
30+
max_len::R
31+
symb::AbstractString
32+
33+
function BarplotGraphics{R}(
34+
bars::Vector{R},
35+
width::Int,
36+
color::Symbol,
37+
symb) where R
38+
width = max(width, 5)
39+
max_freq = maximum(bars)
40+
max_len = length(string(max_freq))
41+
new(bars, color, width, max_freq, max_len, symb)
42+
end
43+
end
44+
"""
45+
end
46+
include_string(_type_string)
2047

2148
nrows(c::BarplotGraphics) = length(c.bars)
2249
ncols(c::BarplotGraphics) = c.width

src/graphics/blockcanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const block_signs = [0b1000 0b0010;
22
0b0100 0b0001]
33

4-
const block_decode = Array(Char, 16)
4+
const block_decode = Vector{Char}(16)
55
block_decode[0b0000 + 1] = ' '
66
block_decode[0b0001 + 1] = ''
77
block_decode[0b0010 + 1] = ''

src/graphics/dotcanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const dot_signs = [0b10 0b01]
22

3-
const dot_decode = Array(Char, 5)
3+
const dot_decode = Array{Char}(5)
44
dot_decode[0b00 + 1] = ' '
55
dot_decode[0b01 + 1] = '.'
66
dot_decode[0b10 + 1] = '\''

src/graphics/lookupcanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
abstract LookupCanvas <: Canvas
1+
@compat abstract type LookupCanvas <: Canvas end
22

33
lookup_encode(::LookupCanvas) = error()
44
lookup_decode(::LookupCanvas) = error()

src/interface/histogram.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ See also
8282
function histogram(v, bins::Int; symb = "", args...)
8383
result = fit(Histogram, v; nbins = bins)
8484
edges, counts = result.edges[1], result.weights
85-
labels = Array(String, length(counts))
86-
binwidth = edges.step / edges.divisor
85+
labels = Vector{String}(length(counts))
86+
@static if VERSION < v"0.6.0-dev.2390"
87+
binwidth = edges.step / edges.divisor
88+
else
89+
binwidth = edges.step.hi
90+
end
8791
@inbounds for i in 1:length(counts)
8892
val = float_round_log10(edges[i], binwidth)
8993
labels[i] = string("(", val, ",", float_round_log10(val+binwidth, binwidth), "]")

src/interface/lineplot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function lineplot{D<:TimeType, R<:Real}(
289289
X::AbstractVector{D},
290290
Y::AbstractVector{R};
291291
args...)
292-
d = convert(Vector{Float64}, X)
292+
d = convert(Vector{Float64}, Dates.value.(X))
293293
new_plot = lineplot(d, Y; args...)
294294
annotate!(new_plot, :bl, string(first(X)))
295295
annotate!(new_plot, :br, string(last(X)))

src/interface/spy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function spy{T<:Canvas}(
176176
color)
177177
else
178178
pos_idx = vals .> 0
179-
neg_idx = !pos_idx
179+
neg_idx = (!).(pos_idx)
180180
pos_cols = cols[pos_idx]
181181
pos_rows = rows[pos_idx]
182182
neg_cols = cols[neg_idx]

0 commit comments

Comments
 (0)