From d6e32b270af24254333232e4ac5b234c10575829 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 14:43:56 -0400 Subject: [PATCH 1/8] some updates for 0.7, must still remove all warnings --- REQUIRE | 12 ++-- src/KernelDensityEstimatePlotting.jl | 86 ++++++++++++++-------------- test/runtests.jl | 5 +- 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/REQUIRE b/REQUIRE index 0b7eb8b..142753f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,7 +1,7 @@ -julia 0.6 -KernelDensityEstimate -Cairo +julia 0.7 +KernelDensityEstimate 0.4.1 +Cairo 0.5.5 Fontconfig -Gadfly -Colors -Compose +Gadfly 1.0.0 +Colors 0.9.4 +Compose 0.7.1 diff --git a/src/KernelDensityEstimatePlotting.jl b/src/KernelDensityEstimatePlotting.jl index 252f92e..0aee7d7 100644 --- a/src/KernelDensityEstimatePlotting.jl +++ b/src/KernelDensityEstimatePlotting.jl @@ -20,7 +20,7 @@ export toggleYTicks, DOYTICKS -VoidUnion{T} = Union{Void, T} +NothingUnion{T} = Union{Nothing, T} # Guide.manual_color_key("Legend", ["Points", "Line"], ["green", "deepskyblue"]) @@ -38,16 +38,16 @@ end # end function plot(darr::Union{BallTreeDensity, Vector{BallTreeDensity}}; - c::VoidUnion{Vector{T}}=nothing, + c::NothingUnion{Vector{T}}=nothing, N::Int=200, rmax=-Inf,rmin=Inf, # should be deprecated - axis::VoidUnion{Array{Float64,2}}=nothing, - dims::VoidUnion{VectorRange{Int}}=nothing, + axis::NothingUnion{Array{Float64,2}}=nothing, + dims::NothingUnion{VectorRange{Int}}=nothing, xlbl::T="X", # to be deprecated - title::VoidUnion{T}=nothing, - legend::VoidUnion{Vector{T}}=nothing, - dimLbls::VoidUnion{Vector{T}}=nothing, - levels::VoidUnion{Int}=nothing, + title::NothingUnion{T}=nothing, + legend::NothingUnion{Vector{T}}=nothing, + dimLbls::NothingUnion{Vector{T}}=nothing, + levels::NothingUnion{Int}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} # plotKDE(darr, c=c, N=N, rmin=rmin, rmax=rmax, axis=axis, dims=dims, xlbl=xlbl, title=title, legend=legend, dimLbls=dimLbls, levels=levels, fill=fill, layers=layers ) @@ -62,7 +62,7 @@ function draw1D!(bd::BallTreeDensity, myStyle::T=""; xlbl="X", legend=nothing, - title::VoidUnion{T}=nothing, + title::NothingUnion{T}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} # global DOYTICKS @@ -105,10 +105,10 @@ function plotKDEContour(pp::Vector{BallTreeDensity}; xmin=-Inf,xmax=Inf,ymin=-Inf,ymax=Inf, xlbl::T="x", ylbl::T="y", N::Int=200, - c::VoidUnion{Vector{T}}=nothing, + c::NothingUnion{Vector{T}}=nothing, legend=nothing, - title::VoidUnion{T}=nothing, - levels::VoidUnion{Int}=nothing, + title::NothingUnion{T}=nothing, + levels::NothingUnion{Int}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} rangeV = getKDERange(pp[1]) @@ -140,8 +140,8 @@ function plotKDEContour(pp::Vector{BallTreeDensity}; for p in pp i+=1 push!(PL, layer(z=(x,y)->evaluateDualTree(p,([[x]';[y]']))[1], - x=linspace(xmin,xmax,N), - y=linspace(ymin,ymax,N), + x=range(xmin,stop=xmax,length=N), + y=range(ymin,stop=ymax,length=N), CO, Theme(default_color=parse(Colorant,c[i])))[1] ) end @@ -174,10 +174,10 @@ function plotKDEContour(p::BallTreeDensity; xmin=-Inf,xmax=Inf,ymin=-Inf,ymax=Inf, xlbl::T="x", ylbl::T="y", N::Int=200, - c::VoidUnion{Vector{T}}=nothing, + c::NothingUnion{Vector{T}}=nothing, legend=nothing, - title::VoidUnion{T}=nothing, - levels::VoidUnion{Int}=nothing, + title::NothingUnion{T}=nothing, + levels::NothingUnion{Int}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} plotKDEContour([p], @@ -192,12 +192,12 @@ function plotKDEContour(p::BallTreeDensity; end function drawPair(xx::Vector{BallTreeDensity}, dims::Vector{Int}; - axis::VoidUnion{Array{Float64,2}}=nothing, - dimLbls::VoidUnion{Vector{T}}=nothing, + axis::NothingUnion{Array{Float64,2}}=nothing, + dimLbls::NothingUnion{Vector{T}}=nothing, legend=nothing, - title::VoidUnion{T}=nothing, - levels::VoidUnion{Int}=nothing, - c::VoidUnion{Vector{T}}=nothing, + title::NothingUnion{T}=nothing, + levels::NothingUnion{Int}=nothing, + c::NothingUnion{Vector{T}}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} # pts = getPoints(x); xmin, xmax, ymin, ymax = -Inf,Inf,-Inf,Inf @@ -229,13 +229,13 @@ end # function to draw all pairs of mulitdimensional kernel density estimate # axis is matrix with rows as dimensions and two columns for min and max axis cutoffs function drawAllPairs(xx::Vector{BallTreeDensity}; - dims::VoidUnion{VectorRange{Int}}=nothing, - axis::VoidUnion{Array{Float64,2}}=nothing, - dimLbls::VoidUnion{Vector{T}}=nothing, + dims::NothingUnion{VectorRange{Int}}=nothing, + axis::NothingUnion{Array{Float64,2}}=nothing, + dimLbls::NothingUnion{Vector{T}}=nothing, legend=nothing, - title::VoidUnion{T}=nothing, - levels::VoidUnion{Int}=nothing, - c::VoidUnion{Vector{T}}=nothing, + title::NothingUnion{T}=nothing, + levels::NothingUnion{Int}=nothing, + c::NothingUnion{Vector{T}}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} # pts = getPoints(xx[1]); @@ -284,16 +284,16 @@ end # function to draw all pairs of mulitdimensional kernel density estimate # axis is matrix with rows as dimensions and two columns for min and max axis cutoffs function plotKDE(darr::Array{BallTreeDensity,1}; - c::VoidUnion{Vector{T}}=nothing, + c::NothingUnion{Vector{T}}=nothing, N::Int=200, rmax=-Inf,rmin=Inf, # should be deprecated - axis::VoidUnion{Array{Float64,2}}=nothing, - dims::VoidUnion{VectorRange{Int}}=nothing, + axis::NothingUnion{Array{Float64,2}}=nothing, + dims::NothingUnion{VectorRange{Int}}=nothing, xlbl::T="X", # to be deprecated - title::VoidUnion{T}=nothing, - legend::VoidUnion{Vector{T}}=nothing, - dimLbls::VoidUnion{Vector{T}}=nothing, - levels::VoidUnion{Int}=nothing, + title::NothingUnion{T}=nothing, + legend::NothingUnion{Vector{T}}=nothing, + dimLbls::NothingUnion{Vector{T}}=nothing, + levels::NothingUnion{Int}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} @@ -326,7 +326,7 @@ function plotKDE(darr::Array{BallTreeDensity,1}; if rangeV[1] > axis[di,1] rangeV[1] = axis[di,1] end if axis[di,2] > rangeV[2] rangeV[2] = axis[di,2] end end - H=draw1D!(mbd,linspace(rangeV[1],rangeV[2],N), H, c[i],xlbl=xlbl,legend=lg, title=title, fill=fill) #,argsPlot,argsKDE + H=draw1D!(mbd,range(rangeV[1],stop=rangeV[2],length=N), H, c[i],xlbl=xlbl,legend=lg, title=title, fill=fill) #,argsPlot,argsKDE else # end @@ -340,16 +340,16 @@ end function plotKDE(bd::BallTreeDensity; - c::VoidUnion{Vector{T}}=nothing, + c::NothingUnion{Vector{T}}=nothing, N::Int=200, rmax=-Inf,rmin=Inf, # should be deprecated - axis::VoidUnion{Array{Float64,2}}=nothing, - dims::VoidUnion{VectorRange{Int}}=nothing, + axis::NothingUnion{Array{Float64,2}}=nothing, + dims::NothingUnion{VectorRange{Int}}=nothing, xlbl::T="X", - legend::VoidUnion{Vector{T}}=nothing, - title::VoidUnion{T}=nothing, - dimLbls::VoidUnion{Vector{T}}=nothing, - levels::VoidUnion{Int}=nothing, + legend::NothingUnion{Vector{T}}=nothing, + title::NothingUnion{T}=nothing, + dimLbls::NothingUnion{Vector{T}}=nothing, + levels::NothingUnion{Int}=nothing, fill=false, layers::Bool=false ) where {T <: AbstractString} plotKDE([bd],N=N,c=c,rmax=rmax,rmin=rmin,xlbl=xlbl,legend=legend, dims=dims, axis=axis, dimLbls=dimLbls, levels=levels, title=title, fill=fill, layers=layers) diff --git a/test/runtests.jl b/test/runtests.jl index 062c73b..d031f7f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,6 @@ -using Base: Test -using KernelDensityEstimate, KernelDensityEstimatePlotting +using Test +using KernelDensityEstimate +using KernelDensityEstimatePlotting using Colors # check for errors on plotting code From d2433fa47d12987a13b0f33857aebf375d5c56e5 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 15:06:46 -0400 Subject: [PATCH 2/8] working on 0.7 --- src/KernelDensityEstimatePlotting.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/KernelDensityEstimatePlotting.jl b/src/KernelDensityEstimatePlotting.jl index 0aee7d7..486fea9 100644 --- a/src/KernelDensityEstimatePlotting.jl +++ b/src/KernelDensityEstimatePlotting.jl @@ -1,5 +1,6 @@ module KernelDensityEstimatePlotting +using LinearAlgebra, Statistics using KernelDensityEstimate using Gadfly, Colors, Cairo, Fontconfig, Compose @@ -69,7 +70,7 @@ function draw1D!(bd::BallTreeDensity, yV = evaluateDualTree(bd,bins) # clamp max y values - yV[3.0 .< yV] = 3.0 + yV[3.0 .< yV] .= 3.0 if e == nothing ptArr = Any[] @@ -242,13 +243,14 @@ function drawAllPairs(xx::Vector{BallTreeDensity}; # e = []; dims = dims != nothing ? collect(dims) : collect(1:Ndim(xx[1])) Nout = length(dims); - PlotI2 = triu(repmat( (dims)' ,Nout, 1), 1); - PlotI1 = triu(repmat((dims)' , Nout, 1)', 1); - PlotI1, PlotI2 = PlotI1[find(PlotI1)], PlotI2[find(PlotI2)]; + PlotI2 = triu(repeat( (dims)' ,Nout, 1), 1); + PlotI1 = triu(repeat((dims)' , Nout, 1)', 1); + PlotI1, PlotI2 = PlotI1[(LinearIndices(PlotI1))[findall(x->x!=0,PlotI1)]], PlotI2[(LinearIndices(PlotI2))[findall(x->x!=0,PlotI2)]]; + # PlotI1, PlotI2 = PlotI1[find(PlotI1)], PlotI2[find(PlotI2)]; Ncol = round(Int, sqrt(length(PlotI2))); Nrow = ceil(Int, length(PlotI2)/Ncol); - subplots = Array{Gadfly.Plot,2}(Nrow,Ncol) + subplots = Array{Gadfly.Plot,2}(undef, Nrow,Ncol) for iT=1:length(PlotI2) # only returns layers for first pair if !layers @@ -259,7 +261,7 @@ function drawAllPairs(xx::Vector{BallTreeDensity}; end; Nrow==1 && Ncol==1 ? nothing : println("Multiple planes stacked into Compose.Context, use Gadfly.draw(PNG(file.png,10cm,10cm),plothdl). Or PDF.") - hh = Vector{Gadfly.Context}(Nrow) + hh = Vector{Gadfly.Context}(undef, Nrow) for i in 1:Nrow sp = Compose.Context[] for j in 1:Ncol @@ -303,7 +305,7 @@ function plotKDE(darr::Array{BallTreeDensity,1}; if c==nothing c, defaultcolor = ["black"], true end - c = (length(c)>=2) ? c : repmat(c,length(darr)) + c = (length(c)>=2) ? c : repeat(c,length(darr)) lg = (legend == nothing) ? nothing : Guide.manual_color_key("Legend", legend, c) H = nothing From 2787e9a7fc00b64c60b6fa240b028180861eb1c9 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 15:13:03 -0400 Subject: [PATCH 3/8] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fb5c5d..ccd6d5b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![KernelDensityEstimatePlotting](http://pkg.julialang.org/badges/KernelDensityEstimatePlotting_0.6.svg)](http://pkg.julialang.org/?pkg=KernelDensityEstimatePlotting&ver=0.6) [![KernelDensityEstimatePlotting](http://pkg.julialang.org/badges/KernelDensityEstimatePlotting_0.7.svg)](http://pkg.julialang.org/?pkg=KernelDensityEstimatePlotting&ver=0.7) +[![KernelDensityEstimatePlotting](http://pkg.julialang.org/badges/KernelDensityEstimatePlotting_1.0.svg)](http://pkg.julialang.org/?pkg=KernelDensityEstimatePlotting&ver=1.0) This package provides the plotting functionality for the [KernelDensityEstimate.jl](https://github.com/JuliaRobotics/KernelDensityEstimate.jl) package, and currently only supports the Gadfly back-end. @@ -14,7 +15,8 @@ This package is also used extensively by the [RoMEPlotting.jl](https://github.co This package can be installed with: ```julia -Pkg.add("KernelDensityEstimatePlotting") +julia> ] # to activate package manager +pkg> add KernelDensityEstimatePlotting ``` From 1a4515eeeb2bbd39dc59cfe6743f6fede146f00a Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 15:14:21 -0400 Subject: [PATCH 4/8] update travis tests --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 256c989..8826503 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,15 @@ os: - linux - osx julia: - - 0.6 + - 0.7 + - 1.0 - nightly notifications: email: false matrix: allow_failures: - os: osx + - julia: 1.0 - julia: nightly script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi From b13b0e0344d3448aef727a91f3de417f5fc136fc Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 15:37:06 -0400 Subject: [PATCH 5/8] fix travis --- .travis.yml | 4 ++-- REQUIRE | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8826503..277631c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ matrix: - julia: nightly script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.test("KernelDensityEstimate"; coverage=true)' + - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.test("KernelDensityEstimate"; coverage=true)' after_success: - - julia -e 'cd(Pkg.dir("KernelDensityEstimate")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' + - julia -e 'using Pkg; cd(Pkg.dir("KernelDensityEstimate")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' diff --git a/REQUIRE b/REQUIRE index 142753f..82cba74 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.7 -KernelDensityEstimate 0.4.1 +KernelDensityEstimate 0.4.0 Cairo 0.5.5 Fontconfig Gadfly 1.0.0 From 8265b315be106b85e50992edc5c4c091696a0de4 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 16:48:45 -0400 Subject: [PATCH 6/8] KDE 0.4.1 --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 82cba74..142753f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.7 -KernelDensityEstimate 0.4.0 +KernelDensityEstimate 0.4.1 Cairo 0.5.5 Fontconfig Gadfly 1.0.0 From a1edbf3ba0348d6039510f9318d0addbd7b260bf Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 19:35:06 -0400 Subject: [PATCH 7/8] change require order to try fix travis --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 142753f..6074429 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,7 +1,7 @@ julia 0.7 -KernelDensityEstimate 0.4.1 Cairo 0.5.5 Fontconfig Gadfly 1.0.0 Colors 0.9.4 Compose 0.7.1 +KernelDensityEstimate 0.4.1 From fcaf9df85c0a752cb4f9f414314f24fcf5326933 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 20 Oct 2018 19:58:02 -0400 Subject: [PATCH 8/8] oops, fix typo --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 277631c..0a0923a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ matrix: - julia: nightly script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.test("KernelDensityEstimate"; coverage=true)' + - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.test("KernelDensityEstimatePlotting"; coverage=true)' after_success: - - julia -e 'using Pkg; cd(Pkg.dir("KernelDensityEstimate")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' + - julia -e 'using Pkg; cd(Pkg.dir("KernelDensityEstimatePlotting")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'