From 3b325b2482a25a4e0b7152ceeccd248bc5be9a05 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Fri, 10 Jun 2016 10:04:33 -0400 Subject: [PATCH] pyplot figure finalizer; accept 2-len AVec for limits (#289); sleep/skip/only options in test_examples --- src/axes.jl | 2 +- src/backends/pyplot.jl | 1 + src/examples.jl | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/axes.jl b/src/axes.jl index 9ea0dbce..1b04469a 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -229,7 +229,7 @@ function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis) ex = axis[:extrema] amin, amax = ex.emin, ex.emax lims = axis[:lims] - if isa(lims, Tuple) && length(lims) == 2 + if (isa(lims, Tuple) || isa(lims, AVec)) && length(lims) == 2 if isfinite(lims[1]) amin = lims[1] end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 85a7abd8..0c429e6a 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -348,6 +348,7 @@ function _create_backend_figure(plt::Plot{PyPlotBackend}) PyPlot.gcf() else PyPlot.figure() + finalizer(fig, close) end # clear the figure diff --git a/src/examples.jl b/src/examples.jl index bd48d63c..427cb1e9 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -325,11 +325,13 @@ function test_examples(pkgname::Symbol, idx::Int; debug = false, disp = true) end # generate all plots and create a dict mapping idx --> plt -function test_examples(pkgname::Symbol; debug = false, disp = true) +function test_examples(pkgname::Symbol; debug = false, disp = true, sleep = nothing, + skip = [], only = nothing) Plots._debugMode.on = debug plts = Dict() for i in 1:length(_examples) - + only != nothing && !(i in only) && continue + i in skip && continue try plt = test_examples(pkgname, i, debug=debug, disp=disp) plts[i] = plt @@ -337,6 +339,9 @@ function test_examples(pkgname::Symbol; debug = false, disp = true) # TODO: put error info into markdown? warn("Example $pkgname:$i:$(_examples[i].header) failed with: $ex") end + if sleep != nothing + Base.sleep(sleep) + end end plts end