-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] Fix numpy FutureWarning #11704
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
Conversation
796017d
to
e8f4388
Compare
sklearn/cluster/birch.py
Outdated
@@ -74,7 +74,7 @@ def _split_node(node, threshold, branching_factor): | |||
|
|||
farthest_idx = np.unravel_index( | |||
dist.argmax(), (n_clusters, n_clusters)) | |||
node1_dist, node2_dist = dist[[farthest_idx]] | |||
node1_dist, node2_dist = dist[tuple(farthest_idx)] |
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'm not sure that this is the intention here. I think the list might have been intended to extract a result with a different shape.... Please double check
3fbc7e7
to
a2ee963
Compare
@jnothman thanks for the input |
sklearn/cluster/birch.py
Outdated
@@ -74,7 +74,7 @@ def _split_node(node, threshold, branching_factor): | |||
|
|||
farthest_idx = np.unravel_index( | |||
dist.argmax(), (n_clusters, n_clusters)) | |||
node1_dist, node2_dist = dist[[farthest_idx]] | |||
node1_dist, node2_dist = dist[tuple([farthest_idx])] |
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'm still confused about whether this is doing the same as it was before
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.
The list was wrapping farthest_idx
(a tuple) inside a list, now it's a tuple inside a tuple - I'm a bit confused too even though it's passing.
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've checked the code, and this does look right (semantically). But the standard way to indicate a tuple of one element is: (farthest_idx,)
.
9449f49
to
a2ee963
Compare
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.
Otherwise LGTM
sklearn/cluster/birch.py
Outdated
@@ -74,7 +74,7 @@ def _split_node(node, threshold, branching_factor): | |||
|
|||
farthest_idx = np.unravel_index( | |||
dist.argmax(), (n_clusters, n_clusters)) | |||
node1_dist, node2_dist = dist[[farthest_idx]] | |||
node1_dist, node2_dist = dist[tuple([farthest_idx])] |
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've checked the code, and this does look right (semantically). But the standard way to indicate a tuple of one element is: (farthest_idx,)
.
Sounds good, changed the tuple notation. Otherwise I think we need SciPy nightlies on 3.7 to make the other |
Thanks numpy.percentile is a superior implementation so I wouldn't mind seeing scoreatpercentile disappear anyway. Do you want to look into the Travis install script that's giving us to wrong scipy? |
@jnothman we'd need to revert to Python 3.6 or wait for SciPy nightlies to build on Python 3.7. I opened a PR here: MacPython/scipy-wheels#33 |
Ahh right. I suppose we can wait.
|
Reference Issues/PRs
Part of #11697, continue #11701
What does this implement/fix? Explain your changes.
Attempt to get rid of FutureWarnings by accessing ndarrays with tuples
Any other comments?