Skip to content

Commit

Permalink
Throw ArgumentError for Interval divisor for mod
Browse files Browse the repository at this point in the history
  • Loading branch information
petvana committed May 27, 2022
1 parent 6fdc809 commit f9f4733
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/intervals/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function nthroot(a::Interval{T}, n::Integer) where T
end

"""
Calculate `x::Interval mod y::Real`, limited by `y != 0`.
Calculate `x::Interval mod y::Real` where y != zero(y) and y is not inteval`.
"""
function mod(x::Interval, y::Real)
@assert y != zero(y) """mod(x::Interval, y::Real)
Expand All @@ -389,4 +389,5 @@ is currently implemented only for a strictly positive or negative divisor y."""
end
end

mod(x:T, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))
mod(x::Interval, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))
mod(x::Real, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))
3 changes: 2 additions & 1 deletion test/interval_tests/numeric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,6 @@ end
@test mod(x, -0.5) == -0.5..0

# TODO - implement mod for two intervals
@test_throws TypeError mod(1..2, 1.4..1.5)
@test_throws ArgumentError mod(1..2, 1.4..1.5)
@test_throws ArgumentError mod(1.0, 1.4..1.5)
end

0 comments on commit f9f4733

Please sign in to comment.