From cd450f49d45ccb005dc77ad161bd9e5ae2b527e3 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 13:26:26 -0500 Subject: [PATCH 01/11] Added tests for plots where xlims are Dates and DateTimes --- test/integration_dates.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index 6a5756c7..85ed3da6 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -14,3 +14,19 @@ using Plots, Test, Dates @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims end # testset + +@testset "Date xlims" begin + y=[1.0*i*i for i in 1:10] + x=[Date(2019,11,i) for i in 1:10] + span = (Date(2019,10,31), Date(2019,11,11)) + + p = plot(x,y, xlims=span, widen = false) +end # testset + +@testset "DateTime xlims" begin + y=[1.0*i*i for i in 1:10] + x=[DateTime(2019,11,i,11) for i in 1:10] + span = (DateTime(2019,10,31,11,59,59), DateTime(2019,11,11,12,01,15)) + + p = plot(x,y, xlims=span, widen = false) +end # testset From eea73202e22a9ededb9e2e3489890e1225b435d2 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 13:27:30 -0500 Subject: [PATCH 02/11] Added display checks to Date/DateTime tests to ensure they are able to be displayed --- test/integration_dates.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index 85ed3da6..b4598d4c 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -13,6 +13,7 @@ using Plots, Test, Dates ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims + @test isa(display(p), Nothing) == true end # testset @testset "Date xlims" begin @@ -21,6 +22,7 @@ end # testset span = (Date(2019,10,31), Date(2019,11,11)) p = plot(x,y, xlims=span, widen = false) + @test isa(display(p), Nothing) == true end # testset @testset "DateTime xlims" begin @@ -29,4 +31,5 @@ end # testset span = (DateTime(2019,10,31,11,59,59), DateTime(2019,11,11,12,01,15)) p = plot(x,y, xlims=span, widen = false) + @test isa(display(p), Nothing) == true end # testset From 8a3ee7bb752f9b773034a7b270fa06e40cd06fe4 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 13:30:14 -0500 Subject: [PATCH 03/11] Added fix for case where lims are Date/DateTime s --- src/axes.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/axes.jl b/src/axes.jl index 0ef3a3a7..4523a973 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -94,6 +94,11 @@ function attr!(axis::Axis, args...; kw...) for vi in v discrete_value!(axis, vi) end + elseif k == :lims && isa(v, Tuple{Date,Date}) + plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) + elseif k == :lims && isa(v, Tuple{DateTime,DateTime}) + println("Converting datetime") + plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) else plotattributes[k] = v end From 2013215ef28efbbf9ce568174dffb9800361c307 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 13:35:00 -0500 Subject: [PATCH 04/11] Removed a println --- src/axes.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/axes.jl b/src/axes.jl index 4523a973..5f6b469d 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -97,7 +97,6 @@ function attr!(axis::Axis, args...; kw...) elseif k == :lims && isa(v, Tuple{Date,Date}) plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) elseif k == :lims && isa(v, Tuple{DateTime,DateTime}) - println("Converting datetime") plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) else plotattributes[k] = v From c9b1de33f641bf3e6a25ff53f81788f70a02aaf7 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 13:35:25 -0500 Subject: [PATCH 05/11] Added comments about possible alternate solutions --- src/axes.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/axes.jl b/src/axes.jl index 5f6b469d..37ea8eaa 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -94,6 +94,8 @@ function attr!(axis::Axis, args...; kw...) for vi in v discrete_value!(axis, vi) end + #could perhaps use TimeType here, as Date and DateTime are both subtypes of TimeType + # or could perhaps check if dateformatter or datetimeformatter is in use elseif k == :lims && isa(v, Tuple{Date,Date}) plotattributes[k] = (v[1].instant.periods.value, v[2].instant.periods.value) elseif k == :lims && isa(v, Tuple{DateTime,DateTime}) From e9a4231a5f35d6806dd2e0dff6327503eb1d1369 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 14:30:11 -0500 Subject: [PATCH 06/11] Added checks around display checks to see if we're in CI --- test/integration_dates.jl | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index b4598d4c..4d43ccaf 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -13,7 +13,11 @@ using Plots, Test, Dates ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims - @test isa(display(p), Nothing) == true + @static if haskey(ENV, "APPVEYOR") + @info "Skipping display tests on AppVeyor" + else + @test isa(display(p), Nothing) == true + end end # testset @testset "Date xlims" begin @@ -21,8 +25,16 @@ end # testset x=[Date(2019,11,i) for i in 1:10] span = (Date(2019,10,31), Date(2019,11,11)) + ref_xlims = map(date->date.instant.periods.value, span) + p = plot(x,y, xlims=span, widen = false) - @test isa(display(p), Nothing) == true + + @test Plots.xlims(p) == ref_xlims + @static if haskey(ENV, "APPVEYOR") + @info "Skipping display tests on AppVeyor" + else + @test isa(display(p), Nothing) == true + end end # testset @testset "DateTime xlims" begin @@ -30,6 +42,13 @@ end # testset x=[DateTime(2019,11,i,11) for i in 1:10] span = (DateTime(2019,10,31,11,59,59), DateTime(2019,11,11,12,01,15)) + ref_xlims = map(date->date.instant.periods.value, span) + p = plot(x,y, xlims=span, widen = false) - @test isa(display(p), Nothing) == true + @test Plots.xlims(p) == ref_xlims + @static if haskey(ENV, "APPVEYOR") + @info "Skipping display tests on AppVeyor" + else + @test isa(display(p), Nothing) == true + end end # testset From 0849471bf66b9e43a5de0c2de953c96e3de5143f Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 14:50:16 -0500 Subject: [PATCH 07/11] Added second condition to skip display checks --- test/integration_dates.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index 4d43ccaf..924d9446 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -13,7 +13,7 @@ using Plots, Test, Dates ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims - @static if haskey(ENV, "APPVEYOR") + @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true @@ -28,9 +28,9 @@ end # testset ref_xlims = map(date->date.instant.periods.value, span) p = plot(x,y, xlims=span, widen = false) - + @test Plots.xlims(p) == ref_xlims - @static if haskey(ENV, "APPVEYOR") + @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true @@ -46,7 +46,7 @@ end # testset p = plot(x,y, xlims=span, widen = false) @test Plots.xlims(p) == ref_xlims - @static if haskey(ENV, "APPVEYOR") + @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true From 8c49652add61a794804a58e3539d91ae4e2a4d37 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 15:20:11 -0500 Subject: [PATCH 08/11] Moved Dates tests to be before backend tests --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 18ac4366..4c26e3bf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -31,10 +31,10 @@ end # testset include("test_defaults.jl") include("test_axes.jl") include("test_axis_letter.jl") +include("integration_dates.jl") include("test_recipes.jl") include("test_hdf5plots.jl") include("test_pgfplotsx.jl") -include("integration_dates.jl") reference_dir(args...) = joinpath(homedir(), ".julia", "dev", "PlotReferenceImages", args...) From 06a823a3be3893f5abaed4ee3a57d1feb4947648 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 15:21:15 -0500 Subject: [PATCH 09/11] Removed CI env check in Dates tests --- test/integration_dates.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index 924d9446..13faf26b 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -13,7 +13,8 @@ using Plots, Test, Dates ref_xlims = (x[1].instant.periods.value, x[end].instant.periods.value) @test Plots.ylims(p) == ref_ylims @test Plots.xlims(p) == ref_xlims - @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + #@static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + @static if haskey(ENV, "APPVEYOR") @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true @@ -30,7 +31,8 @@ end # testset p = plot(x,y, xlims=span, widen = false) @test Plots.xlims(p) == ref_xlims - @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + #@static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + @static if haskey(ENV, "APPVEYOR") @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true @@ -46,7 +48,8 @@ end # testset p = plot(x,y, xlims=span, widen = false) @test Plots.xlims(p) == ref_xlims - @static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + #@static if (haskey(ENV, "APPVEYOR") || haskey(ENV, "CI")) + @static if haskey(ENV, "APPVEYOR") @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true From f6627f3c5cdc3262fd2bf3ea76272fd1ed6ed28e Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Sun, 6 Dec 2020 18:54:53 -0500 Subject: [PATCH 10/11] Now closing plots after display calls --- test/integration_dates.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration_dates.jl b/test/integration_dates.jl index 13faf26b..081d69fb 100644 --- a/test/integration_dates.jl +++ b/test/integration_dates.jl @@ -18,6 +18,7 @@ using Plots, Test, Dates @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true + closeall() end end # testset @@ -36,6 +37,7 @@ end # testset @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true + closeall() end end # testset @@ -53,5 +55,6 @@ end # testset @info "Skipping display tests on AppVeyor" else @test isa(display(p), Nothing) == true + closeall() end end # testset From 9ba633bb5983d4de921cb5cc7f6ec1fc362052f0 Mon Sep 17 00:00:00 2001 From: Thatcher Chamberlin Date: Mon, 7 Dec 2020 08:26:48 -0500 Subject: [PATCH 11/11] retrigger checks