Changing the problem with numpy unique#2
Open
abalagopal wants to merge 1 commit into
Open
Conversation
austinschneider
requested changes
May 20, 2021
| for level_i, level in enumerate(levels): | ||
| connected_line_segments = simplex_intersections_by_level[level_i] | ||
| lines_in_contours = np.unique([line for index_contour in connected_line_segments for line in index_contour], axis=0) | ||
| if len(connected_line_segments)!=0: |
Owner
There was a problem hiding this comment.
Can you change this to an "if / else", and in the else block append an empty list to contours_by_level? Without this I think the output will be broken, because contours_by_level could end up with too few entries.
This next part may be a little pedantic, but it would be cleaner to compare against the length of the list comprehension passed to np.unique rather than the length of connected_line_segments. This cuts more at the heart of the bug, and does not rely on the assumption that at least one element of connected_line_segments will have non-zero length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed the raised issue. Now the code will check if the array is empty or not.