-
Notifications
You must be signed in to change notification settings - Fork 175
Deal with Random changing attributes of object #2165
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
Conversation
|
Could you give a concrete example where this takes effect? |
Codecov Report
@@ Coverage Diff @@
## master #2165 +/- ##
==========================================
- Coverage 69.61% 69.6% -0.01%
==========================================
Files 482 482
Lines 254580 254646 +66
==========================================
+ Hits 177218 177254 +36
- Misses 77362 77392 +30
|
|
@ChrisJefferson I don't understand, I see no |
|
Ahhh, I assume f48dc21 is meant -- I commented there on a changed |
|
I'mfairly sure I do mean d51d458. That can be observed by: Which will fail on that commit. We can fix the problem by asking for |
|
Logically the "call this a bug" option would seem to mean that we want Random, with the same random seed, to produce the same results on equal objects, the fact that the two objects in this case are the same one with different known attributes is kind of incidental. I think this would be a very high burden to impose. An alternative would be try and document, for each category of collections, exactly what promises Random does make -- eg it could be consistent for permutation groups with the same ordered generators, but not for equal groups given by different generating sets. I'm not wild even about this, which leads me to suggest that this test should probably just be advisory for developers -- did you lose repeatability by accident, or was it an unavoidable consequence of something else. |
|
I agree with @stevelinton -- imposing any kind of consistency rule here will be extremely painful to implement, for a very small gain. As it is, even without this rule, all computations are still 100% deterministic, but of course there are cases were it is tricky to repeat a computation unless one can repeat the input 100% precisely. That's annoying, but still relatively uncommon and exotic, and not enough reason to limit implementors by imposing a strict rule here. Of course in specific cases, we can and should try to make separate BTW, I am going to @-mention @hulpke now, just in case he has something to add? |
|
I'm happy to keep adjusting this test in future, where approriate. I certainly wouldn't want to enshrine into GAP any promises about repeatability. At the moment it isn't even true that if you run the same GAP twice with the same inputs, you get the same outputs (as some algorithms run based on time). |
This changes the tester to add one initial call to
Randomwhen testing random generation. This deals with the problem where the first call toRandomadds attributes, which changes whichRandommethod gets called. Therefore callingRandomtwice, even if we resetGlobalMersenneTwister, produces different values.The other alternative (why I marked this discussion) is that we could say this is a bug, and different overloads must provide the same sequence of random values.