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 shuffle tests in CoinSelectionSpec once and for all #295

Merged
merged 1 commit into from
May 21, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented May 21, 2019

Issue Number

#291

Overview

  • I have removed the precondition about the list length in favor of a correct generator

Comments

Turns out that the problem wasn't much the confidence interval that was being too strict as I thought in the past, but simply that the precondition was too hard to satistify. Indeed, quickcheck does generate empty lists quite often, (more than 10% of the generated values actually) and this caused the checkCoverage to give up very early despite the coverage being okay.

I've switched to using a generator of NonEmptyList instead of the precondition and re-run both statistical tests a thousand times:

            replicateM_ 1000 $ quickCheck (checkCoverageWith lowerConfidence prop_shuffleNotDeterministic)

without observing any failure. So I've got quite some confidence that this is now fixed..

@KtorZ KtorZ self-assigned this May 21, 2019
@KtorZ KtorZ requested a review from paweljakubas May 21, 2019 08:57
@jonathanknowles jonathanknowles self-requested a review May 21, 2019 09:03
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me.

return $ cover 90 (xs /= xs') "shuffled" ()
prop_shuffleCanShuffle (NonEmpty xs) = monadicIO $ liftIO $ do
xs' <- shuffle xs
return $ cover 90 (xs /= xs') "shuffled" ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

prop_shuffleNotDeterministic (NonEmpty xs) = monadicIO $ liftIO $ do
xs1 <- shuffle xs
xs2 <- shuffle xs
return $ cover 90 (xs1 /= xs2) "not deterministic" ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@KtorZ
Copy link
Member Author

KtorZ commented May 21, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request May 21, 2019
289: show feature availability in API specification r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

N/A

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have removed the"priority" from the specification and added a "status" indicating the availability of a particular feature in the API.

# Comments

<!-- Additional comments or screenshots to attach if any -->

As requested by Chris. Makes it easier for externals to know what's available or not. 

A preview:

![image](https://user-images.githubusercontent.com/5680256/58074137-bdc26f00-7ba4-11e9-95b5-33ff723e0f2a.png)

![image](https://user-images.githubusercontent.com/5680256/58074150-c6b34080-7ba4-11e9-83a5-943877e14fd7.png)

![image](https://user-images.githubusercontent.com/5680256/58074161-cfa41200-7ba4-11e9-8d83-0948b129e856.png)

![image](https://user-images.githubusercontent.com/5680256/58074177-dd599780-7ba4-11e9-867e-5047012b1f93.png)

![image](https://user-images.githubusercontent.com/5680256/58074188-e5193c00-7ba4-11e9-845c-cacfd34a9fc9.png)

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


295:  fix shuffle tests in CoinSelectionSpec once and for all  r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#291 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have removed the precondition about the list length in favor of a correct generator

# Comments

<!-- Additional comments or screenshots to attach if any -->

Turns out that the problem wasn't much the confidence interval that was being too strict as I thought in the past, but simply that the precondition was too hard to satistify. Indeed, quickcheck does generate empty lists quite often, (more than 10% of the generated values actually) and this caused the `checkCoverage` to give up very early despite the coverage being okay. 

I've switched to using a generator of `NonEmptyList` instead of the precondition and re-run both statistical tests a thousand times:

```
            replicateM_ 1000 $ quickCheck (checkCoverageWith lowerConfidence prop_shuffleNotDeterministic)
```

without observing any failure. So I've got quite some confidence that this is now fixed..

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <[email protected]>
@KtorZ KtorZ merged commit 2749d41 into master May 21, 2019
@iohk-bors iohk-bors bot deleted the KtorZ/291/shuffle-gave-up branch May 21, 2019 10:56
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.

3 participants