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: return 1 for gcd_for_slice if all elements are 0.0 #5

Merged
merged 4 commits into from
Oct 1, 2023

Conversation

DanArmor
Copy link
Contributor

For WalkerTableBuilder if we call build and the sum of elements is 0 - it returns "WalkerTable that performs unweighted random sampling"
image

But during call of new for WalkerTableBuilder (f32) we have a division by gcd - it leads to division by zero errors because it returns 0 for slice of 0. We need to return 1 for gcd if all elements are 0, so we can get "WalkerTable that performs unweighted random sampling" from build call for WalkerTableBuilder (f32) where all elements are 0.0
image

Copy link
Owner

@ichi-h ichi-h left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in commenting!
Thank you for noticing the bug!
I will merge it now!

@ichi-h ichi-h merged commit 44feed1 into ichi-h:main Oct 1, 2023
3 checks passed
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