Skip to content

Commit

Permalink
Fix tests. So far no iteration for IntervalBox
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsanders committed May 17, 2018
1 parent aeb6a5b commit 0f8cb49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/multidim/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

/(a::IntervalBox, b::Real) = IntervalBox( a.v ./ b )

broadcast(f, X::IntervalBox) = IntervalBox(f.(X.v))
Base.broadcast(f, X::IntervalBox) = IntervalBox(f.(X.v))
Base.broadcast(f, X::IntervalBox, Y::IntervalBox) = IntervalBox( f.(X.v, Y.v) )
12 changes: 6 additions & 6 deletions src/multidim/intervalbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ struct IntervalBox{N,T}
v::SVector{N,Interval{T}}
end

IntervalBox(x::Interval) = IntervalBox( SVector(x) ) # single interval treated as tuple with one element

IntervalBox(x...) = IntervalBox(SVector(x))
# IntervalBox(x::Interval) = IntervalBox( SVector(x) ) # single interval treated as tuple with one element

IntervalBox(x::Interval...) = IntervalBox(SVector(x))
IntervalBox(x::Tuple{T}) where {T<:Interval} = IntervalBox(SVector(x))

Base.getindex(X::IntervalBox, i) = X.v[i]

Expand Down Expand Up @@ -46,9 +46,9 @@ emptyinterval(X::IntervalBox{N,T}) where {N,T} = IntervalBox(emptyinterval.(X.v)

import Base
×(a::Interval...) = IntervalBox(a...)
×(a::Interval, b::IntervalBox) = IntervalBox(a, b...)
×(a::IntervalBox, b::Interval) = IntervalBox(a..., b)
×(a::IntervalBox, b::IntervalBox) = IntervalBox(a..., b...)
×(a::Interval, b::IntervalBox) = IntervalBox(a, b.v...)
×(a::IntervalBox, b::Interval) = IntervalBox(a.v..., b)
×(a::IntervalBox, b::IntervalBox) = IntervalBox(a.v..., b.v...)

IntervalBox(x::Interval, ::Type{Val{n}}) where {n} = IntervalBox(SVector(ntuple(i->x, Val{n})))

Expand Down
4 changes: 2 additions & 2 deletions src/multidim/setdiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Algorithm: Start from the total overlap (in all directions);
expand each direction in turn.
"""
function setdiff(A::IntervalBox{N,T}, B::IntervalBox{N,T}) where {N,T}
X = [labelled_setdiff(a,b) for (a, b) in zip(A, B)]
X = [labelled_setdiff(a, b) for (a, b) in zip(A.v, B.v)]
# ordered such that the first in each is the excluded interval

first = [ i[1] for i in X ]
Expand All @@ -61,7 +61,7 @@ function setdiff(A::IntervalBox{N,T}, B::IntervalBox{N,T}) where {N,T}
for which in X[dimension][2:end]
excluded[dimension] = which[1]
push!(result_list,
IntervalBox(excluded[1:dimension]..., A[dimension+1:end]...))
IntervalBox(excluded[1:dimension]..., A[dimension+1:N]...))
end
end

Expand Down

0 comments on commit 0f8cb49

Please sign in to comment.