Skip to content

Commit 5a47df0

Browse files
authored
Merge branch 'master' into try_traits
2 parents 78d1ea1 + bca078e commit 5a47df0

29 files changed

+325
-137
lines changed

.github/workflows/gh-pages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
rm target/doc/.lock
3636
3737
- name: Setup Pages
38-
uses: actions/configure-pages@v4
38+
uses: actions/configure-pages@v5
3939

4040
- name: Upload artifact
4141
uses: actions/upload-pages-artifact@v3

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
99
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
1010

1111
## [Unreleased]
12+
- Add `rand::distributions::WeightedIndex::{weight, weights, total_weight}` (#1420)
1213
- Bump the MSRV to 1.61.0
1314

1415
## [0.9.0-alpha.1] - 2024-03-18

benches/distributions.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ macro_rules! distr_duration {
101101
let x: Duration = distr.sample(&mut rng);
102102
accum = accum
103103
.checked_add(x)
104-
.unwrap_or(Duration::new(u64::max_value(), 999_999_999));
104+
.unwrap_or(Duration::new(u64::MAX, 999_999_999));
105105
}
106106
accum
107107
});
@@ -145,10 +145,10 @@ distr_int!(distr_uniform_isize, isize, Uniform::new(-1060478432isize, 1858574057
145145
distr_float!(distr_uniform_f32, f32, Uniform::new(2.26f32, 2.319).unwrap());
146146
distr_float!(distr_uniform_f64, f64, Uniform::new(2.26f64, 2.319).unwrap());
147147

148-
const LARGE_SEC: u64 = u64::max_value() / 1000;
148+
const LARGE_SEC: u64 = u64::MAX / 1000;
149149

150150
distr_duration!(distr_uniform_duration_largest,
151-
Uniform::new_inclusive(Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999)).unwrap()
151+
Uniform::new_inclusive(Duration::new(0, 0), Duration::new(u64::MAX, 999_999_999)).unwrap()
152152
);
153153
distr_duration!(distr_uniform_duration_large,
154154
Uniform::new(Duration::new(0, 0), Duration::new(LARGE_SEC, 1_000_000_000 / 2)).unwrap()
@@ -332,26 +332,26 @@ macro_rules! uniform_single {
332332
// (32769) will only reject 32769 / 4294967296 samples.
333333
const HALF_16_BIT_UNSIGNED: u16 = 1 << 15;
334334

335-
uniform_sample!(uniform_u16x1_allm1_new, u16, 0, u16::max_value(), 1);
335+
uniform_sample!(uniform_u16x1_allm1_new, u16, 0, u16::MAX, 1);
336336
uniform_sample!(uniform_u16x1_halfp1_new, u16, 0, HALF_16_BIT_UNSIGNED + 1, 1);
337337
uniform_sample!(uniform_u16x1_half_new, u16, 0, HALF_16_BIT_UNSIGNED, 1);
338338
uniform_sample!(uniform_u16x1_halfm1_new, u16, 0, HALF_16_BIT_UNSIGNED - 1, 1);
339339
uniform_sample!(uniform_u16x1_6_new, u16, 0, 6u16, 1);
340340

341-
uniform_single!(uniform_u16x1_allm1_single, u16, 0, u16::max_value(), 1);
341+
uniform_single!(uniform_u16x1_allm1_single, u16, 0, u16::MAX, 1);
342342
uniform_single!(uniform_u16x1_halfp1_single, u16, 0, HALF_16_BIT_UNSIGNED + 1, 1);
343343
uniform_single!(uniform_u16x1_half_single, u16, 0, HALF_16_BIT_UNSIGNED, 1);
344344
uniform_single!(uniform_u16x1_halfm1_single, u16, 0, HALF_16_BIT_UNSIGNED - 1, 1);
345345
uniform_single!(uniform_u16x1_6_single, u16, 0, 6u16, 1);
346346

347-
uniform_inclusive!(uniform_u16x10_all_new_inclusive, u16, 0, u16::max_value(), 10);
348-
uniform_sample!(uniform_u16x10_allm1_new, u16, 0, u16::max_value(), 10);
347+
uniform_inclusive!(uniform_u16x10_all_new_inclusive, u16, 0, u16::MAX, 10);
348+
uniform_sample!(uniform_u16x10_allm1_new, u16, 0, u16::MAX, 10);
349349
uniform_sample!(uniform_u16x10_halfp1_new, u16, 0, HALF_16_BIT_UNSIGNED + 1, 10);
350350
uniform_sample!(uniform_u16x10_half_new, u16, 0, HALF_16_BIT_UNSIGNED, 10);
351351
uniform_sample!(uniform_u16x10_halfm1_new, u16, 0, HALF_16_BIT_UNSIGNED - 1, 10);
352352
uniform_sample!(uniform_u16x10_6_new, u16, 0, 6u16, 10);
353353

354-
uniform_single!(uniform_u16x10_allm1_single, u16, 0, u16::max_value(), 10);
354+
uniform_single!(uniform_u16x10_allm1_single, u16, 0, u16::MAX, 10);
355355
uniform_single!(uniform_u16x10_halfp1_single, u16, 0, HALF_16_BIT_UNSIGNED + 1, 10);
356356
uniform_single!(uniform_u16x10_half_single, u16, 0, HALF_16_BIT_UNSIGNED, 10);
357357
uniform_single!(uniform_u16x10_halfm1_single, u16, 0, HALF_16_BIT_UNSIGNED - 1, 10);
@@ -360,80 +360,80 @@ uniform_single!(uniform_u16x10_6_single, u16, 0, 6u16, 10);
360360

361361
const HALF_32_BIT_UNSIGNED: u32 = 1 << 31;
362362

363-
uniform_sample!(uniform_u32x1_allm1_new, u32, 0, u32::max_value(), 1);
363+
uniform_sample!(uniform_u32x1_allm1_new, u32, 0, u32::MAX, 1);
364364
uniform_sample!(uniform_u32x1_halfp1_new, u32, 0, HALF_32_BIT_UNSIGNED + 1, 1);
365365
uniform_sample!(uniform_u32x1_half_new, u32, 0, HALF_32_BIT_UNSIGNED, 1);
366366
uniform_sample!(uniform_u32x1_halfm1_new, u32, 0, HALF_32_BIT_UNSIGNED - 1, 1);
367367
uniform_sample!(uniform_u32x1_6_new, u32, 0, 6u32, 1);
368368

369-
uniform_single!(uniform_u32x1_allm1_single, u32, 0, u32::max_value(), 1);
369+
uniform_single!(uniform_u32x1_allm1_single, u32, 0, u32::MAX, 1);
370370
uniform_single!(uniform_u32x1_halfp1_single, u32, 0, HALF_32_BIT_UNSIGNED + 1, 1);
371371
uniform_single!(uniform_u32x1_half_single, u32, 0, HALF_32_BIT_UNSIGNED, 1);
372372
uniform_single!(uniform_u32x1_halfm1_single, u32, 0, HALF_32_BIT_UNSIGNED - 1, 1);
373373
uniform_single!(uniform_u32x1_6_single, u32, 0, 6u32, 1);
374374

375-
uniform_inclusive!(uniform_u32x10_all_new_inclusive, u32, 0, u32::max_value(), 10);
376-
uniform_sample!(uniform_u32x10_allm1_new, u32, 0, u32::max_value(), 10);
375+
uniform_inclusive!(uniform_u32x10_all_new_inclusive, u32, 0, u32::MAX, 10);
376+
uniform_sample!(uniform_u32x10_allm1_new, u32, 0, u32::MAX, 10);
377377
uniform_sample!(uniform_u32x10_halfp1_new, u32, 0, HALF_32_BIT_UNSIGNED + 1, 10);
378378
uniform_sample!(uniform_u32x10_half_new, u32, 0, HALF_32_BIT_UNSIGNED, 10);
379379
uniform_sample!(uniform_u32x10_halfm1_new, u32, 0, HALF_32_BIT_UNSIGNED - 1, 10);
380380
uniform_sample!(uniform_u32x10_6_new, u32, 0, 6u32, 10);
381381

382-
uniform_single!(uniform_u32x10_allm1_single, u32, 0, u32::max_value(), 10);
382+
uniform_single!(uniform_u32x10_allm1_single, u32, 0, u32::MAX, 10);
383383
uniform_single!(uniform_u32x10_halfp1_single, u32, 0, HALF_32_BIT_UNSIGNED + 1, 10);
384384
uniform_single!(uniform_u32x10_half_single, u32, 0, HALF_32_BIT_UNSIGNED, 10);
385385
uniform_single!(uniform_u32x10_halfm1_single, u32, 0, HALF_32_BIT_UNSIGNED - 1, 10);
386386
uniform_single!(uniform_u32x10_6_single, u32, 0, 6u32, 10);
387387

388388
const HALF_64_BIT_UNSIGNED: u64 = 1 << 63;
389389

390-
uniform_sample!(uniform_u64x1_allm1_new, u64, 0, u64::max_value(), 1);
390+
uniform_sample!(uniform_u64x1_allm1_new, u64, 0, u64::MAX, 1);
391391
uniform_sample!(uniform_u64x1_halfp1_new, u64, 0, HALF_64_BIT_UNSIGNED + 1, 1);
392392
uniform_sample!(uniform_u64x1_half_new, u64, 0, HALF_64_BIT_UNSIGNED, 1);
393393
uniform_sample!(uniform_u64x1_halfm1_new, u64, 0, HALF_64_BIT_UNSIGNED - 1, 1);
394394
uniform_sample!(uniform_u64x1_6_new, u64, 0, 6u64, 1);
395395

396-
uniform_single!(uniform_u64x1_allm1_single, u64, 0, u64::max_value(), 1);
396+
uniform_single!(uniform_u64x1_allm1_single, u64, 0, u64::MAX, 1);
397397
uniform_single!(uniform_u64x1_halfp1_single, u64, 0, HALF_64_BIT_UNSIGNED + 1, 1);
398398
uniform_single!(uniform_u64x1_half_single, u64, 0, HALF_64_BIT_UNSIGNED, 1);
399399
uniform_single!(uniform_u64x1_halfm1_single, u64, 0, HALF_64_BIT_UNSIGNED - 1, 1);
400400
uniform_single!(uniform_u64x1_6_single, u64, 0, 6u64, 1);
401401

402-
uniform_inclusive!(uniform_u64x10_all_new_inclusive, u64, 0, u64::max_value(), 10);
403-
uniform_sample!(uniform_u64x10_allm1_new, u64, 0, u64::max_value(), 10);
402+
uniform_inclusive!(uniform_u64x10_all_new_inclusive, u64, 0, u64::MAX, 10);
403+
uniform_sample!(uniform_u64x10_allm1_new, u64, 0, u64::MAX, 10);
404404
uniform_sample!(uniform_u64x10_halfp1_new, u64, 0, HALF_64_BIT_UNSIGNED + 1, 10);
405405
uniform_sample!(uniform_u64x10_half_new, u64, 0, HALF_64_BIT_UNSIGNED, 10);
406406
uniform_sample!(uniform_u64x10_halfm1_new, u64, 0, HALF_64_BIT_UNSIGNED - 1, 10);
407407
uniform_sample!(uniform_u64x10_6_new, u64, 0, 6u64, 10);
408408

409-
uniform_single!(uniform_u64x10_allm1_single, u64, 0, u64::max_value(), 10);
409+
uniform_single!(uniform_u64x10_allm1_single, u64, 0, u64::MAX, 10);
410410
uniform_single!(uniform_u64x10_halfp1_single, u64, 0, HALF_64_BIT_UNSIGNED + 1, 10);
411411
uniform_single!(uniform_u64x10_half_single, u64, 0, HALF_64_BIT_UNSIGNED, 10);
412412
uniform_single!(uniform_u64x10_halfm1_single, u64, 0, HALF_64_BIT_UNSIGNED - 1, 10);
413413
uniform_single!(uniform_u64x10_6_single, u64, 0, 6u64, 10);
414414

415415
const HALF_128_BIT_UNSIGNED: u128 = 1 << 127;
416416

417-
uniform_sample!(uniform_u128x1_allm1_new, u128, 0, u128::max_value(), 1);
417+
uniform_sample!(uniform_u128x1_allm1_new, u128, 0, u128::MAX, 1);
418418
uniform_sample!(uniform_u128x1_halfp1_new, u128, 0, HALF_128_BIT_UNSIGNED + 1, 1);
419419
uniform_sample!(uniform_u128x1_half_new, u128, 0, HALF_128_BIT_UNSIGNED, 1);
420420
uniform_sample!(uniform_u128x1_halfm1_new, u128, 0, HALF_128_BIT_UNSIGNED - 1, 1);
421421
uniform_sample!(uniform_u128x1_6_new, u128, 0, 6u128, 1);
422422

423-
uniform_single!(uniform_u128x1_allm1_single, u128, 0, u128::max_value(), 1);
423+
uniform_single!(uniform_u128x1_allm1_single, u128, 0, u128::MAX, 1);
424424
uniform_single!(uniform_u128x1_halfp1_single, u128, 0, HALF_128_BIT_UNSIGNED + 1, 1);
425425
uniform_single!(uniform_u128x1_half_single, u128, 0, HALF_128_BIT_UNSIGNED, 1);
426426
uniform_single!(uniform_u128x1_halfm1_single, u128, 0, HALF_128_BIT_UNSIGNED - 1, 1);
427427
uniform_single!(uniform_u128x1_6_single, u128, 0, 6u128, 1);
428428

429-
uniform_inclusive!(uniform_u128x10_all_new_inclusive, u128, 0, u128::max_value(), 10);
430-
uniform_sample!(uniform_u128x10_allm1_new, u128, 0, u128::max_value(), 10);
429+
uniform_inclusive!(uniform_u128x10_all_new_inclusive, u128, 0, u128::MAX, 10);
430+
uniform_sample!(uniform_u128x10_allm1_new, u128, 0, u128::MAX, 10);
431431
uniform_sample!(uniform_u128x10_halfp1_new, u128, 0, HALF_128_BIT_UNSIGNED + 1, 10);
432432
uniform_sample!(uniform_u128x10_half_new, u128, 0, HALF_128_BIT_UNSIGNED, 10);
433433
uniform_sample!(uniform_u128x10_halfm1_new, u128, 0, HALF_128_BIT_UNSIGNED - 1, 10);
434434
uniform_sample!(uniform_u128x10_6_new, u128, 0, 6u128, 10);
435435

436-
uniform_single!(uniform_u128x10_allm1_single, u128, 0, u128::max_value(), 10);
436+
uniform_single!(uniform_u128x10_allm1_single, u128, 0, u128::MAX, 10);
437437
uniform_single!(uniform_u128x10_halfp1_single, u128, 0, HALF_128_BIT_UNSIGNED + 1, 10);
438438
uniform_single!(uniform_u128x10_half_single, u128, 0, HALF_128_BIT_UNSIGNED, 10);
439439
uniform_single!(uniform_u128x10_halfm1_single, u128, 0, HALF_128_BIT_UNSIGNED - 1, 10);

benches/misc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn misc_gen_bool_const(b: &mut Bencher) {
2323
let mut rng = Pcg32::from_rng(thread_rng());
2424
b.iter(|| {
2525
let mut accum = true;
26-
for _ in 0..crate::RAND_BENCH_N {
26+
for _ in 0..RAND_BENCH_N {
2727
accum ^= rng.gen_bool(0.18);
2828
}
2929
accum
@@ -36,7 +36,7 @@ fn misc_gen_bool_var(b: &mut Bencher) {
3636
b.iter(|| {
3737
let mut accum = true;
3838
let mut p = 0.18;
39-
for _ in 0..crate::RAND_BENCH_N {
39+
for _ in 0..RAND_BENCH_N {
4040
accum ^= rng.gen_bool(p);
4141
p += 0.0001;
4242
}
@@ -49,7 +49,7 @@ fn misc_gen_ratio_const(b: &mut Bencher) {
4949
let mut rng = Pcg32::from_rng(thread_rng());
5050
b.iter(|| {
5151
let mut accum = true;
52-
for _ in 0..crate::RAND_BENCH_N {
52+
for _ in 0..RAND_BENCH_N {
5353
accum ^= rng.gen_ratio(2, 3);
5454
}
5555
accum
@@ -61,7 +61,7 @@ fn misc_gen_ratio_var(b: &mut Bencher) {
6161
let mut rng = Pcg32::from_rng(thread_rng());
6262
b.iter(|| {
6363
let mut accum = true;
64-
for i in 2..(crate::RAND_BENCH_N as u32 + 2) {
64+
for i in 2..(RAND_BENCH_N as u32 + 2) {
6565
accum ^= rng.gen_ratio(i, i + 1);
6666
}
6767
accum
@@ -72,9 +72,9 @@ fn misc_gen_ratio_var(b: &mut Bencher) {
7272
fn misc_bernoulli_const(b: &mut Bencher) {
7373
let mut rng = Pcg32::from_rng(thread_rng());
7474
b.iter(|| {
75-
let d = rand::distributions::Bernoulli::new(0.18).unwrap();
75+
let d = Bernoulli::new(0.18).unwrap();
7676
let mut accum = true;
77-
for _ in 0..crate::RAND_BENCH_N {
77+
for _ in 0..RAND_BENCH_N {
7878
accum ^= rng.sample(d);
7979
}
8080
accum
@@ -87,7 +87,7 @@ fn misc_bernoulli_var(b: &mut Bencher) {
8787
b.iter(|| {
8888
let mut accum = true;
8989
let mut p = 0.18;
90-
for _ in 0..crate::RAND_BENCH_N {
90+
for _ in 0..RAND_BENCH_N {
9191
let d = Bernoulli::new(p).unwrap();
9292
accum ^= rng.sample(d);
9393
p += 0.0001;

benches/seq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn seq_slice_choose_1_of_1000(b: &mut Bencher) {
4747
}
4848
s
4949
});
50-
b.bytes = size_of::<usize>() as u64 * crate::RAND_BENCH_N;
50+
b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N;
5151
}
5252

5353
macro_rules! seq_slice_choose_multiple {

rand_distr/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ rand_pcg = { version = "=0.9.0-alpha.1", path = "../rand_pcg" }
3737
# For inline examples
3838
rand = { path = "..", version = "=0.9.0-alpha.1", features = ["small_rng"] }
3939
# Histogram implementation for testing uniformity
40-
average = { version = "0.14", features = [ "std" ] }
40+
average = { version = "0.15", features = [ "std" ] }
4141
# Special functions for testing distributions
4242
special = "0.10.3"

rand_distr/src/binomial.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Binomial {
7777

7878
/// Convert a `f64` to an `i64`, panicking on overflow.
7979
fn f64_to_i64(x: f64) -> i64 {
80-
assert!(x < (core::i64::MAX as f64));
80+
assert!(x < (i64::MAX as f64));
8181
x as i64
8282
}
8383

@@ -117,7 +117,7 @@ impl Distribution<u64> for Binomial {
117117
// When n*p < 10, so is n*p*q which is the variance, so a result > 110 would be 100 / sqrt(10) = 31 standard deviations away.
118118
const BINV_MAX_X : u64 = 110;
119119

120-
if (self.n as f64) * p < BINV_THRESHOLD && self.n <= (core::i32::MAX as u64) {
120+
if (self.n as f64) * p < BINV_THRESHOLD && self.n <= (i32::MAX as u64) {
121121
// Use the BINV algorithm.
122122
let s = p / q;
123123
let a = ((self.n + 1) as f64) * s;

rand_distr/src/cauchy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ mod test {
137137

138138
#[test]
139139
fn value_stability() {
140-
fn gen_samples<F: Float + FloatConst + core::fmt::Debug>(m: F, s: F, buf: &mut [F])
140+
fn gen_samples<F: Float + FloatConst + fmt::Debug>(m: F, s: F, buf: &mut [F])
141141
where Standard: Distribution<F> {
142142
let distr = Cauchy::new(m, s).unwrap();
143143
let mut rng = crate::test::rng(353);

rand_distr/src/frechet.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ mod tests {
112112
#[test]
113113
#[should_panic]
114114
fn test_infinite_scale() {
115-
Frechet::new(0.0, core::f64::INFINITY, 1.0).unwrap();
115+
Frechet::new(0.0, f64::INFINITY, 1.0).unwrap();
116116
}
117117

118118
#[test]
119119
#[should_panic]
120120
fn test_nan_scale() {
121-
Frechet::new(0.0, core::f64::NAN, 1.0).unwrap();
121+
Frechet::new(0.0, f64::NAN, 1.0).unwrap();
122122
}
123123

124124
#[test]
@@ -130,25 +130,25 @@ mod tests {
130130
#[test]
131131
#[should_panic]
132132
fn test_infinite_shape() {
133-
Frechet::new(0.0, 1.0, core::f64::INFINITY).unwrap();
133+
Frechet::new(0.0, 1.0, f64::INFINITY).unwrap();
134134
}
135135

136136
#[test]
137137
#[should_panic]
138138
fn test_nan_shape() {
139-
Frechet::new(0.0, 1.0, core::f64::NAN).unwrap();
139+
Frechet::new(0.0, 1.0, f64::NAN).unwrap();
140140
}
141141

142142
#[test]
143143
#[should_panic]
144144
fn test_infinite_location() {
145-
Frechet::new(core::f64::INFINITY, 1.0, 1.0).unwrap();
145+
Frechet::new(f64::INFINITY, 1.0, 1.0).unwrap();
146146
}
147147

148148
#[test]
149149
#[should_panic]
150150
fn test_nan_location() {
151-
Frechet::new(core::f64::NAN, 1.0, 1.0).unwrap();
151+
Frechet::new(f64::NAN, 1.0, 1.0).unwrap();
152152
}
153153

154154
#[test]

rand_distr/src/geometric.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Distribution<u64> for Geometric
9494
return failures;
9595
}
9696

97-
if self.p == 0.0 { return core::u64::MAX; }
97+
if self.p == 0.0 { return u64::MAX; }
9898

9999
let Geometric { p, pi, k } = *self;
100100

@@ -121,7 +121,7 @@ impl Distribution<u64> for Geometric
121121
// fewer iterations on average. ~ October 28, 2020
122122
let m = loop {
123123
let m = rng.gen::<u64>() & ((1 << k) - 1);
124-
let p_reject = if m <= core::i32::MAX as u64 {
124+
let p_reject = if m <= i32::MAX as u64 {
125125
(1.0 - p).powi(m as i32)
126126
} else {
127127
(1.0 - p).powf(m as f64)
@@ -176,9 +176,9 @@ mod test {
176176

177177
#[test]
178178
fn test_geo_invalid_p() {
179-
assert!(Geometric::new(core::f64::NAN).is_err());
180-
assert!(Geometric::new(core::f64::INFINITY).is_err());
181-
assert!(Geometric::new(core::f64::NEG_INFINITY).is_err());
179+
assert!(Geometric::new(f64::NAN).is_err());
180+
assert!(Geometric::new(f64::INFINITY).is_err());
181+
assert!(Geometric::new(f64::NEG_INFINITY).is_err());
182182

183183
assert!(Geometric::new(-0.5).is_err());
184184
assert!(Geometric::new(0.0).is_ok());

rand_distr/src/gumbel.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,25 @@ mod tests {
101101
#[test]
102102
#[should_panic]
103103
fn test_infinite_scale() {
104-
Gumbel::new(0.0, core::f64::INFINITY).unwrap();
104+
Gumbel::new(0.0, f64::INFINITY).unwrap();
105105
}
106106

107107
#[test]
108108
#[should_panic]
109109
fn test_nan_scale() {
110-
Gumbel::new(0.0, core::f64::NAN).unwrap();
110+
Gumbel::new(0.0, f64::NAN).unwrap();
111111
}
112112

113113
#[test]
114114
#[should_panic]
115115
fn test_infinite_location() {
116-
Gumbel::new(core::f64::INFINITY, 1.0).unwrap();
116+
Gumbel::new(f64::INFINITY, 1.0).unwrap();
117117
}
118118

119119
#[test]
120120
#[should_panic]
121121
fn test_nan_location() {
122-
Gumbel::new(core::f64::NAN, 1.0).unwrap();
122+
Gumbel::new(f64::NAN, 1.0).unwrap();
123123
}
124124

125125
#[test]

rand_distr/src/normal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ mod tests {
348348
#[test]
349349
fn test_log_normal_cv() {
350350
let lnorm = LogNormal::from_mean_cv(0.0, 0.0).unwrap();
351-
assert_eq!((lnorm.norm.mean, lnorm.norm.std_dev), (-core::f64::INFINITY, 0.0));
351+
assert_eq!((lnorm.norm.mean, lnorm.norm.std_dev), (f64::NEG_INFINITY, 0.0));
352352

353353
let lnorm = LogNormal::from_mean_cv(1.0, 0.0).unwrap();
354354
assert_eq!((lnorm.norm.mean, lnorm.norm.std_dev), (0.0, 0.0));

0 commit comments

Comments
 (0)