allclose
Compare numbers, arrays, or nested arrays for equality up to some tolerance. Checks both shapes and values. Uses almost-equal and generalizes array-almost-equal. Useful when working with lists of coordinates and other numerical data.
install
use npm
npm install allclose
usage
allclose(a, b, [atol], [rtol])
requires two numbers or arrays or nested arrays a
and b
, and optionally an absolute tolerance atol
and a relative tolerance rtol
. returns true
if a
and b
have the same shape and value, and false
otherwise.
examples
you can test numbers
> true > false
or arrays
> true > false > false
or nested arrays
> true > false > false
and you can optionally specify a tolerance
> false > true