diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ac4a0084..dcec41d6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: version: - - "1.0" # LTS + - "1.6" # LTS - "1" # Latest Release os: - ubuntu-latest @@ -30,11 +30,6 @@ jobs: arch: x86 - os: windows-latest arch: x86 - include: - # Add a 1.5 job because that's what Invenia actually uses - - os: ubuntu-latest - version: 1.5 - arch: x64 steps: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 diff --git a/Project.toml b/Project.toml index 4b976c86..2d6b35de 100644 --- a/Project.toml +++ b/Project.toml @@ -12,11 +12,11 @@ Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" [compat] -Documenter = "0.23, 0.24" +Documenter = "0.23, 0.24, 0.25, 0.26, 0.27" Infinity = "0.2.3" RecipesBase = "0.7, 0.8, 1" -TimeZones = "0.7, 0.8, 0.9, 0.10, 0.11, 1" -julia = "1" +TimeZones = "1.7" +julia = "1.6" [extras] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" diff --git a/src/Intervals.jl b/src/Intervals.jl index 0a66b81a..d0fc0d67 100644 --- a/src/Intervals.jl +++ b/src/Intervals.jl @@ -10,12 +10,6 @@ using Dates: AbstractDateTime, value, coarserperiod import Base: ⊆, ⊇, ⊈, ⊉, union, union!, merge -# Extend `Base.isdisjoint` when it exists -# https://github.com/JuliaLang/julia/pull/34427 -if VERSION >= v"1.5.0-DEV.124" - import Base: isdisjoint -end - abstract type Bound end abstract type Bounded <: Bound end struct Closed <: Bounded end diff --git a/src/compat.jl b/src/compat.jl index f85e5c6d..f0939a0a 100644 --- a/src/compat.jl +++ b/src/compat.jl @@ -21,11 +21,3 @@ function Serialization.deserialize(s::AbstractSerializer, ::Type{AnchoredInterva return AnchoredInterval{P,T,L,R}(anchor) end - -# Works around an issue where a `StepRangeLen` tries to convert the step to an -# `AbstractInterval`. -# Issue introduced in https://github.com/JuliaLang/julia/pull/23194 (a698230daf6) -# and fixed in https://github.com/JuliaLang/julia/pull/34412 (fca037a162) -if v"0.7.0-DEV.1399" <= VERSION < v"1.5.0-DEV.127" - Base.step(r::StepRangeLen{<:AbstractInterval}) = r.step -end diff --git a/src/interval.jl b/src/interval.jl index 73f6d3f4..a674c2e6 100644 --- a/src/interval.jl +++ b/src/interval.jl @@ -365,7 +365,7 @@ function Base.issubset(a::AbstractInterval, b::AbstractInterval) return LeftEndpoint(a) ≥ LeftEndpoint(b) && RightEndpoint(a) ≤ RightEndpoint(b) end -function isdisjoint(a::AbstractInterval, b::AbstractInterval) +function Base.isdisjoint(a::AbstractInterval, b::AbstractInterval) return RightEndpoint(a) < LeftEndpoint(b) || LeftEndpoint(a) > RightEndpoint(b) end diff --git a/test/anchoredinterval.jl b/test/anchoredinterval.jl index 6a21a2ff..90858815 100644 --- a/test/anchoredinterval.jl +++ b/test/anchoredinterval.jl @@ -245,38 +245,35 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded # When dropping VERSION < v"1.2.0-DEV.223" (https://github.com/JuliaLang/julia/pull/30817) # - `repr(Period(...))`can be converted to hardcode strings - where_lr = "where R<:$Bounded where L<:$Bounded" - where_tlr = "$where_lr where T" + where_lr = "where {L<:$Bounded, R<:$Bounded}" + where_tlr = "where {T, L<:$Bounded, R<:$Bounded}" - where_lr2 = "where {L<:$Bounded, R<:$Bounded}" - where_tlr2 = "where {T, L<:$Bounded, R<:$Bounded}" - - if VERSION >= v"1.6.0" + if VERSION >= v"1.7.0" @test sprint(show, AnchoredInterval{Hour(-1)}) == - "HourEnding{T, L, R} $where_tlr2" + "HourEnding" @test sprint(show, AnchoredInterval{Hour(1)}) == - "HourBeginning{T, L, R} $where_tlr2" + "HourBeginning" @test sprint(show, AnchoredInterval{Day(-1)}) == - "AnchoredInterval{$(repr(Day(-1))), T, L, R} $where_tlr2" + "AnchoredInterval{$(repr(Day(-1)))}" @test sprint(show, AnchoredInterval{Day(1)}) == - "AnchoredInterval{$(repr(Day(1))), T, L, R} $where_tlr2" + "AnchoredInterval{$(repr(Day(1)))}" @test sprint(show, AnchoredInterval{Day(-1), DateTime}) == - "AnchoredInterval{$(repr(Day(-1))), DateTime, L, R} $where_lr2" + "AnchoredInterval{$(repr(Day(-1))), DateTime}" @test sprint(show, AnchoredInterval{Day(1), DateTime}) == - "AnchoredInterval{$(repr(Day(1))), DateTime, L, R} $where_lr2" + "AnchoredInterval{$(repr(Day(1))), DateTime}" else @test sprint(show, AnchoredInterval{Hour(-1)}) == - "AnchoredInterval{$(repr(Hour(-1))),T,L,R} $where_tlr" + "HourEnding{T, L, R} $where_tlr" @test sprint(show, AnchoredInterval{Hour(1)}) == - "AnchoredInterval{$(repr(Hour(1))),T,L,R} $where_tlr" + "HourBeginning{T, L, R} $where_tlr" @test sprint(show, AnchoredInterval{Day(-1)}) == - "AnchoredInterval{$(repr(Day(-1))),T,L,R} $where_tlr" + "AnchoredInterval{$(repr(Day(-1))), T, L, R} $where_tlr" @test sprint(show, AnchoredInterval{Day(1)}) == - "AnchoredInterval{$(repr(Day(1))),T,L,R} $where_tlr" + "AnchoredInterval{$(repr(Day(1))), T, L, R} $where_tlr" @test sprint(show, AnchoredInterval{Day(-1), DateTime}) == - "AnchoredInterval{$(repr(Day(-1))),DateTime,L,R} $where_lr" + "AnchoredInterval{$(repr(Day(-1))), DateTime, L, R} $where_lr" @test sprint(show, AnchoredInterval{Day(1), DateTime}) == - "AnchoredInterval{$(repr(Day(1))),DateTime,L,R} $where_lr" + "AnchoredInterval{$(repr(Day(1))), DateTime, L, R} $where_lr" end # Tuples contain fields: interval, printed, shown @@ -285,11 +282,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(dt), "(2016-08-11 HE02]", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" - end, + "HourEnding{DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -297,11 +290,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding{Closed, Open}(DateTime(2013, 2, 13)), "[2013-02-12 HE24)", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime, Closed, Open}" - else - "AnchoredInterval{$(repr(Hour(-1))),DateTime,Closed,Open}" - end, + "HourEnding{DateTime, Closed, Open}", "($(repr(DateTime(2013, 2, 13))))", ), ), @@ -309,11 +298,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(dt + Minute(15) + Second(30)), "(2016-08-11 HE02:15:30]", string( - if VERSION >= v"1.6.0" - "HourEnding{DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" - end, + "HourEnding{DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2, 15, 30))))", ), ), @@ -321,11 +306,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(dt + Millisecond(2)), "(2016-08-11 HE02:00:00.002]", string( - if VERSION >= v"1.6.0" - "HourEnding{DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" - end, + "HourEnding{DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2, 0, 0, 2))))", ), ), @@ -333,11 +314,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding{Closed, Open}(DateTime(2013, 2, 13, 0, 1)), "[2013-02-13 HE00:01:00)", string( - if VERSION >= v"1.6.0" - "HourEnding{DateTime, Closed, Open}" - else - "AnchoredInterval{$(repr(Hour(-1))),DateTime,Closed,Open}" - end, + "HourEnding{DateTime, Closed, Open}", "($(repr(DateTime(2013, 2, 13, 0, 1))))", ), ), @@ -345,11 +322,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourBeginning(dt), "[2016-08-11 HB02)", string( - if VERSION >= v"1.6.0" - "HourBeginning{DateTime, Closed, Open}" - else - "AnchoredInterval{$(repr(Hour(1))),DateTime,Closed,Open}" - end, + "HourBeginning{DateTime, Closed, Open}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -357,11 +330,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourBeginning{Open, Closed}(DateTime(2013, 2, 13)), "(2013-02-13 HB00]", string( - if VERSION >= v"1.6.0" - "HourBeginning{DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Hour(1))),DateTime,Open,Closed}" - end, + "HourBeginning{DateTime, Open, Closed}", "($(repr(DateTime(2013, 2, 13))))", ), ), @@ -369,11 +338,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(ZonedDateTime(dt, tz"America/Winnipeg")), "(2016-08-11 HE02-05:00]", string( - if VERSION >= v"1.6.0" - "HourEnding{$ZonedDateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Hour(-1))),$ZonedDateTime,Open,Closed}" - end, + "HourEnding{$ZonedDateTime, Open, Closed}", "($(repr(ZonedDateTime(dt, tz"America/Winnipeg"))))", ), ), @@ -381,11 +346,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Year(-1)}(Date(dt)), "(YE 2016-08-11]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}" - else - "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}" - end, + "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}", "($(repr(Date(2016, 8, 11))))", ), ), @@ -393,11 +354,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Year(-1)}(ceil(Date(dt), Year)), "(YE 2017-01-01]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}" - else - "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}" - end, + "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}", "($(repr(Date(2017, 1, 1))))", ), ), @@ -405,11 +362,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Month(-1)}(dt), "(MoE 2016-08-11 02:00:00]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2, 0, 0))))", ), ), @@ -417,11 +370,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Month(-1)}(ceil(dt, Month)), "(MoE 2016-09-01]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 9, 1))))", ), ), @@ -429,11 +378,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(DateTime(dt)), "(DE 2016-08-11 02:00:00]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -441,11 +386,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(ceil(DateTime(dt), Day)), "(DE 2016-08-12]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 12))))", ), ), @@ -454,11 +395,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(Date(dt)), "(DE 2016-08-11]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Day(-1))), Date, Open, Closed}" - else - "AnchoredInterval{$(repr(Day(-1))),Date,Open,Closed}" - end, + "AnchoredInterval{$(repr(Day(-1))), Date, Open, Closed}", "($(repr(Date(2016, 8, 11))))", ), ), @@ -470,11 +407,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded ), "(DE 2016-08-12 00:00:00-05:00]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Day(-1))), $ZonedDateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Day(-1))),$ZonedDateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Day(-1))), $ZonedDateTime, Open, Closed}", "($(repr(ZonedDateTime(2016, 8, 12, tz"America/Winnipeg"))))", ), ), @@ -482,11 +415,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Minute(-5)}(dt), "(2016-08-11 5ME02:00]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Minute(-5))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Minute(-5))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Minute(-5))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -494,11 +423,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Second(-30)}(dt), "(2016-08-11 30SE02:00:00]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Second(-30))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Second(-30))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Second(-30))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -506,11 +431,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Millisecond(-10)}(dt), "(2016-08-11 10msE02:00:00.000]", string( - if VERSION >= v"1.6.0" - "AnchoredInterval{$(repr(Millisecond(-10))), DateTime, Open, Closed}" - else - "AnchoredInterval{$(repr(Millisecond(-10))),DateTime,Open,Closed}" - end, + "AnchoredInterval{$(repr(Millisecond(-10))), DateTime, Open, Closed}", "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -532,23 +453,13 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded @test string(interval) == "(0 .. 10]" @test sprint(show, interval, context=:compact=>true) == string(interval) - shown = if VERSION >= v"1.6.0" - "AnchoredInterval{-10, $Int, Open, Closed}(10)" - else - "AnchoredInterval{-10,$Int,Open,Closed}(10)" - end - @test sprint(show, interval) == shown + @test sprint(show, interval) == "AnchoredInterval{-10, $Int, Open, Closed}(10)" interval = AnchoredInterval{25}('a') @test string(interval) == "[a .. z)" @test sprint(show, interval, context=:compact=>true) == string(interval) - shown = if VERSION >= v"1.6.0" - "AnchoredInterval{25, Char, Closed, Open}('a')" - else - "AnchoredInterval{25,Char,Closed,Open}('a')" - end - @test sprint(show, interval) == shown + @test sprint(show, interval) == "AnchoredInterval{25, Char, Closed, Open}('a')" end @testset "equality" begin diff --git a/test/interval.jl b/test/interval.jl index 84fd9818..0025e14e 100644 --- a/test/interval.jl +++ b/test/interval.jl @@ -282,33 +282,17 @@ interval = Interval{Open, Open}(1, 2) @test string(interval) == "(1 .. 2)" @test sprint(show, interval, context=:compact=>true) == string(interval) - - shown = if VERSION >= v"1.6.0" - "Interval{$Int, Open, Open}(1, 2)" - else - "Interval{$Int,Open,Open}(1, 2)" - end - @test sprint(show, interval) == shown + @test sprint(show, interval) == "Interval{$Int, Open, Open}(1, 2)" interval = Interval{Open, Closed}('a', 'b') @test string(interval) == "(a .. b]" @test sprint(show, interval, context=:compact=>true) == string(interval) - shown = if VERSION >= v"1.6.0" - "Interval{Char, Open, Closed}('a', 'b')" - else - "Interval{Char,Open,Closed}('a', 'b')" - end - @test sprint(show, interval) == shown + @test sprint(show, interval) == "Interval{Char, Open, Closed}('a', 'b')" interval = Interval{Closed, Open}(Date(2012), Date(2013)) - type_str = if VERSION >= v"1.6.0" - "Interval{Date, Closed, Open}" - else - "Interval{Date,Closed,Open}" - end shown = string( - type_str, + "Interval{Date, Closed, Open}", "(", sprint(show, Date(2012, 1, 1)), ", ", @@ -323,12 +307,7 @@ interval = Interval{Closed, Closed}("a", "b") @test string(interval) == "[a .. b]" @test sprint(show, interval, context=:compact=>true) == string(interval) - shown = if VERSION >= v"1.6.0" - "Interval{String, Closed, Closed}(\"a\", \"b\")" - else - "Interval{String,Closed,Closed}(\"a\", \"b\")" - end - @test sprint(show, interval) == shown + @test sprint(show, interval) == "Interval{String, Closed, Closed}(\"a\", \"b\")" end @testset "equality" begin diff --git a/test/plotting.jl b/test/plotting.jl index 70f17633..d0924a14 100644 --- a/test/plotting.jl +++ b/test/plotting.jl @@ -6,12 +6,12 @@ using VisualRegressionTests @testset "Interval{Float64,$L,$R}" for (L, R) in BOUND_PERMUTATIONS intervals = [Interval{L,R}(float(x), float(x + 0.5)) for x in 1:11] plot_file = "interval_$(lowercase("$(L)_$(R)")).png" - @plottest plot(intervals, 1:11) "references/$plot_file" false + @plottest plot(intervals, 1:11) "references/$plot_file" false 0.01 @testset "scatter" begin # Earlier versions of this functionality showed only end-points if plotted in # scatter, but for intervals the connect-line is part of the "marker" - @plottest scatter(intervals, 1:11) "references/$plot_file" false + @plottest scatter(intervals, 1:11) "references/$plot_file" false 0.01 end end @@ -22,12 +22,12 @@ using VisualRegressionTests @testset "Interval{DateTime}" begin date_intervals = [dt .. (dt + Hour(1)) for dt in datetimes] - @plottest plot(date_intervals, 1:11) "references/interval_datetime.png" false + @plottest plot(date_intervals, 1:11) "references/interval_datetime.png" false 0.01 end @testset "AnchoredInterval" begin - @plottest plot(HE.(datetimes), 1:11) "references/HE.png" false - @plottest plot(HB.(datetimes), 1:11) "references/HB.png" false + @plottest plot(HE.(datetimes), 1:11) "references/HE.png" false 0.01 + @plottest plot(HB.(datetimes), 1:11) "references/HB.png" false 0.01 end end end