Skip to content

Commit 73e0c41

Browse files
authored
Merge pull request #563 from OlivierHnt/1.0-dev-display
1.0-dev: Remove `@format`
2 parents 7bfad94 + 38d0c8e commit 73e0c41

File tree

3 files changed

+5
-78
lines changed

3 files changed

+5
-78
lines changed

src/IntervalArithmetic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export
6666
PointwisePolicy,
6767
cancelminus, cancelplus, isbounded, isunbounded,
6868
pow, extended_div, nthroot,
69-
setformat, @format
69+
setformat
7070

7171
if VERSION >= v"1.5.0-DEV.124"
7272
import Base: isdisjoint

src/display.jl

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@ are reset to the default display options.
3030
3131
Possible options:
3232
- `format` can be:
33-
- `:standard`: `[1, 2]`
34-
- `:midpoint`: display `x::Interval` in the form "mid(x) ± radius(x)"
33+
- `:standard`: `[1, 2]`.
34+
- `:midpoint`: display `x::Interval` in the form "mid(x) ± radius(x)".
3535
- `:full`: display the entire bounds regardless of `sigdigits`.
3636
- `sigdigits`: number (greater or equal to 1) of significant digits to display.
3737
- `decorations`: display the decorations or not.
3838
39-
See also: `@format`.
40-
4139
# Example
4240
```
4341
julia> x = interval(0.1, 0.3) # Default display options
4442
[0.0999999, 0.300001]
4543
46-
julia> setformat(:full) # Equivalent to `@format full`
44+
julia> setformat(:full)
4745
Display parameters:
4846
- format: full
4947
- decorations: true
@@ -52,7 +50,7 @@ Display parameters:
5250
julia> x
5351
Interval(0.09999999999999999, 0.30000000000000004)
5452
55-
julia> setformat(:standard; sigdigits = 3) # Equivalent to `@format standard 3`
53+
julia> setformat(:standard; sigdigits = 3)
5654
Display parameters:
5755
- format: standard
5856
- decorations: true
@@ -76,64 +74,6 @@ function setformat(format::Symbol = display_params.format;
7674
return display_params
7775
end
7876

79-
"""
80-
@format [format::Symbol] [decorations::Bool] [sigdigits::Integer]
81-
82-
Change the format used by `show` to display intervals. These options are passed
83-
to the `setformat` function.
84-
85-
Possible options:
86-
- `format` can be:
87-
- `:standard`: `[1, 2]`
88-
- `:midpoint`: display `x::Interval` in the form "mid(x) ± radius(x)"
89-
- `:full`: display the entire bounds regardless of `sigdigits`.
90-
- `sigdigits`: number (greater or equal to 1) of significant digits to display.
91-
- `decorations`: display the decorations or not.
92-
93-
See also: `setformat`.
94-
95-
# Example
96-
```
97-
julia> x = interval(0.1, 0.3) # Default display options
98-
[0.0999999, 0.300001]
99-
100-
julia> @format full # Equivalent to `setformat(:full)``
101-
Display parameters:
102-
- format: full
103-
- decorations: true
104-
- significant digits: 6
105-
106-
julia> x
107-
Interval(0.09999999999999999, 0.30000000000000004)
108-
109-
julia> @format standard true 3 # Equivalent to `setformat(:standard; decorations = true, sigdigits = 3)`
110-
Display parameters:
111-
- format: standard
112-
- decorations: true
113-
- significant digits: 3
114-
115-
julia> x
116-
[0.0999, 0.301]
117-
```
118-
"""
119-
macro format(expr...)
120-
format = Meta.quot(display_params.format)
121-
decorations = display_params.decorations
122-
sigdigits = display_params.sigdigits
123-
for ex in expr
124-
if isa(ex, Symbol)
125-
format = Meta.quot(ex)
126-
elseif isa(ex, Bool)
127-
decorations = ex
128-
elseif isa(ex, Integer)
129-
sigdigits = ex
130-
else
131-
return :(throw(ArgumentError("Only accept arguments of type `Symbol`, `Bool` or `Int` but received $($ex)")))
132-
end
133-
end
134-
return :(setformat($format; decorations = $decorations, sigdigits = $sigdigits))
135-
end
136-
13777
# Printing mechanism for various types of intervals
13878

13979
show(io::IO, ::MIME"text/plain", a::Union{Interval,Complex{<:Interval},DecoratedInterval,IntervalBox}) =

test/display_tests/display.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,6 @@ end
232232

233233
end
234234

235-
@testset "@format tests" begin
236-
x = interval(prevfloat(0.1), nextfloat(0.3))
237-
238-
@format full
239-
@test sprint(show, MIME("text/plain"), x) == "Interval{Float64}(0.09999999999999999, 0.30000000000000004)"
240-
241-
@format standard 3
242-
@test sprint(show, MIME("text/plain"), x) == "[0.0999, 0.301]"
243-
244-
@format standard 10
245-
@test sprint(show, MIME("text/plain"), x) == "[0.09999999999, 0.3000000001]"
246-
end
247-
248235
setprecision(BigFloat, 256)
249236

250237
end

0 commit comments

Comments
 (0)