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 issue #18 #22

Merged
merged 2 commits into from
Mar 2, 2016
Merged

fix issue #18 #22

merged 2 commits into from
Mar 2, 2016

Conversation

gardnerjr
Copy link

minimum distance calculation expects every group to have at least 2 items, and fails with a "Sequence contains no elements" when this expectation is not met

i have no idea why the diff is showing every line is changed. i only changed refactored starting at 507, extracting that section of linq to the method GetMinimumDistanceBetweenItems at the bottom that could handle the case when a group contains one or no elements.

John Gardner added 2 commits March 1, 2016 21:49
minimum distance calculation expects every group to have at least 2 items, and fails with a "Sequence contains no elements" when this expectation is not met
(from element in priorityGroup
orderby GetCenterCoordinate(element) ascending
select element).ToList()
where orderedElements.Count >= 2
Copy link
Author

Choose a reason for hiding this comment

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

this where right here seems to be the source of the bug. if all of the groups have just one item (which seems to be a timing issue, at least for me) , then all of the groups get filtered out here, and the min throws because there are no elements.

also considered adding an extension method like MinOrDefault(0) that would return a default value if a sequence was empty.

@xyzzer
Copy link
Owner

xyzzer commented Mar 2, 2016

Thanks!

xyzzer added a commit that referenced this pull request Mar 2, 2016
@xyzzer xyzzer merged commit a01597a into xyzzer:master Mar 2, 2016
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.

None yet

2 participants