Re: [Python-ideas] math.nextafter

2017-02-24 Thread Nick Coghlan
On 25 February 2017 at 12:43, Nathaniel Smith wrote: > FWIW, numpy provides all of the following as separate functions: > > * an isclose equivalent > * nextafter > * a function for counting the number of ulps between two floats > * a function for checking that two floats differ by at most N ulps

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Nathaniel Smith
On Feb 24, 2017 5:29 PM, "David Mertz" wrote: Marc-André slightly misspelled the recent-ish addition of math.isclose(), but I agree that it is absolutely where a "nextafter" belongs. The function signature is already relatively complex to cover several different but related use cases. I.e.:

Re: [Python-ideas] math.nextafter

2017-02-24 Thread David Mertz
Marc-André slightly misspelled the recent-ish addition of math.isclose(), but I agree that it is absolutely where a "nextafter" belongs. The function signature is already relatively complex to cover several different but related use cases. I.e.: is_close(a, b, *, rel_tol=1e-09, abs_tol=0.0)

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Chris Barker - NOAA Federal
On Feb 24, 2017, at 10:28 AM, Mahmoud Hashemi wrote: By the way, it looks like math doesn't have machine epsilon either: > > > https://en.wikipedia.org/wiki/Machine_epsilon > > Pretty sure machine epsilon is in the sys module's float_info object. Ahh, thanks! I though I remembered it was somewh

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Mahmoud Hashemi
By the way, it looks like math doesn't have machine epsilon either: > > > https://en.wikipedia.org/wiki/Machine_epsilon > > which would be handy as well. > > -CHB > > Pretty sure machine epsilon is in the sys module's float_info object. Or are you saying it would be handy to alias sys.float_info.ep

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Chris Barker
On Fri, Feb 24, 2017 at 1:40 AM, Juraj Sukop wrote: > > > On Fri, Feb 24, 2017 at 5:01 AM, Chris Barker > wrote: > >> cause if your computation was that perfect, why not just check for zero? >> >> > A polynomial root may simply be not representable in double precision > floating-point format. >

Re: [Python-ideas] math.nextafter

2017-02-24 Thread M.-A. Lemburg
On 24.02.2017 10:13, Nick Coghlan wrote: > On 6 February 2017 at 20:29, M.-A. Lemburg wrote: > >> On 04.02.2017 12:59, Stephan Houben wrote: >>> Hi all, >>> >>> Visual C++ 2015 supports this one: >>> >>> https://msdn.microsoft.com/en-us/library/h0dff77w.aspx >>> >>> In any case, this is easy to i

Re: [Python-ideas] if in for-loop statement

2017-02-24 Thread Sven R. Kunze
On 24.02.2017 05:45, Chris Angelico wrote: Don't forget that you can rewrite a "for-if" using two additional lines and no indents, rather than one line and one indent: for ...: if not (...): continue ... ... That's exactly what I meant by "for+if+continue". At work we e

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Juraj Sukop
On Fri, Feb 24, 2017 at 5:01 AM, Chris Barker wrote: > cause if your computation was that perfect, why not just check for zero? > > A polynomial root may simply be not representable in double precision floating-point format. Per the example I posted above, the best one can hope for in such situat

Re: [Python-ideas] math.nextafter

2017-02-24 Thread Nick Coghlan
On 6 February 2017 at 20:29, M.-A. Lemburg wrote: > On 04.02.2017 12:59, Stephan Houben wrote: > > Hi all, > > > > Visual C++ 2015 supports this one: > > > > https://msdn.microsoft.com/en-us/library/h0dff77w.aspx > > > > In any case, this is easy to implement an efficient fallback in C, unlike >