Skip to content

Commit 2ab5c39

Browse files
authored
Merge pull request #384 from fndejan/feature/migarte-from-random-to-rand
Migrate from `random` to `rand`
2 parents ece45d1 + a7fb70a commit 2ab5c39

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ndarray = { version = "0.15.6", optional = true }
3535
rustversion = "1.0.9"
3636

3737
[dev-dependencies]
38-
random = "0.12.2"
38+
rand = "0.8.5"
3939
serial_test = "0.9.0"
4040

4141
[features]

examples/expressions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate random;
1+
extern crate rand;
22
extern crate tensorflow;
33

44
use std::error::Error;

examples/regression.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use random;
2-
use random::Source;
1+
use rand;
32
use std::error::Error;
43
use std::fs::File;
54
use std::io::Read;
@@ -39,11 +38,10 @@ fn main() -> Result<(), Box<dyn Error>> {
3938
let b = 0.3;
4039
let num_points = 100;
4140
let steps = 201;
42-
let mut rand = random::default();
4341
let mut x = Tensor::new(&[num_points as u64]);
4442
let mut y = Tensor::new(&[num_points as u64]);
4543
for i in 0..num_points {
46-
x[i] = (2.0 * rand.read::<f64>() - 1.0) as f32;
44+
x[i] = (2.0 * rand::random::<f64>() - 1.0) as f32;
4745
y[i] = w * x[i] + b;
4846
}
4947

examples/regression_checkpoint.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use random;
2-
use random::Source;
1+
use rand;
32
use std::error::Error;
43
use std::fs::File;
54
use std::io::Read;
@@ -39,11 +38,10 @@ fn main() -> Result<(), Box<dyn Error>> {
3938
let b = 0.3;
4039
let num_points = 100;
4140
let steps = 201;
42-
let mut rand = random::default();
4341
let mut x = Tensor::new(&[num_points as u64]);
4442
let mut y = Tensor::new(&[num_points as u64]);
4543
for i in 0..num_points {
46-
x[i] = (2.0 * rand.read::<f64>() - 1.0) as f32;
44+
x[i] = (2.0 * rand::random::<f64>() - 1.0) as f32;
4745
y[i] = w * x[i] + b;
4846
}
4947

examples/regression_savedmodel.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use random;
2-
use random::Source;
1+
use rand;
32
use std::error::Error;
43
use std::path::Path;
54
use std::result::Result;
@@ -36,11 +35,10 @@ fn main() -> Result<(), Box<dyn Error>> {
3635
let b = 0.3;
3736
let num_points = 100;
3837
let steps = 201;
39-
let mut rand = random::default();
4038
let mut x = Tensor::new(&[num_points as u64]);
4139
let mut y = Tensor::new(&[num_points as u64]);
4240
for i in 0..num_points {
43-
x[i] = (2.0 * rand.read::<f64>() - 1.0) as f32;
41+
x[i] = (2.0 * rand::random::<f64>() - 1.0) as f32;
4442
y[i] = w * x[i] + b;
4543
}
4644

0 commit comments

Comments
 (0)