-
-
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
randjump: deprecate the array version? #27746
Conversation
It seems to me like the problem is that
and therefore
My reasoning for keeping this API is that will be possible to use a different RNG from |
Note that in your example code, But you are of course right to point out the generality of the current API. That could be handled though, e.g. with Alternatively, we could just document that the jump is not exact in some cases, and that this may be updated/fixed later in a breaking way.
|
Yes you're right. The
That is, elements |
Maybe an unexported |
Makes sense, as this function is quite specific and will probably not be used by the majority of the users of
I find that would be quite nice actually. The thing is that one would then need to first create an RNG before calling seed on it, unless with have two functions, Also, this does remove the current functionality of creating an array, which I really like actually. From |
I like |
I think my prefered solution is then to delete the |
Just so you know, things are getting locked down for the release. If this isn't fully settled, it will have to be a post 1.0 thing. |
OK, on my side this is settled, I would propose the plan from my last post, and it's a no-brainer to implement. @vvjn seems to be on the same page, but more people would need to voice their opinion to take a decision. Maybe I should just label this for triage? |
My preference is to remove the aliasing in either of the two proposed ways above, while keeping the array generation. The no array generation is okay with me (it's obviously not trivial to generate an array anymore though) but it's my 2nd preference. Furthermore, the removing of array generation to the new API changes the current API in a breaking way. I don't think breaking API changes should be done anymore. The only real problem I see is the aliasing of the first element and lack of documentation. |
Note that this would also be a breaking change. |
Small recap for triage:
I vote for 3). Solution 1) doesn't seem ideal to me, as it's like we try to guess what the user needs, and the first element would actually not be "jumped" (same problem with the status quo). Also, Viral suggested to rename |
@rfourquet: I think you're really the person to make this call. Random is not in Base so making breaking changes in a 1.x version of Julia is possible. |
I also agree with option (3) above. |
b9d7486
to
2a9ce4e
Compare
I know well the codebase, but I'm not a serious user of the vector version of |
2a9ce4e
to
1bc9a1c
Compare
Original title: randjump: pass a seed instead of an RNG. Which was a bad idea. See the post below for updated proposition.
Another pretty late change, but this could be seen as a bug fix. This updates the API from
randjump(rng::MersenneTwister, steps, len)
torandjump(seed, steps, len)
. The two reasons I see for doing so are:randjump
called on freshly initialized RNGs works exactly, but is a bit off for already used RNGs. Eg:i.e.
x == y
(when #27744 gets merged) when they should be shifted away by 1 position;randjump
. I could be very wrong on that, though. On github, I could find only very few uses ofrandjump
, among which all but 2 (here and there, cc. @bkamins and @vvjn) were artificially creating a temporary RNG just to pass it torandjump
(i.e.mt = MersenneTwister(seed); mts = randjump(mt, steps, len); ... # mt not used anymore
).Because of the fact that
MersenneTwister
has caches forFloat64
andInteger
values, it's not clear at all that 1) can be solved in a satisfying way while keeping the current API. Admitedly the intended use case forrandjump
should not be so concerned by this bug. While working on #25129 few months ago, I had to implement an exact version ofrandjump
, but with aditional parameters to resolve ambiguities (so we may revisit this API when that PR gets finished, likely after 1.0).cc. @wildart