MCPcopy Create free account
hub / github.com/numpy/numpy / assert_almost_equal

Function assert_almost_equal

numpy/ma/testutils.py:176–189  ·  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

174
175
176def assert_almost_equal(actual, desired, decimal=7, err_msg='', verbose=True):
177 """
178 Asserts that two items are almost equal.
179
180 The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).
181
182 """
183 if isinstance(actual, np.ndarray) or isinstance(desired, np.ndarray):
184 return assert_array_almost_equal(actual, desired, decimal=decimal,
185 err_msg=err_msg, verbose=verbose)
186 msg = build_err_msg([actual, desired],
187 err_msg=err_msg, verbose=verbose)
188 if not round(abs(desired - actual), decimal) == 0:
189 raise AssertionError(msg)
190
191
192assert_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_ddofMethod · 0.90
test_biasMethod · 0.90
test_1d_with_missingMethod · 0.90
test_2d_with_missingMethod · 0.90

Calls 4

build_err_msgFunction · 0.90
absFunction · 0.85
roundFunction · 0.50

Tested by

no test coverage detected