From 932d0da73de46dc271947a73299479f5b182a0ec Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 26 Mar 2020 15:09:31 +0100 Subject: [PATCH] move `replaceAliases!` out of recipe processing --- src/args.jl | 4 ++-- src/pipeline.jl | 6 +++--- src/series.jl | 2 -- src/types.jl | 7 ++++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/args.jl b/src/args.jl index 82ca09d8..b388c641 100644 --- a/src/args.jl +++ b/src/args.jl @@ -916,8 +916,8 @@ function _add_markershape(plotattributes::AKW) end "Handle all preprocessing of args... break out colors/sizes/etc and replace aliases." -function preprocessArgs!(plotattributes::AKW) - replaceAliases!(plotattributes, _keyAliases) +function preprocessArgs!(plotattributes::AKW, replace_aliases = true) + replace_aliases && replaceAliases!(plotattributes, _keyAliases) # clear all axis stuff # if haskey(plotattributes, :axis) && plotattributes[:axis] in (:none, nothing, false) diff --git a/src/pipeline.jl b/src/pipeline.jl index 1e9cd991..383ac82a 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -96,7 +96,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.plotattributes - preprocessArgs!(kw) + preprocessArgs!(kw, false) _preprocess_userrecipe(kw) warnOnUnsupported_scales(plt.backend, kw) @@ -185,7 +185,7 @@ function _process_plotrecipe(plt::Plot, kw::AKW, kw_list::Vector{KW}, still_to_p st = kw[:seriestype] = get(_typeAliases, st, st) datalist = RecipesBase.apply_recipe(kw, Val{st}, plt) for data in datalist - preprocessArgs!(data.plotattributes) + preprocessArgs!(data.plotattributes, false) if data.plotattributes[:seriestype] == st error("Plot recipe $st returned the same seriestype: $(data.plotattributes)") end @@ -413,7 +413,7 @@ function _process_seriesrecipe(plt::Plot, plotattributes::AKW) # assuming there was no error, recursively apply the series recipes for data in datalist if isa(data, RecipeData) - preprocessArgs!(data.plotattributes) + preprocessArgs!(data.plotattributes, false) if data.plotattributes[:seriestype] == st error("The seriestype didn't change in series recipe $st. This will cause a StackOverflow.") end diff --git a/src/series.jl b/src/series.jl index afebde8e..3e76d93a 100644 --- a/src/series.jl +++ b/src/series.jl @@ -227,7 +227,6 @@ _apply_type_recipe(plotattributes, v::AbstractArray{<:DataPoint}, letter) = v # axis args before type recipes should still be mapped to all axes function _preprocess_axis_args!(plotattributes) - replaceAliases!(plotattributes, _keyAliases) for (k, v) in plotattributes if haskey(_axis_defaults, k) pop!(plotattributes, k) @@ -247,7 +246,6 @@ end function _postprocess_axis_args!(plotattributes, letter) pop!(plotattributes, :letter) if letter in (:x, :y, :z) - replaceAliases!(plotattributes, _keyAliases) for (k, v) in plotattributes if haskey(_axis_defaults, k) pop!(plotattributes, k) diff --git a/src/types.jl b/src/types.jl index 4ee8e9e0..a866e59f 100644 --- a/src/types.jl +++ b/src/types.jl @@ -26,8 +26,9 @@ struct Attr <: AbstractDict{Symbol,Any} defaults::KW end -Base.getindex(attr::Attr, k) = haskey(attr.explicit,k) ? - attr.explicit[k] : attr.defaults[k] +function Base.getindex(attr::Attr, k) + return haskey(attr.explicit, k) ? attr.explicit[k] : attr.defaults[k] +end Base.haskey(attr::Attr, k) = haskey(attr.explicit,k) || haskey(attr.defaults,k) Base.get(attr::Attr, k, default) = haskey(attr, k) ? attr[k] : default function Base.get!(attr::Attr, k, default) @@ -41,7 +42,7 @@ end function Base.delete!(attr::Attr, k) haskey(attr.explicit, k) && delete!(attr.explicit, k) haskey(attr.defaults, k) && delete!(attr.defaults, k) -end +end Base.length(attr::Attr) = length(union(keys(attr.explicit), keys(attr.defaults))) function Base.iterate(attr::Attr) exp_keys = keys(attr.explicit)