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 wrong leaves determination bug #1186

Merged
merged 3 commits into from
Sep 25, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plotly/figure_factory/_dendrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
for i in range(len(yvals_flat)):
if yvals_flat[i] == 0.0 and xvals_flat[i] not in self.zero_vals:
self.zero_vals.append(xvals_flat[i])

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a nice comment here explaining why this check is here. (e.g. the situation with multiple identical values)

if len(self.zero_vals) > len(yvals) + 1:
l_border = int(min(self.zero_vals))
r_border = int(max(self.zero_vals))
self.zero_vals = [v for v in range(l_border,r_border + 1, int((r_border-l_border) / len(yvals)))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please break this line up into two lines so that it's not so wide. Maybe create a new local variable for the range(...) expression.

self.zero_vals.sort()

self.layout = self.set_figure_layout(width, height)
Expand Down