numpy.testing.print_assert_equal — NumPy v2.6.dev0 Manual

Learn | NEPs | User Guide | API reference | Building from source | Development | Release notes | NumPy’s module structure | Array objects | Universal functions (ufunc) | Routines and objects by topic | Constants | Bit-wise operations | String functionality | Data type routines | Floating point error handling | Discrete Fourier Transform | Input and output | Linear algebra | Logic functions | Masked array operations | Mathematical functions | Miscellaneous routines | Random sampling | Set routines | Sorting, searching, and counting | Test support | Testing guidelines

testing.print_assert_equal(test_string, actual, desired)

[source]

#

Test if two objects are equal, and print an error message if test fails.

The test is performed with actual==desired.

Parameters:test_stringstrThe message supplied to AssertionError.

actualobjectThe object to test for equality against desired.

desiredobjectThe expected result.

Examples

>>> np.testing.print_assert_equal('Test XYZ of func xyz',[0,1],[0,1])>>> np.testing.print_assert_equal('Test XYZ of func xyz',[0,1],[0,2])Traceback (most recent call last):...AssertionError: Test XYZ of func xyz failedACTUAL:[0, 1]DESIRED:[0, 2]

1 1