-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
deprecate srand(rng, filename::AbstractString, n=4) #21359
Conversation
a6ab042
to
48caedf
Compare
The deprecation mechanism does not work as I expect:
Help requested! |
48caedf
to
f7c40df
Compare
I am ok with deprecating this. |
I don't think we should do this right now though, we're just about ready for a release candidate. Should wait until we branch. |
f7c40df
to
fb60449
Compare
I rebased because of conflicts, and introduced a new section for v0.7.0 in "NEWS.md", please tell me if this is not the way. |
base/deprecated.jl
Outdated
@@ -1310,6 +1310,11 @@ end | |||
# PR #16984 | |||
@deprecate MersenneTwister() MersenneTwister(0) | |||
|
|||
# PR #21359 |
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.
these need to be in a new 0.7 section
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.
OK done.
93e8eb1
to
dc2bab7
Compare
I would like to merge this in 1 or 2 days, if no objection comes. |
`srand` should accept a seed as second argument; here `filename` is only an indirect seed, preventing the use a string object as a direct seed.
dc2bab7
to
65757ba
Compare
We used to be able to seed RNGs with a string, but that string was interpreted as the filename containing the seed. This was deprecated in #21359, in order to allow later using a string seed directly, which this patch does.
We used to be able to seed RNGs with a string, but that string was interpreted as the filename containing the actual seed. This was deprecated in #21359, in order to later allow using a string seed directly, which this patch does.
We used to be able to seed RNGs with a string, but that string was interpreted as the filename containing the actual seed. This was deprecated in #21359, in order to later allow using a string seed directly, which this patch does.
We used to be able to seed RNGs with a string, but that string was interpreted as the filename containing the actual seed. This was deprecated in #21359, in order to later allow using a string seed directly, which this patch does.
We used to be able to seed RNGs with a string, but that string was interpreted as the filename containing the actual seed. This was deprecated in #21359, in order to later allow using a string seed directly, which this patch does. --------- Co-authored-by: Nathan Zimmerberg <39104088+nhz2@users.noreply.github.com>
This method
is never used in practice, I guess, which probably makes its maintenance cost not worth it.
was introduced in b13d037 (cc @ViralBShah), mainly (apparently) to be able to seed from "/dev/urandom"; we now have a direct abstraction with
RandomDevice
(e.g.srand(rng, rand(RandomDevice(), UInt32, 4))
, whensrand(rng)
is not enough).prevents the introduction of a more natural
srand(rng, seed::String)
.srand
should only accept a direct seed as second argument (for less confusion); herefilename
is an indirect seed, and hence requires an extra explanation in the docstring. Moreover, it would be easy to usesrand
using a file if the above method existed (e.g.srand(rng, read("/dev/urandom", UInt32, 4))
but not the other way around).is not fully satisfying to use: e.g. if
n
is too big for the file (a finite file, i.e. not "/dev/urandom"), an error is issued, and there is no way to tellsrand
to read exactly the whole file (I agree that this argument is not strong, we could simply improve this method instead of deprecating it).If this method is nonetheless deemed to be useful enough that we want to keep its functionality, I propose to make the filename a keyword argument, allowing the introduction later of
srand(rng, seed::String)
.