-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Remove even more uses np.array_equal in tests #18087
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: Remove even more uses np.array_equal in tests #18087
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18087 +/- ##
==========================================
- Coverage 91.27% 91.23% -0.05%
==========================================
Files 163 163
Lines 50120 50120
==========================================
- Hits 45749 45728 -21
- Misses 4371 4392 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18087 +/- ##
==========================================
- Coverage 91.4% 91.38% -0.02%
==========================================
Files 164 164
Lines 49880 49880
==========================================
- Hits 45592 45583 -9
- Misses 4288 4297 +9
Continue to review full report at Codecov.
|
@@ -237,7 +237,7 @@ def test_modulo(self): | |||
s = p[0] | |||
res = s % p | |||
res2 = p % s | |||
assert not np.array_equal(res.fillna(0), res2.fillna(0)) |
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.
so another way to do this and maybe cleaner is to have a parameter compare='equal|'not_equal'
The main issue I have with this method is the error messages are not as good (though maybe it doesn't matter)
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.
IIUC, wouldn't I have to propagate that parameter across every single assert_*
function? My change allow for any assert_*
function to be passed in.
Also, I'm not sure I follow what error message you would expect. If the assert_*
function passes when it isn't supposed to, you can't specify what was "different" in this case.
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.
@jreback : As I explained why I wasn't really a fan passing in a compare
parameter to all of these assert_*
functions, if you have any other thoughts on this point, let me know. Otherwise, I think this should be good to go.
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.
@jreback : Any thoughts?
@jorisvandenbossche @TomAugspurger : Any thoughts? |
Yeah, this seems good. |
Is there a reason we can't use |
@jorisvandenbossche : Hmm...that's a good point. How comprehensive is it vs. |
In any case, I'm still in favor of using the method I have developed in cases where our equality checking isn't as strict (e.g. |
So personally I don't find that an argument to have |
@jorisvandenbossche : Fair point. This function is meant to be catch-all for any of our in-house That being said, |
ac69b46
to
f49afb9
Compare
lgtm. @jorisvandenbossche ? |
I am still not sure adding an |
@jorisvandenbossche : The whole point is not to use In any case, it just so happened that |
@jorisvandenbossche : If you haven't done so already, have a look at #18047, where this whole discussion started around |
I didn't see that, but that issue does not seem to give a reasoning for the need to remove array_equal? |
I think the idea (and @jreback feel free to jump in) is that we were avoiding explicitly using the As written, |
I am not sure if that is the general direction, eg with the move to pytest we actually moved a bit more away from our in-house testing functionality (and you did some of those PRs to replace in-house methods with standard pytest functionality). |
I'm fine with incorporating So if you have a suggestion for writing this in |
Can you then be more specific? What is 'bad' about array_equal in this specific use case?
I think |
@jorisvandenbossche : In this specific case, I'll give it to you that we actually don't need this paradigm at all, as the shape of the arrays are completely different (just ran through the test manually), making this So in that case, no need to implement That being said, |
Yes, but as I said above, IMO if the reason that you want assert_series/numpy_array_equal to fail is not because the values differ but because the dtype (or name, ..) differs, I find |
So my reasoning: either the values differ -> simply use |
f49afb9
to
85ba491
Compare
@jorisvandenbossche : I just renamed the PR to just remove instances of "array_equal" from tests. Everything is green, so PTAL. |
thanks @gfyoung |
just for edification. we don't like |
All this time, and I didn't know that existed. 😄 Should mention that from now on in case we have this situation down the road. |
Thanks @gfyoung
and on the numpy side, I think |
Follow-up to gh-18087. The remaining test that uses the function call uses functionality that doesn't exist anymore in pandas.
Implement
assert_not
as a way to check that assertions should fail (for methods more sophisticated than a simple bareassert
). Also takes the opportunity to remove several morenp.array_equal
assertions.Follow-up to #18047