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 Pick() returning the same value multiple times #63

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

SapiensAnatis
Copy link
Contributor

@SapiensAnatis SapiensAnatis commented Mar 10, 2024

Closes #62

The cause behind this seems to have been the use of Enumerable.Repeat in DefaultPicker, which called PickPrioritized once and repeated the result multiple times.

A few questions from me before I consider this completely ready for review:

  • Would it be worth testing Pick against other pickers; I believe if the bug was in DefaultPicker the issue may have been more widespread than PrioritizedElements.Pick(n) returns the same value n times #62 describes (but haven't tested yet).
  • Copy-pasting the ProbabilitiesMatter assertion is a bit clunky, maybe it would be better to pass in the dict of random data?

Copy link

codecov bot commented Mar 10, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 96.36%. Comparing base (3812e77) to head (f447b7a).

Files Patch % Lines
FluentRandomPicker/Picker/DefaultPicker.cs 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
+ Coverage   96.31%   96.36%   +0.04%     
==========================================
  Files          19       19              
  Lines         489      495       +6     
  Branches       42       43       +1     
==========================================
+ Hits          471      477       +6     
  Misses         12       12              
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ndsvw ndsvw marked this pull request as ready for review March 16, 2024 07:43
@ndsvw ndsvw merged commit ac86336 into ndsvw:main Mar 16, 2024
2 of 3 checks passed
@ndsvw
Copy link
Owner

ndsvw commented Mar 16, 2024

Hello,

Thank you for reporting the issue and also fixing it.
I can confirm that this is a bug and that the PR fixes it.

I have merged it and addressed your questions from above a few commits:

Would it be worth testing Pick against other pickers?

I have replaced the logic of ProbabilitiesMatter with calls to PickOneProbabilitiesMatter + PickNProbabilitiesMatter, see d9b3ced

So, all tests that tested whether probabilities matter, do that now via PickOne() and Pick(n).

Copy-pasting the ProbabilitiesMatter assertion is a bit clunky, maybe it would be better to pass in the dict of random data?

I outsourced a part of the method in d9b3ced

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.

PrioritizedElements.Pick(n) returns the same value n times
2 participants