[Python-ideas] PEP 485: A Function for testing approximate equality
chris.barker at noaa.gov
Tue Jan 27 22:10:29 CET 2015
On Tue, Jan 27, 2015 at 10:05 AM, Nathaniel Smith <njs at pobox.com> wrote:
> On Tue, Jan 27, 2015 at 4:20 PM, Guido van Rossum <guido at python.org>
> > When does a program need *both* absolute and relative tolerance in a
> > test?
> It's reasonably common in numpy, where the equivalent function is
> vectorized to do multiple checks at once,
exactly -- as do a buch of the the unittest assertXXXX methods
or if folks write their own equivalent in a comprehension.
> if 'math' doesn't provide this then many people will use libraries
> that will or else write their own.
sure -- that's what been done for ages... you could say that about anything
new being proposed for the stdlib.
> I guess I don't have a good sense
> of what the audience for 'math' is these days -- I'm sure it has one,
> but aside from tiny one-off usages I'm not sure what it is. None of
> the production numerical code I see even bothers importing it.
Well, I'm a heavy numpy user as well, but I still use the math module when
I have something simple to calculate (actually, not so much simple as small
-- if I'm not working with a lot of numbers) or if I don't want the numpy
A lot of people do at least some math with python -- I have no idea how
many. And the statistics package was recently added -- I would have thought
that would be next to useless without numpy, but shows you what I know.
> possible that it largely serves a kind of pedagogical role? high
> schoolers learning to program etc.?
anyone learning python may need a bit of math -- there's some pretty basic
stuff in there.
The most compelling argument I see is that if we care about unittest,
> then it would be good to have a better alternative to
> assertAlmostEqual. (...I don't know anyone who uses the unittest API
> directly these days, though!)
I agree -- adding it to unitest would be a very good idea.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas