mirror of https://github.com/mpastell/Weave.jl
Tests for pyplot and minor fixes
parent
0c9d94d11e
commit
b0f2f92e37
|
@ -8,12 +8,18 @@ env:
|
|||
- JULIAVERSION="juliareleases"
|
||||
- JULIAVERSION="julianightlies"
|
||||
before_install:
|
||||
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
|
||||
- chmod +x miniconda.sh
|
||||
- ./miniconda.sh -b
|
||||
- export PATH=/home/travis/miniconda/bin:$PATH
|
||||
- conda update --yes conda
|
||||
- conda install --yes matplotlib
|
||||
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
|
||||
- sudo add-apt-repository ppa:staticfloat/${JULIAVERSION} -y
|
||||
- sudo apt-get update -qq -y
|
||||
- sudo apt-get install libpcre3-dev julia -y
|
||||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
||||
script:
|
||||
- xvfb-run julia -e 'Pkg.init(); Pkg.add("Winston"); Pkg.add("Cairo"); Pkg.add("Gadfly"); Pkg.clone(pwd()); Pkg.test("Weave", coverage=true)'
|
||||
- xvfb-run julia -e 'Pkg.init(); Pkg.add("PyPlot"); Pkg.add("Winston"); Pkg.add("Cairo"); Pkg.add("Gadfly"); Pkg.clone(pwd()); Pkg.test("Weave", coverage=true)'
|
||||
after_success:
|
||||
- julia -e 'cd(Pkg.dir("Weave")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
|
||||
|
|
|
@ -108,10 +108,9 @@ function run_block(code_str)
|
|||
#If there is nothing to read code will hang
|
||||
println()
|
||||
|
||||
|
||||
try
|
||||
n = length(code_str)
|
||||
pos = 2 #The first character is extra line end
|
||||
pos = 1 #The first character is extra line end
|
||||
while pos < n
|
||||
oldpos = pos
|
||||
code, pos = parse(code_str, pos)
|
||||
|
@ -146,7 +145,6 @@ function run_term(code_str)
|
|||
oldpos = pos
|
||||
code, pos = parse(code_str, pos)
|
||||
|
||||
|
||||
report.term_state == :fig && (report.cur_result*= codestart)
|
||||
prompts = string(prompt, rstrip(code_str[oldpos:(pos-1)]), "\n")
|
||||
report.cur_result *= prompts
|
||||
|
|
|
@ -226,7 +226,7 @@ function formatfigures(chunk, docformat::Tex)
|
|||
result *= figstring
|
||||
end
|
||||
|
||||
if chunk[:name] != nothing
|
||||
if chunk[:name] != nothing && f_env !=nothing
|
||||
label = chunk[:name]
|
||||
result *= "\\label{fig:$label}\n"
|
||||
end
|
||||
|
|
|
@ -24,7 +24,6 @@ plot(x=x, y = sin(x), Geom.line)
|
|||
|
||||
|
||||
\includegraphics[width=\linewidth]{figures/gadfly_formats_test_cos2_fun_1.pdf}
|
||||
\label{fig:cos2_fun}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<<fig_cap="sin(x) function."; label="sin_fun"; fig_pos="ht">>=
|
||||
using PyPlot
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x, sin(x))
|
||||
@
|
||||
|
||||
<<echo=false; fig_cap="cos(x) function.">>=
|
||||
plot(x, cos(x))
|
||||
@
|
||||
|
||||
<<echo=false; label="cos2_fun">>=
|
||||
plot(x, cos(2x))
|
||||
@
|
||||
|
||||
<<term=true;fig_width=5>>=
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x, sin(x))
|
||||
y = 20
|
||||
plot(x, cos(x))
|
||||
@
|
||||
|
||||
<<out_width="15cm">>=
|
||||
x = randn(100, 100)
|
||||
contourf(x)
|
||||
@
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
````julia
|
||||
using PyPlot
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x, sin(x))
|
||||
````
|
||||
|
||||
|
||||
![sin(x) function.](figures/pyplot_formats_sin_fun_1.png)
|
||||
|
||||
|
||||
|
||||
![cos(x) function.](figures/pyplot_formats_2_1.png)
|
||||
|
||||
|
||||
|
||||
![](figures/pyplot_formats_cos2_fun_1.png)
|
||||
|
||||
|
||||
|
||||
````julia
|
||||
julia> x = linspace(0, 2π, 200)
|
||||
200-element Array{Float64,1}:
|
||||
0.0
|
||||
0.0315738
|
||||
0.0631476
|
||||
0.0947214
|
||||
0.126295
|
||||
0.157869
|
||||
0.189443
|
||||
0.221017
|
||||
0.25259
|
||||
0.284164
|
||||
⋮
|
||||
6.03059
|
||||
6.06217
|
||||
6.09374
|
||||
6.12532
|
||||
6.15689
|
||||
6.18846
|
||||
6.22004
|
||||
6.25161
|
||||
6.28319
|
||||
|
||||
julia> plot(x, sin(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7fb1d5b0c7d0>
|
||||
|
||||
julia> y = 20
|
||||
20
|
||||
|
||||
julia> plot(x, cos(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7fb1d5b0ca50>
|
||||
|
||||
````
|
||||
|
||||
|
||||
![](figures/pyplot_formats_4_1.png)
|
||||
|
||||
|
||||
|
||||
````julia
|
||||
x = randn(100, 100)
|
||||
contourf(x)
|
||||
````
|
||||
|
||||
|
||||
![](figures/pyplot_formats_5_1.png)
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
.. code-block:: julia
|
||||
|
||||
using PyPlot
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x, sin(x))
|
||||
|
||||
|
||||
|
||||
.. figure:: figures/pyplot_formats_sin_fun_1.svg
|
||||
:width: 15 cm
|
||||
|
||||
sin(x) function.
|
||||
|
||||
|
||||
|
||||
|
||||
.. figure:: figures/pyplot_formats_2_1.svg
|
||||
:width: 15 cm
|
||||
|
||||
cos(x) function.
|
||||
|
||||
|
||||
|
||||
|
||||
.. image:: figures/pyplot_formats_cos2_fun_1.svg
|
||||
:width: 15 cm
|
||||
|
||||
|
||||
|
||||
|
||||
.. code-block:: julia
|
||||
|
||||
julia> x = linspace(0, 2π, 200)
|
||||
200-element Array{Float64,1}:
|
||||
0.0
|
||||
0.0315738
|
||||
0.0631476
|
||||
0.0947214
|
||||
0.126295
|
||||
0.157869
|
||||
0.189443
|
||||
0.221017
|
||||
0.25259
|
||||
0.284164
|
||||
⋮
|
||||
6.03059
|
||||
6.06217
|
||||
6.09374
|
||||
6.12532
|
||||
6.15689
|
||||
6.18846
|
||||
6.22004
|
||||
6.25161
|
||||
6.28319
|
||||
|
||||
julia> plot(x, sin(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7fb1d635b790>
|
||||
|
||||
julia> y = 20
|
||||
20
|
||||
|
||||
julia> plot(x, cos(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7fb1d635ba10>
|
||||
|
||||
|
||||
|
||||
|
||||
.. image:: figures/pyplot_formats_4_1.svg
|
||||
:width: 15 cm
|
||||
|
||||
|
||||
|
||||
|
||||
.. code-block:: julia
|
||||
|
||||
x = randn(100, 100)
|
||||
contourf(x)
|
||||
|
||||
|
||||
|
||||
.. image:: figures/pyplot_formats_5_1.svg
|
||||
:width: 15cm
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
\begin{juliacode}
|
||||
using PyPlot
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x, sin(x))
|
||||
\end{juliacode}
|
||||
\begin{figure}[ht]
|
||||
\center
|
||||
\includegraphics[width=\linewidth]{figures/pyplot_formats_sin_fun_1.pdf}
|
||||
\caption{sin(x) function.}
|
||||
\label{fig:sin_fun}
|
||||
\end{figure}
|
||||
|
||||
|
||||
|
||||
\begin{figure}[htpb]
|
||||
\center
|
||||
\includegraphics[width=\linewidth]{figures/pyplot_formats_2_1.pdf}
|
||||
\caption{cos(x) function.}
|
||||
\end{figure}
|
||||
|
||||
|
||||
|
||||
\includegraphics[width=\linewidth]{figures/pyplot_formats_cos2_fun_1.pdf}
|
||||
|
||||
|
||||
|
||||
\begin{juliaterm}
|
||||
julia> x = linspace(0, 2π, 200)
|
||||
200-element Array{Float64,1}:
|
||||
0.0
|
||||
0.0315738
|
||||
0.0631476
|
||||
0.0947214
|
||||
0.126295
|
||||
0.157869
|
||||
0.189443
|
||||
0.221017
|
||||
0.25259
|
||||
0.284164
|
||||
⋮
|
||||
6.03059
|
||||
6.06217
|
||||
6.09374
|
||||
6.12532
|
||||
6.15689
|
||||
6.18846
|
||||
6.22004
|
||||
6.25161
|
||||
6.28319
|
||||
|
||||
julia> plot(x, sin(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7f9541e564d0>
|
||||
|
||||
julia> y = 20
|
||||
20
|
||||
|
||||
julia> plot(x, cos(x))
|
||||
1-element Array{Any,1}:
|
||||
PyObject <matplotlib.lines.Line2D object at 0x7f9541e56750>
|
||||
|
||||
\end{juliaterm}
|
||||
\includegraphics[width=\linewidth]{figures/pyplot_formats_4_1.pdf}
|
||||
|
||||
|
||||
|
||||
\begin{juliacode}
|
||||
x = randn(100, 100)
|
||||
contourf(x)
|
||||
\end{juliacode}
|
||||
\includegraphics[width=15cm]{figures/pyplot_formats_5_1.pdf}
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using Weave
|
||||
using Base.Test
|
||||
|
||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="tex")
|
||||
result = readall(open("documents/pyplot_formats.tex"))
|
||||
ref = readall(open("documents/pyplot_formats_ref.tex"))
|
||||
result = replace(result, r"\s*PyObject.*\n", "") #Remove PyObjects, because they change
|
||||
ref = replace(ref, r"\s*PyObject.*\n", "")
|
||||
@test result == ref
|
||||
|
||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="github")
|
||||
result = readall(open("documents/pyplot_formats.md"))
|
||||
ref = readall(open("documents/pyplot_formats_ref.md"))
|
||||
result = replace(result, r"\s*PyObject.*\n", "")
|
||||
ref = replace(ref, r"\s*PyObject.*\n", "")
|
||||
@test result == ref
|
||||
|
||||
|
||||
weave("documents/pyplot_formats.txt", plotlib="pyplot", doctype="rst", fig_ext=".svg")
|
||||
result = readall(open("documents/pyplot_formats.tex"))
|
||||
ref = readall(open("documents/pyplot_formats_ref.tex"))
|
||||
result = replace(result, r"\s*PyObject.*\n", "")
|
||||
ref = replace(ref, r"\s*PyObject.*\n", "")
|
||||
@test result == ref
|
|
@ -3,7 +3,7 @@ using Base.Test
|
|||
|
||||
|
||||
include("chunk_options.jl")
|
||||
|
||||
include("pyplot_formats.jl")
|
||||
|
||||
|
||||
#Test Gadfly and markdown reader, Gadfly only works with 0.3
|
||||
|
|
Loading…
Reference in New Issue