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""" """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 chunk = report.cur_chunk
full_name, rel_name = get_figname(report, chunk, ext = ext) 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 return full_name
end end
function Base.display(report::Report, m::MIME"application/pdf", plot::Plots.Plot{Plots.PyPlotBackend}) function Base.display(report::Report, m::MIME"application/pdf", plot::Plots.Plot)
add_pyplot_figure(report, plot, ".pdf") add_plots_figure(report, plot, ".pdf")
end end
function Base.display(report::Report, m::MIME"image/png", plot::Plots.Plot{Plots.PyPlotBackend}) function Base.display(report::Report, m::MIME"image/png", plot::Plots.Plot)
add_pyplot_figure(report, plot, ".png") add_plots_figure(report, plot, ".png")
end end
function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot{Plots.PyPlotBackend}) function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot)
add_pyplot_figure(report, plot, ".svg") add_plots_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")
end end

View File

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

View File

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