Files
smartcore/src/rand.rs
morenol a37b552a7d Lmm/add seeds in more algorithms (#164)
* Provide better output in flaky tests

* feat: add seed parameter to multiple algorithms

* Update changelog

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
2022-11-08 11:29:56 -05:00

22 lines
628 B
Rust

use ::rand::SeedableRng;
#[cfg(not(feature = "std"))]
use rand::rngs::SmallRng as RngImpl;
#[cfg(feature = "std")]
use rand::rngs::StdRng as RngImpl;
pub(crate) fn get_rng_impl(seed: Option<u64>) -> RngImpl {
match seed {
Some(seed) => RngImpl::seed_from_u64(seed),
None => {
cfg_if::cfg_if! {
if #[cfg(feature = "std")] {
use rand::RngCore;
RngImpl::seed_from_u64(rand::thread_rng().next_u64())
} else {
panic!("seed number needed for non-std build");
}
}
}
}
}