make tests pass

This commit is contained in:
Daniel Schwabeneder 2018-08-25 00:44:18 +02:00
parent de3848ff53
commit 962de0bffb
7 changed files with 66 additions and 53 deletions

View File

@ -4,7 +4,8 @@ os:
- linux - linux
# - osx # - osx
julia: julia:
# - 0.7 - 0.7
- 1.0
- nightly - nightly
# matrix: # matrix:
# allow_failures: # allow_failures:
@ -43,10 +44,10 @@ before_install:
notifications: notifications:
email: true email: true
# uncomment the following lines to override the default test script # uncomment the following lines to override the default test script
script: # script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi # - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")' # - julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")'
- julia test/travis_commands.jl # - julia test/travis_commands.jl
# - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")' # - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")'
# - julia -e 'Pkg.clone("GR"); Pkg.build("GR")' # - julia -e 'Pkg.clone("GR"); Pkg.build("GR")'
# # - julia -e 'Pkg.clone("https://github.com/tbreloff/ImageMagick.jl.git"); Pkg.checkout("ImageMagick","tb_write"); Pkg.build("ImageMagick")' # # - julia -e 'Pkg.clone("https://github.com/tbreloff/ImageMagick.jl.git"); Pkg.checkout("ImageMagick","tb_write"); Pkg.build("ImageMagick")'

View File

@ -1,14 +1,23 @@
environment: environment:
matrix: matrix:
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe" - julia_version: 0.7
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe" - julia_version: 1
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - julia_version: nightly
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
platform:
- x86 # 32-bit
- x64 # 64-bit
# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
# matrix: # matrix:
# allow_failures: # allow_failures:
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" # - julia_version: nightly
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
branches:
only:
- master
- /release-.*/
notifications: notifications:
- provider: Email - provider: Email
@ -17,22 +26,18 @@ notifications:
on_build_status_changed: false on_build_status_changed: false
install: install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile($env:JULIA_URL, "C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
build_script: build_script:
# Need to convert from shallow to complete for Pkg.clone to work - echo "%JL_BUILD_SCRIPT%"
- IF EXIST .git\shallow (git fetch --unshallow) - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
- C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"Plots\"); Pkg.build(\"Plots\")"
test_script: test_script:
# - C:\projects\julia\bin\julia -e "Pkg.test(\"Plots\")" - echo "%JL_TEST_SCRIPT%"
- C:\projects\julia\bin\julia -e "include(Pkg.dir(\"Plots\", \"test\", \"travis_commands.jl\"))" - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

View File

@ -116,7 +116,7 @@ ignorenan_minimum(x) = Base.minimum(x)
ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x) ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x)
ignorenan_maximum(x) = Base.maximum(x) ignorenan_maximum(x) = Base.maximum(x)
ignorenan_mean(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.mean(x) ignorenan_mean(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.mean(x)
ignorenan_mean(x) = Base.mean(x) ignorenan_mean(x) = mean(x)
ignorenan_extrema(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.extrema(x) ignorenan_extrema(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.extrema(x)
ignorenan_extrema(x) = Base.extrema(x) ignorenan_extrema(x) = Base.extrema(x)

View File

@ -52,7 +52,7 @@ the `z` argument to turn on series gradients.
[:(begin [:(begin
y = rand(100) y = rand(100)
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6) plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6)
scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y.-0.5).+4, scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,Plots.stroke(1,:green)), ms=10*abs.(y.-0.5).+4,
lab="grad") lab="grad")
end)] end)]
), ),
@ -66,6 +66,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`
`yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
""", """,
[:(begin [:(begin
using Statistics
y = rand(20,3) y = rand(20,3)
plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2),
leg=false) leg=false)
@ -85,8 +86,8 @@ yaxis!("YLABEL", :log10)
PlotExample("Images", PlotExample("Images",
"Plot an image. y-axis is set to flipped", "Plot an image. y-axis is set to flipped",
[:(begin [:(begin
import FileIO import FileIO, PlotReferenceImages
img = FileIO.load(Pkg.dir("PlotReferenceImages","Plots","pyplot","0.7.0","ref1.png")) img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png"))
plot(img) plot(img)
end)] end)]
), ),
@ -102,7 +103,7 @@ series.
""", """,
[:(begin [:(begin
ys = Vector[rand(10), rand(20)] ys = Vector[rand(10), rand(20)]
plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,stroke(3,:gray))) plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,Plots.stroke(3,:gray)))
end)] end)]
), ),
@ -202,7 +203,8 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo
PlotExample("", PlotExample("",
"", "",
[:(begin [:(begin
Random.srand(111) using Random
Random.seed!(111)
plot!(Plots.fakedata(100,10)) plot!(Plots.fakedata(100,10))
end)] end)]
), ),
@ -295,7 +297,7 @@ PlotExample("3D",
x = ts .* map(cos,ts) x = ts .* map(cos,ts)
y = 0.1ts .* map(sin,ts) y = 0.1ts .* map(sin,ts)
z = 1:n z = 1:n
plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, cbar=true, w=5) plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,Plots.stroke(0)), leg=false, cbar=true, w=5)
plot!(zeros(n),zeros(n),1:n, w=10) plot!(zeros(n),zeros(n),1:n, w=10)
end)] end)]
), ),
@ -382,8 +384,9 @@ various different nonzero values, a colorbar is added. The colorbar can be disab
`legend = nothing`. `legend = nothing`.
""", """,
[:(begin [:(begin
a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) using SparseArrays
b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) a = spdiagm(0 => ones(50), 1 => ones(49), -1 => ones(49), 10 => ones(40), -10 => ones(40))
b = spdiagm(0 => 1:50, 1 => 1:49, -1 => 1:49, 10 => 1:40, -10 => 1:40)
plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"]) plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"])
end)] end)]
), ),
@ -411,7 +414,7 @@ attribute. The default framestyle is `:axes`.
scatter(fill(randn(10), 6), fill(randn(10), 6), scatter(fill(randn(10), 6), fill(randn(10), 6),
framestyle = [:box :semi :origin :zerolines :grid :none], framestyle = [:box :semi :origin :zerolines :grid :none],
title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"],
color = RowVector(1:6), layout = 6, label = "", markerstrokewidth = 0, color = permutedims(1:6), layout = 6, label = "", markerstrokewidth = 0,
ticks = -2:2) ticks = -2:2)
end)] end)]
), ),

View File

@ -4,6 +4,7 @@ ImageMagick
@osx QuartzImageIO @osx QuartzImageIO
GR 0.31.0 GR 0.31.0
RDatasets RDatasets
VisualRegressionTests VisualRegressionTests 0.1+
UnicodePlots UnicodePlots
LaTeXStrings LaTeXStrings
Gtk

View File

@ -1,5 +1,5 @@
using VisualRegressionTests using VisualRegressionTests, Gtk, PlotReferenceImages
# using ExamplePlots # using ExamplePlots
# import DataFrames, RDatasets # import DataFrames, RDatasets
@ -15,7 +15,7 @@ using VisualRegressionTests
using Plots using Plots
# using StatPlots # using StatPlots
using Test using Test, Random
default(size=(500,300)) default(size=(500,300))
@ -26,7 +26,7 @@ default(size=(500,300))
const _current_plots_version = v"0.17.4" const _current_plots_version = v"0.17.4"
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], tol = 1e-2)
Plots._debugMode.on = debug Plots._debugMode.on = debug
example = Plots._examples[idx] example = Plots._examples[idx]
@info("Testing plot: $pkg:$idx:$(example.header)") @info("Testing plot: $pkg:$idx:$(example.header)")
@ -38,7 +38,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
# reference image directory setup # reference image directory setup
# refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg)) # refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg))
refdir = Pkg.dir("PlotReferenceImages", "Plots", string(pkg)) refdir = joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots", string(pkg))
fn = "ref$idx.png" fn = "ref$idx.png"
# firgure out version info # firgure out version info
@ -83,7 +83,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
# the test # the test
vtest = VisualTest(func, reffn, idx) vtest = VisualTest(func, reffn, idx)
test_images(vtest, popup=popup, sigma=sigma, eps=eps, newfn = newfn) test_images(vtest, popup=popup, sigma=sigma, tol=tol, newfn = newfn)
end end
function image_comparison_facts(pkg::Symbol; function image_comparison_facts(pkg::Symbol;
@ -91,11 +91,11 @@ function image_comparison_facts(pkg::Symbol;
only = nothing, # limit to these examples (int index) only = nothing, # limit to these examples (int index)
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) tol = 1e-2) # acceptable error (percent)
for i in 1:length(Plots._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
@test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success == true @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true
end end
end end
end end

View File

@ -1,11 +1,14 @@
module PlotsTests module PlotsTests
using Pkg
Pkg.add(PackageSpec(url="https://github.com/tkf/PlotReferenceImages.jl", rev="pkg3"))
include("imgcomp.jl") include("imgcomp.jl")
# don't actually show the plots # don't actually show the plots
Random.seed!(1234) Random.seed!(1234)
default(show=false, reuse=true) default(show=false, reuse=true)
img_eps = isinteractive() ? 1e-2 : 10e-2 img_tol = isinteractive() ? 1e-2 : 10e-2
@testset "GR" begin @testset "GR" begin
ENV["PLOTS_TEST"] = "true" ENV["PLOTS_TEST"] = "true"
@ -13,7 +16,7 @@ img_eps = isinteractive() ? 1e-2 : 10e-2
@test gr() == Plots.GRBackend() @test gr() == Plots.GRBackend()
@test backend() == Plots.GRBackend() @test backend() == Plots.GRBackend()
image_comparison_facts(:gr, eps=img_eps, skip = [25, 30]) image_comparison_facts(:gr, tol=img_tol, skip = [25, 30])
end end
@ -21,7 +24,7 @@ end
# @test pyplot() == Plots.PyPlotBackend() # @test pyplot() == Plots.PyPlotBackend()
# @test backend() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend()
# #
# image_comparison_facts(:pyplot, eps=img_eps) # image_comparison_facts(:pyplot, tol=img_tol)
#end #end
@testset "UnicodePlots" begin @testset "UnicodePlots" begin
@ -46,7 +49,7 @@ end
# 27, # (polar plots) takes very long / not working # 27, # (polar plots) takes very long / not working
# 31, # animation (skipped for speed) # 31, # animation (skipped for speed)
# ], # ],
# eps=img_eps) # tol=img_tol)
# end # end
# end # end
@ -70,7 +73,7 @@ end
# 28, # heatmap not defined # 28, # heatmap not defined
# 31, # animation # 31, # animation
# ], # ],
# eps=img_eps) # tol=img_tol)
# end # end
@ -79,7 +82,7 @@ end
# @test backend() == Plots.PlotlyBackend() # @test backend() == Plots.PlotlyBackend()
# #
# # # until png generation is reliable on OSX, just test on linux # # # until png generation is reliable on OSX, just test on linux
# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) # # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], tol=img_tol)
# end # end
@ -88,7 +91,7 @@ end
# @test backend() == Plots.ImmerseBackend() # @test backend() == Plots.ImmerseBackend()
# #
# # as long as we can plot anything without error, it should be the same as Gadfly # # as long as we can plot anything without error, it should be the same as Gadfly
# image_comparison_facts(:immerse, only=[1], eps=img_eps) # image_comparison_facts(:immerse, only=[1], tol=img_tol)
# end # end
@ -97,7 +100,7 @@ end
# @test backend() == Plots.PlotlyJSBackend() # @test backend() == Plots.PlotlyJSBackend()
# #
# # as long as we can plot anything without error, it should be the same as Plotly # # as long as we can plot anything without error, it should be the same as Plotly
# image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) # image_comparison_facts(:plotlyjs, only=[1], tol=img_tol)
# end # end
@ -110,7 +113,7 @@ end
# @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) # @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing)
# @test plot!(rand(10,3), rand(10,3)) == not(nothing) # @test plot!(rand(10,3), rand(10,3)) == not(nothing)
# #
# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) # image_comparison_facts(:gadfly, skip=[4,6,23,24,27], tol=img_tol)
# end # end