Skip to content

Commit 6b94446

Browse files
committed
rand 0.9 and rand-distr 0.5
1 parent c08e434 commit 6b94446

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ hyperdual = "1.1"
6565
light-curve-common = "0.1.0"
6666
plotters = { version = "0.3.5", default-features = false, features = ["errorbar", "line_series", "ttf"] }
6767
plotters-bitmap = "0.3.3"
68-
rand = "0.8"
69-
rand_distr = "0.4"
68+
rand = "0.9"
69+
rand_distr = "0.5"
7070
rayon = "1.5"
7171
realfft = "3.1"
7272
rustfft = "6.1"

benches/extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ where
179179
{
180180
(0..n)
181181
.map(|_| {
182-
let x: T = thread_rng().sample(StandardNormal);
182+
let x: T = rand::rng().sample(StandardNormal);
183183
x
184184
})
185185
.collect()

benches/fft_crates.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ struct Randoms {}
198198
impl<T> Series<T> for Randoms
199199
where
200200
T: FftNum,
201-
rand::distributions::Standard: Distribution<T>,
201+
rand::distr::StandardUniform: Distribution<T>,
202202
{
203203
fn series(&self, n: usize) -> Vec<T> {
204204
let mut rng = StdRng::seed_from_u64(0);
205-
(0..n).map(|_| rng.gen::<T>()).collect()
205+
(0..n).map(|_| rng.random::<T>()).collect()
206206
}
207207
}
208208

@@ -218,7 +218,7 @@ where
218218
FftwComplex<T>: AlignedAllocable,
219219
Plan<T, FftwComplex<T>, T::Plan>: R2CPlan<Real = T, Complex = FftwComplex<T>>,
220220
Vec<T>: fmt::Debug,
221-
rand::distributions::Standard: Distribution<T>,
221+
rand::distr::StandardUniform: Distribution<T>,
222222
{
223223
let counts: Vec<_> = (8..=20).step_by(4).map(|i| 1_usize << i).collect();
224224
let series: Vec<Box<dyn Series<T>>> = vec![Box::new(Ones {}), Box::new(Randoms {})];

benches/fit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub fn bench_fit_straight_line(c: &mut Criterion) {
1414
const N: usize = 1000;
1515

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

src/features/periodogram.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ mod tests {
546546
.map(|&x| {
547547
3.0 * f32::sin(2.0 * std::f32::consts::PI / period * x + 0.5)
548548
+ 4.0
549-
+ 0.01 * rng.gen::<f32>() // noise stabilizes solution
549+
+ 0.01 * rng.random::<f32>() // noise stabilizes solution
550550
})
551551
.collect();
552552
let mut ts = TimeSeries::new_without_weight(&x[..], &y[..]);
@@ -560,7 +560,7 @@ mod tests {
560560
let periodogram: Periodogram<_, Feature<_>> = Periodogram::default();
561561
let period = 0.17;
562562
let mut rng = StdRng::seed_from_u64(0);
563-
let mut x: Vec<f32> = (0..100).map(|_| rng.gen()).collect();
563+
let mut x: Vec<f32> = (0..100).map(|_| rng.random()).collect();
564564
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
565565
let y: Vec<_> = x
566566
.iter()
@@ -580,7 +580,7 @@ mod tests {
580580
]);
581581
let period = 0.17;
582582
let mut rng = StdRng::seed_from_u64(0);
583-
let mut x: Vec<f32> = (0..100).map(|_| rng.gen()).collect();
583+
let mut x: Vec<f32> = (0..100).map(|_| rng.random()).collect();
584584
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
585585
let y: Vec<_> = x
586586
.iter()
@@ -601,7 +601,7 @@ mod tests {
601601
let period1 = 0.0753;
602602
let period2 = 0.45;
603603
let mut rng = StdRng::seed_from_u64(0);
604-
let mut x: Vec<f32> = (0..1000).map(|_| rng.gen()).collect();
604+
let mut x: Vec<f32> = (0..1000).map(|_| rng.random()).collect();
605605
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
606606
let y: Vec<_> = x
607607
.iter()
@@ -625,14 +625,14 @@ mod tests {
625625
let period1 = 0.0753;
626626
let period2 = 0.46;
627627
let mut rng = StdRng::seed_from_u64(0);
628-
let mut x: Vec<f32> = (0..1000).map(|_| rng.gen()).collect();
628+
let mut x: Vec<f32> = (0..1000).map(|_| rng.random()).collect();
629629
x[..].sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
630630
let y: Vec<_> = x
631631
.iter()
632632
.map(|&x| {
633633
3.0 * f32::sin(2.0 * std::f32::consts::PI / period1 * x + 0.5)
634634
+ -5.0 * f32::cos(2.0 * std::f32::consts::PI / period2 * x + 0.5)
635-
+ 10.0 * rng.gen::<f32>()
635+
+ 10.0 * rng.random::<f32>()
636636
+ 4.0
637637
})
638638
.collect();

src/periodogram/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ mod tests {
252252

253253
let mut rng = StdRng::seed_from_u64(0);
254254
let t: SortedArray<_> = (0..N)
255-
.map(|_| rng.gen::<f64>() * (N - 1) as f64)
255+
.map(|_| rng.random::<f64>() * (N - 1) as f64)
256256
.collect::<Vec<_>>()
257257
.into();
258258
let m: Vec<_> = t
259259
.iter()
260260
.map(|&x| {
261261
f64::sin(OMEGA1 * x)
262262
+ AMPLITUDE2 * f64::cos(OMEGA2 * x)
263-
+ NOISE_AMPLITUDE * rng.gen::<f64>()
263+
+ NOISE_AMPLITUDE * rng.random::<f64>()
264264
})
265265
.collect();
266266
let mut ts = TimeSeries::new_without_weight(&t, &m);

src/periodogram/power_fft.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ mod tests {
344344
let mut rng = StdRng::seed_from_u64(0);
345345

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

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

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

380380
let nyquist = AverageNyquistFreq.into();

src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,12 @@ macro_rules! check_fit_model_derivatives {
389389

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

394394
let param = {
395395
let mut param = [0.0; NPARAMS];
396396
for x in param.iter_mut() {
397-
*x = rng.gen::<f64>() - 0.5;
397+
*x = rng.random::<f64>() - 0.5;
398398
}
399399
param
400400
};

0 commit comments

Comments
 (0)