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 regression in scipy 1.5.0 in dendogram when labels is a numpy array. #12421
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.
LGTM. I'm sorry my previous PR did not test ndarray.
I added the backport label and the |
@@ -812,6 +812,13 @@ def test_valid_orientation(self): | |||
Z = linkage(hierarchy_test_data.ytdist, 'single') | |||
assert_raises(ValueError, dendrogram, Z, orientation="foo") | |||
|
|||
def test_can_take_label_as_array_or_list(self): | |||
Z = linkage(hierarchy_test_data.ytdist, 'single') | |||
labels = np.array([1, 3, 2, 6, 4, 5]) |
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.
testing with an empty NumPy array might also be useful, though maybe not required
adding a comment to the test like # test for gh-12418
can be nice too, though again perhaps not required
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.
I added a test for empty labels. I am not sure which behaviour we want:
- an error "Dimensions of Z and labels must be consistent." (this is the current behaviour)
labels=[]
is the same aslabels=None
(labels=None
is the default)
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.
I also added # test for gh-12418
.
In general I feel git blame
works reasonably well to find the associated PR with the discussion. At the same time it may be annoying if the history is complicated so I can see why the comment is useful.
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.
I'd prefer an error, as it is now.
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.
OK great, let me know if you need anything else, maybe a changelog entry somewhere?
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.
I think this is it, our changelog for the release notes will be auto-generated.
Not a big deal at all. IMO the strength of an ecosystem is not that its members never make any mistake but instead that people are motivated to work together and fix others mistakes when they bump into it and overall make the ecosystem a better place to live in. |
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.
LGTM, merging. Thanks @lesteve, all
Reference issue
Fix #12418.
What does this implement/fix?
This fixes a regression when
labels
is a numpy array.I added a test but I am not too familiar with dendrogram so let me know if the labels I chose do not make sense.