Skip to content

Commit

Permalink
Merge pull request #34 from JuliaRobotics/22Q2/maint/fixcompat
Browse files Browse the repository at this point in the history
missing import, fix test, bug fix
  • Loading branch information
dehann committed Apr 20, 2022
2 parents 75d0351 + 6c18663 commit 8efc73a
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 85 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
env:
JULIA_PKG_SERVER: ""
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- run: |
git config --global user.name Tester
git config --global user.email te@st.er
- uses: julia-actions/julia-runtest@latest
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

17 changes: 7 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,25 @@ desc = "Visualization tools for the KernelDensityEstimate.jl package."
version = "0.1.8"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Fontconfig = "186bb1d3-e1f7-5a2c-a377-96d770f13627"
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
KernelDensityEstimate = "2472808a-b354-52ea-a80e-1658a3c6056d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Cairo = "0.7, 0.8, 1"
Colors = "0.9.4, 0.10, 0.11, 0.12"
Compose = "0.7.4, 0.8, 0.9"
DocStringExtensions = "0.7, 0.8, 0.9, 0.10, 1"
Fontconfig = "0.2, 0.3, 0.4, 0.5"
Colors = "0.11, 0.12"
Compose = "0.8, 0.9"
DocStringExtensions = "0.8"
Gadfly = "1"
KernelDensityEstimate = "0.5, 0.6"
julia = "0.7, 1"
KernelDensityEstimate = "0.5"
julia = "1.6"

[extras]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Cairo","Test"]
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# KernelDensityEstimatePlotting.jl

[![Build Status](https://travis-ci.org/JuliaRobotics/KernelDensityEstimatePlotting.jl.svg?branch=master)](https://travis-ci.org/JuliaRobotics/KernelDensityEstimatePlotting.jl)
[![codecov.io](https://codecov.io/github/JuliaRobotics/KernelDensityEstimatePlotting.jl/coverage.svg?branch=master)](https://codecov.io/github/JuliaRobotics/KernelDensityEstimatePlotting.jl?branch=master)
[![build-dev]][CI-url] [![codecov-img]][codecov-url]

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.

Expand Down Expand Up @@ -31,3 +30,11 @@ plot(p)
## More Examples

Please see examples on [KernelDensityEstimate.jl](https://github.com/JuliaRobotics/KernelDensityEstimate.jl).



[CI-url]: https://github.com/JuliaRobotics/KernelDensityEstimatePlotting.jl/actions/workflows/ci.yml
[build-dev]: https://github.com/JuliaRobotics/KernelDensityEstimatePlotting.jl/actions/workflows/ci.yml/badge.svg?branch=master

[codecov-url]: https://codecov.io/github/JuliaRobotics/KernelDensityEstimatePlotting.jl?branch=master
[codecov-img]: https://codecov.io/github/JuliaRobotics/KernelDensityEstimatePlotting.jl/coverage.svg?branch=master
74 changes: 35 additions & 39 deletions src/KernelDensityEstimatePlotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module KernelDensityEstimatePlotting

using LinearAlgebra, Statistics
using KernelDensityEstimate
using Gadfly, Colors, Cairo, Fontconfig, Compose
using Gadfly, Colors, Compose
# , Cairo, Fontconfig
using DocStringExtensions

import Gadfly: plot
# KDE imports will be remove when plotting is permanently removed from the KDE package
Expand Down Expand Up @@ -60,14 +62,14 @@ end
function draw1D!(bd::BallTreeDensity,
bins::AbstractArray{Float64,1},
e,
c::T="deepskyblue",
myStyle::T="";
c=colorant"deepskyblue",
myStyle::AbstractString="";
xlbl="X",
points::Bool=true,
selectedPoints=nothing,
legend=nothing,
title::NothingUnion{T}=nothing,
fill=false, layers::Bool=false ) where {T <: AbstractString}
title::NothingUnion{<:AbstractString}=nothing,
fill=false, layers::Bool=false )
#
global DOYTICKS

Expand Down Expand Up @@ -336,42 +338,35 @@ function drawAllPairs(xx::AbstractVector{<:BallTreeDensity};
return Nrow==1 && Ncol==1 ? subplots[1,1] : vstack(hh...)
end

# """
# $(SIGNATURES)

# Standardize the length colors used by RoMEPlotting, returns `::Vector{String}`.
# """
function getColorsByLength(len::Int=7)
len > 99 ? error("Don't have enough colors, 100 is the max.") : nothing
COLORS = String["red";"green";"blue";"magenta";"yellow";"deepskyblue"]
if len > 6
scale = len -7 + 2 # + 2 is artificial and avoids gray100==white
scale = 100/scale
for i in 7:len
push!(COLORS, "gray$(floor(Int,(i-7)*scale))")
end
end
return COLORS[1:len]
end
"""
$(SIGNATURES)
Standardize the length colors used by RoMEPlotting, returns `::Vector{String}`.
Notes:
- TODO, use `Colors.distinguishable_colors(10, [RGB(1,1,1), RGB(0,0,0)], dropseed=true)`
"""
getColorsByLength(len::Int=10) = Colors.distinguishable_colors(len, [RGB(1,1,1), RGB(0,0,0)], dropseed=true)


# 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::NothingUnion{Vector{<:AbstractString}}=getColorsByLength(length(darr)), # nothing
N::Int=200,
rmax=-Inf,rmin=Inf, # should be deprecated
axis::NothingUnion{Array{Float64,2}}=nothing,
dims::NothingUnion{VectorRange{Int}}=nothing,
xlbl::AbstractString="X", # to be deprecated
title::NothingUnion{<:AbstractString}=nothing,
legend::NothingUnion{Vector{<:AbstractString}}=nothing,
dimLbls::NothingUnion{Vector{<:AbstractString}}=nothing,
levels::NothingUnion{Int}=nothing,
fill=false,
points::Bool=true,
selectedPoints=nothing,
layers::Bool=false,
overlay=nothing )
c::NothingUnion{Vector{<:AbstractString}}=getColorsByLength(length(darr)), # nothing
N::Int=200,
rmax=-Inf,rmin=Inf, # should be deprecated
axis::NothingUnion{Array{Float64,2}}=nothing,
dims::NothingUnion{VectorRange{Int}}=nothing,
xlbl::AbstractString="X", # to be deprecated
title::NothingUnion{<:AbstractString}=nothing,
legend::NothingUnion{Vector{<:AbstractString}}=nothing,
dimLbls::NothingUnion{Vector{<:AbstractString}}=nothing,
levels::NothingUnion{Int}=nothing,
fill=false,
points::Bool=true,
selectedPoints=nothing,
layers::Bool=false,
overlay=nothing )
#
# defaults
defaultcolor = false
Expand Down Expand Up @@ -411,8 +406,9 @@ 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,range(rangeV[1],stop=rangeV[2],length=N), H,
c[i],xlbl=xlbl,legend=lg, title=title,
H=draw1D!(mbd, range(rangeV[1],stop=rangeV[2],length=N),
H, c[i];
xlbl=xlbl,legend=lg, title=title,
points=points, fill=fill, selectedPoints=selectedPoints ) #,argsPlot,argsKDE
else
#
Expand Down

0 comments on commit 8efc73a

Please sign in to comment.