Skip to content
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

Fix for #530 #531

Merged
merged 1 commit into from
Aug 31, 2019
Merged

Fix for #530 #531

merged 1 commit into from
Aug 31, 2019

Conversation

non
Copy link
Contributor

@non non commented Aug 31, 2019

Here's the basic issue:

When using viewSeed, we need to put an initialSeed in the
Gen.Parameters used to evaluate the Prop, so we can recover
the seed later and display it. So far, so good.

In some cases, we need to "slide" the seed that's embedded
in the parameters, so we don't reuse it. Any time we need
to evaluate several properties and don't want identical
RNG state (which could lead to identical inputs) we need
to slide.

We were missing a "slide" in flatMap -- we were reusing
the same parameters in both cases. Since flatMap was used
to define && (via for-comprehension) that meant that when
you said p0 && p1, you'd use the same seed for both if
viewSeed was set.

Refined's property was unusual, but valid. Basically, one
property had (x >= 0) ==> and one had (x < 0) ==>. So no
single x value would satisfy both, but on average you'd
satisfy each 50% of the time, and together you'd get
a non-discarded case about 25% of the time.

Previously, this worked OK. But since 1.14.0 we started
always displaying seeds. This meant that the bug associated
with failing to slide manifested, and we always generated
the same x value for both sides of the property. This
meant we ended up discarding every x generated.

The fix was to slide correctly in this case. I also added
a toString to Gen.Parameters which was missing, since this
helped with debugging.

Here's the basic issue:

When using viewSeed, we need to put an initialSeed in the
Gen.Parameters used to evaluate the Prop, so we can recover
the seed later and display it. So far, so good.

In some cases, we need to "slide" the seed that's embedded
in the parameters, so we don't reuse it. Any time we need
to evaluate several properties and don't want identical
RNG state (which could lead to identical inputs) we need
to slide.

We were missing a "slide" in flatMap -- we were reusing
the same parameters in both cases. Since flatMap was used
to define && (via for-comprehension) that meant that when
you said p0 && p1, you'd use the same seed for both if
viewSeed was set.

Refined's property was unusual, but valid. Basically, one
property had (x >= 0) ==> and one had (x < 0) ==>. So no
single x value would satisfy both, but on average you'd
satisfy each 50% of the time, and together you'd get
a non-discarded case about 25% of the time.

Previously, this worked OK. But since 1.14.0 we started
always displaying seeds. This meant that the bug associated
with failing to slide manifested, and we always generated
the same x value for both sides of the property. This
meant we ended up discarding every x generated.

The fix was to slide correctly in this case. I also added
a toString to Gen.Parameters which was missing, since this
helped with debugging.
@non non merged commit 74a365a into typelevel:master Aug 31, 2019
@non non deleted the bug/530 branch August 31, 2019 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants