diff --git a/Cargo.toml b/Cargo.toml index aa270bd2..3eb91aec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,12 +45,12 @@ flate2 = { version = "1.0", features = [ serde = "1.0" serde_derive = "1.0" hyperdual = "1.3.0" -rand = "0.8" -rand_distr = "0.4" +rand = "0.9" +rand_distr = "0.5" regex = "1.5" rayon = "1.6" approx = "0.5" -rand_pcg = "0.3" +rand_pcg = "0.9" indicatif = { version = "0.17", features = ["rayon"], default-features = false } rstats = "2.0.1" parquet = { version = "54.0.0", default-features = false, features = [ diff --git a/src/mc/helpers.rs b/src/mc/helpers.rs index 80c45311..11ff8b62 100644 --- a/src/mc/helpers.rs +++ b/src/mc/helpers.rs @@ -23,7 +23,7 @@ use crate::NyxError; /// Returns a unit vector from a normal distribution. /// Implements the Sphere Point Picking method: https://mathworld.wolfram.com/SpherePointPicking.html pub fn unit_vector_from_seed(rng: &mut R) -> Vector3 { - let distr = Uniform::new_inclusive(0.0, 1.0); + let distr = Uniform::new_inclusive(0.0, 1.0).expect("could not initialize uniform PRG"); let u = distr.sample(rng); let v = distr.sample(rng); let theta = std::f64::consts::TAU * u; @@ -82,7 +82,7 @@ pub fn dv_execution_error( #[allow(clippy::float_equality_without_abs)] #[test] fn test_dv_mag_fixed() { - use super::thread_rng; + use super::ThreadRng; use crate::time::Epoch; use anise::constants::frames::EARTH_J2000; use anise::prelude::Orbit; @@ -100,11 +100,13 @@ fn test_dv_mag_fixed() { let dv_mag_distr = Normal::new(5e-3, 5e-4).unwrap(); + let mut thread_rng = ThreadRng::default(); + for _ in 0..=1000 { - let dv_mag = dv_mag_distr.sample(&mut thread_rng()); - let dv_point = unit_vector_from_seed(&mut thread_rng()); + let dv_mag = dv_mag_distr.sample(&mut thread_rng); + let dv_point = unit_vector_from_seed(&mut thread_rng); let dv = dv_point * dv_mag; - let dv_w_err = dv_pointing_error(&orbit.velocity_km_s, dv, 0.1, &mut thread_rng()).unwrap(); + let dv_w_err = dv_pointing_error(&orbit.velocity_km_s, dv, 0.1, &mut thread_rng).unwrap(); assert!( (dv_w_err.norm() - dv_mag) < f64::EPSILON, "{:.1e}", diff --git a/src/mc/montecarlo.rs b/src/mc/montecarlo.rs index 9ea01f24..3ef334d5 100644 --- a/src/mc/montecarlo.rs +++ b/src/mc/montecarlo.rs @@ -288,7 +288,7 @@ where // Setup the RNG let rng = match seed { Some(seed) => Pcg64Mcg::new(seed), - None => Pcg64Mcg::from_entropy(), + None => Pcg64Mcg::from_os_rng(), }; // Generate the states, forcing the borrow as specified in the `sample_iter` docs. diff --git a/src/od/estimate/kfestimate.rs b/src/od/estimate/kfestimate.rs index 495e6ebe..9b155f2e 100644 --- a/src/od/estimate/kfestimate.rs +++ b/src/od/estimate/kfestimate.rs @@ -112,7 +112,7 @@ impl KfEstimate { let mut rng = match seed { Some(seed) => Pcg64Mcg::new(seed), - None => Pcg64Mcg::from_entropy(), + None => Pcg64Mcg::from_os_rng(), }; let dispersed_state = generator.sample(&mut rng); diff --git a/src/od/noise/mod.rs b/src/od/noise/mod.rs index ed78a417..9793cc10 100644 --- a/src/od/noise/mod.rs +++ b/src/od/noise/mod.rs @@ -152,7 +152,7 @@ impl StochasticNoise { let mut samples = Vec::with_capacity(capacity); for run in 0..num_runs { - let mut rng = Pcg64Mcg::from_entropy(); + let mut rng = Pcg64Mcg::from_os_rng(); let mut mdl = self; for epoch in TimeSeries::inclusive(start, end, step) { diff --git a/src/od/simulator/arc.rs b/src/od/simulator/arc.rs index fe2d6606..78ee2b77 100644 --- a/src/od/simulator/arc.rs +++ b/src/od/simulator/arc.rs @@ -145,7 +145,7 @@ where trajectory: Traj, configs: BTreeMap, ) -> Result { - let rng = Pcg64Mcg::from_entropy(); + let rng = Pcg64Mcg::from_os_rng(); Self::with_rng(devices, trajectory, configs, rng) } diff --git a/tests/orbit_determination/measurements.rs b/tests/orbit_determination/measurements.rs index f37d07ee..fde72d61 100644 --- a/tests/orbit_determination/measurements.rs +++ b/tests/orbit_determination/measurements.rs @@ -178,7 +178,7 @@ fn val_measurements_topo(almanac: Arc) { }, ]; - let mut rng = Pcg64Mcg::from_entropy(); + let mut rng = Pcg64Mcg::from_os_rng(); let mut traj1_msr_cnt = 0; for state in traj1.every(1 * Unit::Minute) { if dss65_madrid