-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Axis slicer #4994
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
Axis slicer #4994
Conversation
looks good....once travis finishes...can merge |
Weird. One of the tests failed on plotting. All I did was have Travis rebuild and it worked. Shrug. Sent from my iPhone
|
ok... I think @jtratner has a couple of question about some of the excetions.. |
2 21 23 25 | ||
""" | ||
if not isinstance(axis, int): | ||
raise TypeError("axis paramter must be an int and not {axis}".format(axis=axis)) |
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.
please change this to assert isinstance(axis, int), "Expected 'axis' to be an int. Got: %r" % axis
(since we're assuming that this check is made already by callers - so it's a completely internal error.
@dalejung just left a bunch of comments. Basically, I want it to be clear that this is an internal function and callers should be checking for all those things. |
@@ -997,10 +997,9 @@ def drop(self, labels, axis=0, level=None): | |||
else: | |||
indexer = -axis.isin(labels) | |||
|
|||
slicer = [slice(None)] * self.ndim | |||
slicer[self._get_axis_number(axis_name)] = indexer | |||
slicer = _axis_slicer(indexer, axis=self._get_axis_number(axis_name), ndim=self.ndim) |
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.
can you make sure that indexer and ndim will always be correct for passing here? I know _get_axis_number
checks and raises an apporpriate error.
@jtratner I'm confused. I thought we had removed all |
@dalejung there were a lot of places using asserts incorrectly (like checking that input to Moreover, any exception that this could raise wouldn't make sense to the user. What the heck does it mean to have this wrong start or stop or ndim or indexer? The caller needs to raise a more useful error to the user. |
How is an AssertionError, with the same message, any more understandable by an end user? If |
@dalejung it's not, that's why caller functions have to check for these conditions first. The point is that none of those checks are necessary, because callers need to check for it - you're just establishing the logic that you think should be the case when this function is called. The reason that |
the entirety of the change with -O is that asserts are stripped - http://stackoverflow.com/questions/2830358/what-are-the-implications-of-running-python-with-the-optimize-flag , there's no benefit to it other than that. |
@dalejung last comment on this from me: the reason that all the asserts were changed to |
Anyways, if you don't agree with me on this, then I'll just agree to disagree with you. Then you'd just need to choose the right exceptions to raise (can't raise |
@jtratner Well, I think I can actual resolve this. From the original comment about it on #4874:
I actually use it external to pandas core development. It came out of a private repo. So it's only quasi-internal. Personally, I use a lot of "internal" functions from I'll update the exceptions. |
@jreback Not atm. Need to update exceptions. Got sidetracked on other work. |
@dalejung ok...np...I believe you need this before the Panel.shift. ping when ready |
1 similar comment
@dalejung was accid closed, but needs to revisit this in any event |
pls rebase this....this would be nice as an internal function |
@dalejung this is actually a nice, PR, pls reopen/resubmit when ready |
The internal axis slicer. I overloaded
indexer
to bestart
whenstop
is passed in instead of having a separate indexer kwargs.