Skip to content

Commit

Permalink
Change "weakly" to "weak" in function names
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHnt committed Sep 19, 2023
1 parent bc963fb commit 338eed9
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 311 deletions.
4 changes: 2 additions & 2 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export
Interval, interval, ±, @I_str,
diam, radius, mid, midradius, scaled_mid, mag, mig, hull,
emptyinterval, isemptyinterval, isinterior,
ismember, intersectinterval, isweaklysubset, isweaklysupset, isdisjointinterval,
ismember, intersectinterval, isweaksubset, isweaksupset, isdisjointinterval,
setdiffinterval,
precedes, strictprecedes, isstrictsubset, isstrictsupset, contains_zero, isthinzero,
isweaklyless, isstrictless, overlap, Overlap,
isweakless, isstrictless, overlap, Overlap,
isequalinterval,
entireinterval, isentireinterval, nai, isnai, isthin, iscommon, isatomic,
inf, sup, bounds, bisect, mince,
Expand Down
6 changes: 3 additions & 3 deletions src/decorations/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const bool_functions = (
)

const bool_binary_functions = (
:isweaklysubset, :isweaklysupset, :isstrictsubset, :isstrictsupset,
:isinterior, :isdisjointinterval, :precedes, :strictprecedes, :isstrictless, :isweaklyless,
:isweaksubset, :isweaksupset, :isstrictsubset, :isstrictsupset,
:isinterior, :isdisjointinterval, :precedes, :strictprecedes, :isstrictless, :isweakless,
:isequalinterval, :overlap
)

Expand Down Expand Up @@ -350,7 +350,7 @@ for (f, domain) in restricted_functions2
x = interval(xx)
r = $(f)(x)
d = min(decoration(xx), decoration(r))
isweaklysubset(x, $domain) && return DecoratedInterval(r, d)
isweaksubset(x, $domain) && return DecoratedInterval(r, d)
DecoratedInterval(r, trv)
end
end
2 changes: 1 addition & 1 deletion src/decorations/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ follows Section 11.2 of the IEEE Standard 1788-2015:
- `ill -> 0`: not an interval (ill-formed)
"""
@enum DECORATION ill=0 trv=1 def=2 dac=3 com=4
# Note that `isweaklyless`, and hence `<` and `min`, are automatically defined for enums
# Note that `isweakless`, and hence `<` and `min`, are automatically defined for enums

"""
DecoratedInterval{T<:NumTypes}
Expand Down
2 changes: 1 addition & 1 deletion src/intervals/arithmetic/trigonometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function tan(a::Interval{T}) where {T<:NumTypes}

if iszero(lo_quadrant_mod) && hi_quadrant_mod == 1
# check if really contains singularity:
if isweaklysubset(hi_quadrant * half_pi(T), a)
if isweaksubset(hi_quadrant * half_pi(T), a)
return entireinterval(T) # crosses singularity
end

Expand Down
16 changes: 8 additions & 8 deletions src/intervals/interval_operations/boolean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ Check if the interval `a` contains exactly (and only) the number `x`.
isequalinterval(a::Interval, x::Real) = inf(a) == sup(a) == x

"""
isweaklysubset(a, b)
isweaksubset(a, b)
Checks if all the points of the interval `a` are within the interval `b`.
Typed with \\subseteq<TAB>.
Implement the `isweaklysubset` function of the IEEE Standard 1788-2015 (Table 9.3).
Implement the `isweaksubset` function of the IEEE Standard 1788-2015 (Table 9.3).
"""
function isweaklysubset(a::Interval, b::Interval)
function isweaksubset(a::Interval, b::Interval)
isemptyinterval(a) && return true
return inf(b) inf(a) && sup(a) sup(b)
end

isweaklysupset(a::Interval, b::Interval) = isweaklysubset(b, a)
isweaksupset(a::Interval, b::Interval) = isweaksubset(b, a)

"""
isstrictsubset(a, b)
Expand All @@ -59,13 +59,13 @@ Checks if `a` is a strict subset of interval `b`.
"""
function isstrictsubset(a::Interval, b::Interval)
isequalinterval(a, b) && return false
return isweaklysubset(a, b)
return isweaksubset(a, b)
end

isstrictsupset(a::Interval, b::Interval) = isstrictsubset(b, a)

"""
isweaklyless(a, b)
isweakless(a, b)
Checks if the interval `a` is weakly less than interval `b`.
Expand All @@ -74,7 +74,7 @@ any element of `b`.
Implement the `less` function of the IEEE Standard 1788-2015 (Table 10.3).
"""
function isweaklyless(a::Interval, b::Interval)
function isweakless(a::Interval, b::Interval)
isemptyinterval(a) && isemptyinterval(b) && return true
(isemptyinterval(a) || isemptyinterval(b)) && return false
return (inf(a) inf(b)) && (sup(a) sup(b))
Expand Down Expand Up @@ -164,7 +164,7 @@ function ismember(x::Real, a::Interval)
end

ismember(::Interval, ::Interval) =
throw(ArgumentError("`ismember` is purposely not supported for two interval arguments. See instead `isweaklysubset`."))
throw(ArgumentError("`ismember` is purposely not supported for two interval arguments. See instead `isweaksubset`."))
ismember(x::Real, a::Complex{<:Interval}) = ismember(x, real(a)) && ismember(0, imag(a))
ismember(x::Complex, a::Complex{<:Interval}) = ismember(real(x), real(a)) && ismember(imag(x), imag(a))

Expand Down
6 changes: 3 additions & 3 deletions src/intervals/real_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ dist(a::Interval, b::Interval) = max(abs(inf(a)-inf(b)), abs(sup(a)-sup(b)))
Base.:(==)(::Interval, ::Interval) = # also returned when calling `≤`, `≥`, `isequal`
throw(ArgumentError("`==` is purposely not supported for intervals. See instead `isequalinterval`."))

Base.:<(::Interval, ::Interval) = # also returned when calling `>`
throw(ArgumentError("`<` is purposely not supported for intervals. See instead `isweaklyless`, `precedes`."))
Base.:<(::Interval, ::Interval) = # also returned when calling `isless`, `>`
throw(ArgumentError("`<` is purposely not supported for intervals. See instead `isstrictless`, `strictprecedes`."))

Base.isdisjoint(::Interval, ::Interval) =
throw(ArgumentError("`isdisjoint` is purposely not supported for intervals. See instead `isdisjointinterval`."))

Base.issubset(::Interval, ::Interval) =
throw(ArgumentError("`issubset` is purposely not supported for intervals. See instead `isweaklysubset`."))
throw(ArgumentError("`issubset` is purposely not supported for intervals. See instead `isweaksubset`."))

Base.in(::Interval, ::Interval) =
throw(ArgumentError("`in` is purposely not supported for intervals. See instead `ismember`."))
Expand Down
24 changes: 12 additions & 12 deletions test/interval_tests/consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ import IntervalArithmetic: unsafe_interval
end

@testset "Inclusion tests" begin
@test isweaklysubset(b, c)
@test isweaklysubset(emptyinterval(c), c)
@test !isweaklysubset(c, emptyinterval(c))
@test isweaksubset(b, c)
@test isweaksubset(emptyinterval(c), c)
@test !isweaksubset(c, emptyinterval(c))
@test isinterior(b,c)
@test !isinterior(b, emptyinterval(b))
@test isinterior(emptyinterval(c), c)
Expand All @@ -92,20 +92,20 @@ import IntervalArithmetic: unsafe_interval
@test !isstrictsupset(b, b)
@test !isstrictsupset(emptyinterval(c), c)
@test isstrictsupset(c, emptyinterval(c))
@test isweaklysupset(c, b)
@test isweaklysupset(b, b)
@test !isweaklysupset(emptyinterval(c), c)
@test isweaklysupset(c, emptyinterval(c))
@test isweaksupset(c, b)
@test isweaksupset(b, b)
@test !isweaksupset(emptyinterval(c), c)
@test isweaksupset(c, emptyinterval(c))
@test isdisjointinterval(a, I"2.1")
@test !(isdisjointinterval(a, b))
@test isdisjointinterval(emptyinterval(a), a)
@test isdisjointinterval(emptyinterval(), emptyinterval())
end

@testset "Comparison tests" begin
@test isweaklyless(emptyinterval(), emptyinterval())
@test !isweaklyless(interval(1, 2), emptyinterval())
@test isweaklyless(interval(-Inf,Inf), interval(-Inf,Inf))
@test isweakless(emptyinterval(), emptyinterval())
@test !isweakless(interval(1, 2), emptyinterval())
@test isweakless(interval(-Inf,Inf), interval(-Inf,Inf))
@test precedes(emptyinterval(), emptyinterval())
@test precedes(interval(3, 4), emptyinterval())
@test !(precedes(interval(0, 2),interval(-Inf,Inf)))
Expand Down Expand Up @@ -228,7 +228,7 @@ import IntervalArithmetic: unsafe_interval
@test isequalinterval(cancelplus(x, y), entireinterval(BigFloat))
x = interval(-big(1.0), eps(big(1.0))/2)
y = interval(-eps(big(1.0))/2, big(1.0))
@test isweaklysubset(cancelminus(x, y), interval(-one(BigFloat), one(BigFloat)))
@test isweaksubset(cancelminus(x, y), interval(-one(BigFloat), one(BigFloat)))
@test isequalinterval(cancelplus(x, y), interval(zero(BigFloat), zero(BigFloat)))
@test isequalinterval(cancelminus(emptyinterval(), emptyinterval()), emptyinterval())
@test isequalinterval(cancelplus(emptyinterval(), emptyinterval()), emptyinterval())
Expand Down Expand Up @@ -288,7 +288,7 @@ import IntervalArithmetic: unsafe_interval
@test isequalinterval(sign(interval(-3.0,-1.0)), interval(-1.0, -1.0))

# Test putting functions in interval:
@test isweaklysubset(log(interval(-2, 5)), interval(-Inf, log(interval(5))))
@test isweaksubset(log(interval(-2, 5)), interval(-Inf, log(interval(5))))
end

# @testset "Interval rounding tests" begin
Expand Down
12 changes: 6 additions & 6 deletions test/interval_tests/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ import IntervalArithmetic: unsafe_interval
a = I"[0.1, 0.2]"
b = interval(0.1, 0.2)

@test isweaklysubset(b, a)
@test isweaksubset(b, a)

# TODO Actually use the rounding mode here
for rounding in (:wide, :narrow)
a = interval(0.1, 0.2)
@test isweaklysubset(a, interval(0.09999999999999999, 0.20000000000000004))
@test isweaksubset(a, interval(0.09999999999999999, 0.20000000000000004))

b = interval(0.1)
@test isweaklysubset(b, interval(0.09999999999999999, 0.10000000000000002))
@test isweaklysubset(b, interval(0.09999999999999999, 0.20000000000000004))
@test isweaklysubset(float(b), a)
@test isweaksubset(b, interval(0.09999999999999999, 0.10000000000000002))
@test isweaksubset(b, interval(0.09999999999999999, 0.20000000000000004))
@test isweaksubset(float(b), a)

c = I"[0.1, 0.2]"
@test isweaklysubset(a, c) # a is narrower than c
@test isweaksubset(a, c) # a is narrower than c
@test isequalinterval(interval(1//2), interval(0.5))
@test interval(1//10).lo == rationalize(0.1)
end
Expand Down
70 changes: 35 additions & 35 deletions test/interval_tests/hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using Test
@test isequalinterval(sinh(interval(0.5)), interval(0.5210953054937473, 0.5210953054937474))
@test isequalinterval(sinh(interval(0.5, 1.67)), interval(0.5210953054937473, 2.5619603657712102))
@test isequalinterval(sinh(interval(-4.5, 0.1)), interval(-45.00301115199179, 0.10016675001984404))
@test isweaklysubset(sinh(interval(BigFloat, 0.5, 0.5)), sinh(interval(0.5)))
@test isweaksubset(sinh(interval(BigFloat, 0.5, 0.5)), sinh(interval(0.5)))

@test isweaklysubset(sinh(interval(BigFloat, 0.5, 1.67)), sinh(interval(0.5, 1.67)))
@test isweaklysubset(sinh(interval(BigFloat, 1.67, 3.2)), sinh(interval(1.67, 3.2)))
@test isweaklysubset(sinh(interval(BigFloat, 2.1, 5.6)), sinh(interval(2.1, 5.6)))
@test isweaklysubset(sinh(interval(BigFloat, 0.5, 8.5)), sinh(interval(0.5, 8.5)))
@test isweaklysubset(sinh(interval(BigFloat, -4.5, 0.1)), sinh(interval(-4.5, 0.1)))
@test isweaklysubset(sinh(interval(BigFloat, 1.3, 6.3)), sinh(interval(1.3, 6.3)))
@test isweaksubset(sinh(interval(BigFloat, 0.5, 1.67)), sinh(interval(0.5, 1.67)))
@test isweaksubset(sinh(interval(BigFloat, 1.67, 3.2)), sinh(interval(1.67, 3.2)))
@test isweaksubset(sinh(interval(BigFloat, 2.1, 5.6)), sinh(interval(2.1, 5.6)))
@test isweaksubset(sinh(interval(BigFloat, 0.5, 8.5)), sinh(interval(0.5, 8.5)))
@test isweaksubset(sinh(interval(BigFloat, -4.5, 0.1)), sinh(interval(-4.5, 0.1)))
@test isweaksubset(sinh(interval(BigFloat, 1.3, 6.3)), sinh(interval(1.3, 6.3)))
end

@testset "cosh" begin
Expand All @@ -22,13 +22,13 @@ end
@test isequalinterval(cosh(interval(0.5, 1.67)), interval(1.1276259652063807, 2.750207431409957))
@test isequalinterval(cosh(interval(-4.5, 0.1)), interval(1.0, 45.01412014853003))

@test isweaklysubset(cosh(interval(BigFloat, 0.5, 0.5)), cosh(interval(0.5)))
@test isweaklysubset(cosh(interval(BigFloat, 0.5, 1.67)), cosh(interval(0.5, 1.67)))
@test isweaklysubset(cosh(interval(BigFloat, 1.67, 3.2)), cosh(interval(1.67, 3.2)))
@test isweaklysubset(cosh(interval(BigFloat, 2.1, 5.6)), cosh(interval(2.1, 5.6)))
@test isweaklysubset(cosh(interval(BigFloat, 0.5, 8.5)), cosh(interval(0.5, 8.5)))
@test isweaklysubset(cosh(interval(BigFloat, -4.5, 0.1)), cosh(interval(-4.5, 0.1)))
@test isweaklysubset(cosh(interval(BigFloat, 1.3, 6.3)), cosh(interval(1.3, 6.3)))
@test isweaksubset(cosh(interval(BigFloat, 0.5, 0.5)), cosh(interval(0.5)))
@test isweaksubset(cosh(interval(BigFloat, 0.5, 1.67)), cosh(interval(0.5, 1.67)))
@test isweaksubset(cosh(interval(BigFloat, 1.67, 3.2)), cosh(interval(1.67, 3.2)))
@test isweaksubset(cosh(interval(BigFloat, 2.1, 5.6)), cosh(interval(2.1, 5.6)))
@test isweaksubset(cosh(interval(BigFloat, 0.5, 8.5)), cosh(interval(0.5, 8.5)))
@test isweaksubset(cosh(interval(BigFloat, -4.5, 0.1)), cosh(interval(-4.5, 0.1)))
@test isweaksubset(cosh(interval(BigFloat, 1.3, 6.3)), cosh(interval(1.3, 6.3)))
end

@testset "tanh" begin
Expand All @@ -37,37 +37,37 @@ end
@test isequalinterval(tanh(interval(0.5, 1.67)), interval(0.46211715726000974, 0.9315516846152083))
@test isequalinterval(tanh(interval(-4.5, 0.1)), interval(-0.9997532108480276, 0.09966799462495583))

@test isweaklysubset(tanh(interval(BigFloat, 0.5, 0.5)), tanh(interval(0.5)))
@test isweaklysubset(tanh(interval(BigFloat, 0.5, 1.67)), tanh(interval(0.5, 1.67)))
@test isweaklysubset(tanh(interval(BigFloat, 1.67, 3.2)), tanh(interval(1.67, 3.2)))
@test isweaklysubset(tanh(interval(BigFloat, 2.1, 5.6)), tanh(interval(2.1, 5.6)))
@test isweaklysubset(tanh(interval(BigFloat, 0.5, 8.5)), tanh(interval(0.5, 8.5)))
@test isweaklysubset(tanh(interval(BigFloat, -4.5, 0.1)), tanh(interval(-4.5, 0.1)))
@test isweaklysubset(tanh(interval(BigFloat, 1.3, 6.3)), tanh(interval(1.3, 6.3)))
@test isweaksubset(tanh(interval(BigFloat, 0.5, 0.5)), tanh(interval(0.5)))
@test isweaksubset(tanh(interval(BigFloat, 0.5, 1.67)), tanh(interval(0.5, 1.67)))
@test isweaksubset(tanh(interval(BigFloat, 1.67, 3.2)), tanh(interval(1.67, 3.2)))
@test isweaksubset(tanh(interval(BigFloat, 2.1, 5.6)), tanh(interval(2.1, 5.6)))
@test isweaksubset(tanh(interval(BigFloat, 0.5, 8.5)), tanh(interval(0.5, 8.5)))
@test isweaksubset(tanh(interval(BigFloat, -4.5, 0.1)), tanh(interval(-4.5, 0.1)))
@test isweaksubset(tanh(interval(BigFloat, 1.3, 6.3)), tanh(interval(1.3, 6.3)))

@test isweaklysubset(tanh(interval(-4.5, 0.1)), tanh(interval(Float32, -4.5, 0.1)))
@test isweaklysubset(tanh(interval(1.3, 6.3)), tanh(interval(Float32, 1.3, 6.3)))
@test isweaksubset(tanh(interval(-4.5, 0.1)), tanh(interval(Float32, -4.5, 0.1)))
@test isweaksubset(tanh(interval(1.3, 6.3)), tanh(interval(Float32, 1.3, 6.3)))

for a in [ interval(17, 19), interval(0.5, 1.2) ]
@test isweaklysubset(tanh(a), sinh(a)/cosh(a))
@test isweaksubset(tanh(a), sinh(a)/cosh(a))
end
end

# TODO For reason unkown these tests fail when put in the previous testset
@testset "tanh with Float32" begin
@test isweaklysubset(tanh(interval(0.5)), tanh(interval(Float32, 0.5, 0.5)))
@test isweaklysubset(tanh(interval(0.5, 1.67)), tanh(interval(Float32, 0.5, 1.67)))
@test isweaklysubset(tanh(interval(1.67, 3.2)), tanh(interval(Float32, 1.67, 3.2)))
@test isweaklysubset(tanh(interval(2.1, 5.6)), tanh(interval(Float32, 2.1, 5.6)))
@test isweaklysubset(tanh(interval(0.5, 8.5)), tanh(interval(Float32, 0.5, 8.5)))
@test isweaksubset(tanh(interval(0.5)), tanh(interval(Float32, 0.5, 0.5)))
@test isweaksubset(tanh(interval(0.5, 1.67)), tanh(interval(Float32, 0.5, 1.67)))
@test isweaksubset(tanh(interval(1.67, 3.2)), tanh(interval(Float32, 1.67, 3.2)))
@test isweaksubset(tanh(interval(2.1, 5.6)), tanh(interval(Float32, 2.1, 5.6)))
@test isweaksubset(tanh(interval(0.5, 8.5)), tanh(interval(Float32, 0.5, 8.5)))
end

@testset "inverse" begin
@test isweaklysubset(asinh(interval(BigFloat, 1, 1)), asinh(interval(1)))
@test isweaklysubset(asinh(interval(BigFloat, 0.9, 2)), asinh(interval(0.9, 2)))
@test isweaklysubset(asinh(interval(BigFloat, 3, 4)), asinh(interval(3, 4)))
@test isweaksubset(asinh(interval(BigFloat, 1, 1)), asinh(interval(1)))
@test isweaksubset(asinh(interval(BigFloat, 0.9, 2)), asinh(interval(0.9, 2)))
@test isweaksubset(asinh(interval(BigFloat, 3, 4)), asinh(interval(3, 4)))

@test isweaklysubset(acosh(interval(BigFloat, 1, 1)), acosh(interval(1)))
@test isweaklysubset(acosh(interval(BigFloat, -2, -0.9)), acosh(interval(-2, -0.9)))
@test isweaklysubset(acosh(interval(BigFloat, 3, 4)), acosh(interval(3, 4)))
@test isweaksubset(acosh(interval(BigFloat, 1, 1)), acosh(interval(1)))
@test isweaksubset(acosh(interval(BigFloat, -2, -0.9)), acosh(interval(-2, -0.9)))
@test isweaksubset(acosh(interval(BigFloat, 3, 4)), acosh(interval(3, 4)))
end
2 changes: 1 addition & 1 deletion test/interval_tests/non_BigFloat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
c = I"[0.1, 0.2]"

@test isa(I"0.1", Interval)
@test isweaklysubset(c, interval(prevfloat(0.1), nextfloat(0.2)))
@test isweaksubset(c, interval(prevfloat(0.1), nextfloat(0.2)))

@test isequalinterval(interval(Float64, pi), interval(3.141592653589793, 3.1415926535897936))
end
Expand Down
Loading

0 comments on commit 338eed9

Please sign in to comment.