list_is_almost_equal#

caf.toolkit.math_utils.list_is_almost_equal(vals, rel_tol=0.0001, abs_tol=0.0)[source]#

Check if a list of values are similar.

Whether two values are considered close is determined according to given absolute and relative tolerances. Wrapper around ` math.isclose()` to set default values for rel_tol and abs_tol.

Parameters:
  • vals (list[int | float]) – The values to check if similar

  • rel_tol (float) – The relative tolerance – it is the maximum allowed difference between two values to be considered similar, relative to the largest absolute value . By default, this is set to 0.0001, meaning the values must be within 0.01% of each other.

  • abs_tol (float) – The minimum absolute tolerance – useful for comparisons near zero. Must be at least zero.

Returns:

True if vals are all similar. False otherwise.

Return type:

is_close

See also

math.isclose()