Skip to content

Commit 42f7855

Browse files
authored
Remove deprecated methods and bump version to v0.7.0 (#107)
* remove deprecated functions and methods * update tests * bump version to v0.7.0
1 parent 39b9007 commit 42f7855

File tree

4 files changed

+2
-73
lines changed

4 files changed

+2
-73
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "IntervalSets"
22
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
3-
version = "0.6.2"
3+
version = "0.7.0"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/IntervalSets.jl

+1-49
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Statistics: mean
1010
using Dates
1111

1212
export AbstractInterval, Interval, OpenInterval, ClosedInterval,
13-
, .., ±, ordered, width, duration, leftendpoint, rightendpoint, endpoints,
13+
, .., ±, ordered, width, leftendpoint, rightendpoint, endpoints,
1414
isopenset, isclosedset, isleftclosed, isrightclosed,
1515
isleftopen, isrightopen, closedendpoints,
1616
infimum, supremum
@@ -227,55 +227,7 @@ Clamp the scalar `t` such that the result is in the interval `i`.
227227
clamp(t, i::TypedEndpointsInterval{:closed,:closed}) =
228228
clamp(t, leftendpoint(i), rightendpoint(i))
229229

230-
231-
"""
232-
duration(iv)
233-
234-
calculates the the total number of integers or dates of an integer or date
235-
valued interval. For example, `duration(0..1)` is 2, while `width(0..1)` is 1.
236-
"""
237-
function duration(A::TypedEndpointsInterval{:closed,:closed,T}) where {T<:Integer}
238-
# TODO: Remove this method in the next breaking release
239-
Base.depwarn("`duration` will be removed in the next breaking release because it is ill-defined concept. " *
240-
"If you need 3 from 2..4, replace duration(2..4) with width(2..4)+1", :duration)
241-
max(0, Int(A.right - A.left) + 1)
242-
end
243-
function duration(A::TypedEndpointsInterval{:closed,:closed,Date})
244-
# TODO: Remove this method in the next breaking release
245-
Base.depwarn("`duration` will be removed in the next breaking release because it is ill-defined concept. " *
246-
"If you need 961 from A=Date(2018,08,08)..Date(2021,03,25), replace duration(A) with Dates.days(width(A))+1", :duration)
247-
max(0, Dates.days(A.right - A.left) + 1)
248-
end
249-
250230
include("interval.jl")
251-
252-
# convert numbers to intervals
253-
# TODO: These conversions will be removed in the next breaking release (#97)
254-
function convert(::Type{AbstractInterval}, x::Number)
255-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
256-
x..x
257-
end
258-
function convert(::Type{AbstractInterval{T}}, x::Number) where T
259-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
260-
convert(AbstractInterval{T}, convert(AbstractInterval, x))
261-
end
262-
function convert(::Type{TypedEndpointsInterval{:closed,:closed}}, x::Number)
263-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
264-
x..x
265-
end
266-
function convert(::Type{TypedEndpointsInterval{:closed,:closed,T}}, x::Number) where T
267-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
268-
convert(AbstractInterval{T}, convert(AbstractInterval, x))
269-
end
270-
function convert(::Type{ClosedInterval}, x::Number)
271-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
272-
x..x
273-
end
274-
function convert(::Type{ClosedInterval{T}}, x::Number) where T
275-
Base.depwarn("`The conversion number to interval will be removed; construct an interval explicitly, e.g., `x..x`.", :convert)
276-
convert(AbstractInterval{T}, convert(AbstractInterval, x))
277-
end
278-
279231
include("findall.jl")
280232

281233
end # module

src/interval.jl

-6
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@ Construct a ClosedInterval `iv` spanning the region from
9292
`center - halfwidth` to `center + halfwidth`.
9393
"""
9494
±(x, y) = ClosedInterval(x - y, x + y)
95-
function ±(x::CartesianIndex, y)
96-
# TODO: Remove this method in the next breaking release
97-
Base.depwarn("This method for `CartesianIndex(1,2) ± 1 == (0..2, 1..3)` is not consistent and will be removed because CartesianIndex(1,1) + 1 is not defined. " *
98-
"If you need tuple such as `(0..2, 1..3)` from `CartesianIndex`, just write it in a plain tuple form.", :±)
99-
(xy = y * one(x); map(ClosedInterval, (x - xy).I, (x + xy).I))
100-
end
10195
±(x::CartesianIndex, y::CartesianIndex) = ClosedInterval(x-y, x+y)
10296

10397
show(io::IO, I::ClosedInterval) = print(io, leftendpoint(I), "..", rightendpoint(I))

test/runtests.jl

-17
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ struct IncompleteInterval <: AbstractInterval{Int} end
4949
M = @inferred(ClosedInterval(2, 5.0))
5050
@test string(M) == "2.0..5.0"
5151
N = @inferred(ClosedInterval(UInt8(255), 300))
52-
O = @inferred(CartesianIndex(1, 2, 3, 4) ± 2)
53-
@test O == (-1..3, 0..4, 1..5, 2..6)
5452

5553
x, y = CartesianIndex(1, 2, 3, 4), CartesianIndex(1, 2, 3, 4)
5654
O = @inferred x±y
@@ -136,10 +134,6 @@ struct IncompleteInterval <: AbstractInterval{Int} end
136134
@test mean(0..1) == 0.5
137135

138136
@test promote(1..2, 1.0..2.0) === (1.0..2.0, 1.0..2.0)
139-
140-
@test duration(1..2) == 2
141-
# duration deliberately not defined for non-integer intervals
142-
@test_throws MethodError duration(1.2..2.4)
143137
end
144138

145139
@testset "Unitful interval" begin
@@ -154,8 +148,6 @@ struct IncompleteInterval <: AbstractInterval{Int} end
154148
@test width(ClosedInterval(A, B)) == Dates.Day(59)
155149
@test width(ClosedInterval(B, A)) == Dates.Day(0)
156150
@test isempty(ClosedInterval(B, A))
157-
@test duration(ClosedInterval(A, B)) 60
158-
@test duration(ClosedInterval(B, A)) 0
159151
end
160152

161153
@testset "Convert" begin
@@ -221,15 +213,6 @@ struct IncompleteInterval <: AbstractInterval{Int} end
221213
@test 1.0..2.0 === 1.0..2 === 1..2.0 === ClosedInterval{Float64}(1..2) ===
222214
Interval(1.0,2.0)
223215

224-
# TODO: Remove this test in the next breaking release (#97)
225-
@test convert(AbstractInterval, 1.0) ==
226-
convert(AbstractInterval{Float64}, 1) ==
227-
convert(TypedEndpointsInterval{:closed,:closed}, 1.0) ==
228-
convert(TypedEndpointsInterval{:closed,:closed,Float64}, 1) ==
229-
convert(ClosedInterval, 1.0) ==
230-
convert(ClosedInterval{Float64}, 1) ==
231-
1.0..1.0
232-
233216
@test promote_type(Interval{:closed,:open,Float64}, Interval{:closed,:open,Int}) ===
234217
Interval{:closed,:open,Float64}
235218
end

0 commit comments

Comments
 (0)