8. numpy.testing

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.

8.1. Functions

assert_(val[, msg]) Assert that works in release mode.
assert_allclose(actual, desired[, rtol, ...]) Raises an AssertionError if two objects are not equal up to desired tolerance.
assert_almost_equal(actual, desired[, ...]) Raises an AssertionError if two items are not equal up to desired precision.
assert_approx_equal(actual, desired[, ...]) Raises an AssertionError if two items are not equal up to significant digits.
assert_array_almost_equal(x, y[, decimal, ...]) Raises an AssertionError if two objects are not equal up to desired precision.
assert_array_almost_equal_nulp(x, y[, nulp]) Compare two arrays relatively to their spacing.
assert_array_equal(x, y[, err_msg, verbose]) Raises an AssertionError if two array_like objects are not equal.
assert_array_less(x, y[, err_msg, verbose]) Raises an AssertionError if two array_like objects are not ordered by less than.
assert_array_max_ulp(a, b[, maxulp, dtype]) Check that all items of arrays differ in at most N Units in the Last Place.
assert_equal(actual, desired[, err_msg, verbose]) Raises an AssertionError if two objects are not equal.
assert_no_warnings(func, *args, **kw) Fail if the given callable produces any warnings.
assert_raises(exception_class, callable, ...) Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs.
assert_raises_regex(exception_class, ...[, ...]) 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.
assert_string_equal(actual, desired) Test if two strings are equal.
assert_warns(warning_class, func, *args, **kw) Fail unless the given callable throws the specified warning.
build_err_msg(arrays, err_msg[, header, ...])
decorate_methods(cls, decorator[, testmatch]) Apply a decorator to all methods in a class matching a regular expression.
jiffies([_proc_pid_stat, _load_time]) Return number of jiffies elapsed.
measure(code_str[, times, label]) Return elapsed time for executing code in the namespace of the caller.
memusage([_proc_pid_stat]) Return virtual memory size in bytes of the running python.
print_assert_equal(test_string, actual, desired) Test if two objects are equal, and print an error message if test fails.
raises(*args, **kwargs)
rand(*args) Returns an array of random numbers with the given shape.
run_module_suite([file_to_run, argv]) Run a test module.
rundocs([filename, raise_on_error]) Run doctests found in the given file.
runstring(astr, dict)

8.2. Classes

TestCase([methodName]) A class whose instances are single test cases.
Tester alias of NoseTester
clear_and_catch_warnings([record, modules]) Context manager that resets warning registry for catching warnings

8.3. Exceptions

IgnoreException Ignoring this exception due to disabled feature