Skip to content

Commit 81cc683

Browse files
committed
Remove @interval, @tinterval and @decorated
1 parent 724b5cc commit 81cc683

20 files changed

+360
-527
lines changed

src/IntervalArithmetic.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import .Broadcast: broadcasted
5050

5151
export
5252
Interval, BooleanInterval,
53-
interval, @interval, @tinterval,
53+
interval, ±, .., @I_str,
5454
diam, radius, mid, scaled_mid, mag, mig, hull,
5555
emptyinterval, ∅, ∞, isempty, isinterior, isdisjoint, ,
5656
precedes, strictprecedes, , , , , contains_zero, isthinzero,
@@ -64,7 +64,6 @@ export
6464
IntervalRounding,
6565
PointwisePolicy,
6666
cancelminus, cancelplus, isbounded, isunbounded,
67-
.., @I_str, ±,
6867
pow, extended_div, nthroot,
6968
setformat, @format
7069

@@ -86,7 +85,6 @@ export
8685

8786
## Decorations
8887
export
89-
@decorated,
9088
interval, decoration, DecoratedInterval,
9189
com, dac, def, trv, ill
9290

src/decorations/intervals.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,3 @@ end
7777

7878
float(x::DecoratedInterval) = DecoratedInterval(float(interval(x)), decoration(x))
7979
big(x::DecoratedInterval) = DecoratedInterval(big(interval(x)), decoration(x))
80-
81-
macro decorated(ex...)
82-
if !(ex[1] isa String)
83-
if length(ex) == 1
84-
x = :(@interval($(esc(ex[1]))))
85-
lo = :(inf($x))
86-
hi = :(sup($x))
87-
else
88-
lo, hi = ex
89-
end
90-
91-
return :(DecoratedInterval($lo, $hi))
92-
else
93-
s = ex[1]
94-
parse(DecoratedInterval{Float64}, s)
95-
end
96-
end

src/intervals/construction.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ Constructors compliant with the IEEE Standard 1788-2015:
1515
- [`interval`](@ref)
1616
- [`..`](@ref)
1717
- [`±`](@ref)
18-
- [`@interval`](@ref)
19-
- [`@tinterval`](@ref)
2018
- [`@I_str`](@ref)
2119
2220
!!! warning
2321
The internal constructor `unsafe_interval` is *not* compliant with the
2422
IEEE Standard 1788-2015.
2523
26-
See also: [`interval`](@ref), [`±`](@ref), [`..`](@ref), [`@interval`](@ref),
27-
[`@tinterval`](@ref) and [`I"desc"`](@ref).
24+
See also: [`interval`](@ref), [`±`](@ref), [`..`](@ref) and [`@I_str`](@ref).
2825
"""
2926
struct Interval{T<:NumTypes} <: Real
3027
lo::T
@@ -125,8 +122,7 @@ empty interval is returned.
125122
rounded to the nearest when parsed (e.g. 0.1). In such cases, use the string
126123
macro [`@I_str`](@ref) to ensure tight enclosure around the typed numbers.
127124
128-
See also: [`±`](@ref), [`..`](@ref), [`@interval`](@ref), [`@tinterval`](@ref)
129-
and [`@I_str`](@ref).
125+
See also: [`±`](@ref), [`..`](@ref) and [`@I_str`](@ref).
130126
131127
# Examples
132128
```jldoctest
@@ -205,8 +201,7 @@ Despite using the midpoint-radius notation, the returned interval is still an
205201
rounded to the nearest when parsed (e.g. 0.1). In such cases, use the string
206202
macro [`@I_str`](@ref) to ensure tight enclosure around the typed numbers.
207203
208-
See also: [`interval`](@ref), [`..`](@ref), [`@interval`](@ref),
209-
[`@tinterval`](@ref) and [`@I_str`](@ref).
204+
See also: [`interval`](@ref), [`..`](@ref) and [`@I_str`](@ref).
210205
211206
# Examples
212207
```jldoctest

src/intervals/construction_macros.jl

Lines changed: 0 additions & 131 deletions
This file was deleted.

src/intervals/intervals.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Construction and composability with numbers
22
include("construction.jl")
3-
include("construction_macros.jl")
43
include("real_interface.jl")
54

65
# Rounding
@@ -27,4 +26,4 @@ include("interval_operations/boolean.jl")
2726
include("interval_operations/overlap.jl")
2827
include("interval_operations/numeric.jl")
2928
include("interval_operations/pointwise_boolean.jl")
30-
include("interval_operations/set_operations.jl")
29+
include("interval_operations/set_operations.jl")

src/intervals/rounding_macros.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ themselves single operations.
4242
4343
The macro uses the internal `round_expr` function to transform e.g.
4444
`a + b` into `+(a, b, RoundDown)`.
45-
46-
The user-facing equivalent is `@interval`, which can handle much more general cases.
4745
"""
4846
macro round(T, ex1, ex2)
49-
:(unsafe_interval($(esc(T)), $(round_expr(ex1, RoundDown)), $(round_expr(ex2, RoundUp))))
47+
return :(unsafe_interval($(esc(T)), $(round_expr(ex1, RoundDown)), $(round_expr(ex2, RoundUp))))
5048
end

src/parsing.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
"""
2+
I"str"
3+
4+
Create an interval according to the IEEE Standard 1788-2015. This is
5+
semantically equivalent to `parse(DecoratedInterval{default_numtype()}, str)` if
6+
the string contains the character `_` which delimits the interval and its
7+
decoration; otherwise, it is semantically equivalent to
8+
`parse(Interval{default_numtype()}, str)`.
9+
10+
# Examples
11+
```jldoctest
12+
julia> setformat(:full);
13+
14+
julia> I"[3, 4]"
15+
Interval{Float64}(3.0, 4.0)
16+
17+
julia> I"0.1"
18+
Interval{Float64}(0.09999999999999999, 0.1)
19+
```
20+
"""
21+
macro I_str(str)
22+
if '_' str
23+
return parse(DecoratedInterval{default_numtype()}, str)
24+
else
25+
return parse(Interval{default_numtype()}, str)
26+
end
27+
end
28+
29+
#
30+
131
"""
232
parse(Interval, s::AbstractString)
333

src/symbols.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
Create an interval according to the IEEE Standard 1788-2015. This is
66
semantically equivalent to [`interval(a, b)`](@ref).
77
8-
See also: [`interval`](@ref), [`@interval`](@ref), [`@tinterval`](@ref) and
9-
[`I_str`](@ref).
8+
See also: [`interval`](@ref), [`±`](@ref) and [`@I_str`](@ref).
109
1110
# Examples
1211
```jldoctest

test/decoration_tests/decoration_tests.jl

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ using IntervalArithmetic
44
let b
55

66
@testset "DecoratedInterval tests" begin
7-
a = DecoratedInterval(@interval(1, 2), com)
7+
a = DecoratedInterval(interval(1, 2), com)
88
@test decoration(a) == com
99

1010
b = sqrt(a)
1111
@test interval(b) sqrt(interval(a))
1212
@test decoration(b) == com
1313

14-
a = DecoratedInterval(@interval(-1, 1), com)
14+
a = DecoratedInterval(interval(-1, 1), com)
1515
b = sqrt(a)
1616
@test interval(b) sqrt(interval(0, 1))
1717
@test decoration(b) == trv
@@ -25,44 +25,41 @@ let b
2525
@test decoration(DecoratedInterval(2, 0.1, com)) == ill
2626
@test decoration(DecoratedInterval(2, 0.1)) == ill
2727
@test isnai(DecoratedInterval(2, 0.1))
28-
@test decoration(@decorated(2, 0.1)) == ill
2928
@test decoration(DecoratedInterval(big(2), big(1))) == ill
3029
@test isnai((DecoratedInterval(big(2), big(1))))
31-
@test isnai(@decorated(big(2), big(1)))
3230

3331
# Disabling the following tests, because Julia 0.5 has some strange behaviour here
3432
# @test_throws ArgumentError DecoratedInterval(BigInt(1), 1//10)
35-
# @test_throws ArgumentError @decorated(BigInt(1), 1//10)
3633

3734
# Tests related to powers of decorated Intervals
38-
@test @decorated(2,3) ^ 2 DecoratedInterval(4, 9)
39-
@test @decorated(2,3) ^ -2 DecoratedInterval(1/9,1/4)
40-
@test @decorated(-3,2) ^ 3 DecoratedInterval(-27., 8.)
41-
@test @decorated(-3,-2) ^ -3 DecoratedInterval(-1/8.,-1/27)
42-
@test @decorated(0,3) ^ 2 DecoratedInterval(0, 9)
43-
@test @decorated(0,3) ^ -2 DecoratedInterval(1/9, Inf, trv)
44-
@test @decorated(2,3)^interval(0.0, 1.0) DecoratedInterval(1.0,3.0)
45-
@test @decorated(2,3)^@decorated(0.0, 1.0) DecoratedInterval(1.0,3.0)
46-
@test @decorated(0, 2)^interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
47-
@test @decorated(0, 2)^@decorated(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
48-
@test @decorated(-3, 2)^interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
49-
@test @decorated(-3, 2)^@decorated(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
50-
@test @decorated(-3, 2)^interval(-1.0, 1.0) DecoratedInterval(0.0,Inf, trv)
51-
@test @decorated(-3, 2)^@decorated(-1.0, 1.0) DecoratedInterval(0.0, Inf, trv)
35+
@test DecoratedInterval(2, 3) ^ 2 DecoratedInterval(4, 9)
36+
@test DecoratedInterval(2, 3) ^ -2 DecoratedInterval(1/9,1/4)
37+
@test DecoratedInterval(-3, 2) ^ 3 DecoratedInterval(-27, 8)
38+
@test DecoratedInterval(-3, -2) ^ -3 DecoratedInterval(-1/8, -1/27)
39+
@test DecoratedInterval(0, 3) ^ 2 DecoratedInterval(0, 9)
40+
@test DecoratedInterval(0, 3) ^ -2 DecoratedInterval(1/9, Inf, trv)
41+
@test DecoratedInterval(2, 3)^interval(0, 1) DecoratedInterval(1, 3)
42+
@test DecoratedInterval(2, 3)^DecoratedInterval(0, 1) DecoratedInterval(1, 3)
43+
@test DecoratedInterval(0, 2)^interval(0, 1) DecoratedInterval(0, 2, trv)
44+
@test DecoratedInterval(0, 2)^DecoratedInterval(0, 1) DecoratedInterval(0, 2, trv)
45+
@test DecoratedInterval(-3, 2)^interval(0, 1) DecoratedInterval(0, 2, trv)
46+
@test DecoratedInterval(-3, 2)^DecoratedInterval(0, 1) DecoratedInterval(0, 2, trv)
47+
@test DecoratedInterval(-3, 2)^interval(-1, 1) DecoratedInterval(0, Inf, trv)
48+
@test DecoratedInterval(-3, 2)^DecoratedInterval(-1, 1) DecoratedInterval(0, Inf, trv)
5249

53-
a = @decorated 1 2
54-
b = @decorated 3 4
50+
a = DecoratedInterval(1, 2)
51+
b = DecoratedInterval(3, 4)
5552

5653
@test dist(a, b) == 2.0
5754

5855
# invalid input
59-
@test isnai(@decorated(3, 1, com))
60-
@test isnai(@decorated(3, 1))
61-
@test isnai(@decorated(Inf, Inf))
62-
@test isnai(@decorated(-Inf, -Inf))
63-
@test isnai(@decorated(NaN, 3))
64-
@test isnai(@decorated(3, NaN))
65-
@test isnai(@decorated(NaN, NaN))
56+
@test isnai(DecoratedInterval(3, 1, com))
57+
@test isnai(DecoratedInterval(3, 1))
58+
@test isnai(DecoratedInterval(Inf, Inf))
59+
@test isnai(DecoratedInterval(-Inf, -Inf))
60+
@test isnai(DecoratedInterval(NaN, 3))
61+
@test isnai(DecoratedInterval(3, NaN))
62+
@test isnai(DecoratedInterval(NaN, NaN))
6663
end
6764

6865
end

test/display_tests/display.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let x, b
6161
@test sprint(show, MIME("text/plain"), large_expo) == "(5.0e+123456788 ± 5.00001e+123456788)₂₅₆"
6262

6363
# issue 175:
64-
@test sprint(show, MIME("text/plain"), @tinterval(BigFloat, 1, 2)) == "(1.5 ± 0.5)₂₅₆"
64+
@test sprint(show, MIME("text/plain"), interval(BigFloat, 1, 2)) == "(1.5 ± 0.5)₂₅₆"
6565
end
6666
end
6767

@@ -109,7 +109,7 @@ let x, b
109109
setprecision(BigFloat, 256)
110110

111111
@testset "DecoratedInterval" begin
112-
a = @decorated(1, 2)
112+
a = DecoratedInterval(1, 2)
113113
@test typeof(a) == DecoratedInterval{Float64}
114114

115115
setformat(:standard; decorations = false)
@@ -207,7 +207,7 @@ end
207207
@test sprint(show, MIME("text/plain"), x) == "[0.0, 1.0]"
208208
@test sprint(show, x) == "Interval{Float64}(0.0, 1.0)"
209209

210-
x = @tinterval(BigFloat, 0, 1)
210+
x = interval(BigFloat, 0, 1)
211211
@test sprint(show, MIME("text/plain"), x) == "[0.0, 1.0]₁₂₈"
212212
@test sprint(show, x) == "Interval{BigFloat}(0.0, 1.0)"
213213

0 commit comments

Comments
 (0)