sao_fcmp

sherpa.utils.sao_fcmp(x, y, tol)[source] [edit on github]

Compare y to x, using an absolute tolerance.

Parameters
  • x (number or array_like) – The expected value, or values.

  • y (number or array_like) – The value, or values, to check. If x is an array, then y must be an array of the same size. If x is a scalar then y can be a scalar or an array.

  • tol (number) – The absolute tolerance used for comparison.

Returns

flags – 0, 1, or -1 for each value in second. If the values match, then 0, otherwise -1 if the expected value (x) is less than the comparison value (y) or +1 if x is larger than y.

Return type

int or array_like

See also

Knuth_close

Examples

>>> sao_fcmp(1, 1.01, 0.01)
0
>>> sao_fcmp(1, [0.9, 1, 1.1], 0.01)
array([ 1,  0, -1], dtype=int32)
>>> utils.sao_fcmp([1.2, 2.3], [1.22, 2.29], 0.01)
array([-1,  0], dtype=int32)