From 5e3117515d4e716feb57eb5e4f068d3b28da105d Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Thu, 9 May 2024 14:04:12 +0200 Subject: [PATCH] only add method to `Random._GLOBAL_RNG` if it is defined This was removed in Julia 1.11+ --- src/ensembles.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ensembles.jl b/src/ensembles.jl index cb2775d..122a87b 100644 --- a/src/ensembles.jl +++ b/src/ensembles.jl @@ -412,7 +412,9 @@ end # Random._GLOBAL_RNG() and Random.default_rng() are threadsafe by default_rng # as they have thread local state from julia >=1.3<=1.6 and task local state Julia >=1.7 threadsafe_rng(rng::typeof(Random.default_rng())) = rng -threadsafe_rng(rng::Random._GLOBAL_RNG) = rng +if isdefined(Random, :_GLOBAL_RNG) + threadsafe_rng(rng::Random._GLOBAL_RNG) = rng +end threadsafe_rng(rng) = deepcopy(rng) function _fit(res::CPUThreads, func, verbosity, stuff)