-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
ENH: Fix output of assert_frame_equal if indexes differ and check_like=True #37479
Conversation
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.
Thanks @amilbourne for the PR! Looks good
I don't know what the pandas policy is on API changes for the testing module (I think it's private but I think it gets used outside our testing suite) so one thing you might need to get agreement on
Related to the above if we regard this as a user-facing change you will need to add a whatsnew note
I guess that |
check_order: bool = True, | ||
rtol: float = 1.0e-5, |
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.
Probably it is necessary to have the new parameter added to the very end of this function signature in order not to break any user's code, which for some reason use positional arguments.
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.
Thanks for the feedback.
I debated that and it looked like the rtol
and atol
params had been added before the (older) obj
param, so I decided to put check_order
with the other check params. That said, obj
is not something that most user code would pass so perhaps the comparrison doesn't hold.
Happy to move the parameter.
I also just noticed that I forgot to add a versionadded
tag (will do).
I made the suggested changes and added a unit test for the new |
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.
Looks good to me.
The build is failing due to a failing test, but it doesn't seem to be anything to do with the changes I made, so I'm assuming that is an anomaly in the build (or a flakey test or something). The failing test is: This test is also failing for other unrelated PRs, so I don't think it was 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.
this lgtm. just a small comment. pls rebase and ping on green.
86bc7c0
to
42fc265
Compare
@jreback I moved the parameter as asked and rebased. The build is failing on |
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.
small comment, pls merge master and ping on green.
check_order : bool, default True | ||
Whether to compare the order of index entries as well as their values. | ||
If True, both indexes must contain the same elements, in the same order. | ||
If False, both indexes must contain the same elements, but in any order. |
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 add a versionadded tag 1.2 here
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.
Oh, that's annoying, sorry.
I removed the versionadded tag when I moved the parameters :-(
I have put it back and rebased again.
42fc265
to
25066f6
Compare
thanks @amilbourne very nice |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
As described in #37478 This PR fixes some very misleading output when
assert_frame_equal
is called with differing index values andcheck_like=True
I have added a
check_order
parameter to theassert_index_equal
function. This does essentially the same thing as thecheck_like
parmeter onassert_frame_equal
(but for indexes). I thinkcheck_order
gives a much clearer idea of what the parameter does, but it is a break from the previous naming. I am unsure whether I should have stuck withcheck_like
for the new parameter.