allclose

compas.geometry.allclose(l1, l2, tol=1e-05)[source]

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

Parameters
  • l1 (sequence[float]) – The first list of values.

  • l2 (sequence[float]) – The second list of values.

  • tol (float, optional) – The tolerance for comparing values.

Returns

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

Notes

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

References

1

https://docs.scipy.org/doc/numpy/reference/generated/numpy.allclose.html

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