-
Notifications
You must be signed in to change notification settings - Fork 25
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
Consecutive calls of random
returns the same instance
#44
Comments
Hi @zzvara, See #37 (comment) for an explanation of this issue. Happy to discuss possible solutions or suggestions on how to improve this, if you have any. |
I see, thanks for clarifying. I'll modify my test design according to this.
My idea would be to specify an another seed, a "transition seed", in which consecutive "picks" from the random[T] function with the same type would generate a new T as follows. Combine the (RANDOM_DATA_GENERATOR_SEED: Seed, NTH_CALL_FOR_T: Int, TRANSITION_SEED: Seed) to derive a new RANDOM_DATA_GENERATOR_SEED for that random generation. Still, "most" of the tests could be replicated.
On 2017-06-26 19:08:11, Daniela Sfregola <[email protected]> wrote:
Hi @zzvara [https://github.com/zzvara],
this is actually not a Shapeless problem, but it is enforced by design of the library.
See #37 (comment) [#37 (comment)] for an explanation of this issue.
Happy to discuss possible solutions or suggestions on how to improve this, if you have any.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [#44 (comment)], or mute the thread [https://github.com/notifications/unsubscribe-auth/AH--TVk-THCy0oLnR4ndPiiIitDL-nynks5sH-V4gaJpZM4OEUSf].
|
How would you handle that tests can run in parallel? i.e.: the order in which |
Encapsulate random into an Iterator, and each thread should acquire the iterator instead of accessing random directly. Iterator only needs to store NTH_CALL_FOR_T.
On 2017-06-26 20:07:19, Daniela Sfregola <[email protected]> wrote:
How would you handle that tests can run in parallel? i.e.: the order in which random is called is not guaranteed...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [#44 (comment)], or mute the thread [https://github.com/notifications/unsubscribe-auth/AH--TcNjvCEffZ1S5xapvP6TWPppIjPlks5sH_NWgaJpZM4OEUSf].
|
Give it a try @zzvara! Please, if it works I'd love to see a PR on this. Cheers, |
…ages are available for each stream type
Hi @zzvara and @DanielaSfregola Why can't we go for "call by name" which makes the body of the method to execute, every time when this method is called? This makes every, consecutive call to random an actual invocation and will always return a new instance (instead of cached results). I am pretty sure that, I am missing some context. If so, please correct me. Thank you. |
Hi @krishna-meduri, In the current implementation, requesting a random value of the same type will provide always the same value because we fix the seed. I am pretty sure there must be a solution - such as having the idea of the global seed and a local seed that we can combine to obtain different values of the same type. We "just" need to find a solution that guarantees that a session can be reproduced by fixing the seed independently from the execution order of a test. |
@DanielaSfregola Got it. Thank you. Will try to see if I could come up with a solution and will update you. |
I just use these 2 directly without random-data-generator:
https://booksites.artima.com/scalacheck/examples/html/ch06.html |
Consecutive calls of
random
returns the same instance. Providing an integer to get multiple random elements will however generate different instances. How to overcome this?(I'm not familiar with Shapless, just want to have simple instances fast.)
The text was updated successfully, but these errors were encountered: