-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Correctly document rand_distr
features and forward "std" feature to num-traits
#1100
Conversation
Previously, the features were undocumented and it was incorrectly claimed that `no_std` is not supported.
rand_distr/README.md
Outdated
functions from `std`. Otherwise, the floating point functions from `num_traits` | ||
and `libm` are used to support `no_std` environments. |
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.
Isn't this not true right now? We don't seem to forward the std
trait to num-traits, so would we even end up using the std
implementations?
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.
ya we need to add "rand-traits/std"
to this line:
Line 24 in 3a03c9e
std = ["alloc", "rand/std"] |
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.
You mean "num-traits/std"?
This actually brings up another question though: should we prefer the std
impls? This might affect portability of results.
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.
You mean "num-traits/std"
Whoops, ya
This actually brings up another question though: should we prefer the
std
impls?
I feel like we should, if only because that's what num-traits does. Also, preffering std
over libm is what I would expect. But I don't have that strong a feeling either way.
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.
I feel like we should
Maybe; I don't have a strong opinion on it, though we should probably mention it in the book and maybe also try to gather data on where results may differ.
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.
Fair enough, I decided to forward our "std" feature as "num-traits/std", since this is the behavior I would expect.
Of course, this might technically be a value-breaking change. If we really want to have value stability for floating-point distributions, we might want to always use libm
, because I am not sure that all implementations of the C standard math libraries produce the same results.
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.
Another point: enabling std
in rand
does not enable std
in rand_distr
. Perhaps we don't want this though; in any case, we can't without rust-lang/cargo#8832.
rand_distr/README.md
Outdated
functions from `std`. Otherwise, the floating point functions from `num_traits` | ||
and `libm` are used to support `no_std` environments. |
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.
You mean "num-traits/std"?
This actually brings up another question though: should we prefer the std
impls? This might affect portability of results.
This means that the floating point functions from `std` are used if available, instead of always using the ones from `libm`.
|
rand_distr
featuresrand_distr
features and forward "std" feature to num-traits
Are the changes here ok or should I forgo forwarding "std" for now? |
Yes, I'd consider this a breaking change and not for a patch version. Also, regarding the latter point, better value portability sounds desirable. Is there any real cost to using For now maybe we should add a different flag like |
Ok, I reverted the change to use
There are reports on their issue tracker about
I'm not sure the differences in results would be big enough to justify a feature flag, but let's keep that for another PR. |
I still don't see a reason not to add |
I added an "std_math" feature and made sure our CI covers the different |
@dhardy I think I addressed all of your concerns? |
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.
Yes, sorry. Approved.
Previously, the features were undocumented and it was incorrectly claimed that
no_std
is not supported.