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

max() over empty list in Gingleator #424

Open
AustinLBuchanan opened this issue Jul 10, 2024 · 0 comments
Open

max() over empty list in Gingleator #424

AustinLBuchanan opened this issue Jul 10, 2024 · 0 comments

Comments

@AustinLBuchanan
Copy link

In Gingleator, if all districts become majority-minority, then an error occurs on line 144 of reward_partial_dist(). In this case, it tries to take the max( ) over an empty list, and the code breaks. The same issue could arise on line 171 of reward_next_highest_close().

next_dist = max(i for i in dist_percs if i < threshold)

next_dist = max(i for i in dist_percs if i < threshold)

It would be great if GerryChain could terminate gracefully in such circumstances, either terminating the chain early because a global max has been found, or finishing the chain as intended but without returning an exception. Either seems reasonable to me.

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

No branches or pull requests

1 participant