fix tests

This commit is contained in:
Daniel Schwabeneder 2018-08-26 21:11:23 +02:00
parent e0f9313b8b
commit b2f2ffcfed
4 changed files with 38 additions and 24 deletions

View File

@ -52,7 +52,7 @@ the `z` argument to turn on series gradients.
[:(begin [:(begin
y = rand(100) y = rand(100)
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6) plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6)
scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y.-0.5).+4, scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,Plots.stroke(1,:green)), ms=10*abs.(y.-0.5).+4,
lab="grad") lab="grad")
end)] end)]
), ),
@ -66,6 +66,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`
`yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
""", """,
[:(begin [:(begin
using Statistics
y = rand(20,3) y = rand(20,3)
plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2),
leg=false) leg=false)
@ -85,8 +86,8 @@ yaxis!("YLABEL", :log10)
PlotExample("Images", PlotExample("Images",
"Plot an image. y-axis is set to flipped", "Plot an image. y-axis is set to flipped",
[:(begin [:(begin
import FileIO import FileIO, PlotReferenceImages
img = FileIO.load(Pkg.dir("PlotReferenceImages","Plots","pyplot","0.7.0","ref1.png")) img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png"))
plot(img) plot(img)
end)] end)]
), ),
@ -102,7 +103,7 @@ series.
""", """,
[:(begin [:(begin
ys = Vector[rand(10), rand(20)] ys = Vector[rand(10), rand(20)]
plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,stroke(3,:gray))) plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,Plots.stroke(3,:gray)))
end)] end)]
), ),
@ -202,7 +203,8 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo
PlotExample("", PlotExample("",
"", "",
[:(begin [:(begin
Random.srand(111) using Random
Random.seed!(111)
plot!(Plots.fakedata(100,10)) plot!(Plots.fakedata(100,10))
end)] end)]
), ),
@ -295,7 +297,7 @@ PlotExample("3D",
x = ts .* map(cos,ts) x = ts .* map(cos,ts)
y = 0.1ts .* map(sin,ts) y = 0.1ts .* map(sin,ts)
z = 1:n z = 1:n
plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, cbar=true, w=5) plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,Plots.stroke(0)), leg=false, cbar=true, w=5)
plot!(zeros(n),zeros(n),1:n, w=10) plot!(zeros(n),zeros(n),1:n, w=10)
end)] end)]
), ),
@ -382,8 +384,9 @@ various different nonzero values, a colorbar is added. The colorbar can be disab
`legend = nothing`. `legend = nothing`.
""", """,
[:(begin [:(begin
a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) using SparseArrays
b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) a = spdiagm(0 => ones(50), 1 => ones(49), -1 => ones(49), 10 => ones(40), -10 => ones(40))
b = spdiagm(0 => 1:50, 1 => 1:49, -1 => 1:49, 10 => 1:40, -10 => 1:40)
plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"]) plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"])
end)] end)]
), ),
@ -411,7 +414,7 @@ attribute. The default framestyle is `:axes`.
scatter(fill(randn(10), 6), fill(randn(10), 6), scatter(fill(randn(10), 6), fill(randn(10), 6),
framestyle = [:box :semi :origin :zerolines :grid :none], framestyle = [:box :semi :origin :zerolines :grid :none],
title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"],
color = RowVector(1:6), layout = 6, label = "", markerstrokewidth = 0, color = permutedims(1:6), layout = 6, label = "", markerstrokewidth = 0,
ticks = -2:2) ticks = -2:2)
end)] end)]
), ),

View File

@ -3,7 +3,7 @@ using Pkg
# need this to use Conda # need this to use Conda
# ENV["PYTHON"] = "" # ENV["PYTHON"] = ""
Pkg.add([ to_add = [
PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"),
# PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"),
PackageSpec(name="PlotUtils", rev="master"), PackageSpec(name="PlotUtils", rev="master"),
@ -14,7 +14,18 @@ Pkg.add([
# PackageSpec(name="VisualRegressionTests", rev="master"), # PackageSpec(name="VisualRegressionTests", rev="master"),
# PackageSpec("PyPlot"), # PackageSpec("PyPlot"),
# PackageSpec("InspectDR"), # PackageSpec("InspectDR"),
]) ]
if isinteractive()
append!(to_add, [
PackageSpec(name="FileIO"),
PackageSpec(name="ImageMagick"),
PackageSpec(name="UnicodePlots"),
PackageSpec(name="VisualRegressionTests"),
])
end
Pkg.add(to_add)
Pkg.build("ImageMagick") Pkg.build("ImageMagick")
# Pkg.build("GR") # Pkg.build("GR")

View File

@ -32,7 +32,7 @@ default(size=(500,300))
const _current_plots_version = v"0.17.4" const _current_plots_version = v"0.17.4"
function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], eps = 1e-2) function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2)
Plots._debugMode.on = debug Plots._debugMode.on = debug
example = Plots._examples[idx] example = Plots._examples[idx]
@info("Testing plot: $pkg:$idx:$(example.header)") @info("Testing plot: $pkg:$idx:$(example.header)")
@ -89,7 +89,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
# the test # the test
vtest = VisualTest(func, reffn, idx) vtest = VisualTest(func, reffn, idx)
test_images(vtest, popup=popup, sigma=sigma, eps=eps, newfn = newfn) test_images(vtest, popup=popup, sigma=sigma, tol=tol, newfn = newfn)
end end
function image_comparison_facts(pkg::Symbol; function image_comparison_facts(pkg::Symbol;
@ -97,11 +97,11 @@ function image_comparison_facts(pkg::Symbol;
only = nothing, # limit to these examples (int index) only = nothing, # limit to these examples (int index)
debug = false, # print debug information? debug = false, # print debug information?
sigma = [1,1], # number of pixels to "blur" sigma = [1,1], # number of pixels to "blur"
eps = 1e-2) # acceptable error (percent) tol = 1e-2) # acceptable error (percent)
for i in 1:length(Plots._examples) for i in 1:length(Plots._examples)
i in skip && continue i in skip && continue
if only == nothing || i in only if only == nothing || i in only
@test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success == true @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true
end end
end end
end end

View File

@ -6,7 +6,7 @@ include("imgcomp.jl")
# don't actually show the plots # don't actually show the plots
Random.seed!(1234) Random.seed!(1234)
default(show=false, reuse=true) default(show=false, reuse=true)
img_eps = isinteractive() ? 1e-2 : 10e-2 img_tol = isinteractive() ? 1e-2 : 10e-2
@testset "GR" begin @testset "GR" begin
ENV["PLOTS_TEST"] = "true" ENV["PLOTS_TEST"] = "true"
@ -14,7 +14,7 @@ img_eps = isinteractive() ? 1e-2 : 10e-2
@test gr() == Plots.GRBackend() @test gr() == Plots.GRBackend()
@test backend() == Plots.GRBackend() @test backend() == Plots.GRBackend()
image_comparison_facts(:gr, eps=img_eps, skip = [25, 30]) image_comparison_facts(:gr, tol=img_tol, skip = [25, 30])
end end
@ -22,7 +22,7 @@ end
# @test pyplot() == Plots.PyPlotBackend() # @test pyplot() == Plots.PyPlotBackend()
# @test backend() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend()
# #
# image_comparison_facts(:pyplot, eps=img_eps) # image_comparison_facts(:pyplot, tol=img_tol)
#end #end
@testset "UnicodePlots" begin @testset "UnicodePlots" begin
@ -47,7 +47,7 @@ end
# 27, # (polar plots) takes very long / not working # 27, # (polar plots) takes very long / not working
# 31, # animation (skipped for speed) # 31, # animation (skipped for speed)
# ], # ],
# eps=img_eps) # tol=img_tol)
# end # end
# end # end
@ -71,7 +71,7 @@ end
# 28, # heatmap not defined # 28, # heatmap not defined
# 31, # animation # 31, # animation
# ], # ],
# eps=img_eps) # tol=img_tol)
# end # end
@ -80,7 +80,7 @@ end
# @test backend() == Plots.PlotlyBackend() # @test backend() == Plots.PlotlyBackend()
# #
# # # until png generation is reliable on OSX, just test on linux # # # until png generation is reliable on OSX, just test on linux
# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) # # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], tol=img_tol)
# end # end
@ -89,7 +89,7 @@ end
# @test backend() == Plots.ImmerseBackend() # @test backend() == Plots.ImmerseBackend()
# #
# # as long as we can plot anything without error, it should be the same as Gadfly # # as long as we can plot anything without error, it should be the same as Gadfly
# image_comparison_facts(:immerse, only=[1], eps=img_eps) # image_comparison_facts(:immerse, only=[1], tol=img_tol)
# end # end
@ -98,7 +98,7 @@ end
# @test backend() == Plots.PlotlyJSBackend() # @test backend() == Plots.PlotlyJSBackend()
# #
# # as long as we can plot anything without error, it should be the same as Plotly # # as long as we can plot anything without error, it should be the same as Plotly
# image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) # image_comparison_facts(:plotlyjs, only=[1], tol=img_tol)
# end # end
@ -111,7 +111,7 @@ end
# @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) # @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing)
# @test plot!(rand(10,3), rand(10,3)) == not(nothing) # @test plot!(rand(10,3), rand(10,3)) == not(nothing)
# #
# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) # image_comparison_facts(:gadfly, skip=[4,6,23,24,27], tol=img_tol)
# end # end