working on switch to PlotReferenceImages

This commit is contained in:
Thomas Breloff 2016-06-02 17:23:40 -05:00
parent 85f91b9075
commit 1d5cce61ac
4 changed files with 63 additions and 27 deletions

View File

@ -161,6 +161,8 @@ export
@recipe, @recipe,
# @plotrecipe, # @plotrecipe,
test_examples,
translate, translate,
translate!, translate!,
rotate, rotate,
@ -197,6 +199,7 @@ include("subplots.jl")
include("recipes.jl") include("recipes.jl")
include("animation.jl") include("animation.jl")
include("output.jl") include("output.jl")
include("examples.jl")
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -13,3 +13,4 @@ DataFrames
RDatasets RDatasets
VisualRegressionTests VisualRegressionTests
UnicodePlots UnicodePlots
Glob

View File

@ -1,6 +1,6 @@
using VisualRegressionTests using VisualRegressionTests
using ExamplePlots # using ExamplePlots
import DataFrames, RDatasets import DataFrames, RDatasets
@ -14,6 +14,7 @@ end
using Plots, FactCheck using Plots, FactCheck
using Glob
default(size=(500,300)) default(size=(500,300))
@ -21,37 +22,66 @@ default(size=(500,300))
# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that # TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that
# is referenced in a button press callback (the button clicked callback will call notify() on that condition) # is referenced in a button press callback (the button clicked callback will call notify() on that condition)
const _current_plots_version = v"0.6.1"
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], eps = 1e-2)
Plots._debugMode.on = debug
example = Plots._examples[idx]
info("Testing plot: $pkg:$idx:$(example.header)")
backend(pkg)
backend()
# first # ensure consistent results
Plots._debugMode.on = debug srand(1234)
example = ExamplePlots._examples[idx]
info("Testing plot: $pkg:$idx:$(example.header)")
backend(pkg)
backend()
# ensure consistent results # reference image directory setup
srand(1234) # refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg))
refdir = Pkg.dir("PlotReferenceImages", "Plots", string(pkg))
fn = "ref$idx.png"
# reference image directory setup # firgure out version info
refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg)) G = glob(relpath(refdir) * "/*")
@show refdir fn G
versions = map(fn -> VersionNumber(split(fn,"/")[end]), G)
versions = reverse(sort(versions))
@show refdir fn versions
# test function reffn = nothing
func = (fn, idx) -> begin newfn = joinpath(refdir, string(_current_plots_version), fn)
map(eval, example.exprs) for v in versions
png(fn) try
end tmpfn = joinpath(refdir, string(v), fn)
@show "trying", tmpfn
f = open(tmpfn)
reffn = tmpfn
end
end
try # now we have the fn (if any)... do the comparison
run(`mkdir -p $refdir`) @show reffn
catch err if reffn == nothing
display(err) reffn = newfn
end end
reffn = joinpath(refdir, "ref$idx.png") @show reffn
# return
# the test # test function
vtest = VisualTest(func, reffn, idx) func = (fn, idx) -> begin
test_images(vtest, popup=popup, sigma=sigma, eps=eps) map(eval, example.exprs)
png(fn)
end
# try
# run(`mkdir -p $refdir`)
# catch err
# display(err)
# end
# reffn = joinpath(refdir, "ref$idx.png")
# the test
vtest = VisualTest(func, reffn, idx)
test_images(vtest, popup=popup, sigma=sigma, eps=eps, newfn = newfn)
end end
function image_comparison_facts(pkg::Symbol; function image_comparison_facts(pkg::Symbol;
@ -60,7 +90,7 @@ function image_comparison_facts(pkg::Symbol;
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) eps = 1e-2) # acceptable error (percent)
for i in 1:length(ExamplePlots._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
@fact image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success --> true @fact image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success --> true

View File

@ -8,7 +8,8 @@ Pkg.clone("GR")
Pkg.build("GR") Pkg.build("GR")
# Pkg.clone("https://github.com/JuliaPlots/RecipesBase.jl.git") # Pkg.clone("https://github.com/JuliaPlots/RecipesBase.jl.git")
Pkg.clone("https://github.com/tbreloff/ExamplePlots.jl.git"); # Pkg.clone("https://github.com/tbreloff/ExamplePlots.jl.git");
Pkg.clone("https://github.com/JuliaPlots/PlotReferenceImages.jl.git")
# Pkg.clone("https://github.com/JunoLab/Blink.jl.git") # Pkg.clone("https://github.com/JunoLab/Blink.jl.git")
# Pkg.build("Blink") # Pkg.build("Blink")
@ -17,6 +18,7 @@ Pkg.clone("https://github.com/tbreloff/ExamplePlots.jl.git");
# Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git") # Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git")
Pkg.checkout("RecipesBase") Pkg.checkout("RecipesBase")
Pkg.checkout("VisualRegressionTests")
ENV["PYTHON"] = "" ENV["PYTHON"] = ""
Pkg.add("PyPlot") Pkg.add("PyPlot")