diff --git a/.travis.yml b/.travis.yml index fb9a97a2..04da5561 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ os: - linux # - osx julia: - # - 0.7 + - 0.7 + - 1.0 - nightly # matrix: # allow_failures: @@ -43,10 +44,10 @@ before_install: notifications: email: true # uncomment the following lines to override the default test script -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")' - - julia test/travis_commands.jl +# script: +# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi +# - julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")' +# - julia test/travis_commands.jl # - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")' # - 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")' diff --git a/appveyor.yml b/appveyor.yml index a626cae5..c2588f1d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,14 +1,23 @@ environment: matrix: - # - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe" - # - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" + - julia_version: 0.7 + - julia_version: 1 + - julia_version: nightly +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: # allow_failures: -# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" -# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" +# - julia_version: nightly + +branches: + only: + - master + - /release-.*/ notifications: - provider: Email @@ -17,22 +26,18 @@ notifications: on_build_status_changed: false install: - - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" -# 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 + - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: -# Need to convert from shallow to complete for Pkg.clone to work - - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"Plots\"); Pkg.build(\"Plots\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - # - C:\projects\julia\bin\julia -e "Pkg.test(\"Plots\")" - - C:\projects\julia\bin\julia -e "include(Pkg.dir(\"Plots\", \"test\", \"travis_commands.jl\"))" + - echo "%JL_TEST_SCRIPT%" + - 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%" diff --git a/src/Plots.jl b/src/Plots.jl index 2b96c5cb..502996ba 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -116,7 +116,7 @@ ignorenan_minimum(x) = Base.minimum(x) ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x) ignorenan_maximum(x) = Base.maximum(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) = Base.extrema(x) diff --git a/src/examples.jl b/src/examples.jl index 71c41a8c..759a5127 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -52,7 +52,7 @@ the `z` argument to turn on series gradients. [:(begin y = rand(100) 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") end)] ), @@ -66,6 +66,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!` `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` """, [:(begin +using Statistics y = rand(20,3) plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false) @@ -85,8 +86,8 @@ yaxis!("YLABEL", :log10) PlotExample("Images", "Plot an image. y-axis is set to flipped", [:(begin - import FileIO - img = FileIO.load(Pkg.dir("PlotReferenceImages","Plots","pyplot","0.7.0","ref1.png")) + import FileIO, PlotReferenceImages + img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png")) plot(img) end)] ), @@ -102,7 +103,7 @@ series. """, [:(begin 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)] ), @@ -202,7 +203,8 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo PlotExample("", "", [:(begin - Random.srand(111) + using Random + Random.seed!(111) plot!(Plots.fakedata(100,10)) end)] ), @@ -295,7 +297,7 @@ PlotExample("3D", x = ts .* map(cos,ts) y = 0.1ts .* map(sin,ts) 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) end)] ), @@ -382,8 +384,9 @@ various different nonzero values, a colorbar is added. The colorbar can be disab `legend = nothing`. """, [:(begin - a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) - b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) + using SparseArrays + 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"]) end)] ), @@ -411,7 +414,7 @@ attribute. The default framestyle is `:axes`. scatter(fill(randn(10), 6), fill(randn(10), 6), framestyle = [: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) end)] ), diff --git a/test/REQUIRE b/test/REQUIRE index 6cd6a973..0d9a15c5 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -4,6 +4,7 @@ ImageMagick @osx QuartzImageIO GR 0.31.0 RDatasets -VisualRegressionTests +VisualRegressionTests 0.2 UnicodePlots LaTeXStrings +Gtk diff --git a/test/imgcomp.jl b/test/imgcomp.jl index abc08b13..2a01c24f 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -1,5 +1,5 @@ -using VisualRegressionTests +using VisualRegressionTests, Gtk, PlotReferenceImages # using ExamplePlots # import DataFrames, RDatasets @@ -15,7 +15,7 @@ using VisualRegressionTests using Plots # using StatPlots -using Test +using Test, Random default(size=(500,300)) @@ -26,7 +26,7 @@ default(size=(500,300)) 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 example = Plots._examples[idx] @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 # 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" # firgure out version info @@ -83,7 +83,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # the test 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 function image_comparison_facts(pkg::Symbol; @@ -91,11 +91,11 @@ function image_comparison_facts(pkg::Symbol; only = nothing, # limit to these examples (int index) debug = false, # print debug information? 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) i in skip && continue 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 diff --git a/test/runtests.jl b/test/runtests.jl index fd9f00bf..41f91229 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,14 @@ module PlotsTests +using Pkg +Pkg.add(PackageSpec(url="https://github.com/tkf/PlotReferenceImages.jl")) + include("imgcomp.jl") # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) -img_eps = isinteractive() ? 1e-2 : 10e-2 +img_tol = isinteractive() ? 1e-2 : 10e-2 @testset "GR" begin ENV["PLOTS_TEST"] = "true" @@ -13,7 +16,7 @@ img_eps = isinteractive() ? 1e-2 : 10e-2 @test gr() == 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 @@ -21,7 +24,7 @@ end # @test pyplot() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend() # -# image_comparison_facts(:pyplot, eps=img_eps) +# image_comparison_facts(:pyplot, tol=img_tol) #end @testset "UnicodePlots" begin @@ -46,7 +49,7 @@ end # 27, # (polar plots) takes very long / not working # 31, # animation (skipped for speed) # ], -# eps=img_eps) +# tol=img_tol) # end # end @@ -70,7 +73,7 @@ end # 28, # heatmap not defined # 31, # animation # ], -# eps=img_eps) +# tol=img_tol) # end @@ -79,7 +82,7 @@ end # @test backend() == Plots.PlotlyBackend() # # # # 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 @@ -88,7 +91,7 @@ end # @test backend() == Plots.ImmerseBackend() # # # 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 @@ -97,7 +100,7 @@ end # @test backend() == Plots.PlotlyJSBackend() # # # 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 @@ -110,7 +113,7 @@ end # @test plot(sort(rand(10)), rand(Int, 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