MCPcopy
hub / github.com/numpy/numpy / assert_almost_equal

Function assert_almost_equal

numpy/ma/testutils.py:182–195  ·  view source on GitHub ↗

Asserts that two items are almost equal. The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).

(actual, desired, decimal=7, err_msg='', verbose=True)

Source from the content-addressed store, hash-verified

180
181
182def assert_almost_equal(actual, desired, decimal=7, err_msg='', verbose=True):
183 """
184 Asserts that two items are almost equal.
185
186 The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).
187
188 """
189 if isinstance(actual, np.ndarray) or isinstance(desired, np.ndarray):
190 return assert_array_almost_equal(actual, desired, decimal=decimal,
191 err_msg=err_msg, verbose=verbose)
192 msg = build_err_msg([actual, desired],
193 err_msg=err_msg, verbose=verbose)
194 if not round(abs(desired - actual), decimal) == 0:
195 raise AssertionError(msg)
196
197
198assert_close = assert_almost_equal

Callers 15

test_complexMethod · 0.90
test_masked_weightsMethod · 0.90
test_1d_with_missingMethod · 0.90
test_2d_with_missingMethod · 0.90
test_1d_with_missingMethod · 0.90
test_2d_with_missingMethod · 0.90
test_polyfitMethod · 0.90

Calls 3

build_err_msgFunction · 0.90
roundFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…