Skip to content

[MRG] Avoid duplicated methods whenever possible + more robust parameter passing #3790

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

Closed
wants to merge 7 commits into from

Conversation

arjoly
Copy link
Member

@arjoly arjoly commented Oct 21, 2014

The main goal of this pr is to ease maintenance.

@arjoly arjoly changed the title [MRG] Avoid duplicated method whenever possible + more robust parameter passing [MRG] Avoid duplicated methods whenever possible + more robust parameter passing Oct 21, 2014
@arjoly
Copy link
Member Author

arjoly commented Oct 21, 2014

@pprett Are there reasons to keep the bunch of single use methods such (_init_state, _clear_state, _resize_state, _is_initialized, _fit_stages, _check_params, _fit_stage,...)? It makes the code very hard to read in my opinion.

yield self.classes_.take(decisions, axis=0)
else:
for y in self.staged_decision_function(X):
yield y.ravel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually been removing this idiom in various places (maybe this exact module). It defeats the use of inheritance by mixing the subclasses' logic in the base class.

If you want to de-duplicate the docstrings, you can use the template method pattern:

def staged_predict(self, x):
    """docstring"""
    return self._staged_predict(x)

This way, if you want to understand one subclass's logic, you don't have to disentangle it from the other's.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will revert the change for the predict functions. However, I don't think it's worth to have separate fit function.

@arjoly
Copy link
Member Author

arjoly commented Oct 23, 2014

@larsmans Do you have more comments?

@arjoly
Copy link
Member Author

arjoly commented Nov 10, 2014

@pprett any more comments?

@pprett
Copy link
Member

pprett commented Nov 25, 2014

sorry -- missed the PR @arjoly

@pprett
Copy link
Member

pprett commented Nov 25, 2014

LGTM -- +100 for using keyword arguments over positional args -- thanks @arjoly

@arjoly arjoly closed this in 373e641 Nov 25, 2014
@larsmans
Copy link
Member

Pulled, squashed and pushed. Thanks @arjoly, sorry to have kept you waiting!

@arjoly
Copy link
Member Author

arjoly commented Nov 25, 2014

Great :-) Happy that this is merged!

@arjoly arjoly deleted the gbrt-one-fit branch November 25, 2014 17:03
@arjoly
Copy link
Member Author

arjoly commented Nov 25, 2014

Thanks for the review!

jmetzen pushed a commit to jmetzen/scikit-learn that referenced this pull request Dec 13, 2014
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