From f9f4733a1134e4ad3a946ddf8023e0d7b5d7fa80 Mon Sep 17 00:00:00 2001 From: Petr Vana Date: Fri, 27 May 2022 11:10:05 +0200 Subject: [PATCH] Throw ArgumentError for Interval divisor for mod --- src/intervals/functions.jl | 5 +++-- test/interval_tests/numeric.jl | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/intervals/functions.jl b/src/intervals/functions.jl index 588b163d7..fdb3f3f16 100644 --- a/src/intervals/functions.jl +++ b/src/intervals/functions.jl @@ -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) @@ -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`")) diff --git a/test/interval_tests/numeric.jl b/test/interval_tests/numeric.jl index d933f9c7c..11f1d0877 100644 --- a/test/interval_tests/numeric.jl +++ b/test/interval_tests/numeric.jl @@ -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