Skip to content

Changing the problem with numpy unique#2

Open
abalagopal wants to merge 1 commit into
austinschneider:mainfrom
abalagopal:master
Open

Changing the problem with numpy unique#2
abalagopal wants to merge 1 commit into
austinschneider:mainfrom
abalagopal:master

Conversation

@abalagopal

Copy link
Copy Markdown

Fixed the raised issue. Now the code will check if the array is empty or not.

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:

@austinschneider austinschneider May 20, 2021

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

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