Skip to content

Commit b33a5fd

Browse files
fix: import rand distributions from ndarray_rand::rand_distr to fix E0277 trait-bound (#55)
## Why Both `crates/esn/src/lib.rs` and `crates/lsm/src/lib.rs` import `Normal`, `Uniform`, `Bernoulli` from the top-level `rand_distr` crate, then pass those distribution instances to: - `Array2::random_using(...)` from `ndarray_rand::RandomExt`, which requires `ndarray_rand::rand_distr::Distribution` - `rng.sample(...)` which works fine with either `ndarray-rand` re-exports its own pinned version of `rand_distr` and the `RandomExt::random_using` trait bound is over that re-exported `Distribution`. When the top-level `rand_distr` version drifts (Dependabot bump), it stops being the same type as `ndarray_rand::rand_distr::Distribution` and the trait bound fails: ``` error[E0277]: the trait bound `rand_distr::Normal<{float}>: ndarray_rand::rand_distr::Distribution<_>` is not satisfied ``` …on every Dependabot PR that touched the `rand` family. ## Fix Import distributions through `ndarray_rand::rand_distr` so the version always matches the trait bound. No runtime / behaviour change. ## Tested Static: rg confirms `Normal`/`Uniform`/`Bernoulli` are only used through `rng.sample()` and `Array2::random_using()`, both of which accept the ndarray_rand::rand_distr versions. After this lands, the workspace's top-level `rand_distr` dep may be unused — left in place to avoid scope creep; can drop in a follow-up if cargo-udeps flags it. --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8d20593 commit b33a5fd

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

crates/esn/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use ndarray::{Array1, Array2};
1515
use ndarray_rand::RandomExt;
1616
use rand::Rng;
17-
use rand_distr::{Normal, Uniform};
17+
use ndarray_rand::rand_distr::{Normal, Uniform};
1818
use serde::{Deserialize, Serialize};
1919
use std::collections::VecDeque;
2020
use thiserror::Error;

crates/lsm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use ndarray::{Array1, Array2, Axis};
1010
use ndarray_rand::RandomExt;
1111
use rand::Rng;
12-
use rand_distr::{Bernoulli, Normal, Uniform};
12+
use ndarray_rand::rand_distr::{Bernoulli, Normal, Uniform};
1313
use serde::{Deserialize, Serialize};
1414
use std::collections::VecDeque;
1515
use thiserror::Error;

0 commit comments

Comments
 (0)