Re: [Python-ideas] math.nextafter

2017-02-28 Thread Chris Barker
On Fri, Feb 24, 2017 at 6:43 PM, Nathaniel Smith wrote: > 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. > > > My 2c: I disagree -- numerical tolerance b

Re: [Python-ideas] math.nextafter

2017-02-25 Thread David Mertz
I do agree that a math.count_ulps() would be very nice to have. Or whatever spelling NumPy users for that concept. I see nextafter as more similar. Yes, it's not a uniform increment, which is the whole point. If you want a convergence that is as good as it can be in float, that's the relevant meas

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] 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 >

Re: [Python-ideas] math.nextafter

2017-02-23 Thread Chris Barker
On Mon, Feb 6, 2017 at 5:42 AM, Juraj Sukop wrote: > Do you mean something like: > > isclose(f(x), 0.0, rel_tol, abs_tol) > > If so, what should `rel_tol` and `abs_tol` be? > isclose is mostly about "relative" closeness, so rel_tol is more-or-less the number of decimal digits you want the s

Re: [Python-ideas] math.nextafter

2017-02-07 Thread Random832
On Sat, Feb 4, 2017, at 10:15, Steve Dower wrote: > These days, the subset of C99 supported by MSVC is "most" of it, so feel > free to start off by assuming the best, at least for new features (the > version we use for 2.7 obviously is not improving). The subset of the C *library*, anyway, since i

Re: [Python-ideas] math.nextafter

2017-02-06 Thread M.-A. Lemburg
On 07.02.2017 00:46, Steven D'Aprano wrote: > On Mon, Feb 06, 2017 at 11:29:17AM +0100, M.-A. Lemburg wrote: > >> I'm not sure how useful this would be in the stdlib, >> since it's very much tied to whatever float type Python >> happens to use on a platform. > > With the possible exception of µPy

Re: [Python-ideas] math.nextafter

2017-02-06 Thread Steven D'Aprano
On Mon, Feb 06, 2017 at 11:29:17AM +0100, M.-A. Lemburg wrote: > I'm not sure how useful this would be in the stdlib, > since it's very much tied to whatever float type Python > happens to use on a platform. With the possible exception of µPy, are there any Python implementations which don't use

Re: [Python-ideas] math.nextafter

2017-02-06 Thread Juraj Sukop
Do you mean something like: isclose(f(x), 0.0, rel_tol, abs_tol) If so, what should `rel_tol` and `abs_tol` be? On Mon, Feb 6, 2017 at 2:16 PM, M.-A. Lemburg wrote: > On 06.02.2017 13:22, Juraj Sukop wrote: > > On Mon, Feb 6, 2017 at 11:29 AM, M.-A. Lemburg wrote: > > > >> > >> Juraj: Cou

Re: [Python-ideas] math.nextafter

2017-02-06 Thread M.-A. Lemburg
On 06.02.2017 13:22, Juraj Sukop wrote: > On Mon, Feb 6, 2017 at 11:29 AM, M.-A. Lemburg wrote: > >> >> Juraj: Could you provide some use cases, where such a function >> would help in Python applications ? (I can see use cases >> written in C, but due to the low level, find it hard to >> believe

Re: [Python-ideas] math.nextafter

2017-02-06 Thread Juraj Sukop
On Mon, Feb 6, 2017 at 11:29 AM, M.-A. Lemburg wrote: > > Juraj: Could you provide some use cases, where such a function > would help in Python applications ? (I can see use cases > written in C, but due to the low level, find it hard to > believe that people would use this at the Python level) >

Re: [Python-ideas] math.nextafter

2017-02-06 Thread M.-A. Lemburg
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 > the fma() function we discussed some time ago. > > To put this i

Re: [Python-ideas] math.nextafter

2017-02-04 Thread Steve Dower
"tritium-l...@sdamon.com" Sent: ‎2/‎4/‎2017 3:53 To: "python-ideas@python.org" Subject: Re: [Python-ideas] math.nextafter The presence of the function in C99’s math.h isn’t strictly useful unless it is also in the MSVC math.h. MSVC only supports a subset of C99 From: Python-ideas

Re: [Python-ideas] math.nextafter

2017-02-04 Thread Stephan Houben
rom:* Python-ideas [mailto:python-ideas-bounces+tritium-list=sdamon.com@ > python.org] *On Behalf Of *Juraj Sukop > *Sent:* Saturday, February 4, 2017 6:31 AM > *To:* python-ideas@python.org > *Subject:* [Python-ideas] math.nextafter > > > > Hello! > > > > Function `nextafter

Re: [Python-ideas] math.nextafter

2017-02-04 Thread tritium-list
To: python-ideas@python.org Subject: [Python-ideas] math.nextafter Hello! Function `nextafter(x, y)` returns the next representable value of `x` in the direction of `y`, and if `x` equals to `y`, `y` is returned. [1] It is useful for incrementing/decrementing floating-point number by

[Python-ideas] math.nextafter

2017-02-04 Thread Juraj Sukop
Hello! Function `nextafter(x, y)` returns the next representable value of `x` in the direction of `y`, and if `x` equals to `y`, `y` is returned. [1] It is useful for incrementing/decrementing floating-point number by the smallest amount possible or for testing if two numbers are closest to each