-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-export rand
distributions
#663
Re-export rand
distributions
#663
Conversation
Great, thanks @LukeMathWalker |
I'm in favor of trying to prevent confusion like #530 and #658 from ocurring again, but I'm not sure that this is the right approach. If we do this, should we also re-export the Here are a few options:
Personally, I prefer option 3 because it's the simplest and because I don't see much benefit to supporting multiple versions of Fwiw, when I use |
I was focusing on proving that the approach actually worked to solve #658, but I do agree with your list when it comes to the options we have to move forward.
I would personally go for both 1. and 3. - at least until `rand` reaches 1.0.
We can vendor it in a `ndarray_rand::rand` submodule and it would provide a confusion-free experience for most of the people using the crate. As far as I can see, the latest `rand` also includes the Isaac RNG, so you would not need any additional dependency for a basic workflow with reproducible results. I don't see too many disadvantages.
|
Okay, that sounds good to me. Thanks for looking into this. |
Should we re-export |
I'd say it makes sense to do so. |
Add hyperlinks where helpful.
Ok, this should be ready now:
Once this gets merged I think we could cut a release (or should we wait on #670 and just release everything at once?). |
Seems reasonable, although I don't see a written motivation for why we should depend on rand_distr (since it's an optional extra), but it seems reasonable. An important note though, with It's still a burden and a risk - we risk having to support many rand versions per ndarray version. If it would work, ndarray 0.13 (next version) could be released with a feature called rand_0_7, and one could add a rand_0_8 feature later during the ndarray 0.13.x cycle if required. It's a bit messy, and I'm not sure users would enjoy to have traits called One way to avoid the parallel names would be if we could "key" the trait by a type or trait from rand. Like the trait |
I am little scared by this - I don't have good visibility over |
When I envison the parallel rand features, it just doesn't work out for our use case. We'd need some way to make it work transparently without resorting to parallel RandExt07, RandExt08 traits etc, that would just move the problem to a different place. Oh and i noticed that ndarray-rand is still not published with a new version.. What's holding this back? Is it just that the releasers are not paying attention? (That's me, by the way) |
Ok, so I initially agree with jturner that reexporting is not a great solution. The only way I can see it as a good solution is if you have a project that's very ndarray focused, and only consuming rand through ndarray itself, and no other ways? I have a hard time deciding, but I think this is an ok solution, when I realize that using the reexports is optional. Users can use the crate directly if they want, and hopefully this will be clear. With that said, I'd like to get this merged so that we can release ndarray-rand with rand 0.7 support soon. |
Everything looks good to me except for the |
In the end, it's up to the user to use it, we are not forcing it on them. |
|
||
use ndarray::ShapeBuilder; | ||
use ndarray::{ArrayBase, DataOwned, Dimension}; | ||
|
||
/// [`rand`](https://docs.rs/rand/0.7.0/rand/), re-exported for convenience and version-compatibility. | ||
pub mod rand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be my ignorance, I thought we had pub extern crate for re-exporting, but I'm unsure what difference it makes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never heard of pub extern crate <...>
!
Digging around, it seems they have exactly the same effect ( nix-rust/nix#694 ).
Using mod
has the plus of being more explicit in my eyes, given that it uses the "standard" visibility mechanism of the 2018 edition.
Nice :) so I published the next version of ndarray-rand 0.10, so we finally have that out the door, sorry for the delay in that. ndarray-rand might need to be careful about guaranteeing specific minor versions since we don't track or check it perfectly, when it's embedded in this repo. But it's such a small crate it might not matter. |
This is what I meant in #659 @max-sixty.
I have tested it on my linear regression example - it runs without any issue, even if I explicitly specify
rand = 0.7
inCargo.toml
.