Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rand requirement from 0.8 to 0.9 #402

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
12 changes: 7 additions & 5 deletions src/mc/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<R: Rng>(rng: &mut R) -> Vector3<f64> {
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;
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn dv_execution_error<R: Rng>(
#[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;
Expand All @@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion src/mc/montecarlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/od/estimate/kfestimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl KfEstimate<Spacecraft> {

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);

Expand Down
2 changes: 1 addition & 1 deletion src/od/noise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/od/simulator/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ where
trajectory: Traj<MsrIn>,
configs: BTreeMap<String, TrkConfig>,
) -> Result<Self, ConfigError> {
let rng = Pcg64Mcg::from_entropy();
let rng = Pcg64Mcg::from_os_rng();

Self::with_rng(devices, trajectory, configs, rng)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/orbit_determination/measurements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn val_measurements_topo(almanac: Arc<Almanac>) {
},
];

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
Expand Down