Skip to content

Commit 4bee459

Browse files
rofinnomus
authored andcommitted
Added a broadcastable method on 0.7 and tests for scalar broadcasting. (#58)
1 parent 810b8f4 commit 4bee459

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Intervals.jl

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ abstract type AbstractInterval{T} end
1616

1717
Base.eltype(::AbstractInterval{T}) where {T} = T
1818

19+
if VERSION >= v"0.7"
20+
Base.broadcastable(x::AbstractInterval) = Ref(x)
21+
end
22+
1923
include("inclusivity.jl")
2024
include("endpoint.jl")
2125
include("interval.jl")

test/anchoredinterval.jl

+12
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,16 @@ using Intervals: canonicalize
590590
end
591591
end
592592
end
593+
594+
@testset "broadcasting" begin
595+
# Check that we can broadcast a vector of anchored intervals against a scalar
596+
597+
a = [
598+
HourEnding(DateTime(2016, 8, 11)),
599+
HourEnding(DateTime(2016, 8, 12)),
600+
]
601+
602+
mask = a .== a[2]
603+
@test mask == [false, true]
604+
end
593605
end

0 commit comments

Comments
 (0)