Skip to content

Commit

Permalink
Merge pull request #12 from SebastianM-C/vc2
Browse files Browse the repository at this point in the history
Attempt to complete pipeline change
  • Loading branch information
daschw authored Mar 14, 2020
2 parents 4b9cf60 + 9580d06 commit 281cc13
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
2 changes: 1 addition & 1 deletion RecipesPipeline/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "RecipeUtils"
name = "RecipePipeline"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
authors = ["Michael Krabbe Borregaard <[email protected]>"]
version = "0.1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module RecipeUtils
module RecipePipeline

import RecipesBase
include("pipeline.jl")
include("process_recipes.jl")

end # module
63 changes: 47 additions & 16 deletions RecipesPipeline/src/pipeline.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
## Stubs
function _recipe_init!(plt, plotattributes, args) end
function _recipe_after_user!(plt, plotattributes, args) end
function _recipe_after_plot!(plt, plotattributes, args) end
function _recipe_after_series!(plt, plotattributes, args, series_ind) end
function _recipe_after_plot!(plt, plotattributes, kw_list) end
function _recipe_before_series!(plt, kw, kw_list) end
function _recipe_finish!(plt, plotattributes, args) end

##
# Here comes the specification of when which recipe is processed.
# It contains functions before and after every stage for interaction with the plotting package.

function recipe_pipeline!(plt, # frontend specific representation of a plot
plotattributes, # current state of recipe keywords
args, # set of arguments passed by the user
)
_recipe_init!(plt, plotattributes, args)
kw_list = _process_userrecipes(plt, plotattributes, args)
_recipe_after_user!(plt, plotattributes, args)
kw_list = _process_plotrecipes(plt, plotattributes, args)
_recipe_after_plot!(plt, plotattributes, args)
for (series_ind, series) in enumerate(series_list)
kw_list = _process_seriesrecipe(plt, plotattributes)
_recipe_after_series!(plt, plotattributes, series_ind)
end
_recipe_finish!((plt, plotattributes, args)
function recipe_pipeline!(plt, # frontend specific representation of a plot
plotattributes, # current state of recipe keywords
args; # set of arguments passed by the user
type_aliases)

_recipe_init!(plt, plotattributes, args)

# --------------------------------
# "USER RECIPES"
# --------------------------------

kw_list = _process_userrecipes(plt, plotattributes, args)
_recipe_after_user!(plt, plotattributes, args)

# --------------------------------
# "PLOT RECIPES"
# --------------------------------

# "plot recipe", which acts like a series type, and is processed before
# the plot layout is created, which allows for setting layouts and other plot-wide attributes.
# we get inputs which have been fully processed by "user recipes" and "type recipes",
# so we can expect standard vectors, surfaces, etc. No defaults have been set yet.
still_to_process = kw_list
kw_list = Dict{Symbol,Any}[]
while !isempty(still_to_process)
next_kw = popfirst!(still_to_process)
_process_plotrecipe(plt, next_kw, kw_list, still_to_process; type_aliases=type_aliases)
end

_recipe_after_plot!(plt, plotattributes, kw_list)

# !!! note: At this point, kw_list is fully decomposed into individual series... one KW per series. !!!
# !!! The next step is to recursively apply series recipes until the backend supports that series type !!!

# --------------------------------
# "SERIES RECIPES"
# --------------------------------

for kw in kw_list
series_attr = _recipe_before_series!(plt, kw, kw_list)
kw_list = _process_seriesrecipe(plt, series_attr)
end

_recipe_finish!(plt, plotattributes, args)
end
3 changes: 2 additions & 1 deletion RecipesPipeline/src/process_recipes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

_preprocess_args(p, args, s) = args #needs to modify still_to_process
_process_userrecipe(plt, kw_list, next_series) = nothing
preprocessArgs!(p) = p
is_st_supported(st) = true
finalize_subplot!(plt, att) = nothing
Expand Down Expand Up @@ -72,7 +73,7 @@ end

# this method recursively applies series recipes when the seriestype is not supported
# natively by the backend
function _process_seriesrecipe(plt, plotattributes::AbstractDict{Symbol,Any}; _typeAliases::AbstractDict{Symbol,Symbol}=Dict())
function _process_seriesrecipe(plt, plotattributes::AbstractDict{Symbol,Any}; type_aliases::AbstractDict{Symbol,Symbol})
#println("process $(typeof(plotattributes))")
# replace seriestype aliases
st = Symbol(plotattributes[:seriestype])
Expand Down
4 changes: 2 additions & 2 deletions RecipesPipeline/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using RecipeUtils
using RecipePipeline
using Test

@testset "RecipeUtils.jl" begin
@testset "RecipePipeline.jl" begin
# Write your own tests here.
end

0 comments on commit 281cc13

Please sign in to comment.