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
ENH: add parameter strict
to assert_equal
#24770
Conversation
This adds the parameter strict to np.testing.assert_equal. With strict=True, the shape and dtype of the two arguments must match for the assertion to pass.
strict
to assert_equal
@@ -232,22 +232,22 @@ def test_array_vs_scalar_strict(self): | |||
b = 1. | |||
|
|||
with pytest.raises(AssertionError): | |||
assert_array_equal(a, b, strict=True) | |||
self._assert_func(a, b, strict=True) |
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.
TestEqual
, the class used to test assert_equal
, inherits from this class. This class is TestArrayEqual
, which is used to test assert_array_equal
.)
Before this PR, these three tests of the strict
parameter would run twice - once for TestArrayEqual
, and once for TestEqual
- but assert_array_equal
was tested both times. Now, these will test the appropriate assertion function each time they run.
These were the only tests of the strict
parameter added when the strict
parameter was added to assert_array_equal
in gh-21595. If they were sufficient there, hopefully enabling them for assert_equal
is sufficient here.
LGTM. I will merge it soon if no-one else has any comments. |
Thanks @mdhaber |
This adds the parameter
strict
tonp.testing.assert_equal
. Withstrict=True
, the shape and dtype of the two arguments must match for the assertion to pass.Follows the example of #21595
Partially addresses suggestion in #24667 (comment)
Addresses #24680 (comment)