Skip to content

BUG: reindex_like after shape comparison #15496

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

Closed
wants to merge 5 commits into from

Conversation

jojomdt
Copy link
Contributor

@jojomdt jojomdt commented Feb 24, 2017

in assert_frame_equal, if check_like, the former code reindex_like before shape comparison.
for example:
if left.shape=(2,2), right.shpae=(2.0), after reindex_like, left.shape=(2,0),right.shape=(2,0),then the shape comparison will not find out that the two dataframes are different. For that, the assert_frame_equal will not raise assertion errors. But in fact it should raise.
@jreback

in assert_frame_equal, if check_like, the former code reindex_like before shape comparison.
for example:
if left.shape=(2,2), right.shpae(2.0), after reindex_like, left.shape(2,0),right.shape(2,0),then the shape comparison will get wrong result.
@jojomdt jojomdt changed the title reindex_like after shape comparison BUG: reindex_like after shape comparison Feb 24, 2017
@jorisvandenbossche
Copy link
Member

@jojomdt Thanks for the contribution. We also have tests for our testing infrastructure, so can you add a test for this? (in pandas/tests/test_testing.py)

I suppose your change was the original intended behaviour (@jreback? that is what it is used for in our tests), i.e. to support comparing frames with different row order. But if so, we should clarify that in the docstring of check_like, as you can also interpret it that they don't need to have the same shape.

@jorisvandenbossche jorisvandenbossche added the Testing pandas testing functions or related to the test suite label Feb 24, 2017
@jreback
Copy link
Contributor

jreback commented Feb 24, 2017

this is probably more correct in that it gives a nicer error if you have s shape mismatch (it works now but will give a value comparison error)

what case did this come up in? (ideally add this to the tests of the testers as joris indicates)

@codecov-io
Copy link

codecov-io commented Feb 24, 2017

Codecov Report

Merging #15496 into master will decrease coverage by -0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master   #15496      +/-   ##
==========================================
- Coverage   90.36%   90.36%   -0.01%     
==========================================
  Files         135      135              
  Lines       49519    49519              
==========================================
- Hits        44747    44746       -1     
- Misses       4772     4773       +1
Impacted Files Coverage Δ
pandas/util/testing.py 82.09% <100%> (ø)
pandas/core/common.py 91.02% <ø> (-0.34%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b94186d...7b3437b. Read the comment docs.

add test_equal_with_different_row_order, change shape error message test
change it to ''If true, ignore the order of rows & columns''
@jojomdt
Copy link
Contributor Author

jojomdt commented Feb 24, 2017

add a test for dataframe with different row order to be equal, simplify shape comparison
@jorisvandenbossche @jreback

change 
\\[right\\]: \\(4, 1\\)
to 
\\[right\\]: \\(3, 1\\)
jreback pushed a commit to jreback/pandas that referenced this pull request Feb 27, 2017
in assert_frame_equal, if check_like, the former code reindex_like
before shape comparison.  for example:  if left.shape=(2,2),
right.shpae=(2.0), after reindex_like,
left.shape=(2,0),right.shape=(2,0),then the shape comparison will not
find out that the two dataframes are different. For that, the
assert_frame_equal will not raise assertion errors. But in fact it
should raise.

Author: jojomdt <[email protected]>

Closes pandas-dev#15496 from jojomdt/master and squashes the following commits:

7b3437b [jojomdt] fix test_frame_equal_message error
0340b5c [jojomdt] change check_like description
c03e0af [jojomdt] add test for TestAssertFrameEqual
470dbaa [jojomdt] combine row and column shape comparison
ce7bd74 [jojomdt] reindex_like after shape comparison
@jreback jreback added this to the 0.20.0 milestone Feb 27, 2017
@jreback jreback closed this in 55eccd9 Feb 27, 2017
@jreback
Copy link
Contributor

jreback commented Feb 27, 2017

thanks @jojomdt

AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
in assert_frame_equal, if check_like, the former code reindex_like
before shape comparison.  for example:  if left.shape=(2,2),
right.shpae=(2.0), after reindex_like,
left.shape=(2,0),right.shape=(2,0),then the shape comparison will not
find out that the two dataframes are different. For that, the
assert_frame_equal will not raise assertion errors. But in fact it
should raise.

Author: jojomdt <[email protected]>

Closes pandas-dev#15496 from jojomdt/master and squashes the following commits:

7b3437b [jojomdt] fix test_frame_equal_message error
0340b5c [jojomdt] change check_like description
c03e0af [jojomdt] add test for TestAssertFrameEqual
470dbaa [jojomdt] combine row and column shape comparison
ce7bd74 [jojomdt] reindex_like after shape comparison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants