Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

rth
Copy link
Member

@rth rth commented Oct 2, 2018

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.

@@ -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
Copy link
Member

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

Copy link
Member Author

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)

Copy link
Member

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?

Copy link
Member Author

@rth rth Oct 2, 2018

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.

@amueller
Copy link
Member

amueller commented Oct 2, 2018

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
Copy link
Member Author

@rth rth Oct 2, 2018

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))
Copy link
Member Author

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
Copy link
Member Author

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):
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.