<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Vito De Tullio wrote:<br>
<blockquote cite="mid:lscbe0$ba4$1@ger.gmane.org" type="cite">
There are many pitfalls comparing floats, isn't better to delegate
these checks in a function?
</blockquote>
<br>
The problem with a function or a statement like "abs(a - b) <
delta"
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
is that it's not suitable for documentation. I usually end up doing
something like this:<br>
<br>
>>> expression # doctest: +SKIP<br>
123.456<br>
<br>
.. testcleanup::<br>
>>> assert abs(expression - 123.456) < delta<br>
<br>
and that's the situation that I could simplify to<br>
<br>
>>> expression # doctest: +FLOAT_CMP<br>
123.456<br>
<br>
Terry Reedy wrote:<br>
<blockquote cite="mid:lscbe0$ba4$1@ger.gmane.org" type="cite">
Erik would have to offer his code.
</blockquote>
<br>
Erik suggested that I could propose this idea to python-ideas, and
the Astropy project is licensed as BSD 3-clause, so I expect that
it'd be possible to use the code. The work of properly integrating
it is another story...<br>
</body>
</html>