From 011f51fbd91a7dac440569426b24766f39aa813f Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Fri, 19 Aug 2016 19:04:10 -0400 Subject: [PATCH] recipe postprocessing for aliases and magic args --- src/args.jl | 8 ++++---- src/pipeline.jl | 6 ++++++ test/runtests.jl | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/args.jl b/src/args.jl index b1e7c552..1592bd5e 100644 --- a/src/args.jl +++ b/src/args.jl @@ -688,7 +688,7 @@ function preprocessArgs!(d::KW) a = d[:arrow] d[:arrow] = if a == true arrow() - elseif a == false + elseif a in (false, nothing, :none) nothing elseif !(typeof(a) <: Arrow) arrow(wraptuple(a)...) @@ -698,9 +698,9 @@ function preprocessArgs!(d::KW) end - if get(d, :arrow, false) == true - d[:arrow] = arrow() - end + # if get(d, :arrow, false) == true + # d[:arrow] = arrow() + # end # legends if haskey(d, :legend) diff --git a/src/pipeline.jl b/src/pipeline.jl index 9e8c504e..817cbb9e 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -95,6 +95,7 @@ function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeD # when the arg tuple is empty, that means there's nothing left to recursively # process... finish up and add to the kw_list kw = recipedata.d + preprocessArgs!(kw) _preprocess_userrecipe(kw) warnOnUnsupported_scales(plt.backend, kw) @@ -183,6 +184,7 @@ function _process_plotrecipe(plt::Plot, kw::KW, kw_list::Vector{KW}, still_to_pr st = kw[:seriestype] = get(_typeAliases, st, st) datalist = RecipesBase.apply_recipe(kw, Val{st}, plt) for data in datalist + preprocessArgs!(data.d) if data.d[:seriestype] == st error("Plot recipe $st returned the same seriestype: $(data.d)") end @@ -389,6 +391,10 @@ function _process_seriesrecipe(plt::Plot, d::KW) # assuming there was no error, recursively apply the series recipes for data in datalist if isa(data, RecipeData) + preprocessArgs!(data.d) + if data.d[:seriestype] == st + error("The seriestype didn't change in series recipe $st. This will cause a StackOverflow.") + end _process_seriesrecipe(plt, data.d) else warn("Unhandled recipe: $(data)") diff --git a/test/runtests.jl b/test/runtests.jl index 7eb315f2..2d384136 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -85,6 +85,44 @@ facts("Axes") do end +# tests for preprocessing recipes + +# facts("recipes") do + + # user recipe + + # type T end + # @recipe function f(::T) + # line := (3,0.3,:red) + # marker := (20,0.5,:blue,:o) + # bg := :yellow + # rand(10) + # end + # plot(T()) + + # plot recipe + + # @recipe function f(::Type{Val{:hiplt}},plt::Plot) + # line := (3,0.3,:red) + # marker := (20,0.5,:blue,:o) + # t := :path + # bg:=:green + # () + # end + # plot(rand(10),t=:hiplt) + + # series recipe + + # @recipe function f(::Type{Val{:hi}},x,y,z) + # line := (3,0.3,:red) + # marker := (20,0.5,:blue,:o) + # t := :path + # () + # end + # plot(rand(10),t=:hiplt) + +# end + FactCheck.exitstatus()