spacepy.toolbox.feq

spacepy.toolbox.feq(x, y, precision=5e-07)[source]

compare two floating point values if they are equal after: http://www.lahey.com/float.htm

Parameters:

x : float

a number

y : float or array of floats

other numbers to compare

precision : float (optional)

Relative precision for equal (default 0.0000005) Specified as a fraction of the sum of x and y.

Returns:

out : bool

True (equal) or False (not equal)

See also

numpy.allclose

Examples

>>> import spacepy.toolbox as tb
>>> x = 1 + 1e-4
>>> y = 1 + 2e-4
>>> tb.feq(x, y)
False
>>> tb.feq(x, y, 1e-3)
True