Skip to content

Commit

Permalink
rand 0.9 and rand-distr 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hombit committed Feb 3, 2025
1 parent c08e434 commit 6b94446
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ hyperdual = "1.1"
light-curve-common = "0.1.0"
plotters = { version = "0.3.5", default-features = false, features = ["errorbar", "line_series", "ttf"] }
plotters-bitmap = "0.3.3"
rand = "0.8"
rand_distr = "0.4"
rand = "0.9"
rand_distr = "0.5"
rayon = "1.5"
realfft = "3.1"
rustfft = "6.1"
Expand Down
2 changes: 1 addition & 1 deletion benches/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
{
(0..n)
.map(|_| {
let x: T = thread_rng().sample(StandardNormal);
let x: T = rand::rng().sample(StandardNormal);
x
})
.collect()
Expand Down
6 changes: 3 additions & 3 deletions benches/fft_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ struct Randoms {}
impl<T> Series<T> for Randoms
where
T: FftNum,
rand::distributions::Standard: Distribution<T>,
rand::distr::StandardUniform: Distribution<T>,
{
fn series(&self, n: usize) -> Vec<T> {
let mut rng = StdRng::seed_from_u64(0);
(0..n).map(|_| rng.gen::<T>()).collect()
(0..n).map(|_| rng.random::<T>()).collect()
}
}

Expand All @@ -218,7 +218,7 @@ where
FftwComplex<T>: AlignedAllocable,
Plan<T, FftwComplex<T>, T::Plan>: R2CPlan<Real = T, Complex = FftwComplex<T>>,
Vec<T>: fmt::Debug,
rand::distributions::Standard: Distribution<T>,
rand::distr::StandardUniform: Distribution<T>,
{
let counts: Vec<_> = (8..=20).step_by(4).map(|i| 1_usize << i).collect();
let series: Vec<Box<dyn Series<T>>> = vec![Box::new(Ones {}), Box::new(Randoms {})];
Expand Down
4 changes: 2 additions & 2 deletions benches/fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub fn bench_fit_straight_line(c: &mut Criterion) {
const N: usize = 1000;

let x = linspace(0.0_f64, 1.0, N);
let y: Vec<_> = x.iter().map(|&x| x + thread_rng().gen::<f64>()).collect();
let y: Vec<_> = x.iter().map(|&x| x + rand::rng().random::<f64>()).collect();
let w: Vec<_> = x
.iter()
.map(|_| thread_rng().gen_range(10.0..100.0))
.map(|_| rand::rng().random_range(10.0..100.0))
.collect();
let ts = TimeSeries::new(&x, &y, &w);

Expand Down
12 changes: 6 additions & 6 deletions src/features/periodogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mod tests {
.map(|&x| {
3.0 * f32::sin(2.0 * std::f32::consts::PI / period * x + 0.5)
+ 4.0
+ 0.01 * rng.gen::<f32>() // noise stabilizes solution
+ 0.01 * rng.random::<f32>() // noise stabilizes solution
})
.collect();
let mut ts = TimeSeries::new_without_weight(&x[..], &y[..]);
Expand All @@ -560,7 +560,7 @@ mod tests {
let periodogram: Periodogram<_, Feature<_>> = Periodogram::default();
let period = 0.17;
let mut rng = StdRng::seed_from_u64(0);
let mut x: Vec<f32> = (0..100).map(|_| rng.gen()).collect();
let mut x: Vec<f32> = (0..100).map(|_| rng.random()).collect();
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
let y: Vec<_> = x
.iter()
Expand All @@ -580,7 +580,7 @@ mod tests {
]);
let period = 0.17;
let mut rng = StdRng::seed_from_u64(0);
let mut x: Vec<f32> = (0..100).map(|_| rng.gen()).collect();
let mut x: Vec<f32> = (0..100).map(|_| rng.random()).collect();
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
let y: Vec<_> = x
.iter()
Expand All @@ -601,7 +601,7 @@ mod tests {
let period1 = 0.0753;
let period2 = 0.45;
let mut rng = StdRng::seed_from_u64(0);
let mut x: Vec<f32> = (0..1000).map(|_| rng.gen()).collect();
let mut x: Vec<f32> = (0..1000).map(|_| rng.random()).collect();
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
let y: Vec<_> = x
.iter()
Expand All @@ -625,14 +625,14 @@ mod tests {
let period1 = 0.0753;
let period2 = 0.46;
let mut rng = StdRng::seed_from_u64(0);
let mut x: Vec<f32> = (0..1000).map(|_| rng.gen()).collect();
let mut x: Vec<f32> = (0..1000).map(|_| rng.random()).collect();
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
let y: Vec<_> = x
.iter()
.map(|&x| {
3.0 * f32::sin(2.0 * std::f32::consts::PI / period1 * x + 0.5)
+ -5.0 * f32::cos(2.0 * std::f32::consts::PI / period2 * x + 0.5)
+ 10.0 * rng.gen::<f32>()
+ 10.0 * rng.random::<f32>()
+ 4.0
})
.collect();
Expand Down
4 changes: 2 additions & 2 deletions src/periodogram/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ mod tests {

let mut rng = StdRng::seed_from_u64(0);
let t: SortedArray<_> = (0..N)
.map(|_| rng.gen::<f64>() * (N - 1) as f64)
.map(|_| rng.random::<f64>() * (N - 1) as f64)
.collect::<Vec<_>>()
.into();
let m: Vec<_> = t
.iter()
.map(|&x| {
f64::sin(OMEGA1 * x)
+ AMPLITUDE2 * f64::cos(OMEGA2 * x)
+ NOISE_AMPLITUDE * rng.gen::<f64>()
+ NOISE_AMPLITUDE * rng.random::<f64>()
})
.collect();
let mut ts = TimeSeries::new_without_weight(&t, &m);
Expand Down
4 changes: 2 additions & 2 deletions src/periodogram/power_fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod tests {
let mut rng = StdRng::seed_from_u64(0);

let t = linspace(0.0, (N - 1) as f64, N);
let m: Vec<f64> = (0..N).map(|_| rng.gen()).collect();
let m: Vec<f64> = (0..N).map(|_| rng.random()).collect();
let mut ts = TimeSeries::new_without_weight(&t[..], &m[..]);

let nyquist = AverageNyquistFreq.into();
Expand Down Expand Up @@ -374,7 +374,7 @@ mod tests {
let mut rng = StdRng::seed_from_u64(0);

let t = linspace(0.0, (N - 1) as f64, N);
let m: Vec<f64> = (0..N).map(|_| rng.gen()).collect();
let m: Vec<f64> = (0..N).map(|_| rng.random()).collect();
let mut ts = TimeSeries::new_without_weight(&t[..], &m[..]);

let nyquist = AverageNyquistFreq.into();
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ macro_rules! check_fit_model_derivatives {

let mut rng = StdRng::seed_from_u64(0);
for _ in 0..REPEAT {
let t = 10.0 * rng.gen::<f64>();
let t = 10.0 * rng.random::<f64>();

let param = {
let mut param = [0.0; NPARAMS];
for x in param.iter_mut() {
*x = rng.gen::<f64>() - 0.5;
*x = rng.random::<f64>() - 0.5;
}
param
};
Expand Down

0 comments on commit 6b94446

Please sign in to comment.