numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersRaisesBackRef
assert_equal(actual, desired, err_msg='', verbose=True)

Given two objects (scalars, lists, tuples, dictionaries or numpy arrays), check that all elements of these objects are equal. An exception is raised at the first conflicting values.

When one of :None:None:`actual` and :None:None:`desired` is a scalar and the other is array_like, the function checks that each element of the array_like object is equal to the scalar.

This function handles NaN comparisons as if NaN was a "normal" number. That is, AssertionError is not raised if both objects have NaNs in the same positions. This is in contrast to the IEEE standard on NaNs, which says that NaN compared to anything must return False.

Parameters

actual : array_like

The object to check.

desired : array_like

The expected object.

err_msg : str, optional

The error message to be printed in case of failure.

verbose : bool, optional

If True, the conflicting values are appended to the error message.

Raises

AssertionError

If actual and desired are not equal.

Raises an AssertionError if two objects are not equal.

Examples

This example is valid syntax, but we were not able to check execution
>>> 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.

This example is valid syntax, but we were not able to check execution
>>> np.testing.assert_equal(np.array([1.0, 2.0, np.nan]), [1, 2, np.nan])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.testing._private.utils.assert_approx_equal numpy.testing._private.utils.assert_array_almost_equal numpy.testing._private.utils.assert_almost_equal numpy.testing._private.utils.assert_array_equal

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/testing/_private/utils.py#275
type: <class 'function'>
Commit: