Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Julia 0.6 #63

Merged
merged 1 commit into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.5
StatsBase
Compat 0.18
3 changes: 2 additions & 1 deletion src/UnicodePlots.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
isdefined(Base, :__precompile__) && __precompile__()
__precompile__()
module UnicodePlots

using Base.Dates
using Compat
import StatsBase: Histogram, fit

export
Expand Down
4 changes: 2 additions & 2 deletions src/canvas.jl
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/asciicanvas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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] = '$'
Expand Down
27 changes: 27 additions & 0 deletions src/graphics/bargraphics.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if VERSION < v"0.6-"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please be more specific with VERSION cutoffs like this, where isn't going to work for all 0.6-dev versions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would be a way to find a reasonable lower bound? any pointer where to start looking. Is it related to the merge of JuliaLang/julia#18457 ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, check out the merge commit there and run contrib/commit-name.sh

_type_string = """
type BarplotGraphics{R<:Real} <: GraphicsArea
bars::Vector{R}
color::Symbol
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/blockcanvas.jl
Original file line number Diff line number Diff line change
@@ -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] = '▖'
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/dotcanvas.jl
Original file line number Diff line number Diff line change
@@ -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] = '\''
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/lookupcanvas.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract LookupCanvas <: Canvas
@compat abstract type LookupCanvas <: Canvas end

lookup_encode(::LookupCanvas) = error()
lookup_decode(::LookupCanvas) = error()
Expand Down
8 changes: 6 additions & 2 deletions src/interface/histogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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), "]")
Expand Down
2 changes: 1 addition & 1 deletion src/interface/lineplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion src/interface/spy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down