def replace_close(x, xhat, rtol=default_rtol, atol=default_atol, copy=True):
if rtol is None: rtol = default_rtol<EOL>if atol is None: atol = default_atol<EOL>x = np.array(x) if copy else np.asarray(x)<EOL>w = np.isclose(x, xhat, rtol=rtol, atol=atol)<EOL>x[w] = np.asarray(xhat)[w]<EOL>return x<EOL>
replace_close(x, xhat) yields x if x is not close to xhat and xhat otherwise. Closeness is
  determined by numpy's isclose(), and the atol and rtol options are passed along.

The x and xhat arguments may be lists/arrays.

The optional argument copy may also be set to False to chop x in-place.