-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
TST/REF: refactor the arithmetic tests for IntegerArray #34454
TST/REF: refactor the arithmetic tests for IntegerArray #34454
Conversation
Nice @jorisvandenbossche, this looks much easier to follow / understand |
All good here? |
yep looks good, pls rebase and merge on green. |
Have people seen these test failures recently:
And the arm build timed out. |
Yes. I've been ignoring them until i can get around to them |
@TomAugspurger open an issue for that? |
Will do a follow-up doing the same for BooleanArray, and then deduplicating some of them |
This is an attempt to make the arithmetic tests for the masked arrays more understandable and maintainable (doing it here for IntegerArray as a start, but the idea would be to do the same for BooleanArray, and later FloatingArray as well, and at that point also share some of those tests).
The problem with the current
arrays/integer/test_arithmetic.py
is that is quite complex to see what is going on (which I experienced when making a version for FloatingArray in #34307): for example, there is a huge_check_op
method that has all the logic to created the expected result, but so this also has all the special cases of all ops combined, making it very difficult to see what is going on or to know what is now exactly tested for a certain op.The reason for this structure is that those tests originally came from the base extension tests in
tests/extension/
, where the tests needed to be very generic. However, we already moved out those tests for IntgerArray, since they were all customized (nothing was still being inherited from the base class), but so we also don't need to maintain the original class structure then.The logic how I constructed the new tests:
op
with an explicitly constructed expected result. Here, we test the IntegerArray-specific special cases (like things as1 ** pd.NA
, or division resulting in a float numpy array, ..). Explicitly writing it down makes it a lot easier to read and to see what is tested (no complexif op == ...: ..,
constructs, and no complex correcting of expected results based on ndarray)_check_op
handle that as well.cc @dsaxton @jreback