Mask of where x and y are element-wise "equal" to each other.
Returns an int integer array with elements equal to 1 where x
and y are "equal", and 0 otherwise. If x or y are floating
point, "equal" means where abs(x-y) <= atol + rtol * abs(y).
This is essentially the same algorithm used in the
numpy/Numeric/numarray function allclose. If x and y are
integer, "equal" means strict equality. Shape and size of
output is the same as x and y; if one is an array and the other
is scalar, shape and size of the output is the same as the
array.
Output is an MA/ma masked array, unless both inputs are not
MA/ma objects, in which case output is a numpy/Numeric/numarray
array. If inputs are both unmasked scalars the output is a
Python integer scalar.
Positional Input Arguments:
* x: Scalar, numpy/Numeric/numarray array, MA/ma array, Python
list/tuple of any size and shape. Floating or integer type.
* y: Scalar, numpy/Numeric/numarray array, MA/ma array, Python
list/tuple of any size and shape. Floating or integer type.
Keyword Input Arguments:
* rtol: "Relative" tolerance. Default is 1.e-5. Used in the
comparison between x and y only if the two are floating point.
* atol: "Absolute" tolerance. Default is 1.e-8. Used in the
comparison between x and y only if the two are floating point.
If either of the inputs are MA/ma masked objects, this function
uses the MA/ma default algorithm for comparison, i.e., masked
values are always considered equal.
Examples:
>>> from where_close import where_close
>>> x = [20., -32., -1., 2. , 5., 29.]
>>> y = [20.1, -31., -1., 2.01, 3., 28.99]
>>> ind = where_close(x, y)
>>> ['%.1g' % ind[i] for i in range(len(ind))]
['0', '0', '1', '0', '0', '0']
>>> from where_close import where_close
>>> x = [20., -32., -1., 2. , 5., 29.]
>>> y = [20.1, -31., -1., 2.000000000001, 3., 28.99]
>>> ind = where_close(x, y)
>>> ['%.1g' % ind[i] for i in range(len(ind))]
['0', '0', '1', '1', '0', '0']
>>> x = N.array([1, 5, 7, -2, 10])
>>> y = N.array([1, -5, 17, -2, 0])
>>> ind = where_close(x, y)
>>> ['%.1g' % ind[i] for i in range(len(ind))]
['1', '0', '0', '1', '0']
|