Skip to content

Commit

Permalink
Mark Compat.Random from #460, #601, and #647 for deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 8, 2019
1 parent d5d9943 commit f1c2a3f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 60 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).

Expand Down Expand Up @@ -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]).
Expand Down
45 changes: 1 addition & 44 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions test/old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 0 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit f1c2a3f

Please sign in to comment.