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: Fix IndexError resulting from cumsum(fractions)[-1] != 1 #169

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

adigitoleo
Copy link
Member

This fixes an occasional IndexError that occurs during resampling, if np.cumsum(fractions_ascending) < rng.random(), which results in np.searchsorted() returning an index outside the size of the new arrays.

This fixes an occasional IndexError that occurs during resampling, if
np.cumsum(fractions_ascending) < rng.random(), which results in
np.searchsorted() returning an index outside the size of the new arrays.
@adigitoleo
Copy link
Member Author

From the np.cumsum docs:

cumsum(a)[-1] may not be equal to sum(a) for floating-point values since sum may use a pairwise summation routine, reducing the roundoff-error. See sum for more information.

@Patol75 Patol75 merged commit 590ac52 into main Feb 29, 2024
4 checks passed
@adigitoleo adigitoleo deleted the resampling-fix branch March 22, 2024 03:13
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