-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
NotImplementedError messages doc update #7872 #7899
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
don't worry about the coverage file |
@@ -2179,7 +2179,7 @@ def fillna(self, value=None, method=None, axis=0, inplace=False, | |||
raise ValueError('must specify a fill method or value') | |||
if self._is_mixed_type and axis == 1: | |||
if inplace: | |||
raise NotImplementedError() | |||
raise NotImplementedError("fillna with inplace=True and _is_mixed_type=True") |
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.
and axis=1
pls squash the commits to one, see here: https://github.com/pydata/pandas/wiki/Using-Git |
@hayd @cpcloud @jorisvandenbossche usually for an abstract type class I would NotImplementedError; is this standard? anything else to indicate that its an abc method? |
there's the from abc import abstractmethod, ABCMeta
class CannotInstantiate(object):
__metaclass__ = ABCMeta
@abstractmethod
def hardy_har(self):
pass This will raise 😡 |
ok maybe should then have the not implemented errors signify that they are abstract e.g. in indexing, the or the message like you did above |
All the commits are squashed into one commit. Next time, I will careful to do the same before pushing it to the public repo. |
Thanks for going through this! Part of the reason for the original issue is that the error message is it should say why not just where/what.... Unfortunately, I can't find any specific advice online about writing good exceptions messages. :( I do think these ought to be proper sentences... IMO it would be nice if abstract methods were reflected in the error message (confession: I also do this)... Would it be easier/compat solution to define an AbstractMethodError <: NotImplementedError (whose message is (or is prefixed with) "This method must be defined on the concrete class" or something)? :s |
@jreback Sure. As far as I understand, instead of raising NotImplementedError, instead raising AbstractMethodError (after defining it) with the appropriate message would be good. Right? |
@ilam exactly. If you have about whether certain classes should be abstract or not, pls post a link here and we can discuss. |
@jreback Sure, I am sorry, I made that mistake again, I will squash them, and include here a list of Abstract classes, if any for which these changes might be required. |
https://github.com/pydata/pandas/blob/master/pandas/core/indexing.py#L58 |
yep |
Cool. Will change them to |
@@ -382,7 +382,7 @@ def _box_func(self): | |||
""" | |||
box function to get object from internal representation | |||
""" | |||
raise NotImplementedError | |||
raise NotImplementedError("Box function to get object from internal representation") |
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.
these are both abstract as well
@@ -3172,7 +3172,7 @@ def _chop(self, sdata, slice_obj): | |||
return sdata.iloc[slice_obj] | |||
|
|||
def apply(self, f): | |||
raise NotImplementedError | |||
raise NotImplementedError("DataSplitter apply function") |
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.
abstract
@cpcloud solution for the python 2/3 meta class thing is to copy six's with_metaclass into compat http://stackoverflow.com/a/18513858/1240268 using |
@ilam want to rebase & update? |
@ilam can you rebase and revisit this? |
This issue fixes pandas-dev#7872 by either describing the reason why a NotImplementedError is raised, or by throwing an AbstractMethodError in the case of abstract methods (eg: Mixins) that should be overwritten by the inheriting classes. This issue is based on discussion of PR pandas-dev#7899 which was never merged.
replaced by #9887 |
closes #7872
I have updated the NonImplementedError messages #7872 in all places applicable.
It includes changes to statements of type
Comment on the changes.
The one place I have doubt and not sure whether to add one or not would be https://github.com/pydata/pandas/blob/master/.coveragerc#L17