From f1c2a3f72c802848570b572cb8daba01565ea12b Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 16:05:23 +0200 Subject: [PATCH] Mark `Compat.Random` from #460, #601, and #647 for deprecation --- README.md | 5 ----- src/Compat.jl | 45 +-------------------------------------------- test/old.jl | 11 +++++++++++ test/runtests.jl | 11 ----------- 4 files changed, 12 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index e16734225..258ad5b79 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.Random` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#24874]). - * `using Compat.REPL` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25544]). @@ -276,8 +273,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `atan2` is now a 2-argument method of `atan` ([#27253]). -* `srand` is now `Compat.Random.seed!` ([#28295]) - * `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302]) * `squeeze` is now `dropdims` ([#28303], [#26660]). diff --git a/src/Compat.jl b/src/Compat.jl index 3e363945c..fb557db51 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -26,54 +26,11 @@ const AbstractDateTime = Compat.Dates.AbstractDateTime import Printf import LinearAlgebra import SparseArrays +import Random include("compatmacro.jl") -# v"0.7.0-beta.234" introduced Random.gentype (formerly Base.eltype) -# v"0.7.0-beta2.171" deprecated Random.srand in favor of Random.seed! (unexported) -# v"0.7.0-DEV.3406" moved Base.Random to stdlib Random -if VERSION >= v"0.7.0-beta.234" - import Random -else - const exported_random_fields = [ - :AbstractRNG, :MersenneTwister, :RandomDevice, :bitrand, :rand, :rand!, - :randcycle, :randexp, :randexp!, :randjump, :randn!, - :randperm, :randstring, :randsubseq, :randsubseq!, :shuffle, - :shuffle! - ] - const unexported_random_fields = [ - :GLOBAL_RNG, :RangeGenerator - ] - const random_fields = [exported_random_fields; unexported_random_fields] - @eval module Random - if VERSION < v"0.7.0-DEV.3406" - $((:(using Base.Random: $f) for f in random_fields)...) - const seed! = Base.Random.srand - else - $((:(using Random: $f) for f in random_fields)...) - import Random - if VERSION < v"0.7.0-beta2.171" - const seed! = Random.srand - else - using Random: seed! - end - end - if VERSION < v"0.7.0-DEV.3666" - import ..Compat - Base.@deprecate uuid1() Compat.UUIDs.uuid1() false - Base.@deprecate uuid1(rng) Compat.UUIDs.uuid1(rng) false - Base.@deprecate uuid4() Compat.UUIDs.uuid4() false - Base.@deprecate uuid4(rng) Compat.UUIDs.uuid4(rng) false - Base.@deprecate uuid_version(u) Compat.UUIDs.uuid_version(u) false - end - - gentype(args...) = eltype(args...) - - export $(exported_random_fields...) - end -end - if VERSION < v"0.7.0-DEV.3589" const Markdown = Base.Markdown else diff --git a/test/old.jl b/test/old.jl index 0c359008a..5320545ee 100644 --- a/test/old.jl +++ b/test/old.jl @@ -122,6 +122,17 @@ let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] @test diag(A) == b end +# 0.7.0-DEV.3406 +using Compat.Random +@test rand(MersenneTwister(1234)) == 0.5908446386657102 + +# 0.7.0-beta2.171 +Random.seed!(1) +rng = MersenneTwister(0) +Random.seed!(rng, 1) +@test rand(rng) ≈ 0.23603334566204692 +@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 52cfcd848..f49d74f62 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -233,10 +233,6 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end -# 0.7.0-DEV.3406 -using Compat.Random -@test rand(MersenneTwister(1234)) == 0.5908446386657102 - # 0.7, make sure this works on 0.6 if VERSION < v"0.7.0-DEV.3272" @test contains("Hello, World!", r"World") @@ -1006,13 +1002,6 @@ let a = rand(5,5) end end -# 0.7.0-beta2.171 -Random.seed!(1) -rng = MersenneTwister(0) -Random.seed!(rng, 1) -@test rand(rng) ≈ 0.23603334566204692 -@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 - # 0.7.0-beta2.169 @test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) @test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff))