From b48fcd1b5ab4472cf0ecfbf129a5074dddccf090 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Tue, 21 Feb 2023 12:24:28 +0100 Subject: [PATCH] Use `default_rng` (#248) --- Project.toml | 2 +- src/Bijectors.jl | 2 ++ src/transformed_distribution.jl | 6 ++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 938d4735..1bdacc96 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Bijectors" uuid = "76274a88-744f-5084-9051-94815aaf08c4" -version = "0.10.6" +version = "0.10.7" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" diff --git a/src/Bijectors.jl b/src/Bijectors.jl index 193327fa..48a8220f 100644 --- a/src/Bijectors.jl +++ b/src/Bijectors.jl @@ -44,6 +44,8 @@ import IrrationalConstants import LogExpFunctions import Roots +import Random + export TransformDistribution, PositiveDistribution, UnitDistribution, diff --git a/src/transformed_distribution.jl b/src/transformed_distribution.jl index f51013c3..56d06b2e 100644 --- a/src/transformed_distribution.jl +++ b/src/transformed_distribution.jl @@ -215,8 +215,6 @@ end # forward function -const GLOBAL_RNG = Distributions.GLOBAL_RNG - function _forward(d::UnivariateDistribution, x) y, logjac = with_logabsdet_jacobian(Identity{0}(), x) return (x = x, y = y, logabsdetjac = logjac, logpdf = logpdf.(d, x)) @@ -265,8 +263,8 @@ In the case where `d isa Distribution`, this means - `logabsdetjac = 0.0` - `logpdf` is logpdf of `x` """ -forward(d::Distribution) = forward(GLOBAL_RNG, d) -forward(d::Distribution, num_samples::Int) = forward(GLOBAL_RNG, d, num_samples) +forward(d::Distribution) = forward(Random.default_rng(), d) +forward(d::Distribution, num_samples::Int) = forward(Random.default_rng(), d, num_samples) # utility stuff Distributions.params(td::Transformed) = Distributions.params(td.dist)