-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Get tests to run and fix them to pass #50636
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
Conversation
@MarcoGorelli Thank you for your patience, I'm learning a lot. The work is explained in the description above. There are five groups of tests that weren't passing and four of them are fixed.
Also, the |
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.
Nice work @phershbe !
For the metadata test, here's how I'd approach it:
tm.assert_metadata_equivalent(result)
doesn't run, so let's check which PR last touched it:
$ git log -G 'tm.assert_metadata_equivalent\(result\)'
commit 3570efd439ae49a7800f63a6247f089fa462405a
Author: Matthew Roeschke <>
Date: Tue Dec 28 12:32:31 2021 -0800
TST: More pytest idioms in tests/generic (#45086)
- let's look at TST: More pytest idioms in tests/generic #45086 - we see that
def check_metadata(self, x, y=None):
for m in x._metadata:
v = getattr(x, m, None)
if y is None:
assert v is None
else:
assert v == getattr(y, m, None)
became
def assert_metadata_equivalent(left, right):
"""
Check that ._metadata attributes are equivalent.
"""
for attr in left._metadata:
val = getattr(left, attr, None)
if right is None:
assert val is None
else:
assert val == getattr(right, attr, None)
-
Looks like there was a little difference between the functions, but it wasn't picked up because the tests weren't running - can you spot it?
-
finally, it would be good to add type annotations to this function, whilst we're changing it. I think just
DataFrame | Series
should work
@MarcoGorelli Whoa, you're the best, thank you for the guidance. The advice to find which PR last touched the code and then investigate it should be very helpful for me in the future, thank you. I updated the code and the tests all pass now! I didn't add anything to the Also, after my initial commit, I got some e-mails saying that various checks in CI were failing, is that normal? Of course, feel free to let me know if there is anything else that needs to be changed. |
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.
nice!
yeah you can see the failing check here: https://github.com/pandas-dev/pandas/actions/runs/3880306936/jobs/6618255248
can you also remove the exclude
from
pandas/.pre-commit-config.yaml
Lines 446 to 448 in 0fa40d8
exclude: | | |
(?x) | |
^pandas/tests/generic/test_generic.py # GH50380 |
please?
@MarcoGorelli Great, thank you for the reminder about reading about the failed check. On a similar note, there is already a failed check here, but it's something about Ubuntu that is failing on a lot of other pull requests from other people I noticed. I'm trying to read about the meaning of the |
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 @phershbe - can you mark as ready for review please? should be good to go
for exclude
, check the pre-commit docs
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.
actually, blocking as there's something I hadn't picked up on, which we should check
pandas/tests/generic/test_generic.py
Outdated
result = o._get_bool_data() | ||
expected = construct(n, value="empty", **kwargs) | ||
expected = construct(frame_or_series, n, value="empty", **kwargs) | ||
if isinstance(o, DataFrame): | ||
# preserve columns dtype | ||
expected.columns = o.columns[:0] | ||
tm.assert_equal(result, expected) | ||
tm.assert_equal(result.reset_index(drop=True), expected) |
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.
@topper-123 is this right?
In [1]: ser = Series([1,2,3])
In [2]: ser.index
Out[2]: RangeIndex(start=0, stop=3, step=1)
In [3]: ser._get_bool_data()
Out[3]: Series([], dtype: int64)
In [4]: ser._get_bool_data().index
Out[4]: Index([], dtype='object')
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.
@phershbe OK for now could you please just add a comment with
# https://github.com/pandas-dev/pandas/issues/50862
above this line? then we can get this in and address that separately if needed
@MarcoGorelli I'll wait for the response on the part that's blocking in the comment above before marking as ready because maybe that will inform another reviewer that it's ready I guess, but I'll check back in a few hours at the end of the night and again in the morning and mark it ready when you let me know so that it can get finished since it has taken me so long. |
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.
Just left a comment
If you fetch and merge upstream/main and mark as ready for review then we can get this in
pandas/tests/generic/test_generic.py
Outdated
result = o._get_bool_data() | ||
expected = construct(n, value="empty", **kwargs) | ||
expected = construct(frame_or_series, n, value="empty", **kwargs) | ||
if isinstance(o, DataFrame): | ||
# preserve columns dtype | ||
expected.columns = o.columns[:0] | ||
tm.assert_equal(result, expected) | ||
tm.assert_equal(result.reset_index(drop=True), expected) |
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.
@phershbe OK for now could you please just add a comment with
# https://github.com/pandas-dev/pandas/issues/50862
above this line? then we can get this in and address that separately if needed
@MarcoGorelli Thank you, I'm on it, doing it now |
@MarcoGorelli Okay, I think everything should be ready now. I was a little bit confused because your message here in the conversation was a comment about a comment in the files changed tab about adding a comment to the code ... it's clear enough though, it's my inexperience. I added the comment above |
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 @phershbe !
* updated tests * updated assert_metadata_equivalent * updated assert_metadata_equivalent and deleted exclude in YAML check-test-naming * added comment * move comment Co-authored-by: Marco Edward Gorelli <[email protected]>
NOTE:
test_metadata_propagation
is still not fixed yet in this draft pull requestChanged the class name from
Generic
toTestGeneric
in order to get the test to run and then fixed five groups of tests (test_rename
,test_get_numeric_data
,test_frame_or_series_compound_dtypes
,test_metadata_propagation
,test_api_compat
) in order to make sure that all of the tests pass.