fix: import rand distributions from ndarray_rand::rand_distr to fix E0277 trait-bound#55
Merged
Merged
Conversation
…and_distr
ndarray-rand's RandomExt expects distributions from ndarray_rand::rand_distr (its own re-export of rand_distr), not from the top-level rand_distr crate, because ndarray-rand pins its own internal version. With the top-level import the build fails with E0277:
the trait bound rand_distr::Normal<{float}>: ndarray_rand::rand_distr::Distribution<_> is not satisfied
import from ndarray_rand::rand_distr to keep the version aligned.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…and_distr
ndarray-rand's RandomExt expects distributions from ndarray_rand::rand_distr (its own re-export of rand_distr), not from the top-level rand_distr crate, because ndarray-rand pins its own internal version. With the top-level import the build fails with E0277:
the trait bound rand_distr::Normal<{float}>: ndarray_rand::rand_distr::Distribution<_> is not satisfied
import from ndarray_rand::rand_distr to keep the version aligned.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Both
crates/esn/src/lib.rsandcrates/lsm/src/lib.rsimportNormal,Uniform,Bernoullifrom the top-levelrand_distrcrate, then pass those distribution instances to:Array2::random_using(...)fromndarray_rand::RandomExt, which requiresndarray_rand::rand_distr::Distributionrng.sample(...)which works fine with eitherndarray-randre-exports its own pinned version ofrand_distrand theRandomExt::random_usingtrait bound is over that re-exportedDistribution. When the top-levelrand_distrversion drifts (Dependabot bump), it stops being the same type asndarray_rand::rand_distr::Distributionand the trait bound fails:…on every Dependabot PR that touched the
randfamily.Fix
Import distributions through
ndarray_rand::rand_distrso the version always matches the trait bound. No runtime / behaviour change.Tested
Static: rg confirms
Normal/Uniform/Bernoulliare only used throughrng.sample()andArray2::random_using(), both of which accept the ndarray_rand::rand_distr versions.After this lands, the workspace's top-level
rand_distrdep may be unused — left in place to avoid scope creep; can drop in a follow-up if cargo-udeps flags it.