Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-27 Thread Mark Dickinson
On Thu, Mar 25, 2010 at 1:15 AM, Jeffrey Yasskin wrote: > On Wed, Mar 24, 2010 at 2:09 PM, Mark Dickinson wrote: >> Slight change of topic.  I've been implementing the extra comparisons >> required for the Decimal type and found an anomaly while testing. >> Currently in py3k, order comparisons (b

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Mark Dickinson
On Fri, Mar 26, 2010 at 11:16 PM, Raymond Hettinger wrote: > Of the ideas I've seen in this thread, only two look reasonable: > * Do nothing.  This is attractive because it doesn't break anything. > * Have float.__eq__(x, y) return True whenever x and y are >    the same NaN object.  This is attra

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Nick Coghlan
Mark Dickinson wrote: > On Fri, Mar 26, 2010 at 11:16 PM, Raymond Hettinger > wrote: >> Of the ideas I've seen in this thread, only two look reasonable: >> * Do nothing. This is attractive because it doesn't break anything. >> * Have float.__eq__(x, y) return True whenever x and y are >>the s

Re: [Python-Dev] Optional delta argument for assertAlmostEqual

2010-03-27 Thread Mark Dickinson
On Sat, Mar 27, 2010 at 12:59 AM, Michael Foord wrote: > Hello all, > > A user has suggested an optional argument to > unittest.TestCase.assertAlmostEqual for specifying a maximum difference > between the expected and actual values, instead of using rounding. +1. Mark ___

Re: [Python-Dev] Optional delta argument for assertAlmostEqual

2010-03-27 Thread Gregory P. Smith
On Fri, Mar 26, 2010 at 5:59 PM, Michael Foord wrote: > Hello all, > > A user has suggested an optional argument to > unittest.TestCase.assertAlmostEqual for specifying a maximum difference > between the expected and actual values, instead of using rounding. > > This sounds great to me as the defa

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Adam Olsen
On Fri, Mar 26, 2010 at 17:16, Raymond Hettinger wrote: > Of the ideas I've seen in this thread, only two look reasonable: > * Do nothing.  This is attractive because it doesn't break anything. > * Have float.__eq__(x, y) return True whenever x and y are >    the same NaN object.  This is attracti

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Robert Kern
On 2010-03-27 00:32 , David Cournapeau wrote: On Sat, Mar 27, 2010 at 8:16 AM, Raymond Hettinger wrote: On Mar 26, 2010, at 2:16 PM, Xavier Morel wrote: How about raising an exception instead of creating nans in the first place, except maybe within specific contexts (so that the IEEE-754 min

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Robert Kern
On 2010-03-27 13:36 , Adam Olsen wrote: On Fri, Mar 26, 2010 at 17:16, Raymond Hettinger wrote: Of the ideas I've seen in this thread, only two look reasonable: * Do nothing. This is attractive because it doesn't break anything. * Have float.__eq__(x, y) return True whenever x and y are t

Re: [Python-Dev] Optional delta argument for assertAlmostEqual

2010-03-27 Thread Charles McCreary
Perhaps not just absolute but relative tolerance, e.g.: def isclose(x, y, rtol=1.e-5, atol=1.e-8): return abs(x-y) <= atol + rtol * abs(y) On Fri, Mar 26, 2010 at 7:59 PM, Michael Foord wrote: > Hello all, > > A user has suggested an optional argument to > unittest.TestCase.assertAlmostEqual

Re: [Python-Dev] Why is nan != nan?

2010-03-27 Thread Adam Olsen
On Sat, Mar 27, 2010 at 18:27, Robert Kern wrote: > On 2010-03-27 13:36 , Adam Olsen wrote: >> What's the flaw in using isnan()? > > There are implicit comparisons being done inside list.__contains__() and > other such methods. They do not, and should not, know about isnan(). Those methods should