Skip to content

Commit 989e85c

Browse files
committed
Mark Compat.Random from #460, #601, and #647 for deprecation
1 parent d9647f9 commit 989e85c

File tree

4 files changed

+12
-60
lines changed

4 files changed

+12
-60
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes:
5858
* `using Compat.Unicode` is provided on versions older than 0.7, where this library is not
5959
yet a part of the standard library. ([#25021])
6060

61-
* `using Compat.Random` is provided on versions older than 0.7, where this library is
62-
not yet part of the standard library ([#24874]).
63-
6461
* `using Compat.REPL` is provided on versions older than 0.7, where this library is
6562
not yet part of the standard library ([#25544]).
6663

@@ -274,8 +271,6 @@ Currently, the `@compat` macro supports the following syntaxes:
274271

275272
* `atan2` is now a 2-argument method of `atan` ([#27253]).
276273

277-
* `srand` is now `Compat.Random.seed!` ([#28295])
278-
279274
* `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302])
280275

281276
* `squeeze` is now `dropdims` ([#28303], [#26660]).

src/Compat.jl

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,11 @@ const AbstractDateTime = Compat.Dates.AbstractDateTime
2626
import Printf
2727
import LinearAlgebra
2828
import SparseArrays
29+
import Random
2930

3031

3132
include("compatmacro.jl")
3233

33-
# v"0.7.0-beta.234" introduced Random.gentype (formerly Base.eltype)
34-
# v"0.7.0-beta2.171" deprecated Random.srand in favor of Random.seed! (unexported)
35-
# v"0.7.0-DEV.3406" moved Base.Random to stdlib Random
36-
if VERSION >= v"0.7.0-beta.234"
37-
import Random
38-
else
39-
const exported_random_fields = [
40-
:AbstractRNG, :MersenneTwister, :RandomDevice, :bitrand, :rand, :rand!,
41-
:randcycle, :randexp, :randexp!, :randjump, :randn!,
42-
:randperm, :randstring, :randsubseq, :randsubseq!, :shuffle,
43-
:shuffle!
44-
]
45-
const unexported_random_fields = [
46-
:GLOBAL_RNG, :RangeGenerator
47-
]
48-
const random_fields = [exported_random_fields; unexported_random_fields]
49-
@eval module Random
50-
if VERSION < v"0.7.0-DEV.3406"
51-
$((:(using Base.Random: $f) for f in random_fields)...)
52-
const seed! = Base.Random.srand
53-
else
54-
$((:(using Random: $f) for f in random_fields)...)
55-
import Random
56-
if VERSION < v"0.7.0-beta2.171"
57-
const seed! = Random.srand
58-
else
59-
using Random: seed!
60-
end
61-
end
62-
if VERSION < v"0.7.0-DEV.3666"
63-
import ..Compat
64-
Base.@deprecate uuid1() Compat.UUIDs.uuid1() false
65-
Base.@deprecate uuid1(rng) Compat.UUIDs.uuid1(rng) false
66-
Base.@deprecate uuid4() Compat.UUIDs.uuid4() false
67-
Base.@deprecate uuid4(rng) Compat.UUIDs.uuid4(rng) false
68-
Base.@deprecate uuid_version(u) Compat.UUIDs.uuid_version(u) false
69-
end
70-
71-
gentype(args...) = eltype(args...)
72-
73-
export $(exported_random_fields...)
74-
end
75-
end
76-
7734
if VERSION < v"0.7.0-DEV.3589"
7835
const Markdown = Base.Markdown
7936
else

test/old.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0]
122122
@test diag(A) == b
123123
end
124124

125+
# 0.7.0-DEV.3406
126+
using Compat.Random
127+
@test rand(MersenneTwister(1234)) == 0.5908446386657102
128+
129+
# 0.7.0-beta2.171
130+
Random.seed!(1)
131+
rng = MersenneTwister(0)
132+
Random.seed!(rng, 1)
133+
@test rand(rng) 0.23603334566204692
134+
@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4
135+
125136

126137
# tests of removed functionality (i.e. justs tests Base)
127138

test/runtests.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ let A = [0, 0, 0], B = [1, 2, 3]
233233
@test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0]
234234
end
235235

236-
# 0.7.0-DEV.3406
237-
using Compat.Random
238-
@test rand(MersenneTwister(1234)) == 0.5908446386657102
239-
240236
# 0.7, make sure this works on 0.6
241237
if VERSION < v"0.7.0-DEV.3272"
242238
@test contains("Hello, World!", r"World")
@@ -1006,13 +1002,6 @@ let a = rand(5,5)
10061002
end
10071003
end
10081004

1009-
# 0.7.0-beta2.171
1010-
Random.seed!(1)
1011-
rng = MersenneTwister(0)
1012-
Random.seed!(rng, 1)
1013-
@test rand(rng) 0.23603334566204692
1014-
@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4
1015-
10161005
# 0.7.0-beta2.169
10171006
@test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400))
10181007
@test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff))

0 commit comments

Comments
 (0)