diff --git a/src/Plots.jl b/src/Plots.jl index e7a71878..5b067f0a 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -118,7 +118,6 @@ export scalefontsizes, resetfontsizes - # --------------------------------------------------------- import NaNMath # define functions that ignores NaNs. To overcome the destructive effects of https://github.com/JuliaLang/julia/pull/12563 @@ -250,6 +249,7 @@ end # --------------------------------------------------------- const CURRENT_BACKEND = CurrentBackend(:none) +const PLOTS_SEED = 1234 include("precompile_includer.jl") diff --git a/src/examples.jl b/src/examples.jl index 838af274..03d4ae4f 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -128,8 +128,7 @@ const _examples = PlotExample[ :( begin import FileIO - path = - download("http://juliaplots.org/PlotReferenceImages.jl/Plots/pyplot/0.7.0/ref1.png") + path = download("http://juliaplots.org/PlotReferenceImages.jl/Plots/pyplot/0.7.0/ref1.png") img = FileIO.load(path) plot(img) end diff --git a/src/utils.jl b/src/utils.jl index 4ebdc01e..f07945a2 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -303,10 +303,12 @@ function convert_to_polar(theta, r, r_extrema = ignorenan_extrema(r)) x, y end -function fakedata(sz...) +fakedata(sz::Int...) = fakedata(Random.seed!(PLOTS_SEED), sz...) + +function fakedata(rng::AbstractRNG, sz...) y = zeros(sz...) for r in 2:size(y,1) - y[r,:] = 0.95 * vec(y[r-1,:]) + randn(size(y,2)) + y[r,:] = 0.95 * vec(y[r-1,:]) + randn(rng, size(y,2)) end y end diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 3a0af3ca..879a87ea 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -6,14 +6,14 @@ function replace_rand!(ex::Expr) for arg in ex.args replace_rand!(arg) end - if ex.head === :call && ex.args[1] ∈ (:rand, :randn) + if ex.head === :call && ex.args[1] ∈ (:rand, :randn, :(Plots.fakedata)) pushfirst!(ex.args, ex.args[1]) ex.args[2] = :rng end end function fix_rand!(ex) replace_rand!(ex) - pushfirst!(ex.args[1].args, :(rng = StableRNG(1234))) + pushfirst!(ex.args[1].args, :(rng = StableRNG(PLOTS_SEED))) end function image_comparison_tests( @@ -35,6 +35,7 @@ function image_comparison_tests( fn = "ref$idx.png" reffn = reference_file(pkg, idx, _current_plots_version) newfn = joinpath(reference_path(pkg, _current_plots_version), fn) + @debug example.exprs # test function func = (fn, idx) -> begin diff --git a/test/runtests.jl b/test/runtests.jl index 5b280508..4bea6dd0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using Plots: guidefont, series_annotations +using Plots: guidefont, series_annotations, PLOTS_SEED import ImageMagick using VisualRegressionTests using Plots @@ -13,7 +13,6 @@ import GeometryBasics using Dates using RecipesBase - @testset "Plotly standalone" begin @test_nowarn Plots._init_ijulia_plotting() @test Plots.plotly_local_file_path[] === nothing @@ -68,7 +67,7 @@ end include("imgcomp.jl") # don't actually show the plots -Random.seed!(1234) +Random.seed!(PLOTS_SEED) default(show=false, reuse=true) is_ci() = get(ENV, "CI", "false") == "true" const PLOTS_IMG_TOL = parse(