Skip to content

Commit

Permalink
Fix decoration for atan with two arguments (#672)
Browse files Browse the repository at this point in the history
* Fix `atan` decoration

* Fix the parsing of the test suite
  • Loading branch information
OlivierHnt authored Jul 2, 2024
1 parent 00fe0ac commit 16dcd3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/intervals/arithmetic/trigonometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,10 @@ function Base.atan(y::Interval, x::Interval)
d = min(decoration(y), decoration(x), decoration(r))
d = min(d,
ifelse(in_interval(0, by),
ifelse(in_interval(0, bx), trv,
ifelse(sup(bx) < 0, ifelse(inf(by) < 0, def, dac), d)),
d))
ifelse(in_interval(0, bx),
trv,
ifelse(sup(bx) < 0, ifelse(inf(by) < 0, def, d), d)),
d))
t = isguaranteed(y) & isguaranteed(x)
return _unsafe_interval(r, d, t)
end
Expand Down
3 changes: 2 additions & 1 deletion test/ITF1788_tests/libieeep1788_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7144,7 +7144,8 @@ end

@test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-0.0, -0.0), def)) === interval(bareinterval(0x1.921FB54442D18P+0, 0x1.921FB54442D19P+0), trv)

@test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), dac)
@warn "The original test `atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac` is wrong and has been modified. The result should have the decoration `com`"
@test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), com)

@test atan(interval(bareinterval(-0.0, 1.0), def), interval(bareinterval(-2.0, 0.0), com)) === interval(bareinterval(0x1.921FB54442D18P+0, 0x1.921FB54442D19P+1), trv)

Expand Down
16 changes: 12 additions & 4 deletions test/generate_ITF1788.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,18 @@ function parse_command(line)
rhs = parse_rhs(rhs)

expr = build_expression(lhs, rhs)
command = "@test $expr"

# one known broken test, unrelated to interval airthmetic
command = occursin("dot_nearest {0x10000000000001p0, 0x1p104} {0x0fffffffffffffp0, -1.0} = -1.0", line) ?
"@test_broken $expr" : "@test $expr"
if occursin("dot_nearest {0x10000000000001p0, 0x1p104} {0x0fffffffffffffp0, -1.0} = -1.0", line)
# broken test unrelated to interval airthmetic
command = "@test_broken $expr"
elseif occursin("atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac", line)
# erroneous test: the decoration of the result should be `com`
command =
"""
@warn "The original test `atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac` is wrong and has been modified. The result should have the decoration `com`"
@test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), com)"""
end

command = haswarning ? "@test_logs (:warn,) $command" : command

Expand Down Expand Up @@ -238,7 +246,7 @@ end
function parse_interval(ival::AbstractString, dec::Union{Nothing,AbstractString})
ival == "nai" && return "nai(Interval{Float64})"
if ival == "entire"
ival = "entireinterval(BareInterval{Float64})"
ival = "entireinterval(BareInterval{Float64})"
elseif ival == "empty"
ival = "emptyinterval(BareInterval{Float64})"
else
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ for f ∈ readdir("ITF1788_tests"; join = true)
@testset "$f" begin
include(f)
end
end
end

0 comments on commit 16dcd3b

Please sign in to comment.