Skip to content

Commit f9f4733

Browse files
committed
Throw ArgumentError for Interval divisor for mod
1 parent 6fdc809 commit f9f4733

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/intervals/functions.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ function nthroot(a::Interval{T}, n::Integer) where T
375375
end
376376

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

392-
mod(x:T, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))
392+
mod(x::Interval, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))
393+
mod(x::Real, y::Interval) where T = throw(ArgumentError("mod not defined for interval as divisor `y`"))

test/interval_tests/numeric.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -472,5 +472,6 @@ end
472472
@test mod(x, -0.5) == -0.5..0
473473

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

0 commit comments

Comments
 (0)