From ca386cd183e5fb012eb15eed16a46ad7f0f65213 Mon Sep 17 00:00:00 2001 From: Christof Stocker Date: Fri, 10 Mar 2017 19:05:12 +0100 Subject: [PATCH] update to 0.6 compat --- README.md | 48 ++++++++++++------------------------------- REQUIRE | 7 ++++--- appveyor.yml | 16 ++++++++------- src/ValueHistories.jl | 6 +----- src/abstract.jl | 6 +++--- src/history.jl | 2 +- src/mvhistory.jl | 2 +- src/qhistory.jl | 2 +- src/recipes.jl | 2 +- test/bm_history.jl | 4 ++-- test/runtests.jl | 8 +------- test/tst_history.jl | 6 +++--- test/tst_mvhistory.jl | 9 ++++++-- 13 files changed, 47 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index a9b5a3d..bd26828 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ arbitrarily spaced sampling times* | **Package Status** | **Package Evaluator** | **Build Status** | |:------------------:|:---------------------:|:-----------------:| -| [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md) | [![Package Evaluator v4](http://pkg.julialang.org/badges/ValueHistories_0.4.svg)](http://pkg.julialang.org/?pkg=ValueHistories&ver=0.4) [![Package Evaluator v5](http://pkg.julialang.org/badges/ValueHistories_0.5.svg)](http://pkg.julialang.org/?pkg=ValueHistories&ver=0.5) | [![Build Status](https://travis-ci.org/JuliaML/ValueHistories.jl.svg?branch=master)](https://travis-ci.org/JuliaML/ValueHistories.jl) [![Build status](https://ci.appveyor.com/api/projects/status/8v1n9hqfnn5jslyn/branch/master?svg=true)](https://ci.appveyor.com/project/Evizero/valuehistories-jl/branch/master) [![Coverage Status](https://coveralls.io/repos/github/JuliaML/ValueHistories.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaML/ValueHistories.jl?branch=master) | +| [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md) | [![ValueHistories](http://pkg.julialang.org/badges/ValueHistories_0.5.svg)](http://pkg.julialang.org/?pkg=ValueHistories) [![ValueHistories](http://pkg.julialang.org/badges/ValueHistories_0.6.svg)](http://pkg.julialang.org/?pkg=ValueHistories) | [![Build Status](https://travis-ci.org/JuliaML/ValueHistories.jl.svg?branch=master)](https://travis-ci.org/JuliaML/ValueHistories.jl) [![Build status](https://ci.appveyor.com/api/projects/status/8v1n9hqfnn5jslyn/branch/master?svg=true)](https://ci.appveyor.com/project/Evizero/valuehistories-jl/branch/master) [![Coverage Status](https://coveralls.io/repos/github/JuliaML/ValueHistories.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaML/ValueHistories.jl?branch=master) | ## Installation This package is registered in `METADATA.jl` and can be installed as usual -```Julia +```julia Pkg.add("ValueHistories") using ValueHistories ``` @@ -49,7 +49,9 @@ Supported operations for univalue histories: Here is a little example code showing the basic usage: -```Julia +```julia +using Primes + # Specify the type of value you wish to track history = QHistory(Float64) @@ -83,12 +85,12 @@ QHistory For easy visualisation we also provide recipes for `Plots.jl`. Note that this is only supported for `Real` types. -```Julia +```julia using Plots plot(history, legend=false) ``` -![univalue](https://cloud.githubusercontent.com/assets/10854026/17746218/70d10760-64af-11e6-94c4-b711a9ac018b.png) +![qhistory](https://rawgithub.com/JuliaML/FileStorage/master/ValueHistories/qhistory.svg) ### Multivalue Histories @@ -109,7 +111,7 @@ Supported operations for multivalue histories: Here is a little example code showing the basic usage: -```Julia +```julia history = MVHistory() for i=1:100 @@ -136,7 +138,7 @@ x, y = get(history, :mysin) x, y = get(history, :mystring) @assert length(x) == length(y) == 100 @assert typeof(x) <: Vector{Int64} -@assert typeof(y) <: Vector{ASCIIString} +@assert typeof(y) <: Vector{String} @assert y[1] == "i=1" # You can also enumerate over the observations @@ -152,45 +154,21 @@ history ``` MVHistory{ValueHistories.History{I,V}} :mysin => 100 elements {Float64,Float64} - :mystring => 100 elements {Int64,ASCIIString} + :mystring => 100 elements {Int64,String} :mycos => 25 elements {Float32,Float64} ``` For easy visualisation we also provide recipes for `Plots.jl`. Note that this is only supported for `Real` types. -```Julia +```julia using Plots plot(history) ``` -![multivalue](https://cloud.githubusercontent.com/assets/10854026/17746217/70d0ad9c-64af-11e6-8453-bf94aad32571.png) - - -## Benchmarks - -Compilation already taken into account. The code can be found [here](https://github.com/Evizero/ValueHistories.jl/blob/master/test/bm_history.jl) - -``` -Baseline: 100000 loops that accumulates a Float64 - 0.000127 seconds (5 allocations: 176 bytes) - -History: 100000 loops tracking accumulator as Float64 - 0.003651 seconds (33 allocations: 4.001 MB) -History: Converting result into arrays - 0.000010 seconds (3 allocations: 96 bytes) - -QHistory: 100000 loops tracking accumulator as Float64 - 0.002141 seconds (195 allocations: 1.529 MB) -QHistory: Converting result into arrays - 0.217000 seconds (1.60 M allocations: 35.067 MB, 3.63% gc time) - -MVHistory: 100000 loops tracking accumulator as Float64 and String - 0.185134 seconds (1.70 M allocations: 62.937 MB, 31.24% gc time) -MVHistory: Converting result into arrays - 0.194542 seconds (1.39 M allocations: 28.914 MB, 25.88% gc time) -``` +![mvhistory](https://rawgithub.com/JuliaML/FileStorage/master/ValueHistories/mvhistory.svg) ## License This code is free to use under the terms of the MIT license. + diff --git a/REQUIRE b/REQUIRE index 67f5c30..5bec56e 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,3 +1,4 @@ -julia 0.5- -DataStructures -RecipesBase +julia 0.5 +DataStructures 0.5 +RecipesBase 0.1 +Compat 0.17 diff --git a/appveyor.yml b/appveyor.yml index 25d158f..3528ecc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,11 @@ environment: - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" +branches: + only: + - master + - /release-.*/ + notifications: - provider: Email on_build_success: false @@ -12,13 +17,10 @@ notifications: on_build_status_changed: false install: -# If there's a newer build queued for the same PR, cancel this one - - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` - Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` - throw "There are newer queued builds for this pull request, failing early." } # Download most recent Julia Windows binary - - ps: (new-object net.webclient).DownloadFile($("http://s3.amazonaws.com/"+$env:JULIAVERSION), "C:\projects\julia-binary.exe") + - ps: (new-object net.webclient).DownloadFile( + $("http://s3.amazonaws.com/"+$env:JULIAVERSION), + "C:\projects\julia-binary.exe") # Run installer silently, output to C:\projects\julia - C:\projects\julia-binary.exe /S /D=C:\projects\julia @@ -29,4 +31,4 @@ build_script: Pkg.clone(pwd(), \"ValueHistories\"); Pkg.build(\"ValueHistories\")" test_script: - - C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"ValueHistories\")" +- C:\projects\julia\bin\julia -e "Pkg.test(\"ValueHistories\")" diff --git a/src/ValueHistories.jl b/src/ValueHistories.jl index 7a41cd7..2458988 100644 --- a/src/ValueHistories.jl +++ b/src/ValueHistories.jl @@ -2,6 +2,7 @@ module ValueHistories using DataStructures using RecipesBase +using Compat export @@ -19,9 +20,4 @@ include("qhistory.jl") include("mvhistory.jl") include("recipes.jl") -Base.@deprecate_binding VectorUnivalueHistory History -Base.@deprecate_binding QueueUnivalueHistory QHistory -Base.@deprecate_binding DynMultivalueHistory MVHistory - - end # module diff --git a/src/abstract.jl b/src/abstract.jl index e0bd6ce..4d6acb0 100644 --- a/src/abstract.jl +++ b/src/abstract.jl @@ -1,6 +1,6 @@ -abstract ValueHistory -abstract UnivalueHistory{I} <: ValueHistory -abstract MultivalueHistory <: ValueHistory +@compat abstract type ValueHistory end +@compat abstract type UnivalueHistory{I} <: ValueHistory end +@compat abstract type MultivalueHistory <: ValueHistory end Base.push!(history::UnivalueHistory, iteration, value) = throw(ArgumentError("The specified arguments are of incompatible type")) diff --git a/src/history.jl b/src/history.jl index f8d248b..75bdaab 100644 --- a/src/history.jl +++ b/src/history.jl @@ -4,7 +4,7 @@ type History{I,V} <: UnivalueHistory{I} values::Vector{V} function History(::Type{V}, ::Type{I}) - new(typemin(I), Array(I, 0), Array(V, 0)) + new(typemin(I), Array{I}(0), Array{V}(0)) end end diff --git a/src/mvhistory.jl b/src/mvhistory.jl index cc192ff..9f1f7f9 100644 --- a/src/mvhistory.jl +++ b/src/mvhistory.jl @@ -53,7 +53,7 @@ function Base.get(history::MVHistory, key::Symbol) l = length(history, key) k, v = first(history.storage[key]) karray = zeros(typeof(k), l) - varray = Array(typeof(v), l) + varray = Array{typeof(v)}(l) i = 1 for (k, v) in enumerate(history, key) karray[i] = k diff --git a/src/qhistory.jl b/src/qhistory.jl index 362e9bb..70412ae 100644 --- a/src/qhistory.jl +++ b/src/qhistory.jl @@ -44,7 +44,7 @@ function Base.get{I,V}(history::QHistory{I,V}) l = length(history) k, v = front(history.storage) karray = zeros(I, l) - varray = Array(V, l) + varray = Array{V}(l) i = 1 for (k, v) in enumerate(history) karray[i] = k diff --git a/src/recipes.jl b/src/recipes.jl index b4408d4..6b633f7 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -17,7 +17,7 @@ end v_vec = [v for (k, v) in filtered] if length(v_vec) > 0 markershape --> :ellipse - label --> map(string, k_vec)' + label --> reshape(map(string, k_vec), (1,length(k_vec))) if get(d, :layout, nothing) != nothing title --> d[:label] legend --> false diff --git a/test/bm_history.jl b/test/bm_history.jl index 2b07f61..1225d6f 100644 --- a/test/bm_history.jl +++ b/test/bm_history.jl @@ -24,7 +24,7 @@ end for T in [History, QHistory] - msg("$(T.name.name): $n loops tracking accumulator as Float64") + msg("$(T): $n loops tracking accumulator as Float64") function g(_history,n) tmp = 0. @@ -41,7 +41,7 @@ for T in [History, QHistory] _history = T(Float64) @time g(_history,n) - msg("$(T.name.name): Converting result into arrays") + msg("$(T): Converting result into arrays") @time x,y = get(_history) @time x,y = get(_history) diff --git a/test/runtests.jl b/test/runtests.jl index 49a1848..b03ee95 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,5 @@ using ValueHistories - -if VERSION >= v"0.5-" - using Base.Test -else - using BaseTestNext - const Test = BaseTestNext -end +using Base.Test tests = [ "tst_history.jl" diff --git a/test/tst_history.jl b/test/tst_history.jl index 35e5dbe..3e81a34 100644 --- a/test/tst_history.jl +++ b/test/tst_history.jl @@ -1,5 +1,5 @@ for T in [History, QHistory] - @testset "$(T.name.name): Basic functions" begin + @testset "$(T): Basic functions" begin _history = T(Float64) @test push!(_history, 1, 10.) == Float64(10.) @@ -44,11 +44,11 @@ for T in [History, QHistory] @test convert(Vector{Float64}, a1 + 1) == a2 end - @testset "$(T.name.name): No explicit iteration" begin + @testset "$(T): No explicit iteration" begin _history = T(Float64) end - @testset "$(T.name.name): Storing arbitrary types" begin + @testset "$(T): Storing arbitrary types" begin _history = T(String, UInt8) for i = 1:100 diff --git a/test/tst_mvhistory.jl b/test/tst_mvhistory.jl index e466a70..4469d74 100644 --- a/test/tst_mvhistory.jl +++ b/test/tst_mvhistory.jl @@ -87,8 +87,13 @@ end @test typeof(a1) <: Vector{Int} @test typeof(a2) <: Vector{Float64} - @test haskey(_history, Symbol("round(Int,xi)")) - a1, a2 = get(_history, Symbol("round(Int,xi)")) + a1, a2 = if VERSION < v"0.6-" + @test haskey(_history, Symbol("round(Int,xi)")) + get(_history, Symbol("round(Int,xi)")) + else + @test haskey(_history, Symbol("round(Int, xi)")) + get(_history, Symbol("round(Int, xi)")) + end @test length(a1) == n @test length(a2) == n @test typeof(a1) <: Vector{Int}