From 8e2959a0cffc161fc8f12244cb74e99af050cbeb Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 13:30:03 +0200 Subject: [PATCH 01/24] basic extraction form Plot --- src/Plots.jl | 1 + src/plotattr.jl | 38 ++++++++++++++++++++++++++++++++++++++ test/test_plotattr.jl | 10 ++++++++++ 3 files changed, 49 insertions(+) create mode 100644 test/test_plotattr.jl diff --git a/src/Plots.jl b/src/Plots.jl index 3c8e6b942..869d7e369 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -122,6 +122,7 @@ export BezierCurve, plotattr, + getattr, scalefontsize, scalefontsizes, resetfontsizes diff --git a/src/plotattr.jl b/src/plotattr.jl index 69018dc64..f496f54d2 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -99,3 +99,41 @@ function plotattr(attrtype::Symbol, attribute::Symbol) def == "" ? "" : ", defaults to `$def`.", ) end + +function getattr(plot::Plot, s::Symbol) + attribute = get(_keyAliases, s, s) + if attribute ∈ _all_plot_args + return plot[attribute] + elseif attribute ∈ _all_subplot_args + return getindex.(plot.layout.grid, attribute) + elseif attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args + if attribute ∈ _lettered_all_axis_args + letters = collect(String(attribute)) + letter = Symbol(first(letters)) + attribute = Symbol(letters[2:end]...) + axis = get_attr_symbol(letter, :axis) + getindex.(getindex.(plot.layout.grid, axis), attribute) + else + axes = (:xaxis, :yaxis, :zaxis) + return map(plot.subplots) do sp + return NamedTuple(axis => sp[axis][attribute] for axis in axes) + end + end + elseif attribute ∈ _all_series_args + return reduce(hcat, map(plot.series_list) do series + series[attribute] + end) + else + # TODO: handle magic and extra kwargs + throw(ArgumentError("Attribute not found.")) + end +end +function getattr(sp::Sublot, s::Symbol) + attribute = get(_keyAliases, s, s) +end +function getattr(plot::Axis, s::Symbol) + attribute = get(_keyAliases, s, s) +end +function getattr(plot::Series, s::Symbol) + attribute = get(_keyAliases, s, s) +end diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl new file mode 100644 index 000000000..275d9cf63 --- /dev/null +++ b/test/test_plotattr.jl @@ -0,0 +1,10 @@ +using Plots, Test + +tplot = plot([1:5, 1:5, 2:6, 2:6], layout = 2, this = :that, line = (5, :dash), title = ["A" "B"], xlims=[:auto (0,Inf)]) +@testset "Get attributes" begin + @test getattr(tplot, :size) == default(:size) == getattr(tplot, :sizes) + @test getattr(tplot, :linestyle) == permutedims(fill(:dash, 4)) + @test getattr(tplot, :title) == ["A" "B"] + @test getattr(tplot, :xlims) == [:auto (0, Inf)] #Note: this is different from Plots.xlims.(tplot.subplots) + @test getattr(tplot, :lims) == [(xaxis = :auto, yaxis = :auto, zaxis = :auto), (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto)] +end From e53e7f1bc8e50b7e97726eef96d5891a04d9db47 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 14:18:59 +0200 Subject: [PATCH 02/24] extra_kwargs for Plot --- src/plotattr.jl | 38 +++++++++++++++++++++++--------------- test/test_plotattr.jl | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/plotattr.jl b/src/plotattr.jl index f496f54d2..9549e7e04 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -100,40 +100,48 @@ function plotattr(attrtype::Symbol, attribute::Symbol) ) end -function getattr(plot::Plot, s::Symbol) +function getattr(plt::Plot, s::Symbol) attribute = get(_keyAliases, s, s) if attribute ∈ _all_plot_args - return plot[attribute] + return plt[attribute] elseif attribute ∈ _all_subplot_args - return getindex.(plot.layout.grid, attribute) + return reduce(hcat, getindex.(plt.subplots, attribute)) elseif attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args if attribute ∈ _lettered_all_axis_args letters = collect(String(attribute)) letter = Symbol(first(letters)) attribute = Symbol(letters[2:end]...) axis = get_attr_symbol(letter, :axis) - getindex.(getindex.(plot.layout.grid, axis), attribute) + reduce(hcat, getindex.(getindex.(plt.subplots, axis), attribute)) else axes = (:xaxis, :yaxis, :zaxis) - return map(plot.subplots) do sp + return map(plt.subplots) do sp return NamedTuple(axis => sp[axis][attribute] for axis in axes) end end elseif attribute ∈ _all_series_args - return reduce(hcat, map(plot.series_list) do series + return reduce(hcat, map(plt.series_list) do series series[attribute] end) else # TODO: handle magic and extra kwargs + extra_kwargs = Dict( + :plot => + haskey(plt[:extra_plot_kwargs], attribute) ? + plt[:extra_plot_kwargs][attribute] : [], + :subplots => [ + i => sp[:extra_kwargs][attribute] for + (i, sp) in enumerate(plt.subplots) if haskey(sp[:extra_kwargs], attribute) + ], + :series => [ + i => series[:extra_kwargs][attribute] for (i, series) in enumerate(plt.series_list) if + haskey(series[:extra_kwargs], attribute) + ], + ) + !all(isempty, values(extra_kwargs)) && return extra_kwargs throw(ArgumentError("Attribute not found.")) end end -function getattr(sp::Sublot, s::Symbol) - attribute = get(_keyAliases, s, s) -end -function getattr(plot::Axis, s::Symbol) - attribute = get(_keyAliases, s, s) -end -function getattr(plot::Series, s::Symbol) - attribute = get(_keyAliases, s, s) -end +getattr(sp::Subplot, s::Symbol) = attribute = get(_keyAliases, s, s) +getattr(axis::Axis, s::Symbol) = attribute = get(_keyAliases, s, s) +getattr(series::Series, s::Symbol) = attribute = get(_keyAliases, s, s) diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl index 275d9cf63..f7f94c90f 100644 --- a/test/test_plotattr.jl +++ b/test/test_plotattr.jl @@ -1,10 +1,38 @@ using Plots, Test -tplot = plot([1:5, 1:5, 2:6, 2:6], layout = 2, this = :that, line = (5, :dash), title = ["A" "B"], xlims=[:auto (0,Inf)]) +tplot = plot( + repeat([1:5, 2:6], inner = 3), + layout = @layout([a b; c]), + this = :that, + line = (5, :dash), + title = ["A" "B"], + xlims = [:auto (0, Inf)], +) @testset "Get attributes" begin - @test getattr(tplot, :size) == default(:size) == getattr(tplot, :sizes) - @test getattr(tplot, :linestyle) == permutedims(fill(:dash, 4)) - @test getattr(tplot, :title) == ["A" "B"] - @test getattr(tplot, :xlims) == [:auto (0, Inf)] #Note: this is different from Plots.xlims.(tplot.subplots) - @test getattr(tplot, :lims) == [(xaxis = :auto, yaxis = :auto, zaxis = :auto), (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto)] + @testset "From Plot" begin + @test getattr(tplot, :size) == default(:size) == getattr(tplot, :sizes) + @test getattr(tplot, :linestyle) == permutedims(fill(:dash, 6)) + @test getattr(tplot, :title) == ["A" "B" "A"] + @test getattr(tplot, :xlims) == [:auto (0, Inf) :auto] #Note: this is different from Plots.xlims.(tplot.subplots) + @test getattr(tplot, :lims) == [ + (xaxis = :auto, yaxis = :auto, zaxis = :auto), + (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto), + (xaxis = :auto, yaxis = :auto, zaxis = :auto), + ] + @test getattr(tplot, :this) == Dict( + :series => + [1 => :that, 2 => :that, 3 => :that, 4 => :that, 5 => :that, 6 => :that], + :subplots => Any[], + :plot => Any[], + ) + @test_throws ArgumentError getattr(tplot, :nothere) + end + # @testset "From Sublot" begin + # sp = tplot[2] + # @test getattr(sp, :size) == default(:size) == getattr(sp, :sizes) + # @test getattr(sp, :linestyle) == permutedims(fill(:dash, 2)) + # @test getattr(sp, :title) == "B" + # @test getattr(sp, :xlims) == (0, Inf) + # @test getattr(sp, :lims) == (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto) + # end end From ada3455ce6acfc38d5d26b73488026f488a59cea Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 14:33:05 +0200 Subject: [PATCH 03/24] handle magic arguments for Plot --- src/plotattr.jl | 10 +++++++--- test/test_plotattr.jl | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plotattr.jl b/src/plotattr.jl index 9549e7e04..b8dc673aa 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -104,9 +104,9 @@ function getattr(plt::Plot, s::Symbol) attribute = get(_keyAliases, s, s) if attribute ∈ _all_plot_args return plt[attribute] - elseif attribute ∈ _all_subplot_args + elseif attribute ∈ _all_subplot_args && attribute ∉ _magic_subplot_args return reduce(hcat, getindex.(plt.subplots, attribute)) - elseif attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args + elseif (attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args) && attribute ∉ _magic_axis_args if attribute ∈ _lettered_all_axis_args letters = collect(String(attribute)) letter = Symbol(first(letters)) @@ -119,12 +119,16 @@ function getattr(plt::Plot, s::Symbol) return NamedTuple(axis => sp[axis][attribute] for axis in axes) end end - elseif attribute ∈ _all_series_args + elseif attribute ∈ _all_series_args && attribute ∉ _magic_series_args return reduce(hcat, map(plt.series_list) do series series[attribute] end) else # TODO: handle magic and extra kwargs + if attribute in _all_magic_args + @info "$attribute is a magic argument. These are not present in the Plot object. Please use the more specific attribute, such as `linestyle` instead of `line`." + return missing + end extra_kwargs = Dict( :plot => haskey(plt[:extra_plot_kwargs], attribute) ? diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl index f7f94c90f..176787343 100644 --- a/test/test_plotattr.jl +++ b/test/test_plotattr.jl @@ -25,6 +25,10 @@ tplot = plot( :subplots => Any[], :plot => Any[], ) + @test (@test_logs ( + :info, + r"line is a magic argument", + ) getattr(tplot, :line)) === missing @test_throws ArgumentError getattr(tplot, :nothere) end # @testset "From Sublot" begin From 616cf008535f2d26f7fcb5e8e5537bb08ffc73a5 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 14:57:06 +0200 Subject: [PATCH 04/24] factor out --- src/plotattr.jl | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/plotattr.jl b/src/plotattr.jl index b8dc673aa..ec231dc80 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -102,29 +102,45 @@ end function getattr(plt::Plot, s::Symbol) attribute = get(_keyAliases, s, s) + _getattr(plt, plt.subplots, plt.series_list, attribute) +end +function getattr(sp::Subplot, s::Symbol) + attribute = get(_keyAliases, s, s) + _getattr(sp.plt, [sp], sp.series_list, attribute) +end +function getattr(axis::Axis, s::Symbol) + attribute = get(_keyAliases, s, s) + _getattr(only(axis.sps).plt, axis.sps, only(axis.sps).series_list, attribute) +end +# TODO: to implement this we need a series to know its subplot +# function getattr(series::Series, s::Symbol) +# attribute = get(_keyAliases, s, s) +# _getattr(plt, plt.subplots, [series], attribute) +# end + +function _getattr(plt::Plot, subplots::Vector{Subplot}, serieses::Vector{Series}, attribute::Symbol) if attribute ∈ _all_plot_args return plt[attribute] elseif attribute ∈ _all_subplot_args && attribute ∉ _magic_subplot_args - return reduce(hcat, getindex.(plt.subplots, attribute)) + return reduce(hcat, getindex.(subplots, attribute)) elseif (attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args) && attribute ∉ _magic_axis_args if attribute ∈ _lettered_all_axis_args letters = collect(String(attribute)) letter = Symbol(first(letters)) attribute = Symbol(letters[2:end]...) axis = get_attr_symbol(letter, :axis) - reduce(hcat, getindex.(getindex.(plt.subplots, axis), attribute)) + reduce(hcat, getindex.(getindex.(subplots, axis), attribute)) else axes = (:xaxis, :yaxis, :zaxis) - return map(plt.subplots) do sp + return map(subplots) do sp return NamedTuple(axis => sp[axis][attribute] for axis in axes) end end elseif attribute ∈ _all_series_args && attribute ∉ _magic_series_args - return reduce(hcat, map(plt.series_list) do series + return reduce(hcat, map(serieses) do series series[attribute] end) else - # TODO: handle magic and extra kwargs if attribute in _all_magic_args @info "$attribute is a magic argument. These are not present in the Plot object. Please use the more specific attribute, such as `linestyle` instead of `line`." return missing @@ -135,10 +151,10 @@ function getattr(plt::Plot, s::Symbol) plt[:extra_plot_kwargs][attribute] : [], :subplots => [ i => sp[:extra_kwargs][attribute] for - (i, sp) in enumerate(plt.subplots) if haskey(sp[:extra_kwargs], attribute) + (i, sp) in enumerate(subplots) if haskey(sp[:extra_kwargs], attribute) ], :series => [ - i => series[:extra_kwargs][attribute] for (i, series) in enumerate(plt.series_list) if + i => series[:extra_kwargs][attribute] for (i, series) in enumerate(serieses) if haskey(series[:extra_kwargs], attribute) ], ) @@ -146,6 +162,3 @@ function getattr(plt::Plot, s::Symbol) throw(ArgumentError("Attribute not found.")) end end -getattr(sp::Subplot, s::Symbol) = attribute = get(_keyAliases, s, s) -getattr(axis::Axis, s::Symbol) = attribute = get(_keyAliases, s, s) -getattr(series::Series, s::Symbol) = attribute = get(_keyAliases, s, s) From a29dffe572afbd99829d2b764f04afb77a9c5bfd Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 17:17:42 +0200 Subject: [PATCH 05/24] tests for axis and subplot --- src/plotattr.jl | 5 +++- test/test_plotattr.jl | 69 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/src/plotattr.jl b/src/plotattr.jl index ec231dc80..c6b7397b3 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -110,6 +110,9 @@ function getattr(sp::Subplot, s::Symbol) end function getattr(axis::Axis, s::Symbol) attribute = get(_keyAliases, s, s) + if attribute in _axis_args + attribute = get_attr_symbol(axis[:letter], attribute) + end _getattr(only(axis.sps).plt, axis.sps, only(axis.sps).series_list, attribute) end # TODO: to implement this we need a series to know its subplot @@ -118,7 +121,7 @@ end # _getattr(plt, plt.subplots, [series], attribute) # end -function _getattr(plt::Plot, subplots::Vector{Subplot}, serieses::Vector{Series}, attribute::Symbol) +function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{Series}, attribute::Symbol) if attribute ∈ _all_plot_args return plt[attribute] elseif attribute ∈ _all_subplot_args && attribute ∉ _magic_subplot_args diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl index 176787343..80444ba20 100644 --- a/test/test_plotattr.jl +++ b/test/test_plotattr.jl @@ -31,12 +31,65 @@ tplot = plot( ) getattr(tplot, :line)) === missing @test_throws ArgumentError getattr(tplot, :nothere) end - # @testset "From Sublot" begin - # sp = tplot[2] - # @test getattr(sp, :size) == default(:size) == getattr(sp, :sizes) - # @test getattr(sp, :linestyle) == permutedims(fill(:dash, 2)) - # @test getattr(sp, :title) == "B" - # @test getattr(sp, :xlims) == (0, Inf) - # @test getattr(sp, :lims) == (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto) - # end + @testset "From Sublot" begin + sp = tplot[2] + @test getattr(sp, :size) == default(:size) == getattr(sp, :sizes) + @test getattr(sp, :linestyle) == permutedims(fill(:dash, 2)) + @test getattr(sp, :title) == "B" + @test getattr(sp, :xlims) == (0, Inf) + @test getattr(sp, :lims) == [ + (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto), + ] + @test_broken getattr(sp, :this) == Dict( + :series => + [2 => :that, 5 => :that], # TODO: would be good if Series knew their ID + :subplots => Any[], + :plot => Any[], + ) + @test (@test_logs ( + :info, + r"line is a magic argument", + ) getattr(sp, :line)) === missing + @test_throws ArgumentError getattr(sp, :nothere) + end + @testset "From Axis" begin + axis = tplot[3][:yaxis] + @test getattr(axis, :size) == default(:size) == getattr(axis, :sizes) + @test getattr(axis, :linestyle) == permutedims(fill(:dash, 2)) + @test getattr(axis, :title) == "A" + @test getattr(axis, :xlims) === :auto # TODO: is this expected? + @test getattr(axis, :lims) == :auto + @test_broken getattr(axis, :this) == Dict( + :series => + [3 => :that, 6 => :that], # TODO: would be good if Series knew their ID + :subplots => Any[], + :plot => Any[], + ) + @test (@test_logs ( + :info, + r"line is a magic argument", + ) getattr(axis, :line)) === missing + @test_throws ArgumentError getattr(axis, :nothere) + end + @testset "From Series" begin + series = tplot[1][1] + @test getattr(series, :size) == default(:size) == getattr(series, :sizes) + @test getattr(series, :linestyle) == :dash + @test getattr(series, :title) == "A" + @test getattr(series, :xlims) == :auto + @test getattr(series, :lims) == [ + (xaxis = :auto, yaxis = :auto, zaxis = :auto), + ] + @test_broken getattr(series, :this) == Dict( + :series => + [1 => :that, 4 => :that], # TODO: would be good if Series knew their ID + :subplots => Any[], + :plot => Any[], + ) + @test (@test_logs ( + :info, + r"line is a magic argument", + ) getattr(series, :line)) === missing + @test_throws ArgumentError getattr(series, :nothere) + end end From 9625c76998b1993a2ad7dd100af94802390b5c5b Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 17:36:56 +0200 Subject: [PATCH 06/24] implement getting from series --- src/pipeline.jl | 2 +- src/plotattr.jl | 14 +++++++------- src/types.jl | 5 ++++- test/test_plotattr.jl | 12 ++++++------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/pipeline.jl b/src/pipeline.jl index 3babfb5ab..1e7fb58c6 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -456,7 +456,7 @@ function _add_the_series(plt, sp, plotattributes) throw(ArgumentError("Unsupported type for extra keyword arguments")) end warn_on_unsupported(plt.backend, plotattributes) - series = Series(plotattributes) + series = Series(length(plt.series_list) + 1, sp, plotattributes) push!(plt.series_list, series) if (z_order = plotattributes[:z_order]) === :front push!(sp.series_list, series) diff --git a/src/plotattr.jl b/src/plotattr.jl index c6b7397b3..eaa1b9b06 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -115,13 +115,13 @@ function getattr(axis::Axis, s::Symbol) end _getattr(only(axis.sps).plt, axis.sps, only(axis.sps).series_list, attribute) end -# TODO: to implement this we need a series to know its subplot -# function getattr(series::Series, s::Symbol) -# attribute = get(_keyAliases, s, s) -# _getattr(plt, plt.subplots, [series], attribute) -# end -function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{Series}, attribute::Symbol) +function getattr(series::Series, s::Symbol) + attribute = get(_keyAliases, s, s) + _getattr(series.subplot.plt, [series.subplot], [series], attribute) +end + +function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{<:Series}, attribute::Symbol) if attribute ∈ _all_plot_args return plt[attribute] elseif attribute ∈ _all_subplot_args && attribute ∉ _magic_subplot_args @@ -157,7 +157,7 @@ function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{Serie (i, sp) in enumerate(subplots) if haskey(sp[:extra_kwargs], attribute) ], :series => [ - i => series[:extra_kwargs][attribute] for (i, series) in enumerate(serieses) if + series.id => series[:extra_kwargs][attribute] for series in serieses if haskey(series[:extra_kwargs], attribute) ], ) diff --git a/src/types.jl b/src/types.jl index 6dc6067e2..5270645f3 100644 --- a/src/types.jl +++ b/src/types.jl @@ -15,7 +15,9 @@ struct InputWrapper{T} obj::T end -mutable struct Series +mutable struct Series{S} + id::Int + subplot::S plotattributes::DefaultsDict end @@ -44,6 +46,7 @@ mutable struct Subplot{T<:AbstractBackend} <: AbstractLayout ) end + # simple wrapper around a KW so we can hold all attributes pertaining to the axis in one place mutable struct Axis sps::Vector{Subplot} diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl index 80444ba20..9ce96fee0 100644 --- a/test/test_plotattr.jl +++ b/test/test_plotattr.jl @@ -40,9 +40,9 @@ tplot = plot( @test getattr(sp, :lims) == [ (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto), ] - @test_broken getattr(sp, :this) == Dict( + @test getattr(sp, :this) == Dict( :series => - [2 => :that, 5 => :that], # TODO: would be good if Series knew their ID + [2 => :that, 5 => :that], :subplots => Any[], :plot => Any[], ) @@ -59,9 +59,9 @@ tplot = plot( @test getattr(axis, :title) == "A" @test getattr(axis, :xlims) === :auto # TODO: is this expected? @test getattr(axis, :lims) == :auto - @test_broken getattr(axis, :this) == Dict( + @test getattr(axis, :this) == Dict( :series => - [3 => :that, 6 => :that], # TODO: would be good if Series knew their ID + [3 => :that, 6 => :that], :subplots => Any[], :plot => Any[], ) @@ -80,9 +80,9 @@ tplot = plot( @test getattr(series, :lims) == [ (xaxis = :auto, yaxis = :auto, zaxis = :auto), ] - @test_broken getattr(series, :this) == Dict( + @test getattr(series, :this) == Dict( :series => - [1 => :that, 4 => :that], # TODO: would be good if Series knew their ID + [1 => :that], :subplots => Any[], :plot => Any[], ) From 72dadb3bac4de4c61bb82f6d053b303d381311e6 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 23 Jun 2023 19:04:55 +0200 Subject: [PATCH 07/24] format and stub for <-- --- RecipesBase/src/RecipesBase.jl | 8 +++++ src/plotattr.jl | 14 ++++++--- src/types.jl | 1 - test/test_plotattr.jl | 56 ++++++++++------------------------ 4 files changed, 34 insertions(+), 45 deletions(-) diff --git a/RecipesBase/src/RecipesBase.jl b/RecipesBase/src/RecipesBase.jl index 5f3410aff..e4cfe218d 100644 --- a/RecipesBase/src/RecipesBase.jl +++ b/RecipesBase/src/RecipesBase.jl @@ -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,6 +163,12 @@ function process_recipe_body!(expr::Expr) e = e.args[1] end + # `<--` will be the recommended way to retrieve values + if e.head === :call && e.args[1] === :(<--) + target, attribute = e.args[2], e.args[3] + expr[i] = Expr(:(=), target, plotattributes[canonical_key(attribute)]) + 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 === :(:=) diff --git a/src/plotattr.jl b/src/plotattr.jl index eaa1b9b06..3164bfbca 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -121,12 +121,18 @@ function getattr(series::Series, s::Symbol) _getattr(series.subplot.plt, [series.subplot], [series], attribute) end -function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{<:Series}, attribute::Symbol) +function _getattr( + plt::Plot, + subplots::Vector{<:Subplot}, + serieses::Vector{<:Series}, + attribute::Symbol, +) if attribute ∈ _all_plot_args return plt[attribute] elseif attribute ∈ _all_subplot_args && attribute ∉ _magic_subplot_args return reduce(hcat, getindex.(subplots, attribute)) - elseif (attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args) && attribute ∉ _magic_axis_args + elseif (attribute ∈ _all_axis_args || attribute ∈ _lettered_all_axis_args) && + attribute ∉ _magic_axis_args if attribute ∈ _lettered_all_axis_args letters = collect(String(attribute)) letter = Symbol(first(letters)) @@ -157,8 +163,8 @@ function _getattr(plt::Plot, subplots::Vector{<:Subplot}, serieses::Vector{<:Ser (i, sp) in enumerate(subplots) if haskey(sp[:extra_kwargs], attribute) ], :series => [ - series.id => series[:extra_kwargs][attribute] for series in serieses if - haskey(series[:extra_kwargs], attribute) + series.id => series[:extra_kwargs][attribute] for + series in serieses if haskey(series[:extra_kwargs], attribute) ], ) !all(isempty, values(extra_kwargs)) && return extra_kwargs diff --git a/src/types.jl b/src/types.jl index 5270645f3..e73050fbb 100644 --- a/src/types.jl +++ b/src/types.jl @@ -46,7 +46,6 @@ mutable struct Subplot{T<:AbstractBackend} <: AbstractLayout ) end - # simple wrapper around a KW so we can hold all attributes pertaining to the axis in one place mutable struct Axis sps::Vector{Subplot} diff --git a/test/test_plotattr.jl b/test/test_plotattr.jl index 9ce96fee0..ea1182952 100644 --- a/test/test_plotattr.jl +++ b/test/test_plotattr.jl @@ -25,10 +25,8 @@ tplot = plot( :subplots => Any[], :plot => Any[], ) - @test (@test_logs ( - :info, - r"line is a magic argument", - ) getattr(tplot, :line)) === missing + @test (@test_logs (:info, r"line is a magic argument") getattr(tplot, :line)) === + missing @test_throws ArgumentError getattr(tplot, :nothere) end @testset "From Sublot" begin @@ -37,19 +35,11 @@ tplot = plot( @test getattr(sp, :linestyle) == permutedims(fill(:dash, 2)) @test getattr(sp, :title) == "B" @test getattr(sp, :xlims) == (0, Inf) - @test getattr(sp, :lims) == [ - (xaxis = (0, Inf), yaxis = :auto, zaxis = :auto), - ] - @test getattr(sp, :this) == Dict( - :series => - [2 => :that, 5 => :that], - :subplots => Any[], - :plot => Any[], - ) - @test (@test_logs ( - :info, - r"line is a magic argument", - ) getattr(sp, :line)) === missing + @test getattr(sp, :lims) == [(xaxis = (0, Inf), yaxis = :auto, zaxis = :auto)] + @test getattr(sp, :this) == + Dict(:series => [2 => :that, 5 => :that], :subplots => Any[], :plot => Any[]) + @test (@test_logs (:info, r"line is a magic argument") getattr(sp, :line)) === + missing @test_throws ArgumentError getattr(sp, :nothere) end @testset "From Axis" begin @@ -59,16 +49,10 @@ tplot = plot( @test getattr(axis, :title) == "A" @test getattr(axis, :xlims) === :auto # TODO: is this expected? @test getattr(axis, :lims) == :auto - @test getattr(axis, :this) == Dict( - :series => - [3 => :that, 6 => :that], - :subplots => Any[], - :plot => Any[], - ) - @test (@test_logs ( - :info, - r"line is a magic argument", - ) getattr(axis, :line)) === missing + @test getattr(axis, :this) == + Dict(:series => [3 => :that, 6 => :that], :subplots => Any[], :plot => Any[]) + @test (@test_logs (:info, r"line is a magic argument") getattr(axis, :line)) === + missing @test_throws ArgumentError getattr(axis, :nothere) end @testset "From Series" begin @@ -77,19 +61,11 @@ tplot = plot( @test getattr(series, :linestyle) == :dash @test getattr(series, :title) == "A" @test getattr(series, :xlims) == :auto - @test getattr(series, :lims) == [ - (xaxis = :auto, yaxis = :auto, zaxis = :auto), - ] - @test getattr(series, :this) == Dict( - :series => - [1 => :that], - :subplots => Any[], - :plot => Any[], - ) - @test (@test_logs ( - :info, - r"line is a magic argument", - ) getattr(series, :line)) === missing + @test getattr(series, :lims) == [(xaxis = :auto, yaxis = :auto, zaxis = :auto)] + @test getattr(series, :this) == + Dict(:series => [1 => :that], :subplots => Any[], :plot => Any[]) + @test (@test_logs (:info, r"line is a magic argument") getattr(series, :line)) === + missing @test_throws ArgumentError getattr(series, :nothere) end end From cb5dda91e9748035e1bfb1834537d4a4870990f1 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Mon, 26 Jun 2023 20:00:29 +0200 Subject: [PATCH 08/24] add interpolation and <-- syntax for attribute access --- RecipesBase/Project.toml | 2 +- RecipesBase/src/RecipesBase.jl | 20 ++++++++++---------- RecipesBase/test/runtests.jl | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/RecipesBase/Project.toml b/RecipesBase/Project.toml index 284647765..4948530da 100644 --- a/RecipesBase/Project.toml +++ b/RecipesBase/Project.toml @@ -1,7 +1,7 @@ name = "RecipesBase" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" author = ["Tom Breloff (@tbreloff)"] -version = "1.3.4" +version = "1.4.0" [deps] PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" diff --git a/RecipesBase/src/RecipesBase.jl b/RecipesBase/src/RecipesBase.jl index e4cfe218d..9a6e841cb 100644 --- a/RecipesBase/src/RecipesBase.jl +++ b/RecipesBase/src/RecipesBase.jl @@ -163,11 +163,6 @@ function process_recipe_body!(expr::Expr) e = e.args[1] end - # `<--` will be the recommended way to retrieve values - if e.head === :call && e.args[1] === :(<--) - target, attribute = e.args[2], e.args[3] - expr[i] = Expr(:(=), target, plotattributes[canonical_key(attribute)]) - end # the unused operator `:=` will mean force: `x := 5` is equivalent to `x --> 5, force` # note: this means "x is defined as 5" @@ -176,6 +171,14 @@ function process_recipe_body!(expr::Expr) 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))])) + elseif e.head === :$ # unary use + expr.args[i] = :(plotattributes[$RecipesBase.canonical_key($(QuoteNode(only(e.args))))]) + end + # we are going to recursively swap out `a --> b, flags...` commands # note: this means "x may become 5" if e.head === :(-->) @@ -212,12 +215,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 diff --git a/RecipesBase/test/runtests.jl b/RecipesBase/test/runtests.jl index 2dae4af67..4a4d00b4a 100644 --- a/RecipesBase/test/runtests.jl +++ b/RecipesBase/test/runtests.jl @@ -5,9 +5,13 @@ import RecipesBase as RB using StableRNGs using Test + 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])]) 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 From a69160cf14ed481c28a6ca50df7aa60192ec3ce0 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Mon, 26 Jun 2023 21:45:42 +0200 Subject: [PATCH 09/24] integrate in Plots --- Project.toml | 2 +- RecipesBase/src/RecipesBase.jl | 4 ++-- src/args.jl | 1 + test/test_args.jl | 15 +++++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index c24aa6a01..0fd0284bf 100644 --- a/Project.toml +++ b/Project.toml @@ -104,7 +104,7 @@ Preferences = "1" FFMPEG = "0.2 - 0.4" Measures = "0.3" julia = "1.6" -RecipesBase = "1.3.1" +RecipesBase = "1.4" UnicodeFun = "0.4" UnicodePlots = "3.4" PlotThemes = "2, 3" diff --git a/RecipesBase/src/RecipesBase.jl b/RecipesBase/src/RecipesBase.jl index 9a6e841cb..2101f03bc 100644 --- a/RecipesBase/src/RecipesBase.jl +++ b/RecipesBase/src/RecipesBase.jl @@ -189,10 +189,10 @@ function process_recipe_body!(expr::Expr) set_expr = if force # forced override user settings - :(plotattributes[$k] = $v) + :(plotattributes[$RecipesBase.canonical_key($k)] = $v) else # if the user has set this keyword, use theirs - :($RecipesBase.is_explicit(plotattributes, $k) || (plotattributes[$k] = $v)) + :($RecipesBase.is_explicit(plotattributes, $k) || (plotattributes[$RecipesBase.canonical_key($k)] = $v)) end expr.args[i] = if quiet diff --git a/src/args.jl b/src/args.jl index 03fd775fb..e141cce29 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1518,6 +1518,7 @@ function preprocess_attributes!(plotattributes::AKW) end RecipesPipeline.preprocess_attributes!(plt::Plot, plotattributes::AKW) = Plots.preprocess_attributes!(plotattributes) +RecipesBase.canonical_key(key::Symbol) = get(_keyAliases, key, key) # ----------------------------------------------------------------------------- diff --git a/test/test_args.jl b/test/test_args.jl index 30e337a02..8310c4bdf 100644 --- a/test/test_args.jl +++ b/test/test_args.jl @@ -90,18 +90,14 @@ end @test_throws ArgumentError png(plot(1:2; aspect_ratio = :invalid_ar), fn) end -@testset "aliases" begin - @test :legend in aliases(:legend_position) - Plots.add_non_underscore_aliases!(Plots._typeAliases) - Plots.add_axes_aliases(:ticks, :tick) -end - @userplot MatrixHeatmap @recipe function f(A::MatrixHeatmap) mat = A.args[1] margin --> (0, :mm) seriestype := :heatmap + c --> :red + foreground_color := $color x := axes(mat, 2) y := axes(mat, 1) z := Surface(mat) @@ -113,6 +109,13 @@ end @test show(devnull, matrixheatmap(reshape(1:12, 3, 4))) isa Nothing end +@testset "aliases" begin + @test :legend in aliases(:legend_position) + Plots.add_non_underscore_aliases!(Plots._typeAliases) + Plots.add_axes_aliases(:ticks, :tick) + @test getattr(matrixheatmap(reshape(1:12, 3, 4))[1][1], :foreground_color) == RGBA(colorant"red") +end + @testset "Formatters" begin ts = range(DateTime(today()), step = Hour(1), length = 24) p1 = plot(ts, 100randn(24)) From 62c59d6c6e75a62f16cbc2fcf336d25cfd420cb2 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 17:59:58 +0200 Subject: [PATCH 10/24] use dev versions of Recipe packages in CI --- .github/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5d639098..cc405c737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,10 +99,18 @@ jobs: CondaPkg.PkgREPL.add([libgcc..., "matplotlib"]) CondaPkg.status() - - uses: julia-actions/julia-runtest@latest - timeout-minutes: 60 - with: - prefix: ${{ matrix.prefix }} # for `xvfb-run` + # - uses: julia-actions/julia-runtest@latest + # timeout-minutes: 60 + # with: + # prefix: ${{ matrix.prefix }} # for `xvfb-run` + - name: Run Plots.jl tests + shell: xvfb-run julia --project=@. --color=yes {0} + run: | + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + Pkg.test(; coverage=true) - name: Run downstream tests if: startsWith(matrix.os, 'ubuntu') From f39ae96a769b99a345d1aabac9992923c234e054 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 18:18:46 +0200 Subject: [PATCH 11/24] disable build, format --- .github/workflows/ci.yml | 2 +- test/test_args.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc405c737..892f91c68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: with: version: ${{ matrix.version }} - uses: julia-actions/cache@v1 - - uses: julia-actions/julia-buildpkg@latest + # - uses: julia-actions/julia-buildpkg@latest - name: Run upstream RecipesBase & RecipesPipeline tests shell: julia --project=@. --color=yes {0} diff --git a/test/test_args.jl b/test/test_args.jl index 8310c4bdf..404ed9763 100644 --- a/test/test_args.jl +++ b/test/test_args.jl @@ -113,7 +113,8 @@ end @test :legend in aliases(:legend_position) Plots.add_non_underscore_aliases!(Plots._typeAliases) Plots.add_axes_aliases(:ticks, :tick) - @test getattr(matrixheatmap(reshape(1:12, 3, 4))[1][1], :foreground_color) == RGBA(colorant"red") + @test getattr(matrixheatmap(reshape(1:12, 3, 4))[1][1], :foreground_color) == + RGBA(colorant"red") end @testset "Formatters" begin From f6795186efcaadd9bf3ac76ee82dd2734d18d267 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 18:50:15 +0200 Subject: [PATCH 12/24] fix ci --- .github/workflows/ci.yml | 2 +- RecipesBase/src/RecipesBase.jl | 5 +++-- test/test_recipes.jl | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 892f91c68..0c266f11a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,7 @@ jobs: - name: Run downstream tests if: startsWith(matrix.os, 'ubuntu') - shell: xvfb-run julia --project=@. --color=yes {0} + shell: julia --project=@. --color=yes {0} run: | using Pkg foreach(("StatsPlots", "GraphRecipes")) do name diff --git a/RecipesBase/src/RecipesBase.jl b/RecipesBase/src/RecipesBase.jl index 2101f03bc..e3edf1932 100644 --- a/RecipesBase/src/RecipesBase.jl +++ b/RecipesBase/src/RecipesBase.jl @@ -183,16 +183,17 @@ function process_recipe_body!(expr::Expr) # 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 set_expr = if force # forced override user settings - :(plotattributes[$RecipesBase.canonical_key($k)] = $v) + :(plotattributes[$k] = $v) else # if the user has set this keyword, use theirs - :($RecipesBase.is_explicit(plotattributes, $k) || (plotattributes[$RecipesBase.canonical_key($k)] = $v)) + :($RecipesBase.is_explicit(plotattributes, $k) || (plotattributes[$k] = $v)) end expr.args[i] = if quiet diff --git a/test/test_recipes.jl b/test/test_recipes.jl index 1079306dc..e4cf1862c 100644 --- a/test/test_recipes.jl +++ b/test/test_recipes.jl @@ -1,3 +1,4 @@ +using Plots, Test using OffsetArrays @testset "User recipes" begin @@ -107,35 +108,35 @@ with(:gr) do end @testset "parametric" begin - @test plot(sin, sin, cos, 0, 2π) isa Plot - @test plot(sin, sin, cos, collect((-2π):(π / 4):(2π))) isa Plot + @test plot(sin, sin, cos, 0, 2π) isa Plots.Plot + @test plot(sin, sin, cos, collect((-2π):(π / 4):(2π))) isa Plots.Plot end @testset "dict" begin - show(devnull, plot(Dict(1 => 2, 3 => -1))) + @test_nowarn show(devnull, plot(Dict(1 => 2, 3 => -1))) end @testset "gray image" begin - show(devnull, plot(rand(Gray, 2, 2))) + @test_nowarn show(devnull, plot(rand(Gray, 2, 2))) end @testset "plots_heatmap" begin - show(devnull, plots_heatmap(rand(RGBA, 2, 2))) + @test_nowarn show(devnull, plots_heatmap(rand(RGBA, 2, 2))) end @testset "scatter3d" begin - show(devnull, scatter3d(1:2, 1:2, 1:2)) + @test_nowarn show(devnull, scatter3d(1:2, 1:2, 1:2)) end @testset "sticks" begin - show(devnull, sticks(1:2, marker = :circle)) + @test_nowarn show(devnull, sticks(1:2, marker = :circle)) end @testset "stephist" begin - show(devnull, stephist([1, 2], marker = :circle)) + @test_nowarn show(devnull, stephist([1, 2], marker = :circle)) end @testset "bar with logscales" begin - show(devnull, bar([1 2 3], [0.02 125 10_000]; yscale = :log10)) + @test_nowarn show(devnull, bar([1 2 3], [0.02 125 10_000]; yscale = :log10)) end end From 7642c0a40b0b340f7593741908aabaa63bb66791 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 19:00:36 +0200 Subject: [PATCH 13/24] dev Recipe packages on other actions --- .github/workflows/benchmark.yml | 12 +++++++++--- .github/workflows/format_check.yml | 7 +++++-- .github/workflows/invalidations.yml | 4 +--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e46a09f92..559cb19f9 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -3,7 +3,7 @@ name: benchmarks on: pull_request: -concurrency: +concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -14,11 +14,17 @@ jobs: steps: - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@latest - + - name: Ubuntu TESTCMD run: echo "TESTCMD=xvfb-run --auto-servernum julia" >> $GITHUB_ENV - name: Install Plots dependencies - uses: julia-actions/julia-buildpkg@latest + run: | + julia -e ' + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + ' - name: Install Benchmarking dependencies run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI"' diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index deedd8895..06bb0cb51 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -4,8 +4,8 @@ on: pull_request: push: branches: [master] - -concurrency: + +concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -22,6 +22,9 @@ jobs: PackageSpec("JuliaFormatter"), PackageSpec(url = "https://github.com/tkf/JuliaProjectFormatter.jl.git"), ]) + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end shell: julia --color=yes {0} - name: Format Julia files diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index 4d51d55c9..c62b3e4e7 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -4,7 +4,7 @@ on: push: branches: [master] -concurrency: +concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -16,14 +16,12 @@ jobs: with: version: '1' - uses: actions/checkout@v3 - - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-invalidations@v1 id: invs_pr - uses: actions/checkout@v3 with: ref: 'master' - - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-invalidations@v1 id: invs_master From d9a8c3844952725fd3d2eaeb3097276e22ed75d0 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 19:05:10 +0200 Subject: [PATCH 14/24] Remove PyPlot from test env --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0fd0284bf..ecf35f48d 100644 --- a/Project.toml +++ b/Project.toml @@ -122,7 +122,7 @@ ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" [targets] -test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "InspectDR", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"] +test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "FreeType", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "InspectDR", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"] [extensions] FileIOExt = "FileIO" From cc4be02cea7ddf09a7383cdecfb6121f6d5180be Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 19:06:28 +0200 Subject: [PATCH 15/24] run Plots tests without xvfb --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c266f11a..6d9137918 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: # with: # prefix: ${{ matrix.prefix }} # for `xvfb-run` - name: Run Plots.jl tests - shell: xvfb-run julia --project=@. --color=yes {0} + shell: julia --project=@. --color=yes {0} run: | using Pkg foreach(("RecipesBase", "RecipesPipeline")) do name @@ -114,7 +114,7 @@ jobs: - name: Run downstream tests if: startsWith(matrix.os, 'ubuntu') - shell: julia --project=@. --color=yes {0} + shell: xvfb-run julia --project=@. --color=yes {0} run: | using Pkg foreach(("StatsPlots", "GraphRecipes")) do name From 1f4c0a54f1c044aa3bc6e7115d44517a2f05cd98 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 15:42:36 +0200 Subject: [PATCH 16/24] add prefix to ubuntu runs --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d9137918..a032b9963 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: # with: # prefix: ${{ matrix.prefix }} # for `xvfb-run` - name: Run Plots.jl tests - shell: julia --project=@. --color=yes {0} + shell: ${{ matrix.prefix }} julia --project=@. --color=yes {0} run: | using Pkg foreach(("RecipesBase", "RecipesPipeline")) do name From aa234f84b0ffb51e65f57f6d92abc6dddce78911 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:05:38 +0200 Subject: [PATCH 17/24] update invalidations.yml --- .github/workflows/invalidations.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index c62b3e4e7..9b0cf31e6 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -16,6 +16,13 @@ jobs: with: version: '1' - uses: actions/checkout@v3 + - name: Install dependencies + run: | + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + shell: julia --color=yes {0} - uses: julia-actions/julia-invalidations@v1 id: invs_pr From 516ad8337aee5015f78ef59a3875cb18ea1607dd Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:10:20 +0200 Subject: [PATCH 18/24] uodate ci.yml --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a032b9963..6dcd5c62a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,17 @@ jobs: # with: # prefix: ${{ matrix.prefix }} # for `xvfb-run` - name: Run Plots.jl tests - shell: ${{ matrix.prefix }} julia --project=@. --color=yes {0} + if: startsWith(matrix.os, 'ubuntu') + shell: xvfb-run julia --project=@. --color=yes {0} + run: | + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + Pkg.test(; coverage=true) + - name: Run Plots.jl tests + if: !startsWith(matrix.os, 'ubuntu') + shell: julia --project=@. --color=yes {0} run: | using Pkg foreach(("RecipesBase", "RecipesPipeline")) do name From c657a479a903c5477794fa0fb24f8b799bc95266 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:10:59 +0200 Subject: [PATCH 19/24] take 2 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dcd5c62a..341d73963 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,7 +113,7 @@ jobs: end Pkg.test(; coverage=true) - name: Run Plots.jl tests - if: !startsWith(matrix.os, 'ubuntu') + if: "!startsWith(matrix.os, 'ubuntu')" shell: julia --project=@. --color=yes {0} run: | using Pkg From 2fb98a398c47395bb6b496dc5738cd7707d78a5b Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:22:16 +0200 Subject: [PATCH 20/24] invalidations --- .github/workflows/invalidations.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index 9b0cf31e6..d9833db46 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -16,21 +16,29 @@ jobs: with: version: '1' - uses: actions/checkout@v3 - - name: Install dependencies - run: | - using Pkg - foreach(("RecipesBase", "RecipesPipeline")) do name - Pkg.develop(path=name) - end shell: julia --color=yes {0} - uses: julia-actions/julia-invalidations@v1 id: invs_pr + with: + test_script: | + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + using Plots - uses: actions/checkout@v3 with: ref: 'master' - uses: julia-actions/julia-invalidations@v1 id: invs_master + with: + test_script: | + using Pkg + foreach(("RecipesBase", "RecipesPipeline")) do name + Pkg.develop(path=name) + end + using Plots - name: Report invalidation counts run: | From 6543a42f74f137ee15c6f26c59a5c86c491c87d6 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:25:54 +0200 Subject: [PATCH 21/24] invalidations --- .github/workflows/invalidations.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index d9833db46..4db497013 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -16,7 +16,6 @@ jobs: with: version: '1' - uses: actions/checkout@v3 - shell: julia --color=yes {0} - uses: julia-actions/julia-invalidations@v1 id: invs_pr with: From 3a19444eeb2ee1e37555617bb86cd7abaf2a798d Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:31:54 +0200 Subject: [PATCH 22/24] invalidations --- .github/workflows/invalidations.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index 4db497013..6a1bad8f5 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -20,11 +20,13 @@ jobs: id: invs_pr with: test_script: | + """ using Pkg foreach(("RecipesBase", "RecipesPipeline")) do name Pkg.develop(path=name) end using Plots + """ - uses: actions/checkout@v3 with: @@ -33,11 +35,13 @@ jobs: id: invs_master with: test_script: | + """ using Pkg foreach(("RecipesBase", "RecipesPipeline")) do name Pkg.develop(path=name) end using Plots + """ - name: Report invalidation counts run: | From 3962cb557b9b023f3e8493db9ea658caa04e403e Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:34:45 +0200 Subject: [PATCH 23/24] invalidations --- .github/workflows/invalidations.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index 6a1bad8f5..da48bf5cd 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -27,6 +27,7 @@ jobs: end using Plots """ + shell: julia --project=@. --color=yes {0} - uses: actions/checkout@v3 with: @@ -42,6 +43,7 @@ jobs: end using Plots """ + shell: julia --project=@. --color=yes {0} - name: Report invalidation counts run: | From 1bbf71757a577fbd293f5f108d39619c70a9a928 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 28 Jun 2023 19:45:36 +0200 Subject: [PATCH 24/24] invalidations --- .github/workflows/invalidations.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index da48bf5cd..d5dac254c 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -20,14 +20,7 @@ jobs: id: invs_pr with: test_script: | - """ - using Pkg - foreach(("RecipesBase", "RecipesPipeline")) do name - Pkg.develop(path=name) - end - using Plots - """ - shell: julia --project=@. --color=yes {0} + "using Pkg; foreach((\"RecipesBase\", \"RecipesPipeline\")) do name; Pkg.develop(path=name); end; using Plots" - uses: actions/checkout@v3 with: @@ -36,14 +29,7 @@ jobs: id: invs_master with: test_script: | - """ - using Pkg - foreach(("RecipesBase", "RecipesPipeline")) do name - Pkg.develop(path=name) - end - using Plots - """ - shell: julia --project=@. --color=yes {0} + "using Pkg; foreach((\"RecipesBase\", \"RecipesPipeline\")) do name; Pkg.develop(path=name); end; using Plots" - name: Report invalidation counts run: |