-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @444thLiao! Your approach looks sound.
In addition to the small comments below, could you turn your example in the pull request description into a test?
To do this, add a new method to the TestDendrogram
class in plotly/tests/test_optional/test_figure_factory/test_figure_factory.py
and follow the pattern of the other tests in that class.
Thanks!
plotly/figure_factory/_dendrogram.py
Outdated
@@ -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]) | |||
|
There was a problem hiding this comment.
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)
plotly/figure_factory/_dendrogram.py
Outdated
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)))] |
There was a problem hiding this comment.
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.
I have added comments and add a test function at suitable places. Maybe now it is suitable to merge into the master branch. |
Thanks @444thLiao! I think these two test failures are due to the release of matplotlib 3.0, once I confirm that I'll merge these changes in. This will be released in version 3.3.0 in a week or so. |
@444thLiao Almost there. Matplotlib tests are fixed on master. Please merge master once more and push again. Thanks! |
Add to/from/read/write json functions to the plotly.io module (#1188)
Does it have some problems? I am not familiar with the circleci. @jonmmease |
I restarted the test and everything look good. Thanks for the contribution @444thLiao! |
@jonmmease Sorry for multiple pull request beacuse I am new to github cooperation.
Here is the formal request with code and example.
Before, run the code below
demo_data looks like
The data is some simple data and it mainly simulated the situation which has three and more rows are identical. When we using the euclidean distance, the distance between 0,1 and 3 will be identical.
we could get the dendrogram like that
In the graph above, we can see wrong multiple x-axis ticks text raised. It will be severely when we pass the leaves name. 35 in the graph is the original x-coordinate of the leaves.
After, run the same code above.
Relative issue and request:
#1180
#1181