allclose

compas.geometry.allclose(l1, l2, tol=None)[source]

Returns True if two lists are element-wise equal within a tolerance.

Parameters:
l1sequence[float]

The first list of values.

l2sequence[float]

The second list of values.

tolfloat, optional

The absolute tolerance for comparing values. Default is TOL.absolute.

Returns:
bool

True if all corresponding values of the two lists are closer than the tolerance. False otherwise.

Warning

Deprecated since version 2.0: Will be removed in 2.1 Use TOL.is_close() instead.

The tolerance value used by this function is an absolute tolerance. It is more accurate to use a combination of absolute and relative tolerance. Therefor, use TOL.is_allclose() instead.

Notes

The function is similar to NumPy’s allclose function [1].

References

Examples

>>> allclose([0.1, 0.2, 0.3, 0.4], [0.1, 0.20001, 0.3, 0.4])
True
>>> allclose([0.1, 0.2, 0.3, 0.4], [0.1, 0.20001, 0.3, 0.4], tol=1e-6)
False