Fix saving of Plots formats and update tests

pull/66/head
Matti Pastell 2016-12-19 14:46:00 +02:00
parent 7222bfa9ab
commit ad08d4c4ae
3 changed files with 10 additions and 18 deletions

View File

@ -52,7 +52,7 @@ end
"""Add saved figure name to results and return the name"""
function add_pyplot_figure(report::Report, plot::Plots.Plot, ext)
function add_plots_figure(report::Report, plot::Plots.Plot, ext)
chunk = report.cur_chunk
full_name, rel_name = get_figname(report, chunk, ext = ext)
@ -62,22 +62,14 @@ function add_pyplot_figure(report::Report, plot::Plots.Plot, ext)
return full_name
end
function Base.display(report::Report, m::MIME"application/pdf", plot::Plots.Plot{Plots.PyPlotBackend})
add_pyplot_figure(report, plot, ".pdf")
function Base.display(report::Report, m::MIME"application/pdf", plot::Plots.Plot)
add_plots_figure(report, plot, ".pdf")
end
function Base.display(report::Report, m::MIME"image/png", plot::Plots.Plot{Plots.PyPlotBackend})
add_pyplot_figure(report, plot, ".png")
function Base.display(report::Report, m::MIME"image/png", plot::Plots.Plot)
add_plots_figure(report, plot, ".png")
end
function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot{Plots.PyPlotBackend})
add_pyplot_figure(report, plot, ".svg")
end
function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot{Plots.PGFPlotsBackend})
add_pyplot_figure(report, plot, ".png")
end
function Base.display(report::Report, m::MIME"application/pdf", plot::Plots.Plot{Plots.PGFPlotsBackend})
add_pyplot_figure(report, plot, ".pdf")
function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot)
add_plots_figure(report, plot, ".svg")
end

View File

@ -8,7 +8,7 @@
\end{lstlisting}
\includegraphics{figures/publish_test_1_1.png}
\includegraphics{figures/publish_test_1_1.pdf}
\begin{lstlisting}
@ -18,7 +18,7 @@
\begin{figure}[!h]
\center
\includegraphics{figures/publish_test_somefig_1.png}
\includegraphics{figures/publish_test_somefig_1.pdf}
\caption{Hello}
\label{fig:somefig}
\end{figure}

View File

@ -7,8 +7,8 @@ function publish_test(outfile, format)
weave(infile, doctype = format, out_path = outfile, template = "templates/mini.tpl")
result = readstring(open(outfile))
ref = readstring(open(outfile * ".ref"))
rm(outfile)
@test result == ref
rm(outfile)
end
#Test formatters