Skip to content

Commit 6824bf5

Browse files
lbenetdpsanders
authored andcommitted
Broadcast in isinf and contains_zero, with tests (#162)
1 parent b7163bd commit 6824bf5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/multidim/intervalbox.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ diam(X::IntervalBox) = maximum(diam.(X.v))
7373

7474
emptyinterval(X::IntervalBox{N,T}) where {N,T} = IntervalBox(emptyinterval.(X.v))
7575

76-
isinf(X::IntervalBox) = any(isinf(X))
76+
isinf(X::IntervalBox) = any(isinf.(X))
7777

7878
isinterior(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} = all(isinterior.(X, Y))
7979

80-
contains_zero(X::SVector) = all(contains_zero(X))
81-
contains_zero(X::IntervalBox) = all(contains_zero(X))
80+
contains_zero(X::SVector) = all(contains_zero.(X))
81+
contains_zero(X::IntervalBox) = all(contains_zero.(X))
8282

8383
import Base
8484
×(a::Interval...) = IntervalBox(a...)

test/multidim_tests/multidim.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ using StaticArrays
3333
@test isempty(X Y)
3434
@test X Y == IntervalBox(1..4, 3..4)
3535

36+
@test !contains_zero(X Y)
37+
@test contains_zero( (-1..1) × (-1..1) )
38+
@test !isinf( (-1..1) × (0..Inf) )
39+
@test isinf( entireinterval() × entireinterval() )
40+
3641
X = IntervalBox(2..4, 3..5)
3742
Y = IntervalBox(3..5, 4..17)
3843
@test X Y == IntervalBox(3..4, 4..5)

0 commit comments

Comments
 (0)