Skip to content

Commit

Permalink
Merge pull request #78 from jebej/no-early-stringify
Browse files Browse the repository at this point in the history
don't stringify argument to `warn_on_recipe_aliases!` early
  • Loading branch information
daschw authored Feb 7, 2021
2 parents e5ced73 + 015dfbb commit 34bdb07
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions RecipesPipeline/src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
Warn if an alias is dedected in `plotattributes` after a recipe of type `recipe_type` is
applied to 'args'. `recipe_type` is either `:user`, `:type`, `:plot` or `:series`.
"""
function warn_on_recipe_aliases!(plt, plotattributes::AKW, recipe_type, signature_string) end
function warn_on_recipe_aliases!(plt, v::AbstractVector, recipe_type, signature_string)
function warn_on_recipe_aliases!(plt, plotattributes::AKW, recipe_type::Symbol, args) end
function warn_on_recipe_aliases!(plt, v::AbstractVector, recipe_type::Symbol, args)
for x in v
warn_on_recipe_aliases!(plt, x, recipe_type, signature_string)
warn_on_recipe_aliases!(plt, x, recipe_type, args)
end
end
function warn_on_recipe_aliases!(plt, rd::RecipeData, recipe_type, signature_string)
warn_on_recipe_aliases!(plt, rd.plotattributes, recipe_type, signature_string)
function warn_on_recipe_aliases!(plt, rd::RecipeData, recipe_type::Symbol, args)
warn_on_recipe_aliases!(plt, rd.plotattributes, recipe_type, args)
end


Expand Down
4 changes: 2 additions & 2 deletions RecipesPipeline/src/plot_recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function _process_plotrecipe(plt, kw, kw_list, still_to_process)
st = kw[:seriestype]
st = kw[:seriestype] = type_alias(plt, st)
datalist = RecipesBase.apply_recipe(kw, Val{st}, plt)
warn_on_recipe_aliases!(plt, datalist, :plot, plotrecipe_signature_string(st))
warn_on_recipe_aliases!(plt, datalist, :plot, st)
for data in datalist
preprocess_attributes!(plt, data.plotattributes)
if data.plotattributes[:seriestype] == st
Expand All @@ -49,4 +49,4 @@ function _process_plotrecipe(plt, kw, kw_list, still_to_process)
return
end

@specialize
@specialize
4 changes: 2 additions & 2 deletions RecipesPipeline/src/series_recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function _process_seriesrecipe(plt, plotattributes)
# get a sub list of series for this seriestype
x, y, z = plotattributes[:x], plotattributes[:y], plotattributes[:z]
datalist = RecipesBase.apply_recipe(plotattributes, Val{st}, x, y, z)
warn_on_recipe_aliases!(plt, datalist, :series, seriesrecipe_signature_string(st))
warn_on_recipe_aliases!(plt, datalist, :series, st)

# assuming there was no error, recursively apply the series recipes
for data in datalist
Expand All @@ -67,4 +67,4 @@ function _process_seriesrecipe(plt, plotattributes)
nothing
end

@specialize
@specialize
8 changes: 4 additions & 4 deletions RecipesPipeline/src/type_recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _apply_type_recipe(plotattributes, v, letter)
plt = plotattributes[:plot_object]
preprocess_axis_args!(plt, plotattributes, letter)
rdvec = RecipesBase.apply_recipe(plotattributes, typeof(v), v)
warn_on_recipe_aliases!(plotattributes[:plot_object], plotattributes, :type, typerecipe_signature_string(v))
warn_on_recipe_aliases!(plotattributes[:plot_object], plotattributes, :type, v)
postprocess_axis_args!(plt, plotattributes, letter)
return rdvec[1].args[1]
end
Expand All @@ -31,13 +31,13 @@ function _apply_type_recipe(plotattributes, v::AbstractArray, letter)
preprocess_axis_args!(plt, plotattributes, letter)
# First we try to apply an array type recipe.
w = RecipesBase.apply_recipe(plotattributes, typeof(v), v)[1].args[1]
warn_on_recipe_aliases!(plt, plotattributes, :type, typerecipe_signature_string(v))
warn_on_recipe_aliases!(plt, plotattributes, :type, v)
# If the type did not change try it element-wise
if typeof(v) == typeof(w)
isempty(skipmissing(v)) && return Float64[]
x = first(skipmissing(v))
args = RecipesBase.apply_recipe(plotattributes, typeof(x), x)[1].args
warn_on_recipe_aliases!(plt, plotattributes, :type, typerecipe_signature_string(x))
warn_on_recipe_aliases!(plt, plotattributes, :type, x)
postprocess_axis_args!(plt, plotattributes, letter)
if length(args) == 2 && all(arg -> arg isa Function, args)
numfunc, formatter = args
Expand Down Expand Up @@ -73,4 +73,4 @@ _apply_type_recipe(
) = v
_apply_type_recipe(plotattributes, v::Nothing, letter) = v

@specialize
@specialize
2 changes: 1 addition & 1 deletion RecipesPipeline/src/user_recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function _process_userrecipes!(plt, plotattributes, args)
else
rd_list =
RecipesBase.apply_recipe(next_series.plotattributes, next_series.args...)
warn_on_recipe_aliases!(plt, rd_list, :user, userrecipe_signature_string(next_series.args...))
warn_on_recipe_aliases!(plt, rd_list, :user, next_series.args)
prepend!(still_to_process, rd_list)
end
end
Expand Down
4 changes: 2 additions & 2 deletions RecipesPipeline/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ _map_funcs(fs::AVec{F}, u::AVec) where {F <: Function} = [map(f, u) for f in fs]

@nospecialize

function userrecipe_signature_string(args...)
function userrecipe_signature_string(args)
return string("(::", join(string.(typeof.(args)), ", ::"), ")")
end
typerecipe_signature_string(::T) where T = "(::Type{$T}, ::$T)"
plotrecipe_signature_string(st) = "(::Type{Val{:$st}}, ::AbstractPlot)"
seriesrecipe_signature_string(st) = "(::Type{Val{:$st}}, x, y, z)"

@specialize
@specialize

0 comments on commit 34bdb07

Please sign in to comment.