Skip to content

Commit

Permalink
update to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Evizero committed Sep 5, 2017
1 parent d312eb5 commit ff93a1c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.5
julia 0.6
DataStructures 0.5
RecipesBase 0.1
Compat 0.17
9 changes: 7 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand All @@ -10,6 +10,11 @@ branches:
- master
- /release-.*/

matrix:
allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

notifications:
- provider: Email
on_build_success: false
Expand Down
6 changes: 3 additions & 3 deletions src/abstract.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@compat abstract type ValueHistory end
@compat abstract type UnivalueHistory{I} <: ValueHistory end
@compat abstract type MultivalueHistory <: ValueHistory end
abstract type ValueHistory end
abstract type UnivalueHistory{I} <: ValueHistory end
abstract type MultivalueHistory <: ValueHistory end

Base.push!(history::UnivalueHistory, iteration, value) =
throw(ArgumentError("The specified arguments are of incompatible type"))
Expand Down
22 changes: 9 additions & 13 deletions src/history.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
type History{I,V} <: UnivalueHistory{I}
mutable struct History{I,V} <: UnivalueHistory{I}
lastiter::I
iterations::Vector{I}
values::Vector{V}

function History(::Type{V}, ::Type{I})
new(typemin(I), Array{I}(0), Array{V}(0))
function History(::Type{V}, ::Type{I} = Int) where {I,V}
new{I,V}(typemin(I), Array{I}(0), Array{V}(0))
end
end

function History{I,V}(v::Type{V}, i::Type{I} = Int)
History{I,V}(v, i)
end

Base.length(history::History) = length(history.iterations)
Base.enumerate(history::History) = zip(history.iterations, history.values)
Base.first(history::History) = history.iterations[1], history.values[1]
Base.last(history::History) = history.iterations[end], history.values[end]
Base.get(history::History) = history.iterations, history.values

function Base.push!{I,V}(
function Base.push!(
history::History{I,V},
iteration::I,
value::V)
value::V) where {I,V}
lastiter = history.lastiter
iteration > lastiter || throw(ArgumentError("Iterations must increase over time"))
history.lastiter = iteration
Expand All @@ -30,9 +26,9 @@ function Base.push!{I,V}(
value
end

function Base.push!{I,V}(
function Base.push!(
history::History{I,V},
value::V)
value::V) where {I,V}
lastiter = history.lastiter == typemin(I) ? zero(I) : history.lastiter
iteration = lastiter + one(history.lastiter)
history.lastiter = iteration
Expand All @@ -41,9 +37,9 @@ function Base.push!{I,V}(
value
end

Base.print{I,V}(io::IO, history::History{I,V}) = print(io, "$(length(history)) elements {$I,$V}")
Base.print(io::IO, history::History{I,V}) where {I,V} = print(io, "$(length(history)) elements {$I,$V}")

function Base.show{I,V}(io::IO, history::History{I,V})
function Base.show(io::IO, history::History{I,V}) where {I,V}
println(io, "History")
println(io, " * types: $I, $V")
print(io, " * length: $(length(history))")
Expand Down
16 changes: 8 additions & 8 deletions src/mvhistory.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
immutable MVHistory{H<:UnivalueHistory} <: MultivalueHistory
struct MVHistory{H<:UnivalueHistory} <: MultivalueHistory
storage::Dict{Symbol, H}
end

function MVHistory{H<:UnivalueHistory}(::Type{H} = History)
function MVHistory(::Type{H} = History) where {H<:UnivalueHistory}
MVHistory{H}(Dict{Symbol, H}())
end

# ==========================================================================
# ====================================================================
# Functions

Base.length(history::MVHistory, key::Symbol) = length(history.storage[key])
Base.enumerate(history::MVHistory, key::Symbol) = enumerate(history.storage[key])
Base.first(history::MVHistory, key::Symbol) = first(history.storage[key])
Base.last(history::MVHistory, key::Symbol) = last(history.storage[key])

function Base.push!{I,H<:UnivalueHistory,V}(
function Base.push!(
history::MVHistory{H},
key::Symbol,
iteration::I,
value::V)
value::V) where {I,H<:UnivalueHistory,V}
if !haskey(history.storage, key)
_hist = H(V, I)
push!(_hist, iteration, value)
Expand All @@ -29,10 +29,10 @@ function Base.push!{I,H<:UnivalueHistory,V}(
value
end

function Base.push!{H<:UnivalueHistory,V}(
function Base.push!(
history::MVHistory{H},
key::Symbol,
value::V)
value::V) where {H<:UnivalueHistory,V}
if !haskey(history.storage, key)
_hist = H(V, Int)
push!(_hist, value)
Expand Down Expand Up @@ -63,7 +63,7 @@ function Base.get(history::MVHistory, key::Symbol)
karray, varray
end

function Base.show{H}(io::IO, history::MVHistory{H})
function Base.show(io::IO, history::MVHistory{H}) where {H}
print(io, "MVHistory{$H}")
for (key, val) in history.storage
print(io, "\n", " :$(key) => $(val)")
Expand Down
27 changes: 11 additions & 16 deletions src/qhistory.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
type QHistory{I,V} <: UnivalueHistory{I}
mutable struct QHistory{I,V} <: UnivalueHistory{I}
lastiter::I
storage::Deque{Tuple{I,V}}

function QHistory(::Type{V}, ::Type{I})
new(typemin(I), Deque{Tuple{I,V}}())
function QHistory(::Type{V}, ::Type{I} = Int) where {I,V}
new{I,V}(typemin(I), Deque{Tuple{I,V}}())
end
end

function QHistory{I,V}(v::Type{V}, i::Type{I} = Int)
QHistory{I,V}(v, i)
end

# ==========================================================================
#
# ====================================================================

Base.length(history::QHistory) = length(history.storage)
Base.enumerate(history::QHistory) = history.storage
Base.first(history::QHistory) = front(history.storage)
Base.last(history::QHistory) = back(history.storage)

function Base.push!{I,V}(
function Base.push!(
history::QHistory{I,V},
iteration::I,
value::V)
value::V) where {I,V}
lastiter = history.lastiter
iteration > lastiter || throw(ArgumentError("Iterations must increase over time"))
history.lastiter = iteration
push!(history.storage, (iteration, value))
value
end

function Base.push!{I,V}(
function Base.push!(
history::QHistory{I,V},
value::V)
value::V) where {I,V}
lastiter = history.lastiter == typemin(I) ? zero(I) : history.lastiter
iteration = lastiter + one(history.lastiter)
history.lastiter = iteration
push!(history.storage, (iteration, value))
value
end

function Base.get{I,V}(history::QHistory{I,V})
function Base.get(history::QHistory{I,V}) where {I,V}
l = length(history)
k, v = front(history.storage)
karray = zeros(I, l)
Expand All @@ -54,9 +49,9 @@ function Base.get{I,V}(history::QHistory{I,V})
karray, varray
end

Base.print{I,V}(io::IO, history::QHistory{I,V}) = print(io, "$(length(history)) elements {$I,$V}")
Base.print(io::IO, history::QHistory{I,V}) where {I,V} = print(io, "$(length(history)) elements {$I,$V}")

function Base.show{I,V}(io::IO, history::QHistory{I,V})
function Base.show(io::IO, history::QHistory{I,V}) where {I,V}
println(io, "QHistory")
println(io, " types: $I, $V")
print(io, " length: $(length(history))")
Expand Down
6 changes: 3 additions & 3 deletions src/recipes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_is_plotable_history(::UnivalueHistory) = false
_is_plotable_history{I,V<:Real}(::QHistory{I,V}) = true
_is_plotable_history{I,V<:Real}(::History{I,V}) = true
_is_plotable_history(::QHistory{I,V}) where {I,V<:Real} = true
_is_plotable_history(::History{I,V}) where {I,V<:Real} = true

_filter_plotable_histories(h::MVHistory) =
filter((k,v) -> _is_plotable_history(v), h.storage)
Expand Down Expand Up @@ -31,7 +31,7 @@ end
end
end

@recipe function plot{T<:ValueHistories.UnivalueHistory}(hs::AbstractVector{T})
@recipe function plot(hs::AbstractVector{T}) where {T<:ValueHistories.UnivalueHistory}
for h in hs
@series begin
h
Expand Down

0 comments on commit ff93a1c

Please sign in to comment.