From 33602aca11baedc8e230aea4644ad63f226c7f3f Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 23 Sep 2015 13:03:37 -0400 Subject: [PATCH] fixed tests --- docs/example_generation.jl | 2 +- src/args.jl | 9 ++++++++- src/plot.jl | 2 ++ src/utils.jl | 3 +++ test/runtests.jl | 4 ++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/example_generation.jl b/docs/example_generation.jl index f4b84c4c..87a143c6 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -236,7 +236,7 @@ function buildReadme() # build keyword arg table table = "Keyword | Default | Type | Aliases \n---- | ---- | ---- | ----\n" for d in (Plots._seriesDefaults, Plots._plotDefaults) - for k in sort(collect(keys(d))) + for k in sortedkeys(d) aliasstr = createStringOfMarkDownSymbols(aliases(Plots._keyAliases, k)) table = string(table, "`:$k` | `$(d[k])` | $(d==Plots._seriesDefaults ? "Series" : "Plot") | $aliasstr \n") end diff --git a/src/args.jl b/src/args.jl index 183166ed..8dd9af1d 100644 --- a/src/args.jl +++ b/src/args.jl @@ -153,7 +153,7 @@ end function aliases(aliasMap::Dict, val) # sort(vcat(val, collect(keys(filter((k,v)-> v==val, aliasMap))))) - sort(collect(keys(filter((k,v)-> v==val, aliasMap)))) + sortedkeys(filter((k,v)-> v==val, aliasMap)) end # ----------------------------------------------------------------------------- @@ -247,6 +247,13 @@ end # ----------------------------------------------------------------------------- +function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict) + for k in sortedkeys(d) + if !(k in supportedArgs(pkg)) + warn("Keyword argument $k not supported with $pkg. Choose from: $(supportedArgs(pkg))") + end + end +end function warnOnUnsupported(pkg::PlottingPackage, d::Dict) diff --git a/src/plot.jl b/src/plot.jl index a8a82fff..bcff8abb 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -81,6 +81,8 @@ function plot!(plt::Plot, args...; kw...) d = Dict(kw) replaceAliases!(d, _keyAliases) + warnOnUnsupportedArgs(plt.plotter, d) + # TODO: handle a "group by" mechanism. # will probably want to check for the :group kw param, and split into # index partitions/filters to be passed through to the next step. diff --git a/src/utils.jl b/src/utils.jl index 5d7478e6..2355d386 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -118,6 +118,9 @@ function replaceAliases!(d::Dict, aliases::Dict) end +sortedkeys(d::Dict) = sort(collect(keys(d))) + + function regressionXY(x, y) # regress β, α = [x ones(length(x))] \ y diff --git a/test/runtests.jl b/test/runtests.jl index abd5cfef..a7ccb9ef 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,7 +13,7 @@ try facts("Gadfly") do @fact plotter!(:gadfly) --> Plots.GadflyPackage() @fact plotter() --> Plots.GadflyPackage() - @fact typeof(plot(1:10)) --> Plots.Plot + @fact typeof(plot(1:10)) --> Plots.Plot{Plots.GadflyPackage} # plot(x::AVec, y::AVec; kw...) # one line (will assert length(x) == length(y)) @@ -43,7 +43,7 @@ try facts("Qwt") do @fact plotter!(:qwt) --> Plots.QwtPackage() @fact plotter() --> Plots.QwtPackage() - @fact typeof(plot(1:10)) --> Plots.Plot + @fact typeof(plot(1:10)) --> Plots.Plot{Plots.QwtPackage} # plot(y::AVec; kw...) # one line... x = 1:length(y) @fact plot(1:10) --> not(nothing)