Skip to content

Commit db14e4a

Browse files
committed
Drop compat code for Compat.round and friends #500, #530, and #537
1 parent 660d30e commit db14e4a

File tree

5 files changed

+26
-75
lines changed

5 files changed

+26
-75
lines changed

README.md

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ Currently, the `@compat` macro supports the following syntaxes:
7474

7575
* `Compat.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]).
7676

77-
* `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, take a keyword argument
78-
for `base` and `digits`, `Compat.round` also takes `sigdigits` ([#26156], [#26670]).
79-
8077
* `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]).
8178

8279
* `Compat.accumulate`, `Compat.accumulate!`, `Compat.all`, `Compat.any`,

src/Compat.jl

-52
Original file line numberDiff line numberDiff line change
@@ -76,58 +76,6 @@ end
7676
end
7777
end
7878

79-
# https://github.com/JuliaLang/julia/pull/26670
80-
@static if VERSION < v"0.7.0-DEV.4062"
81-
trunc(x; digits = 0, base = 10) = Base.trunc(x, digits, base)
82-
floor(x; digits = 0, base = 10) = Base.floor(x, digits, base)
83-
ceil(x; digits = 0, base = 10) = Base.ceil(x, digits, base)
84-
function round(x; digits = nothing, sigdigits = nothing, base = 10)
85-
if digits === nothing
86-
if sigdigits === nothing
87-
Base.round(x, 0, base)
88-
else
89-
Base.signif(x, sigdigits, base)
90-
end
91-
else
92-
sigdigits === nothing || throw(AgrumentError("`round` cannot use both `digits` and `sigdigits` arguments"))
93-
Base.round(x, digits, base)
94-
end
95-
end
96-
elseif VERSION < v"0.7.0-DEV.4804"
97-
trunc(x; digits = 0, base = 10) = Base.trunc(x, digits, base = base)
98-
floor(x; digits = 0, base = 10) = Base.floor(x, digits, base = base)
99-
ceil(x; digits = 0, base = 10) = Base.ceil(x, digits, base = base)
100-
function round(x; digits = nothing, sigdigits = nothing, base = 10)
101-
if digits === nothing
102-
if sigdigits === nothing
103-
Base.round(x, 0, base = base)
104-
else
105-
Base.signif(x, sigdigits, base = base)
106-
end
107-
else
108-
sigdigits === nothing || throw(AgrumentError("`round` cannot use both `digits` and `sigdigits` arguments"))
109-
Base.round(x, digits, base = base)
110-
end
111-
end
112-
elseif VERSION < v"0.7.0-beta2.86"
113-
# https://github.com/JuliaLang/julia/pull/28199
114-
trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base)
115-
floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base)
116-
ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base)
117-
function round(x; digits = nothing, sigdigits = nothing, base = 10)
118-
if digits === nothing && sigdigits === nothing
119-
Base.round(x, digits = 0, base = base)
120-
else
121-
Base.round(x, digits = digits, sigdigits = sigdigits, base = base)
122-
end
123-
end
124-
else
125-
trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base)
126-
floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base)
127-
ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base)
128-
round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base)
129-
end
130-
13179
# https://github.com/JuliaLang/julia/pull/25872
13280
if VERSION < v"0.7.0-DEV.3734"
13381
if isdefined(Base, :open_flags)

src/deprecated.jl

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ Base.@deprecate floor(x, digits; base = 10) Compat.floor(x, digits = digits, bas
6262
Base.@deprecate ceil(x, digits; base = 10) Compat.ceil(x, digits = digits, base = base) false
6363
Base.@deprecate round(x, digits; base = 10) Compat.round(x, digits = digits, base = base) false
6464
Base.@deprecate signif(x, digits; base = 10) Compat.round(x, sigdigits = digits, base = base) false
65+
# standard methods from Base; can be removed (so that Compat just inherits the functions
66+
# from Base) once above deprecations are removed
67+
trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base)
68+
floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base)
69+
ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base)
70+
round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base)
6571

6672
if VERSION >= v"1.1.0-DEV.506"
6773
# deprecation of range(start, stop) for earlier versions is done in Compat.jl

test/old.jl

+20
Original file line numberDiff line numberDiff line change
@@ -799,3 +799,23 @@ module TestNames
799799
end
800800
@test :foo in Compat.names(TestNames)
801801
@test :bar in Compat.names(TestNames, all=true)
802+
803+
# 0.7.0-DEV.4804
804+
@test Compat.trunc(pi) == 3.0
805+
@test Compat.floor(pi) == 3.0
806+
@test Compat.ceil(pi) == 4.0
807+
@test Compat.round(pi) == 3.0
808+
@test Compat.trunc(pi, digits = 3) == 3.141
809+
@test Compat.floor(pi, digits = 3) == 3.141
810+
@test Compat.ceil(pi, digits = 3) == 3.142
811+
@test Compat.round(pi, digits = 3) == 3.142
812+
@test Compat.round(pi, sigdigits = 5) == 3.1416
813+
@test Compat.trunc(pi, base = 2) == 3.0
814+
@test Compat.floor(pi, base = 2) == 3.0
815+
@test Compat.ceil(pi, base = 2) == 4.0
816+
@test Compat.round(pi, base = 2) == 3.0
817+
@test Compat.trunc(pi, digits = 3, base = 2) == 3.125
818+
@test Compat.floor(pi, digits = 3, base = 2) == 3.125
819+
@test Compat.ceil(pi, digits = 3, base = 2) == 3.25
820+
@test Compat.round(pi, digits = 3, base = 2) == 3.125
821+
@test Compat.round(pi, sigdigits = 5, base = 2) == 3.125

test/runtests.jl

-20
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,6 @@ end
8282

8383
@test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8
8484

85-
# 0.7.0-DEV.4804
86-
@test Compat.trunc(pi) == 3.0
87-
@test Compat.floor(pi) == 3.0
88-
@test Compat.ceil(pi) == 4.0
89-
@test Compat.round(pi) == 3.0
90-
@test Compat.trunc(pi, digits = 3) == 3.141
91-
@test Compat.floor(pi, digits = 3) == 3.141
92-
@test Compat.ceil(pi, digits = 3) == 3.142
93-
@test Compat.round(pi, digits = 3) == 3.142
94-
@test Compat.round(pi, sigdigits = 5) == 3.1416
95-
@test Compat.trunc(pi, base = 2) == 3.0
96-
@test Compat.floor(pi, base = 2) == 3.0
97-
@test Compat.ceil(pi, base = 2) == 4.0
98-
@test Compat.round(pi, base = 2) == 3.0
99-
@test Compat.trunc(pi, digits = 3, base = 2) == 3.125
100-
@test Compat.floor(pi, digits = 3, base = 2) == 3.125
101-
@test Compat.ceil(pi, digits = 3, base = 2) == 3.25
102-
@test Compat.round(pi, digits = 3, base = 2) == 3.125
103-
@test Compat.round(pi, sigdigits = 5, base = 2) == 3.125
104-
10585
# 0.7.0-DEV.3734
10686
let buf = Compat.IOBuffer(read=true, write=false, maxsize=25)
10787
@test buf.readable

0 commit comments

Comments
 (0)