Skip to content

Commit 25ad9fc

Browse files
committed
Merge branch 'master' into 1.0-dev
2 parents 73e0c41 + 0757194 commit 25ad9fc

18 files changed

+390
-40
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
version:
14+
- '1.6'
1415
- '1'
1516
- 'nightly'
1617
os:

src/IntervalArithmetic.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# This file is part of the IntervalArithmetic.jl package; MIT licensed
22

3-
__precompile__(true)
4-
53
module IntervalArithmetic
64

75
import CRlibm
@@ -68,12 +66,7 @@ export
6866
pow, extended_div, nthroot,
6967
setformat
7068

71-
if VERSION >= v"1.5.0-DEV.124"
72-
import Base: isdisjoint
73-
else
74-
export isdisjoint
75-
end
76-
69+
import Base: isdisjoint
7770

7871
export
7972
setindex # re-export from StaticArrays for IntervalBox
@@ -124,4 +117,15 @@ include("plot_recipes/plot_recipes.jl")
124117
"""
125118
const Region{T} = Union{Interval{T}, IntervalBox{T}}
126119

120+
121+
# These definitions has been put there because generated functions must be
122+
# defined after all methods they use.
123+
@generated function Interval{T}(x::AbstractIrrational) where T
124+
res = atomic(Interval{T}, x()) # Precompute the interval
125+
return :(return $res) # Set body of the function to return the precomputed result
126+
end
127+
128+
Interval{BigFloat}(x::AbstractIrrational) = atomic(Interval{BigFloat}, x)
129+
Interval(x::AbstractIrrational) = Interval{Float64}(x)
130+
127131
end # module IntervalArithmetic

src/multidim/intervalbox.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@ IntervalBox(x) = IntervalBox(x...)
1818
IntervalBox(X::IntervalBox, n) = foldl(×, Iterators.repeated(X, n))
1919

2020
# construct from two vectors giving bottom and top corners:
21-
function IntervalBox(los::AbstractVector, his::AbstractVector)
22-
xs = map(los, his) do lo, hi
23-
# Allow the creation of the intervals even when the bounds are in the
24-
# wrong order
25-
return lo <= hi ? interval(lo, hi) : interval(hi, lo)
26-
end
27-
return IntervalBox(xs...)
28-
end
21+
IntervalBox(lo::AbstractVector, hi::AbstractVector) = IntervalBox(force_interval.(lo, hi))
22+
IntervalBox(lo::SVector{N,T}, hi::SVector{N,T}) where {N,T} = IntervalBox(force_interval.(lo, hi))
2923

3024
Base.@propagate_inbounds Base.getindex(X::IntervalBox, i) = X.v[i]
3125

test/interval_tests/consistency.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ import IntervalArithmetic: unsafe_interval
264264
@test isnan(mid(emptyinterval()))
265265
@test mid(entireinterval()) == 0.0
266266
@test isnan(mid(nai()))
267-
# @test_throws InexactError nai(interval(1//2)) TODO move this test
268-
269267
@test mid(2.125) == 2.125
270268
@test radius(2.125) == 0
271269
end

test/interval_tests/numeric.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ end
329329
end
330330

331331
@testset "Float32 intervals" begin
332-
333332
a = interval(Float32, 1e38)
334333
b = interval(Float32, 1e2)
335334
@test a * b interval(Float32, floatmax(Float32), Inf)
335+
@test Interval(1.0f0) ^ Interval(1.0f0) Interval(1.0f0) # test for PR #482
336336
end
337337

338338

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ include_test("display_tests/display.jl")
2323
# Multidim tests
2424
include_test("multidim_tests/multidim.jl")
2525

26+
include("multidim_tests/multidim.jl")
27+
2628
# ITF1788 tests
27-
include_test("test_ITF1788/run_ITF1788.jl") # TODO fix these tests
29+
include("test_ITF1788/run_ITF1788.jl")

test/test_ITF1788/abs_rev.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@
4747
@test abs_rev(interval(-Inf, -1.0), entireinterval())[2] === emptyinterval()
4848

4949
@test abs_rev(interval(-Inf, 1.0), entireinterval())[2] === interval(-1.0, 1.0)
50-
5150
end

test/test_ITF1788/atan2.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,4 @@
7575
@test atan(interval(0.0, 5.0), interval(0.0, 5.0)) === interval(0x0p0, 0x1.921FB54442D19p0)
7676

7777
@test atan(interval(-5.0, 0.0), interval(0.0, 5.0)) === interval(-0x1.921FB54442D19p0, 0x0p0)
78-
7978
end

test/test_ITF1788/c-xsc.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
@test -(interval(10.0, 20.0)) === interval(-20.0, -10.0)
1212

1313
@test +(interval(10.0, 20.0)) === interval(10.0, 20.0)
14-
1514
end
1615

1716
@testset "cxsc.intervalmuldiv" begin
@@ -77,7 +76,6 @@ end
7776
@test /(interval(-2.0, 1.0), interval(-8.0, -4.0)) === interval(-0.25, 0.5)
7877

7978
@test /(interval(-2.0, -1.0), interval(-8.0, -4.0)) === interval(0.125, 0.5)
80-
8179
end
8280

8381
@testset "cxsc.intervalsetops" begin

0 commit comments

Comments
 (0)