Test support#
Common test support for all numpy test scripts.
This single module should provide all the common functionality for numpy tests in a single location, so that test scripts can just import it and work right away. For background, see the Testing guidelines
Asserts#
|
Raises an AssertionError if two objects are not equal up to desired tolerance. |
|
Compare two arrays relatively to their spacing. |
|
Check that all items of arrays differ in at most N Units in the Last Place. |
|
Raises an AssertionError if two array_like objects are not equal. |
|
Raises an AssertionError if two array_like objects are not ordered by less than. |
|
Raises an AssertionError if two objects are not equal. |
|
Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs. |
|
Fail unless an exception of class exception_class and with message that matches expected_regexp is thrown by callable when invoked with arguments args and keyword arguments kwargs. |
|
Fail unless the given callable throws the specified warning. |
|
Fail if the given callable produces any warnings. |
|
Fail if the given callable produces any reference cycles. |
|
Test if two strings are equal. |
Asserts (not recommended)#
It is recommended to use one of assert_allclose
,
assert_array_almost_equal_nulp
or assert_array_max_ulp
instead of these
functions for more consistent floating point comparisons.
|
Assert that works in release mode. |
|
Raises an AssertionError if two items are not equal up to desired precision. |
|
Raises an AssertionError if two items are not equal up to significant digits. |
|
Raises an AssertionError if two objects are not equal up to desired precision. |
|
Test if two objects are equal, and print an error message if test fails. |
Decorators#
|
Apply a decorator to all methods in a class matching a regular expression. |
Test running#
|
Context manager that resets warning registry for catching warnings |
|
Return elapsed time for executing code in the namespace of the caller. |
|
Run doctests found in the given file. |
|
Context manager and decorator doing much the same as |
Testing custom array containers (numpy.testing.overrides
)#
These functions can be useful when testing custom array container
implementations which make use of __array_ufunc__
/__array_function__
.
Determine if a Numpy function can be overridden via __array_function__ |
|
Determine if a function can be overridden via __array_ufunc__ |
|
List all numpy ufuncs overridable via __array_ufunc__ |
|
List all numpy functions overridable via __array_function__ |