-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: Deprecate NDFrame.swapaxes #26654
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,7 +431,7 @@ def test_size_compat(self): | |
|
||
def test_split_compat(self): | ||
# xref GH8846 | ||
o = self._construct(shape=10) | ||
o = self._construct(shape=10).values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This defeats the purpose of the test, I think, as it was actually testing that So the "quick fix" is rather to ignore warnings in this specific test, so it doesn't fail the test, I think. Ideally we would prevent that the numpy function raises a warning at all, but not sure that is easily possible. |
||
assert len(np.array_split(o, 5)) == 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nparray_split depends on np.swapaxes, so I sidestep the problem here. This test is not very useful. Is that I'm thinking that maybe we should maybe keep swapaxes, perhaps hidden in |
||
assert len(np.array_split(o, 2)) == 2 | ||
|
||
|
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.
Is there a reason you need the
check_stacklevel=False
? (it seems a simple first level function, not multiple levels deep)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.
I got an error related to stack level, because something else is also deprecated. I can't exactly remember which function was deprecated, but I just thought this was the easy solution (the exact stack level isn't that important...)
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.
It is relevant for the user experience. But the stacklevel of 2 should be correct.
But a different deprecation being raised sounds a bit suspicious. Can you check which one it was?
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.
It has something to do with
SparseDataFrame
:I'll try to work around it.
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.
assert_produces_warning doesn't handle stack level correctly with multiple warnings. I'd recommend just
check_stacklevel=False
like you've done.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.
or don't test it for SparseDataFrame? That's deprecated anyway.
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.
Could you explain why the stack level important? Seems not so relevant to me.
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.
It's not that important here, as I can see you set it correctly.
But, in general, we want to test it because it ensures that end-users get a warning with the correction "location" indicated. If the stacklevel is set correctly, the warning message points to where this deprecated feature is being used. If not, it points to some other place, which is not useful or even plain confusing.