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

Fixed furthest_sum initialization error #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mpmbq2
Copy link

@mpmbq2 mpmbq2 commented Aug 5, 2022

The furthest_sum procedure occasionally generates an initial index value that is exactly the length of I, which causes an IndexError. To fix it, I changed the index selection step to force it to select a valid value from I.

Copy link
Owner

@ulfaslak ulfaslak left a comment

Choose a reason for hiding this comment

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

Nice catch. I think you can simplify the line to (no need to cast I as a numpy array):

i = furthest_sum(X[:, I], noc, [np.random.choice(I)])

@ulfaslak
Copy link
Owner

ulfaslak commented Aug 9, 2022

God, now I look at it, it's hard to understand how I wrote it that way. Must have assumes np.random.rand() can never be one.

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