Skip to content

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Sep 11, 2024

I haven't added a whatsnew note, because it shouldn't change behaviour but just avoids a warning being triggered (so thought that to not warrant a mention in the release notes)

@jorisvandenbossche jorisvandenbossche added Bug Testing pandas testing functions or related to the test suite labels Sep 11, 2024
Comment on lines +603 to +604
elif PyArray_Check(x) or PyArray_Check(y):
return False
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below we would essentially do bool(left == right) which raises an error for arrays/lists of size > 1 (and that error would then be caught below, turned into return False. So for now, just directly returning False here when left or right is a numpy array and the other not.

That then avoids doing this bool(left == right) for empty array/list case, which triggers the warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for now, just directly returning False here when left or right is a numpy array and the other not.

Did you mean to use xor instead of or?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first if just before is if PyArray_Check(x) and PyArray_Check(y), so the or is sufficient

@lithomas1
Copy link
Contributor

Does this need a backport?

@jorisvandenbossche
Copy link
Member Author

No, it's just for silencing a warning in a corner case, not worth of backporting

@jorisvandenbossche jorisvandenbossche added this to the 3.0 milestone Sep 12, 2024
@jorisvandenbossche jorisvandenbossche merged commit 2a3cf83 into pandas-dev:main Sep 12, 2024
40 of 47 checks passed
@jorisvandenbossche jorisvandenbossche deleted the assert-empty-list branch September 12, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: assert_frame_equal triggers DeprecationWarning with column with empty lists/arrays

3 participants