On Mon, 15 Jun 2020 at 00:21, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
>
> On 15/06/20 3:52 am, David Mertz wrote:
> > I've had occasion to use math.isclose(), np.isclose(), and np.allclose()
> > quite often.
>
> Can you elaborate a bit on the kinds of things you use them for?

I can't elaborate on David's use but in my own experience these
functions are mostly useful for interactive checking or for something
like unit tests. They can be used extensively in the testing code for
projects with a lot of floating point functions. It's unlikely that a
fundamental numeric algorithm would want to make use of a generic
function such as this though without explicitly setting the tolerance
which wouldn't work with an operator.

Fishing for examples in numpy testing code I quickly came across this
test file where almost every test is based on a function
assert_array_almost_equal:
https://github.com/numpy/numpy/blob/master/numpy/fft/tests/test_helper.py
The docstring for assert_array_almost_equal refers to more functions
that are variants of the idea of closeness testing but somehow not
quite the same.

--
Oscar
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LLVOHYLGGYTDUUQWWF3SU6I4PLOZR5YW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to