Skip to content

Commit ba476b0

Browse files
mcabbottdlfivefifty
authored andcommitted
use .. from EllipsisNotation.jl (#57)
* use .. from EllipsisNotation.jl * skip one test on 1.0 * version 0.3.3 * v0.4
1 parent ecf4377 commit ba476b0

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name = "IntervalSets"
22
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
3-
version = "0.3.2"
3+
version = "0.4.0"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
7+
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
78
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
89

910
[compat]
1011
julia = "0.7, 1"
12+
EllipsisNotation = "0.4"
1113

1214
[extras]
1315
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/IntervalSets.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import Statistics: mean
99

1010
using Dates
1111

12+
using EllipsisNotation
13+
import EllipsisNotation: Ellipsis
14+
1215
export AbstractInterval, Interval, OpenInterval, ClosedInterval,
1316
, .., ±, ordered, width, duration, leftendpoint, rightendpoint, endpoints,
1417
isclosed, isleftclosed, isrightclosed, isleftopen, isrightopen, closedendpoints,
@@ -181,7 +184,7 @@ isrightclosed(d::TypedEndpointsInterval{L,:open}) where {L} = false
181184
# The third is the one we want, but the first two are needed to resolve ambiguities
182185
Base.Slice{T}(i::TypedEndpointsInterval{:closed,:closed,I}) where {T<:AbstractUnitRange,I<:Integer} =
183186
Base.Slice{T}(minimum(i):maximum(i))
184-
Base.Slice(i::TypedEndpointsInterval{:closed,:closed,I}) where I<:Integer =
187+
Base.Slice(i::TypedEndpointsInterval{:closed,:closed,I}) where I<:Integer =
185188
Base.Slice(minimum(i):maximum(i))
186189
function Base.OneTo{T}(i::TypedEndpointsInterval{:closed,:closed,I}) where {T<:Integer,I<:Integer}
187190
@noinline throwstart(i) = throw(ArgumentError("smallest element must be 1, got $(minimum(i))"))

src/interval.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,13 @@ convert(::Type{TypedEndpointsInterval{L,R}}, d::Interval{L,R}) where {L,R} = d
8181
iv = l..r
8282
8383
Construct a ClosedInterval `iv` spanning the region from `l` to `r`.
84+
85+
(The symbol `..` is the same as in the package EllipsisNotation.jl.)
8486
"""
85-
..(x, y) = ClosedInterval(x, y)
87+
..
88+
89+
(::Ellipsis)(x, y) = ClosedInterval(x, y)
90+
8691

8792
"""
8893
iv = center±halfwidth

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
2121
struct IncompleteInterval <: AbstractInterval{Int} end
2222

2323
@testset "IntervalSets" begin
24-
@test isempty(detect_ambiguities(IntervalSets, Base, Core))
24+
if VERSION >= v"1.1"
25+
# Julia 1.0 defines getindex(a::GenericArray, i...) in Test,
26+
# which could cause an ambiguity with getindex(A::AbstractArray, ::EllipsisNotation.Ellipsis)
27+
@test isempty(detect_ambiguities(IntervalSets, Base, Core))
28+
end
2529

2630
@test ordered(2, 1) == (1, 2)
2731
@test ordered(1, 2) == (1, 2)

0 commit comments

Comments
 (0)