<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Erik Bray (the author of the +FLOAT_CMP extension in Astropy), Bruce
Leban, and I had a short off-thread email discussion. Here are the
points: <br>
<ul>
<li>[Bruce]: ALMOST_EQUAL is the best flag name.</li>
<li>[Erik]: If there's agreement on this, Erik will develop a
patch as soon as he can.</li>
<li>[Erik]: There's no way to adjust the tolerance because there
seems to be no easy way to parameterize doctest flags. Ideas are
welcome.</li>
<li>[Erik]: Still, "This +FLOAT_CMP flag enabled removing tons of
ellipses from the test outputs [of Astropy], and restoring the
full outputs which certainly read better in the docs... For more
complete unit tests of course we use assert_almost_equal type
functions."<br>
</li>
<li>[Erik]: This PR is a better link than the one I gave: <a
moz-do-not-send="true"
href="https://github.com/astropy/astropy/pull/2087"
target="_blank">https://github.com/astropy/astropy/pull/2087</a></li>
<li>[Erik]: Most of the code is from the SymPy project with
improvements. Erik had started on a similar feature when he
found that their implementation was further developed.</li>
</ul>
<p>Kevin<br>
</p>
<br>
<div class="moz-forward-container">
-------- Original Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Subject:
</th>
<td>Re: Fwd: Re: [Python-ideas] float comparison in doctest</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Date: </th>
<td>Thu, 14 Aug 2014 15:34:29 -0700</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">From: </th>
<td>Bruce Leban <a class="moz-txt-link-rfc2396E" href="mailto:bruce@leban.us"><bruce@leban.us></a></td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">To: </th>
<td>Erik Bray <a class="moz-txt-link-rfc2396E" href="mailto:erik.m.bray@gmail.com"><erik.m.bray@gmail.com></a></td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">CC: </th>
<td>Kevin Davies <a class="moz-txt-link-rfc2396E" href="mailto:daviesk24@yahoo.com"><daviesk24@yahoo.com></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<div dir="ltr">Well, 'almost' is an adverb so to my ears it sounds
like an incomplete phrase: "almost what??". So I'd still prefer
ALMOST_EQUAL. But it's still better than CMP.</div>
<div class="gmail_extra">
<br clear="all">
<div>
<div dir="ltr"><font face="arial, helvetica, sans-serif">---
Bruce<br>
</font>
<div>
<div><font face="arial, helvetica, sans-serif">Learn how
hackers think: <a moz-do-not-send="true"
href="http://j.mp/gruyere-security" target="_blank">http://j.mp/gruyere-security</a></font></div>
</div>
</div>
</div>
<br>
<br>
<div class="gmail_quote">On Thu, Aug 14, 2014 at 2:15 PM, Erik
Bray <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:erik.m.bray@gmail.com" target="_blank">erik.m.bray@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On Thu, Aug 14, 2014 at 3:50 PM, Kevin Davies
<<a moz-do-not-send="true"
href="mailto:daviesk24@yahoo.com">daviesk24@yahoo.com</a>>
wrote:<br>
> Thanks for your responses. The biggest issue might be
who is going to do the<br>
> coding/integration. Are either of you willing? I'll
paraphrase this email<br>
> chain and post it to the list.<br>
<br>
</div>
If it does indeed sound like a good idea I'll come up with a
patch<br>
soon as I'm able.<br>
<div class=""><br>
> Regarding the name of the flag, if FLOAT_CMP isn't
good, then maybe ALMOST<br>
> (without the _EQUAL since doctest always asserts
equality).<br>
<br>
</div>
I'm okay, I think, with ALMOST.<br>
<div class="HOEnZb">
<div class="h5"><br>
> ________________________________<br>
> From: Bruce Leban <<a moz-do-not-send="true"
href="mailto:bruce@leban.us">bruce@leban.us</a>><br>
> To: <a moz-do-not-send="true"
href="mailto:daviesk24@yahoo.com">daviesk24@yahoo.com</a>;
<a moz-do-not-send="true"
href="mailto:erik.m.bray@gmail.com">erik.m.bray@gmail.com</a><br>
> Sent: Thursday, August 14, 2014 5:42 AM<br>
> Subject: Fwd: Re: [Python-ideas] float comparison
in doctest<br>
><br>
> (Off list because this is bike shedding in a way
and I trust you'll<br>
> incorporate this feedback.)<br>
> I think this is a good idea but the name is not
meaningful.<br>
> Compare it to TestCase.assertAlmostEqual. Using the
same name is a good<br>
> idea.<br>
> FLOAT_ALMOST_EQUAL might be a bit long and
ALMOST_EQUAL might suggest that<br>
> it can compare things other than floats but I think
either is better than<br>
> CMP. And unittest doesn't include the word float in
the name so my vote<br>
> would be for ALMOST_EQUAL.<br>
> --- Bruce<br>
><br>
> On Aug 13, 2014 8:30 AM, "Erik Bray" <<a
moz-do-not-send="true"
href="mailto:erik.m.bray@gmail.com">erik.m.bray@gmail.com</a>>
wrote:<br>
><br>
> [Sorry for breaking the threading--turns out I
didn't have a<br>
> python-ideas subscription from this address]<br>
><br>
> Just a few followup points I wanted to make to
Kevin's post about a<br>
> proposed +FLOAT_CMP flag for doctest. A better
link for the<br>
> implementation is this PR in Astropy:<br>
><br>
> <a moz-do-not-send="true"
href="https://github.com/astropy/astropy/pull/2087"
target="_blank">https://github.com/astropy/astropy/pull/2087</a><br>
><br>
> I can't take full credit either--most of the
existing code was<br>
> borrowed (with some small improvements) from the
SymPy project. I had<br>
> started on a similar feature independently, but
then borrowed their<br>
> implementation upon seeing that it was further
along than mine.<br>
><br>
> On 12 Aug 2014 04:16, "Terry Reedy" <tjreedy at
<a moz-do-not-send="true" href="http://udel.edu"
target="_blank">udel.edu</a>> wrote:<br>
>> The problem with a simple flag is that
almost_equal should sometimes be<br>
>> absolute and sometimes relative and in both
cases a parameter in needed. I<br>
>> think there have been vague proposals for a
float method, but "a - b <<br>
>> delta"<br>
>> is shorter than "a.almost_equat(b, abs=delta)"
and probably easier to<br>
>> understand.<br>
><br>
> Indeed, that's what I had in mind when I told Kevin
that there were<br>
> still issues with this. There's no obvious way (I
can think of at<br>
> least) to parameterize doctest flags.<br>
><br>
> However, the original immediate purpose of this
feature was to handle<br>
> very small differences in representation of the
same value between<br>
> different platforms, and in that respect it has
worked very well.<br>
> Astropy has a lot of doctests, and many of which
have floating point<br>
> outputs. This +FLOAT_CMP flag enabled removing
tons of ellipses from<br>
> the test outputs, and restoring the full outputs
which certainly read<br>
> better in the docs.<br>
><br>
> For more complete unit tests of course we use
assert_almost_equal type<br>
> functions.<br>
><br>
> That said, if anyone has any ideas for allowing
tweaking the<br>
> tolerances for a doctest flag that would be great.
If this otherwise<br>
> seems like a good idea in general to include in the
doctest module I<br>
> will offer a patch.<br>
><br>
> Erik<br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a moz-do-not-send="true"
href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a moz-do-not-send="true"
href="https://mail.python.org/mailman/listinfo/python-ideas"
target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a moz-do-not-send="true"
href="http://python.org/psf/codeofconduct/"
target="_blank">http://python.org/psf/codeofconduct/</a><br>
><br>
><br>
><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
</div>
<br>
</body>
</html>