Skip to content

[DOC]: Explain the choice of absolute/relative tolerance for check_less_precise in assert_almost_equal #21528

Closed
@rs2

Description

@rs2

The docstring in

check_less_precise : bool or int, default False
Specify comparison precision. Only used when check_exact is False.
5 digits (False) or 3 digits (True) after decimal points are compared.
If int, then specify the digits to compare
does not specify how the number of decimal digits is going to be used, yet
if abs(fa) < 1e-5:
if not decimal_almost_equal(fa, fb, decimal):
assert False, ('(very low values) expected %.5f but '
'got %.5f, with decimal %d' % (fb, fa, decimal))
else:
if not decimal_almost_equal(1, fb / fa, decimal):
assert False, ('expected %.5f but got %.5f, '
'with decimal %d' % (fb, fa, decimal))
switches between absolute and relative tolerance depending on the (hardcoded) magnitude on the number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions