Skip to content

Commit 737f5f6

Browse files
authored
Merge pull request #895 from dhardy/master
Re-add Cauchy test with tolerance; remove moved crates.
2 parents 9788995 + 33cd28b commit 737f5f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+19
-6519
lines changed

Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ small_rng = ["rand_pcg"] # enables SmallRng
4444
members = [
4545
"rand_core",
4646
"rand_distr",
47-
"rand_jitter",
48-
"rand_os",
49-
"rand_isaac",
5047
"rand_chacha",
5148
"rand_hc",
5249
"rand_pcg",
53-
"rand_xorshift",
54-
"rand_xoshiro",
5550
"tests/wasm_bindgen",
5651
]
5752

@@ -86,9 +81,6 @@ rand_hc = { path = "rand_hc", version = "0.2" }
8681
rand_pcg = { path = "rand_pcg", version = "0.2" }
8782
# Only for benches:
8883
rand_hc = { path = "rand_hc", version = "0.2" }
89-
rand_xoshiro = { path = "rand_xoshiro", version = "0.4" }
90-
rand_isaac = { path = "rand_isaac", version = "0.2" }
91-
rand_xorshift = { path = "rand_xorshift", version = "0.2" }
9284

9385
[package.metadata.docs.rs]
9486
all-features = true

appveyor.yml

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ test_script:
4242
- cargo test --manifest-path rand_core/Cargo.toml --no-default-features
4343
- cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
4444
- cargo test --manifest-path rand_distr/Cargo.toml
45-
- cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
4645
- cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1
47-
- cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
48-
- cargo test --manifest-path rand_xoshiro/Cargo.toml
4946
- cargo test --manifest-path rand_chacha/Cargo.toml
5047
- cargo test --manifest-path rand_hc/Cargo.toml
51-
- cargo test --manifest-path rand_jitter/Cargo.toml
52-
- cargo test --manifest-path rand_os/Cargo.toml

benches/generators.rs

+1-54
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@ use test::{black_box, Bencher};
2020
use rand::prelude::*;
2121
use rand::rngs::adapter::ReseedingRng;
2222
use rand::rngs::{OsRng, mock::StepRng};
23-
use rand_isaac::{IsaacRng, Isaac64Rng};
2423
use rand_chacha::{ChaCha20Core, ChaCha8Rng, ChaCha12Rng, ChaCha20Rng};
2524
use rand_hc::{Hc128Rng};
2625
use rand_pcg::{Pcg32, Pcg64, Pcg64Mcg};
27-
use rand_xorshift::XorShiftRng;
28-
use rand_xoshiro::{Xoshiro256StarStar, Xoshiro256Plus, Xoshiro128StarStar,
29-
Xoshiro128Plus, Xoroshiro128StarStar, Xoroshiro128Plus, SplitMix64,
30-
Xoroshiro64StarStar, Xoroshiro64Star};
3126

3227
macro_rules! gen_bytes {
3328
($fnn:ident, $gen:expr) => {
@@ -47,25 +42,13 @@ macro_rules! gen_bytes {
4742
}
4843

4944
gen_bytes!(gen_bytes_step, StepRng::new(0, 1));
50-
gen_bytes!(gen_bytes_xorshift, XorShiftRng::from_entropy());
51-
gen_bytes!(gen_bytes_xoshiro256starstar, Xoshiro256StarStar::from_entropy());
52-
gen_bytes!(gen_bytes_xoshiro256plus, Xoshiro256Plus::from_entropy());
53-
gen_bytes!(gen_bytes_xoshiro128starstar, Xoshiro128StarStar::from_entropy());
54-
gen_bytes!(gen_bytes_xoshiro128plus, Xoshiro128Plus::from_entropy());
55-
gen_bytes!(gen_bytes_xoroshiro128starstar, Xoroshiro128StarStar::from_entropy());
56-
gen_bytes!(gen_bytes_xoroshiro128plus, Xoroshiro128Plus::from_entropy());
57-
gen_bytes!(gen_bytes_xoroshiro64starstar, Xoroshiro64StarStar::from_entropy());
58-
gen_bytes!(gen_bytes_xoroshiro64star, Xoroshiro64Star::from_entropy());
59-
gen_bytes!(gen_bytes_splitmix64, SplitMix64::from_entropy());
6045
gen_bytes!(gen_bytes_pcg32, Pcg32::from_entropy());
6146
gen_bytes!(gen_bytes_pcg64, Pcg64::from_entropy());
6247
gen_bytes!(gen_bytes_pcg64mcg, Pcg64Mcg::from_entropy());
6348
gen_bytes!(gen_bytes_chacha8, ChaCha8Rng::from_entropy());
6449
gen_bytes!(gen_bytes_chacha12, ChaCha12Rng::from_entropy());
6550
gen_bytes!(gen_bytes_chacha20, ChaCha20Rng::from_entropy());
6651
gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy());
67-
gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy());
68-
gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy());
6952
gen_bytes!(gen_bytes_std, StdRng::from_entropy());
7053
#[cfg(feature="small_rng")]
7154
gen_bytes!(gen_bytes_small, SmallRng::from_entropy());
@@ -89,50 +72,26 @@ macro_rules! gen_uint {
8972
}
9073

9174
gen_uint!(gen_u32_step, u32, StepRng::new(0, 1));
92-
gen_uint!(gen_u32_xorshift, u32, XorShiftRng::from_entropy());
93-
gen_uint!(gen_u32_xoshiro256starstar, u32, Xoshiro256StarStar::from_entropy());
94-
gen_uint!(gen_u32_xoshiro256plus, u32, Xoshiro256Plus::from_entropy());
95-
gen_uint!(gen_u32_xoshiro128starstar, u32, Xoshiro128StarStar::from_entropy());
96-
gen_uint!(gen_u32_xoshiro128plus, u32, Xoshiro128Plus::from_entropy());
97-
gen_uint!(gen_u32_xoroshiro128starstar, u32, Xoroshiro128StarStar::from_entropy());
98-
gen_uint!(gen_u32_xoroshiro128plus, u32, Xoroshiro128Plus::from_entropy());
99-
gen_uint!(gen_u32_xoroshiro64starstar, u32, Xoroshiro64StarStar::from_entropy());
100-
gen_uint!(gen_u32_xoroshiro64star, u32, Xoroshiro64Star::from_entropy());
101-
gen_uint!(gen_u32_splitmix64, u32, SplitMix64::from_entropy());
10275
gen_uint!(gen_u32_pcg32, u32, Pcg32::from_entropy());
10376
gen_uint!(gen_u32_pcg64, u32, Pcg64::from_entropy());
10477
gen_uint!(gen_u32_pcg64mcg, u32, Pcg64Mcg::from_entropy());
10578
gen_uint!(gen_u32_chacha8, u32, ChaCha8Rng::from_entropy());
10679
gen_uint!(gen_u32_chacha12, u32, ChaCha12Rng::from_entropy());
10780
gen_uint!(gen_u32_chacha20, u32, ChaCha20Rng::from_entropy());
10881
gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy());
109-
gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy());
110-
gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy());
11182
gen_uint!(gen_u32_std, u32, StdRng::from_entropy());
11283
#[cfg(feature="small_rng")]
11384
gen_uint!(gen_u32_small, u32, SmallRng::from_entropy());
11485
gen_uint!(gen_u32_os, u32, OsRng);
11586

11687
gen_uint!(gen_u64_step, u64, StepRng::new(0, 1));
117-
gen_uint!(gen_u64_xorshift, u64, XorShiftRng::from_entropy());
118-
gen_uint!(gen_u64_xoshiro256starstar, u64, Xoshiro256StarStar::from_entropy());
119-
gen_uint!(gen_u64_xoshiro256plus, u64, Xoshiro256Plus::from_entropy());
120-
gen_uint!(gen_u64_xoshiro128starstar, u64, Xoshiro128StarStar::from_entropy());
121-
gen_uint!(gen_u64_xoshiro128plus, u64, Xoshiro128Plus::from_entropy());
122-
gen_uint!(gen_u64_xoroshiro128starstar, u64, Xoroshiro128StarStar::from_entropy());
123-
gen_uint!(gen_u64_xoroshiro128plus, u64, Xoroshiro128Plus::from_entropy());
124-
gen_uint!(gen_u64_xoroshiro64starstar, u64, Xoroshiro64StarStar::from_entropy());
125-
gen_uint!(gen_u64_xoroshiro64star, u64, Xoroshiro64Star::from_entropy());
126-
gen_uint!(gen_u64_splitmix64, u64, SplitMix64::from_entropy());
12788
gen_uint!(gen_u64_pcg32, u64, Pcg32::from_entropy());
12889
gen_uint!(gen_u64_pcg64, u64, Pcg64::from_entropy());
12990
gen_uint!(gen_u64_pcg64mcg, u64, Pcg64Mcg::from_entropy());
13091
gen_uint!(gen_u64_chacha8, u64, ChaCha8Rng::from_entropy());
13192
gen_uint!(gen_u64_chacha12, u64, ChaCha12Rng::from_entropy());
13293
gen_uint!(gen_u64_chacha20, u64, ChaCha20Rng::from_entropy());
13394
gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy());
134-
gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy());
135-
gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy());
13695
gen_uint!(gen_u64_std, u64, StdRng::from_entropy());
13796
#[cfg(feature="small_rng")]
13897
gen_uint!(gen_u64_small, u64, SmallRng::from_entropy());
@@ -142,7 +101,7 @@ macro_rules! init_gen {
142101
($fnn:ident, $gen:ident) => {
143102
#[bench]
144103
fn $fnn(b: &mut Bencher) {
145-
let mut rng = XorShiftRng::from_entropy();
104+
let mut rng = Pcg32::from_entropy();
146105
b.iter(|| {
147106
let r2 = $gen::from_rng(&mut rng).unwrap();
148107
r2
@@ -151,22 +110,10 @@ macro_rules! init_gen {
151110
}
152111
}
153112

154-
init_gen!(init_xorshift, XorShiftRng);
155-
init_gen!(init_xoshiro256starstar, Xoshiro256StarStar);
156-
init_gen!(init_xoshiro256plus, Xoshiro256Plus);
157-
init_gen!(init_xoshiro128starstar, Xoshiro128StarStar);
158-
init_gen!(init_xoshiro128plus, Xoshiro128Plus);
159-
init_gen!(init_xoroshiro128starstar, Xoroshiro128StarStar);
160-
init_gen!(init_xoroshiro128plus, Xoroshiro128Plus);
161-
init_gen!(init_xoroshiro64starstar, Xoroshiro64StarStar);
162-
init_gen!(init_xoroshiro64star, Xoroshiro64Star);
163-
init_gen!(init_splitmix64, SplitMix64);
164113
init_gen!(init_pcg32, Pcg32);
165114
init_gen!(init_pcg64, Pcg64);
166115
init_gen!(init_pcg64mcg, Pcg64Mcg);
167116
init_gen!(init_hc128, Hc128Rng);
168-
init_gen!(init_isaac, IsaacRng);
169-
init_gen!(init_isaac64, Isaac64Rng);
170117
init_gen!(init_chacha, ChaCha20Rng);
171118

172119
const RESEEDING_BYTES_LEN: usize = 1024 * 1024;

rand_core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ pub trait SeedableRng: Sized {
353353
/// (in prior versions this was not required).
354354
///
355355
/// [`rand`]: https://docs.rs/rand
356-
/// [`rand_os`]: https://docs.rs/rand_os
357356
fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
358357
let mut seed = Self::Seed::default();
359358
rng.try_fill_bytes(seed.as_mut())?;

rand_core/src/os.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// except according to those terms.
88

99
//! Interface to the random number generator of the operating system.
10-
// Note: keep this code in sync with the rand_os crate!
1110
1211
use getrandom::getrandom;
1312
use crate::{CryptoRng, RngCore, Error, impls};

rand_distr/src/cauchy.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,28 @@ mod test {
122122

123123
#[test]
124124
fn value_stability() {
125-
fn test_samples<N: Float + core::fmt::Debug>(m: N, s: N, expected: &[N])
125+
fn gen_samples<N: Float + core::fmt::Debug>(m: N, s: N, buf: &mut [N])
126126
where Standard: Distribution<N> {
127127
let distr = Cauchy::new(m, s).unwrap();
128128
let mut rng = crate::test::rng(353);
129-
let mut buf = [m; 4];
130-
for x in &mut buf {
129+
for x in buf {
131130
*x = rng.sample(&distr);
132131
}
133-
assert_eq!(buf, expected);
134132
}
135133

136-
test_samples(100f64, 10.0, &[77.93369152808678, 90.1606912098641,
134+
let mut buf = [0.0; 4];
135+
gen_samples(100f64, 10.0, &mut buf);
136+
assert_eq!(&buf, &[77.93369152808678, 90.1606912098641,
137137
125.31516221323625, 86.10217834773925]);
138+
138139
// Unfortunately this test is not fully portable due to reliance on the
139140
// system's implementation of tanf (see doc on Cauchy struct).
140-
// test_samples(10f32, 7.0, &[15.023088, -5.446413, 3.7092876, 3.112482]);
141+
let mut buf = [0.0; 4];
142+
gen_samples(10f32, 7.0, &mut buf);
143+
let expected = [15.023088, -5.446413, 3.7092876, 3.112482];
144+
for (a,b) in buf.iter().zip(expected.iter()) {
145+
let (a,b) = (*a, *b);
146+
assert!((a - b).abs() < 1e-6, "expected: {} = {}", a, b);
147+
}
141148
}
142149
}

rand_isaac/CHANGELOG.md

-21
This file was deleted.

rand_isaac/COPYRIGHT

-12
This file was deleted.

rand_isaac/Cargo.toml

-33
This file was deleted.

0 commit comments

Comments
 (0)