Skip to content
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

Use abstract base class syntax #1562

Closed
wants to merge 30 commits into from
Closed

Conversation

naoyak
Copy link
Contributor

@naoyak naoyak commented Dec 29, 2016

Ref: #1130

This updates most of the abstract base classes with the @six.add_metaclass and @abc.abstractmethod decorators.

TODO:

  • Update doctests that check for improperly instantiated ABCs

def labels(self):
"""
:return: the list of category labels used by this classifier.
:rtype: list of (immutable)
"""
raise NotImplementedError()
pass
Copy link
Contributor Author

@naoyak naoyak Dec 29, 2016

Choose a reason for hiding this comment

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

WekaClassifier doesn't implement labels() - this would throw an error?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, pass is not needed here, the docstring is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, thanks. Actually I was just figuring out how to reconcile the "hard" enforcement of abc.abstractmethod with how how the ClassifierI ABC is implemented - see 121a24c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dimazest so is it better to remove the pass statements? Most examples of abstract methods I've seen elsewhere leave it in. I think it's a bit more explicit and clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I would not put the pass if there is a docstring. It looks redundant, in the sense that there is a code that does nothing.

@stevenbird stevenbird added this to the 3.3 milestone Dec 29, 2016
@naoyak naoyak changed the title [WIP] Use abstract base class syntax Use abstract base class syntax Dec 30, 2016
@naoyak naoyak mentioned this pull request Feb 27, 2017
@naoyak
Copy link
Contributor Author

naoyak commented Feb 27, 2017

Looks like some of the abstract classes are tricky - moved the simpler ones to #1639.

@naoyak naoyak mentioned this pull request May 2, 2017
@naoyak
Copy link
Contributor Author

naoyak commented May 5, 2017

The straightforward classes were taken care of with #1639 #1707 - closing.

@naoyak naoyak closed this May 5, 2017
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.

None yet

3 participants