Skip to content

Commit

Permalink
use .. from EllipsisNotation.jl (#57)
Browse files Browse the repository at this point in the history
* use .. from EllipsisNotation.jl

* skip one test on 1.0

* version 0.3.3

* v0.4
  • Loading branch information
mcabbott authored and dlfivefifty committed Jan 28, 2020
1 parent ecf4377 commit ba476b0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name = "IntervalSets"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
version = "0.3.2"
version = "0.4.0"

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

[compat]
julia = "0.7, 1"
EllipsisNotation = "0.4"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
5 changes: 4 additions & 1 deletion src/IntervalSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import Statistics: mean

using Dates

using EllipsisNotation
import EllipsisNotation: Ellipsis

export AbstractInterval, Interval, OpenInterval, ClosedInterval,
, .., ±, ordered, width, duration, leftendpoint, rightendpoint, endpoints,
isclosed, isleftclosed, isrightclosed, isleftopen, isrightopen, closedendpoints,
Expand Down Expand Up @@ -181,7 +184,7 @@ isrightclosed(d::TypedEndpointsInterval{L,:open}) where {L} = false
# The third is the one we want, but the first two are needed to resolve ambiguities
Base.Slice{T}(i::TypedEndpointsInterval{:closed,:closed,I}) where {T<:AbstractUnitRange,I<:Integer} =
Base.Slice{T}(minimum(i):maximum(i))
Base.Slice(i::TypedEndpointsInterval{:closed,:closed,I}) where I<:Integer =
Base.Slice(i::TypedEndpointsInterval{:closed,:closed,I}) where I<:Integer =
Base.Slice(minimum(i):maximum(i))
function Base.OneTo{T}(i::TypedEndpointsInterval{:closed,:closed,I}) where {T<:Integer,I<:Integer}
@noinline throwstart(i) = throw(ArgumentError("smallest element must be 1, got $(minimum(i))"))
Expand Down
7 changes: 6 additions & 1 deletion src/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ convert(::Type{TypedEndpointsInterval{L,R}}, d::Interval{L,R}) where {L,R} = d
iv = l..r
Construct a ClosedInterval `iv` spanning the region from `l` to `r`.
(The symbol `..` is the same as in the package EllipsisNotation.jl.)
"""
..(x, y) = ClosedInterval(x, y)
..

(::Ellipsis)(x, y) = ClosedInterval(x, y)


"""
iv = center±halfwidth
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
struct IncompleteInterval <: AbstractInterval{Int} end

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

@test ordered(2, 1) == (1, 2)
@test ordered(1, 2) == (1, 2)
Expand Down

2 comments on commit ba476b0

@dlfivefifty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8573

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" ba476b0fcb059be2ac2c5bb60215ba662c096d81
git push origin v0.4.0

Please sign in to comment.