Test support (cupy.testing)#

Asserts#

Hint

These APIs can accept both numpy.ndarray and cupy.ndarray.

assert_array_almost_equal(x, y[, decimal, ...])

Raises an AssertionError if objects are not equal up to desired precision.

assert_allclose(actual, desired[, rtol, ...])

Raises an AssertionError if objects are not equal up to desired tolerance.

assert_array_almost_equal_nulp(x, y[, nulp])

Compare two arrays relatively to their spacing.

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_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 array_like objects are not ordered by less than.

CuPy-specific APIs#

Asserts#

assert_array_list_equal(xlist, ylist[, ...])

Compares lists of arrays pairwise with assert_array_equal.

NumPy-CuPy Consistency Check#

The following decorators are for testing consistency between CuPy’s functions and corresponding NumPy’s ones.

numpy_cupy_allclose([rtol, atol, err_msg, ...])

Decorator that checks NumPy results and CuPy ones are close.

numpy_cupy_array_almost_equal([decimal, ...])

Decorator that checks NumPy results and CuPy ones are almost equal.

numpy_cupy_array_almost_equal_nulp([nulp, ...])

Decorator that checks results of NumPy and CuPy are equal w.r.t.

numpy_cupy_array_max_ulp([maxulp, dtype, ...])

Decorator that checks results of NumPy and CuPy ones are equal w.r.t.

numpy_cupy_array_equal([err_msg, verbose, ...])

Decorator that checks NumPy results and CuPy ones are equal.

numpy_cupy_array_list_equal([err_msg, ...])

Decorator that checks the resulting lists of NumPy and CuPy's one are equal.

numpy_cupy_array_less([err_msg, verbose, ...])

Decorator that checks the CuPy result is less than NumPy result.

Parameterized dtype Test#

The following decorators offer the standard way for parameterized test with respect to single or the combination of dtype(s).

for_dtypes(dtypes[, name])

Decorator for parameterized dtype test.

for_all_dtypes([name, no_float16, no_bool, ...])

Decorator that checks the fixture with all dtypes.

for_float_dtypes([name, no_float16])

Decorator that checks the fixture with float dtypes.

for_signed_dtypes([name])

Decorator that checks the fixture with signed dtypes.

for_unsigned_dtypes([name])

Decorator that checks the fixture with unsinged dtypes.

for_int_dtypes([name, no_bool])

Decorator that checks the fixture with integer and optionally bool dtypes.

for_complex_dtypes([name])

Decorator that checks the fixture with complex dtypes.

for_dtypes_combination(types[, names, full])

Decorator that checks the fixture with a product set of dtypes.

for_all_dtypes_combination([names, ...])

Decorator that checks the fixture with a product set of all dtypes.

for_signed_dtypes_combination([names, full])

Decorator for parameterized test w.r.t.

for_unsigned_dtypes_combination([names, full])

Decorator for parameterized test w.r.t.

for_int_dtypes_combination([names, no_bool, ...])

Decorator for parameterized test w.r.t.

Parameterized order Test#

The following decorators offer the standard way to parameterize tests with orders.

for_orders(orders[, name])

Decorator to parameterize tests with order.

for_CF_orders([name])

Decorator that checks the fixture with orders 'C' and 'F'.