-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor marker and line attributes #4505
Open
BeastyBlacksmith
wants to merge
29
commits into
master
Choose a base branch
from
bbs/marknline
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0985edb
add attributes via `@add_attributes`
BeastyBlacksmith d12b770
use kwdef in add_attributes
BeastyBlacksmith 5dae3a3
complete marker attributes
BeastyBlacksmith 69e839a
rename yfill -> fill
BeastyBlacksmith aadc7a4
add alias_dict to add_attributes
BeastyBlacksmith 07aa435
add some tests
BeastyBlacksmith 7925968
make aliases work
BeastyBlacksmith f931f7a
complete legend aliases
BeastyBlacksmith dd1f611
add aliases to plotattr
BeastyBlacksmith 65fc04c
move aliases
BeastyBlacksmith 2ddf825
remove fill and errorbar
BeastyBlacksmith 0efda09
Revert "rename yfill -> fill"
BeastyBlacksmith 62fee9b
fix docstrings
BeastyBlacksmith 65fed0a
fix args test
BeastyBlacksmith f47764d
fix aliases, fill_z and filter compounds
BeastyBlacksmith 719f4b0
cosmetics
BeastyBlacksmith 38806ac
fix marker aliases in shapes
BeastyBlacksmith 5e1bd5e
wrap attributes in Attributes
BeastyBlacksmith 65116fb
move alias detection to DefaultDict
BeastyBlacksmith 867afa0
add test
BeastyBlacksmith 90bc39f
Merge remote-tracking branch 'origin/master' into bbs/marknline
BeastyBlacksmith bffd24d
make it precompile
BeastyBlacksmith 6dfba96
harmonize funciton
BeastyBlacksmith f737e0f
fix tests
BeastyBlacksmith 0150ad2
fix recipespipeline tests
BeastyBlacksmith 75db4f3
Merge branch 'master' into bbs/marknline
BeastyBlacksmith c49da28
adlust benchmarks, revert macro test
BeastyBlacksmith 33bae7f
don't dev Plots twice
BeastyBlacksmith 7705f8a
format
BeastyBlacksmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,28 +9,54 @@ const AKW = AbstractDict{Symbol,Any} | |||||||||||||
# ## DefaultsDict | ||||||||||||||
# -------------------------------- | ||||||||||||||
|
||||||||||||||
struct DefaultsDict <: AbstractDict{Symbol,Any} | ||||||||||||||
struct DefaultsDict{P} <: AbstractDict{Symbol,Any} | ||||||||||||||
plot_type::Type{P} | ||||||||||||||
explicit::KW | ||||||||||||||
defaults::KW | ||||||||||||||
function DefaultsDict{P}(plot_type::Type{P}, explicit::AbstractDict, defaults::AbstractDict) where {P} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
e = KW( | ||||||||||||||
key_alias(plot_type, k) => v === :seriestype ? type_alias(plot_type, v) : v | ||||||||||||||
for (k, v) in explicit | ||||||||||||||
) | ||||||||||||||
new{P}(plot_type, e, defaults) | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
Base.merge(d1::DefaultsDict, d2::DefaultsDict) = | ||||||||||||||
DefaultsDict(merge(d1.explicit, d2.explicit), merge(d1.defaults, d2.defaults)) | ||||||||||||||
Base.getindex(dd::DefaultsDict, k) = | ||||||||||||||
DefaultsDict(pt, e, d) = DefaultsDict{pt}(pt, e, d) | ||||||||||||||
function Base.merge(d1::DefaultsDict, d2::DefaultsDict) | ||||||||||||||
@assert d1.plot_type === d2.plot_type | ||||||||||||||
DefaultsDict( | ||||||||||||||
d1.plot_type, | ||||||||||||||
merge(d1.explicit, d2.explicit), | ||||||||||||||
merge(d1.defaults, d2.defaults), | ||||||||||||||
) | ||||||||||||||
end | ||||||||||||||
function Base.getindex(dd::DefaultsDict, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
if haskey(dd.explicit, k) | ||||||||||||||
dd.explicit[k] | ||||||||||||||
else | ||||||||||||||
dd.defaults[k] | ||||||||||||||
end | ||||||||||||||
Base.haskey(dd::DefaultsDict, k) = haskey(dd.explicit, k) || haskey(dd.defaults, k) | ||||||||||||||
Base.get(dd::DefaultsDict, k, default) = haskey(dd, k) ? dd[k] : default | ||||||||||||||
Base.get!(dd::DefaultsDict, k, default) = | ||||||||||||||
end | ||||||||||||||
function Base.haskey(dd::DefaultsDict, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
haskey(dd.explicit, k) || haskey(dd.defaults, k) | ||||||||||||||
end | ||||||||||||||
function Base.get(dd::DefaultsDict, k, default) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
haskey(dd, k) ? dd[k] : default | ||||||||||||||
end | ||||||||||||||
function Base.get!(dd::DefaultsDict, k, default) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
if haskey(dd, k) | ||||||||||||||
dd[k] | ||||||||||||||
else | ||||||||||||||
dd.defaults[k] = default | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
function Base.delete!(dd::DefaultsDict, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
haskey(dd.explicit, k) && delete!(dd.explicit, k) | ||||||||||||||
haskey(dd.defaults, k) && delete!(dd.defaults, k) | ||||||||||||||
dd | ||||||||||||||
|
@@ -46,12 +72,24 @@ function Base.iterate(dd::DefaultsDict, (key_list, i)) | |||||||||||||
(k => dd[k], (key_list, i + 1)) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
Base.copy(dd::DefaultsDict) = DefaultsDict(copy(dd.explicit), dd.defaults) | ||||||||||||||
Base.copy(dd::DefaultsDict) = DefaultsDict(dd.plot_type, copy(dd.explicit), dd.defaults) | ||||||||||||||
|
||||||||||||||
RecipesBase.is_explicit(dd::DefaultsDict, k) = haskey(dd.explicit, k) | ||||||||||||||
RecipesBase.is_default(dd::DefaultsDict, k) = !is_explicit(dd, k) && haskey(dd.defaults, k) | ||||||||||||||
function RecipesBase.is_explicit(dd::DefaultsDict, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
haskey(dd.explicit, k) | ||||||||||||||
end | ||||||||||||||
function RecipesBase.is_default(dd::DefaultsDict, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
!is_explicit(dd, k) && haskey(dd.defaults, k) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
Base.setindex!(dd::DefaultsDict, v, k) = dd.explicit[k] = v | ||||||||||||||
function Base.setindex!(dd::DefaultsDict, v, k) | ||||||||||||||
k = key_alias(dd.plot_type, k) | ||||||||||||||
if k === :seriestype | ||||||||||||||
v = type_alias(dd.plot_type, v) | ||||||||||||||
end | ||||||||||||||
dd.explicit[k] = v | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
# Reset to default value and return dict | ||||||||||||||
function reset_kw!(dd::DefaultsDict, k) | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,8 +6,10 @@ using Test | |||||||||||||
import RecipesPipeline: _prepare_series_data | ||||||||||||||
import RecipesBase | ||||||||||||||
|
||||||||||||||
struct MyPlot end | ||||||||||||||
|
||||||||||||||
@testset "DefaultsDict" begin | ||||||||||||||
dd = DefaultsDict(Dict(:foo => 1, :bar => missing), Dict(:foo => nothing, :baz => 'x')) | ||||||||||||||
dd = DefaultsDict(MyPlot, Dict(:foo => 1, :bar => missing), Dict(:foo => nothing, :baz => 'x')) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
|
||||||||||||||
@test all(explicitkeys(dd) .== [:bar, :foo]) | ||||||||||||||
@test all(defaultkeys(dd) .== [:baz, :foo]) | ||||||||||||||
|
@@ -44,7 +46,8 @@ end | |||||||||||||
@test !is_axis_attribute(plt, :foo) | ||||||||||||||
|
||||||||||||||
@test process_userrecipe!(plt, [:foo], :bar) == [:foo, :bar] | ||||||||||||||
@test type_alias(plt, :wireframe) ≡ :wireframe | ||||||||||||||
@test type_alias(typeof(plt), :wireframe) ≡ :wireframe | ||||||||||||||
@test key_alias(typeof(plt), :label) ≡ :label | ||||||||||||||
|
||||||||||||||
@test plot_setup!(plt, plotattributes, kw_list) isa Nothing | ||||||||||||||
@test slice_series_attributes!(plt, kw_list, kw) isa Nothing | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶