Skip to content

Commit 1114b4c

Browse files
lbenetdpsanders
authored andcommitted
WIP: Fix Julia 0.7 deprecation warnings (#155)
* Fix many deprecation warnings * Fix conversion ambiguity and import Compat.Sys * Remove `@doc doc` * Further deprecation fixes * Export ⊇ for Julia 0.6.x, and avoid testing complex intervals * Fixes broken tests in 0.6 * Update Compat version in REQUIRE * Fix deprecation warnings in bisect
1 parent 6824bf5 commit 1114b4c

40 files changed

+225
-97
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ StaticArrays 0.5
44
FastRounding 0.0.4
55
AdjacentFloats 0.0.5
66
RecipesBase
7-
7+
Compat 0.69.0

src/IntervalArithmetic.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import CRlibm
88
using StaticArrays
99
using FastRounding
1010
using AdjacentFloats
11+
using Compat
12+
13+
if VERSION <= v"0.7.0-DEV.2004"
14+
import Base: ×, dot
15+
import Compat.Sys
16+
export
17+
else
18+
using Markdown
19+
import Base:
20+
import LinearAlgebra: ×, dot
21+
end
22+
1123

1224
import Base:
1325
+, -, *, /, //, fma,
@@ -30,7 +42,7 @@ import Base:
3042
parse, hash
3143

3244
import Base: # for IntervalBox
33-
broadcast, dot, length,
45+
broadcast, length,
3446
getindex, setindex,
3547
start, next, done, eltype
3648

@@ -42,7 +54,7 @@ export
4254
emptyinterval, ∅, ∞, isempty, isinterior, isdisjoint, ,
4355
precedes, strictprecedes, , , , , contains_zero,
4456
entireinterval, isentire, nai, isnai, isthin, iscommon, isatomic,
45-
widen, inf, sup, bisect,
57+
widen, inf, sup, bisect,
4658
parameters, eps, dist,
4759
pi_interval,
4860
midpoint_radius, interval_from_midpoint_radius,
@@ -77,7 +89,10 @@ export
7789

7890
function __init__()
7991
setrounding(BigFloat, RoundNearest)
80-
setrounding(Float64, RoundNearest)
92+
if VERSION < v"0.7.0-DEV"
93+
## deprecated in 0.7
94+
setrounding(Float64, RoundNearest)
95+
end
8196

8297
setprecision(Interval, 256) # set up pi
8398
setprecision(Interval, Float64)

src/bisect.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
const where_bisect = 0.49609375
33

4-
doc"""
4+
"""
55
bisect(X::Interval, α=0.49609375)
66
77
Split the interval `X` at position α; α=0.5 corresponds to the midpoint.
@@ -15,7 +15,7 @@ function bisect(X::Interval, α=where_bisect)
1515
return (Interval(X.lo, m), Interval(m, X.hi))
1616
end
1717

18-
doc"""
18+
"""
1919
bisect(X::IntervalBox, α=0.49609375)
2020
2121
Bisect the `IntervalBox` `X` at position α ∈ [0,1] along its longest side.
@@ -26,7 +26,7 @@ function bisect(X::IntervalBox, α=where_bisect)
2626
return bisect(X, i, α)
2727
end
2828

29-
doc"""
29+
"""
3030
bisect(X::IntervalBox, i::Integer, α=0.49609375)
3131
3232
Bisect the `IntervalBox` in side number `i`.

src/display.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ end
109109
function round_string(x::BigFloat, digits::Int, r::RoundingMode)
110110

111111
lng = digits + Int32(8)
112-
buf = Array{UInt8}(lng + 1)
112+
@compat buf = Array{UInt8}(undef, lng + 1)
113113

114114
lng = ccall((:mpfr_snprintf,:libmpfr), Int32,
115115
(Ptr{UInt8}, Culong, Ptr{UInt8}, Int32, Ref{BigFloat}...),
116116
buf, lng + 1, "%.$(digits)R*g", Base.MPFR.to_mpfr(r), x)
117117

118118
repr = unsafe_string(pointer(buf))
119119

120-
repr = replace(repr, "nan", "NaN")
120+
@compat repr = replace(repr, "nan" => "NaN")
121121

122122
return repr
123123
end
@@ -144,8 +144,8 @@ function basic_representation(a::Interval, format=nothing)
144144
bb = round_string(a.hi, sigfigs, RoundUp)
145145

146146
output = "[$aa, $bb]"
147-
output = replace(output, "inf", "")
148-
output = replace(output, "Inf", "")
147+
@compat output = replace(output, "inf" => "")
148+
@compat output = replace(output, "Inf" => "")
149149

150150
elseif format == :full
151151
output = "Interval($(a.lo), $(a.hi))"

src/intervals/arithmetic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ function diam(a::Interval{T}) where T<:Real
413413
@round_up(a.hi - a.lo) # cf page 64 of IEEE1788
414414
end
415415

416+
# Should `radius` this yield diam(a)/2? This affects other functions!
416417
"""
417418
radius(a::Interval)
418419
419420
Return the radius of the `Interval` `a`, such that
420421
`a ⊆ m ± radius`, where `m = mid(a)` is the midpoint.
421422
"""
422-
# Should `radius` this yield diam(a)/2? This affects other functions!
423423
function radius(a::Interval)
424424
isempty(a) && return convert(eltype(a), NaN)
425425
m = mid(a)

src/intervals/conversion.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ promote_rule(::Type{BigFloat}, ::Type{Interval{T}}) where T<:Real =
1313

1414

1515
# convert methods:
16-
convert(::Type{Interval{T}}, x) where {T} = atomic(Interval{T}, x)
17-
convert(::Type{Interval{T}}, x::T) where {T} = Interval{T}(x)
16+
convert(::Type{Interval{T}}, x::Real) where {T} = atomic(Interval{T}, x)
17+
convert(::Type{Interval{T}}, x::T) where {T<:Real} = Interval{T}(x)
1818
convert(::Type{Interval{T}}, x::Interval{T}) where {T} = x
1919
convert(::Type{Interval{T}}, x::Interval) where {T} = atomic(Interval{T}, x)
2020

@@ -74,7 +74,7 @@ atomic(::Type{Interval{T}}, x::T) where {T<:Integer} = Interval{T}(x)
7474
atomic(::Type{Interval{T}}, x::AbstractString) where T<:AbstractFloat =
7575
parse(Interval{T}, x)
7676

77-
@static if is_windows() # Windows cannot round properly
77+
@static if Sys.iswindows() # Windows cannot round properly
7878
function atomic(::Type{Interval{T}}, x::S) where {T<:AbstractFloat, S<:Real}
7979
isinf(x) && return wideinterval(T(x))
8080

src/intervals/macros.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ end
7777
"""`make_interval` does the hard work of taking expressions
7878
and making each literal (0.1, 1, etc.) into a corresponding interval construction,
7979
by calling `transform`."""
80-
8180
function make_interval(T, expr1, expr2)
8281
# @show expr1, expr2
8382

src/intervals/precision.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const parameters = IntervalParameters()
1515

1616
## Precision:
1717

18-
doc"`big53` creates an equivalent `BigFloat` interval to a given `Float64` interval."
18+
"`big53` creates an equivalent `BigFloat` interval to a given `Float64` interval."
1919
function big53(a::Interval{Float64})
2020
setprecision(Interval, 53) do # precision of Float64
2121
atomic(Interval{BigFloat}, a)

src/intervals/rounding.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function setrounding(::Type{Interval}, rounding_type::Symbol)
269269

270270
path, io = mktemp()
271271

272-
old_stderr = STDERR
272+
old_stderr = stderr
273273
redirect_stderr(io)
274274

275275
_setrounding(Interval, rounding_type)

src/intervals/special.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function iscommon(a::Interval)
5858
true
5959
end
6060

61-
doc"`widen(x)` widens the lowest and highest bounds of `x` to the previous and next representable floating-point numbers, respectively."
61+
"`widen(x)` widens the lowest and highest bounds of `x` to the previous and next representable floating-point numbers, respectively."
6262
widen(x::Interval{T}) where {T<:AbstractFloat} = Interval(prevfloat(x.lo), nextfloat(x.hi))
6363

6464
"""

0 commit comments

Comments
 (0)