Coverage for eminus/testing.py: 100.00%
6 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-21 12:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-21 12:19 +0000
1# SPDX-FileCopyrightText: 2025 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""Array backend testing."""
5import numpy as np
7from . import backend as xp
10def assert_allclose(actual, desired, *args, **kwargs):
11 """Raises an AssertionError if two objects are not equal up to desired tolerance.
13 Args:
14 actual: Array obtained.
15 desired: Array desired.
16 *args: Pass-through arguments.
18 Keyword Args:
19 **kwargs: Pass-through keyword arguments.
20 """
21 np.testing.assert_allclose(xp.to_np(actual), xp.to_np(desired), *args, **kwargs)
24def assert_array_equal(actual, desired, *args, **kwargs):
25 """Raises an AssertionError if two array_like objects are not equal.
27 Args:
28 actual: The actual object to check.
29 desired: The desired, expected object.
30 *args: Pass-through arguments.
32 Keyword Args:
33 **kwargs: Pass-through keyword arguments.
34 """
35 np.testing.assert_array_equal(xp.to_np(actual), xp.to_np(desired), *args, **kwargs)