-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Clarify difference between np.testing.assert_equal and np.testing.assert_array_equal #8457
Comments
I think |
To me it appears that it is
It's also worth mentioning that for the case ({1}, {'a': 1}) (but not ({'a': 1}, {1})), the error message from |
And whenever someone makes changes there, that person might as well add a few spaces in |
It's been a few years since this discussion started, so the code may have changed. This is the current state of things. Whenever either of the objects is an array,
The
It looks like this part would be correct if "array_like" were "array". To resolve this issue, I'd be willing to
This would read:
|
@ngoldbaum Can I get your thoughts on this suggested resolution to this issue (above)? |
What about this example:
Shouldn't the second assert error if your replaced suggestion were true? That said, this is an error:
Looks like this is done already. Thanks, great improvement!
I'm not sure we should go this far. Rather than outright recommending against ever using |
The recommendation about "array_like" was for "Array-like" is incorrect in the statement
I'm confused.
I think the points of confusion here lend support to the idea of trimming down the number of recommended functions with similar names! |
Ah, I thought it was for the similar recommendation in
Sorry for the imprecision, I just edited my comment, it should be what I originally intended now. I totally agree this is confusing! I just don't want to rule out a valid use-case or insist that strict shape typing like you want is always better. Maybe it's even better most of the time, but the reason |
While I think strict checks are an important feature to offer, my motivation here is not so much about the strictness of checks but for simplicity of the (Actually, I would have preferred that these functions follow normal broadcasting rules rather than making a special case for scalars. That would be even less strict.) I do see that this is different from the Ok, well, I'd be interested in a third opinion, but otherwise , I won't push it further. I will submit a PR attempting to clarify the distinction between the two functions, though. Does that sound good? |
Making it clear the checks that
If you have time on Wednesdays, showing up to either the numpy community meeting or triage meeting on zoom is a great way to get quick feedback from several people.
Please! |
Great, thanks for your thoughts! |
To avoid multiple CI runs, perhaps we can sort out the wording here. After the introduction but before the numpy/numpy/testing/_private/utils.py Lines 858 to 872 in 195d85b
how about:
If you'd like to tone down the last sentence even further, LMK what you'd prefer. |
That language sounds fine to me. |
The docs of
assert_equal
andassert_array_equal
point to each other but do not mention the rather subtle differences between the two functions. So far, the only difference I've seen is thatassert_equal
will consider a scalar equal to a singleton array containing that scalar (which matches a precise reading of the docs) but I may or may not be missing something.In any case a clarification in the docs would be appreciated.
The text was updated successfully, but these errors were encountered: