-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
A get API #4783
base: master
Are you sure you want to change the base?
A get API #4783
Changes from all commits
8e2959a
e53e7f1
ada3455
616cf00
a29dffe
9625c76
72dadb3
cb5dda9
a69160c
62c59d6
f39ae96
f679518
7642c0a
d9a8c38
cc4be02
1f4c0a5
5414fc4
aa234f8
516ad83
c657a47
2fb98a3
6543a42
3a19444
3962cb5
1bbf717
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,6 +35,8 @@ function animate end | |||||||||||||
# a placeholder to establish the name so that other packages (Plots.jl for example) | ||||||||||||||
# can add their own definition of RecipesBase.is_key_supported(k::Symbol) | ||||||||||||||
function is_key_supported end | ||||||||||||||
# funciton to determine canonical form of key in presence of aliases | ||||||||||||||
canonical_key(key) = key | ||||||||||||||
|
||||||||||||||
function grid end | ||||||||||||||
|
||||||||||||||
|
@@ -161,17 +163,27 @@ function process_recipe_body!(expr::Expr) | |||||||||||||
e = e.args[1] | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
# the unused operator `:=` will mean force: `x := 5` is equivalent to `x --> 5, force` | ||||||||||||||
# note: this means "x is defined as 5" | ||||||||||||||
if e.head === :(:=) | ||||||||||||||
force = true | ||||||||||||||
e.head = :(-->) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
# `$` will be the recommended way to retrieve values | ||||||||||||||
if e.head === :call && e.args[1] === :(<--) # binary use | ||||||||||||||
target, attribute = e.args[2], e.args[3] | ||||||||||||||
expr.args[i] = Expr(:(=), target, :(plotattributes[$RecipesBase.canonical_key($(attribute))])) | ||||||||||||||
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
|
||||||||||||||
elseif e.head === :$ # unary use | ||||||||||||||
expr.args[i] = :(plotattributes[$RecipesBase.canonical_key($(QuoteNode(only(e.args))))]) | ||||||||||||||
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
|
||||||||||||||
end | ||||||||||||||
|
||||||||||||||
# we are going to recursively swap out `a --> b, flags...` commands | ||||||||||||||
# note: this means "x may become 5" | ||||||||||||||
if e.head === :(-->) | ||||||||||||||
k, v = e.args | ||||||||||||||
k = canonical_key(k) | ||||||||||||||
if isa(k, Symbol) | ||||||||||||||
k = QuoteNode(k) | ||||||||||||||
end | ||||||||||||||
|
@@ -204,12 +216,9 @@ function process_recipe_body!(expr::Expr) | |||||||||||||
elseif e.head ≡ :return | ||||||||||||||
# To allow `return` in recipes just extract the returned arguments. | ||||||||||||||
expr.args[i] = first(e.args) | ||||||||||||||
|
||||||||||||||
elseif e.head ≢ :call | ||||||||||||||
# we want to recursively replace the arrows, but not inside function calls | ||||||||||||||
# as this might include things like Dict(1=>2) | ||||||||||||||
process_recipe_body!(e) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
process_recipe_body!(expr.args[i]) | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5,9 +5,13 @@ import RecipesBase as RB | |||||||
using StableRNGs | ||||||||
using Test | ||||||||
|
||||||||
|
||||||||
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
|
||||||||
const KW = Dict{Symbol,Any} | ||||||||
|
||||||||
RB.is_key_supported(k::Symbol) = true | ||||||||
# Reset method table so tests can be rerun (could be more robust) | ||||||||
recipe_methods = methods(RB.apply_recipe) | ||||||||
length(recipe_methods) > 2 && Base.delete_method.(methods(RB.apply_recipe)[setdiff(1:end, [1,8])]) | ||||||||
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
|
||||||||
|
||||||||
for t in map(i -> Symbol(:T, i), 1:5) | ||||||||
@eval struct $t end | ||||||||
|
@@ -139,9 +143,11 @@ end | |||||||
:markershape --> :auto, :require | ||||||||
:markercolor --> customcolor, :force | ||||||||
:xrotation --> 5 | ||||||||
:zrotation --> 6, :quiet | ||||||||
plotattributes[:hello] = "hi" | ||||||||
plotattributes[:world] = "world" | ||||||||
:zrotation --> $xrotation, :quiet | ||||||||
var = $markercolor | ||||||||
war <-- :markershape | ||||||||
plotattributes[:hello] = "$var" | ||||||||
plotattributes[:world] = "$war" | ||||||||
rand(StableRNG(1), 10, n) | ||||||||
end | ||||||||
check_apply_recipe( | ||||||||
|
@@ -151,9 +157,9 @@ end | |||||||
:markershape => :auto, | ||||||||
:markercolor => :red, | ||||||||
:xrotation => 5, | ||||||||
:zrotation => 6, | ||||||||
:hello => "hi", | ||||||||
:world => "world", | ||||||||
:zrotation => 5, | ||||||||
:hello => "red", | ||||||||
:world => "auto", | ||||||||
), | ||||||||
) | ||||||||
end | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,7 @@ export | |
BezierCurve, | ||
|
||
plotattr, | ||
getattr, | ||
scalefontsize, | ||
scalefontsizes, | ||
resetfontsizes | ||
|
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 🐶