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 classes #1639

Merged
merged 12 commits into from May 2, 2017
Merged

Use abstract classes #1639

merged 12 commits into from May 2, 2017

Conversation

naoyak
Copy link
Contributor

@naoyak naoyak commented Feb 27, 2017

Ref: #1130

Cherry-picking some commits from #1562.

def __str__(self):
raise NotImplementedError()
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

The pass here is inconsistent with the rest of the @abstractmethod. Is it necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah my mistake there's no docstring for this, that's why =)

def _contingency(*marginals):
"""Calculates values of a contingency table from marginal values."""
raise NotImplementedError("The contingency table is not available"
"in the general ngram case")
Copy link
Contributor

Choose a reason for hiding this comment

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

For these cases I think the error message is important. Is there a way to use @abstractmethod and still raise the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, added it back!

def _marginals(*contingency):
"""Calculates values of contingency table marginals from its values."""
raise NotImplementedError("The contingency table is not available"
"in the general ngram case")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

For these cases I think the error message is important. Is there a way to use @abstractmethod and still raise the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, added it back!

@naoyak
Copy link
Contributor Author

naoyak commented Apr 20, 2017

@alvations thanks for the feedback - reflected

@naoyak naoyak closed this Apr 21, 2017
@naoyak naoyak reopened this Apr 21, 2017
@naoyak
Copy link
Contributor Author

naoyak commented Apr 26, 2017

Rebased and updated.

@naoyak
Copy link
Contributor Author

naoyak commented May 1, 2017

@alvations @stevenbird - does this look better?

@stevenbird
Copy link
Member

@naoyak – yes, looking good!

@stevenbird stevenbird merged commit 990851a into nltk:develop May 2, 2017
@naoyak naoyak deleted the abstract-1 branch May 2, 2017 07:39
@naoyak naoyak mentioned this pull request May 2, 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