Skip to content

Commit

Permalink
Fix for issue #125 for real numbers (#126)
Browse files Browse the repository at this point in the history
* Overload indomain for PeriodicSegment

* indomain is only true if real number isfinite

---------

Co-authored-by: Jilhg <[email protected]>
  • Loading branch information
Jilhg and Jilhg authored Aug 18, 2024
1 parent 011e11a commit e8b45c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Domains/PeriodicSegment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ reverseorientation(d::PeriodicSegment) = PeriodicSegment(rightendpoint(d), lefte
==(d::PeriodicSegment,m::PeriodicSegment) = leftendpoint(d) == m.a && rightendpoint(d) == m.b





## algebra

for op in (:*,:+,:-)
Expand Down Expand Up @@ -105,6 +102,7 @@ function convert(::Type{PeriodicDomain},d::ClosedInterval)
end
end

indomain(x::R1, d::PeriodicSegment{R2}) where {R1<:Real,R2<:Real} = isfinite(x)
issubset(a::PeriodicSegment, b::IntervalOrSegment) = Segment(endpoints(a)...)b
issubset(a::IntervalOrSegment, b::PeriodicSegment) = PeriodicSegment(endpoints(a)...)b

Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ end
@test 0.1 PeriodicSegment(2π,0)
@test 100.0 PeriodicSegment(0,2π)
@test -100.0 PeriodicSegment(0,2π)
@test 0 PeriodicSegment(-2,3) #issue 125
@test 1e-15 PeriodicSegment(-2,3) #issue 125

@test 10.0 PeriodicLine()
@test 10.0 PeriodicLine()
@test -10.0 PeriodicLine()
@test -10.0+im PeriodicLine()
@test 0 PeriodicLine() #issue 125
@test 1e-15 PeriodicLine() #issue 125

p = PeriodicSegment(0,2π)
@test leftendpoint(p) == 0
Expand Down

0 comments on commit e8b45c8

Please sign in to comment.