ither argument is an array, this parameter has no effect. .. versionadded:: 2.0.0 Raises ------ AssertionError If actual and desired are not equal. See Also -------- assert_allclose assert_array_almost_equal_nulp, assert_array_max_ulp, Notes ----- By default, when one of `actual` and `desired` is a scalar and the other is an array, the function checks that each element of the array is equal to the scalar. This behaviour can be disabled by setting ``strict==True``. Examples -------- >>> np.testing.assert_equal([4, 5], [4, 6]) Traceback (most recent call last): ... AssertionError: Items are not equal: item=1 ACTUAL: 5 DESIRED: 6 The following comparison does not raise an exception. There are NaNs in the inputs, but they are in the same positions. >>> np.testing.assert_equal(np.array([1.0, 2.0, np.nan]), [1, 2, np.nan]) As mentioned in the Notes section, `assert_equal` has special handling for scalars when one of the arguments is an array. Here, the test checks that each value in `x` is 3: >>> x = np.full((2, 5), fill_value=3) >>> np.testing.assert_equal(x, 3) Use `strict` to raise an AssertionError when comparing a scalar with an array of a different shape: >>> np.testing.assert_equal(x, 3, strict=True) Traceback (most recent call last): ... AssertionError: Arrays are not equal (shapes (2, 5), () mismatch) ACTUAL: array([[3, 3, 3, 3, 3], [3, 3, 3, 3, 3]]) DESIRED: array(3) The `strict` parameter also ensures that the array data types match: >>> x = np.array([2, 2, 2]) >>> y = np.array([2., 2., 2.], dtype=np.float32) >>> np.testing.assert_equal(x, y, strict=True) Traceback (most recent call last): ... AssertionError: Arrays are not equal (dtypes int64, float32 mismatch) ACTUAL: array([2, 2, 2]) DESIRED: array([2., 2., 2.], dtype=float32) Tz