-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] MNT Remove unused private functions #12253
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
@@ -179,7 +179,6 @@ def _open_and_load(f, dtype, multilabel, zero_based, query_id, | ||
actual_dtype, data, ind, indptr, labels, query = \ | ||
_load_svmlight_file(f, dtype, multilabel, zero_based, query_id, | ||
offset, length) | ||
# XXX remove closing when Python 2.7+/3.1+ 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 don't get this
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.
@amueller See my comment in #12253 (comment)
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.
hm I feel like _gen_open
should be a context manager then?
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.
Spend a few minutes trying to make it a context manager: that would require handling closing of the opened handled manually, and in this case it's not that straightforwards as there are 4 fh coming from 2 unrelated if / elif
blocs with some code in between.
In the end, I think closing(_gen_open(f))
keeps the code simplest. It's part of the stdlib, so it's not much different to import contextlib.contextmanager
or contextlib.closing
.
looks good apart from comment. |
@@ -179,7 +179,6 @@ def _open_and_load(f, dtype, multilabel, zero_based, query_id, | ||
actual_dtype, data, ind, indptr, labels, query = \ | ||
_load_svmlight_file(f, dtype, multilabel, zero_based, query_id, | ||
offset, length) | ||
# XXX remove closing when Python 2.7+/3.1+ 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.
Even if it works it CPython, relying on the garbage collection to close file handlers is bad: apparently it's an implementation side-effect, not part of the language specs. It won't work with PyPy.
@@ -366,9 +366,6 @@ def test_radius_neighbors_classifier_when_no_neighbors(): | ||
clf.predict(z1)) | ||
if outlier_label is None: | ||
assert_raises(ValueError, clf.predict, z2) | ||
elif False: | ||
assert_array_equal(np.array([1, outlier_label]), | ||
clf.predict(z2)) |
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.
Set 6 years ago in 2dfe13d so it might as well have not been there..
if X.flags.c_contiguous: | ||
return check_array(X.T, copy=False, order='F'), True | ||
else: | ||
return check_array(X, copy=False, order='F'), False |
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.
Added 5 years ago in 2240e44 and is currently not used in the code base
@@ -92,16 +92,6 @@ def __init__(self, cost_matrix): | ||
self.path = np.zeros((n + m, 2), dtype=int) | ||
self.marked = np.zeros((n, m), dtype=int) | ||
|
||
def _find_prime_in_row(self, row): |
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.
Method doesn't seem to be used anywere. The whole class is private.
This removes a few unused private functions. Used vulture package for the code base analysis. Also went through all
XXX
comments, and made a few updates/clarifications when that was useful.More details in comments below.