[Pyunit-interest] RE: Pyunit-interest digest, Vol 1 #130 - 1 msg
Brought to you by:
purcell
From: Paul F D. <pa...@pf...> - 2002-12-31 20:32:10
|
Was there any discussion of this interface? Sorry if there was and I = missed it. I don't think it is useful. The "places" concept is an unusual test and does not correspond to = normal practice for numerical analysis. The test is usually: abs(x-y) <=3D abstol + reltol * abs(y) where the two parameters abstol and reltol are absolute and relative tolerances. Note that in the case of small y this reduces to abs(x) <=3D abstol, and for y large relative to abstol, it is approximately = abs((x-y)/y) <=3D reltol. By forumulating it in this way there is no need for logic = tests on small y. The "places" formulation seems to be similar to reltol =3D=3D 0.0 and = abstol =3D 5*10**(-places-1) or something like that.=20 > -----Original Message----- > From: pyu...@li...=20 > [mailto:pyu...@li...] On=20 > Behalf Of pyu...@li... > Sent: Monday, December 30, 2002 12:04 PM > To: pyu...@li... > Subject: Pyunit-interest digest, Vol 1 #130 - 1 msg >=20 >=20 > Send Pyunit-interest mailing list submissions to > pyu...@li... >=20 > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/pyunit-interest > or, via email, send a message with subject or body 'help' to > pyu...@li... >=20 > You can reach the person managing the list at > pyu...@li... >=20 > When replying, please edit your Subject line so it is more=20 > specific than "Re: Contents of Pyunit-interest digest..." >=20 >=20 > Today's Topics: >=20 > 1. forwarded message from rhe...@us...=20 > (Fred L. Drake, Jr.) >=20 > --__--__-- >=20 > Message: 1 > Date: Sun, 29 Dec 2002 18:22:14 -0500 > To: pyu...@li... > From: "Fred L. Drake, Jr." <fd...@ac...> > Subject: [Pyunit-interest] forwarded message from=20 > rhe...@us... >=20 >=20 > --yJq/i8nUPa > Content-Type: text/plain; charset=3Dus-ascii > Content-Description: message body and .signature > Content-Transfer-Encoding: 7bit >=20 >=20 > This was recently added to the unittest.py distributed with=20 > Python. It's probably of interest to others as well. >=20 >=20 > -Fred >=20 > --=20 > Fred L. Drake, Jr. <fdrake at acm.org> > PythonLabs at Zope Corporation >=20 >=20 > --yJq/i8nUPa > Content-Type: message/rfc822 > Content-Description: forwarded message > Content-Transfer-Encoding: 7bit >=20 > Return-path: <pyt...@py...> > Received: from bright09. (bright09-qfe0.icomcast.net=20 > [172.20.4.172]) by msgstore01.icomcast.net (iPlanet=20 > Messaging Server 5.2 HotFix 1.07 (built Nov 25 2002)) with=20 > ESMTP id <0H7...@ms...> for =20 > fdrake01@ims-ms-daemon; Sun, 29 Dec 2002 13:00:38 -0500 (EST) > Received: from mtain06 (bright-LB.icomcast.net [172.20.3.155]) > by bright09. (8.11.6/8.11.6) with ESMTP id gBTI0jr12288 for > <@msgstore01.icomcast.net:fdr...@co...>; Sun, > 29 Dec 2002 13:00:45 -0500 (EST) > Received: from mail.python.org (mail.python.org=20 > [12.155.117.29]) by mtain06.icomcast.net (iPlanet Messaging=20 > Server 5.2 HotFix 1.07 (built Nov 25 2002)) with ESMTP id=20 > <0H7...@mt...> for=20 > fdr...@co... (ORCPT fdr...@co...); Sun, 29=20 > Dec 2002 13:00:20 -0500 (EST) > Received: from alias2.acm.org ([199.222.69.92]) by=20 > mail.python.org with esmtp > (Exim 4.05) id 18ShjX-0005rC-00 for fd...@py...; Sun, > 29 Dec 2002 13:00:19 -0500 > Received: from mail.python.org ([12.155.117.29]) > by alias2.acm.org (ACM Email Forwarding Service) with ESMTP=20 > id CRY73883; Sun, 29 Dec 2002 13:00:19 -0500 > Received: from localhost.localdomain ([127.0.0.1]=20 > helo=3Dmail.python.org) > by mail.python.org with esmtp (Exim 4.05) id=20 > 18ShjV-0005qd-00; Sun, > 29 Dec 2002 13:00:17 -0500 > Received: from sc8-sf-sshgate.sourceforge.net > ([66.35.250.220] helo=3Dsc8-sf-netmisc.sourceforge.net) > by mail.python.org with esmtp (Exim 4.05) > id 18Shii-0005p0-00 for pyt...@py...; Sun, > 29 Dec 2002 12:59:28 -0500 > Received: from sc8-pr-cvs1-b.sourceforge.net > ([10.5.1.7] helo=3Dsc8-pr-cvs1.sourceforge.net) > by sc8-sf-netmisc.sourceforge.net with esmtp (Exim 3.36=20 > #1 (Debian)) > id 18Shih-0000KO-00 for <pyt...@py...>; Sun, > 29 Dec 2002 09:59:27 -0800 > Received: from localhost ([127.0.0.1]=20 > helo=3Dsc8-pr-cvs1.sourceforge.net) > by sc8-pr-cvs1.sourceforge.net with esmtp (Exim 3.22 #1=20 > (Debian)) > id 18Shig-0004pw-00 for <pyt...@py...>; Sun, > 29 Dec 2002 09:59:26 -0800 > Errors-to: pyt...@py... > Message-id: <E18...@sc...> > Precedence: bulk > X-BeenThere: pyt...@py... > X-Spam-Status: No, > hits=3D-0.3 required=3D5.0=20 > tests=3DNO_REAL_NAME,PATCH_CONTEXT_DIFF,SPAM_PHRASE_00_01 > X-Spam-Level: > X-Spam-Status: No, > hits=3D-5.4 required=3D5.0=20 > tests=3DBODY_PYTHON_ZOPE,KNOWN_MAILING_LIST,NO_REAL_NAME,PATCH_C > ONTEXT_DIFF,SPAM_PHRASE_00_01,SUBJ_PYTHON_ZOPE > X-Spam-Level: > X-Mailman-Version: 2.0.13 (101270) > List-Post: <mailto:pyt...@py...> > List-Subscribe:=20 > <http://mail.python.org/mailman/listinfo/python-checkins>, > <mailto:pyt...@py...?subject=3Dsubscribe> > List-Unsubscribe:=20 > <http://mail.python.org/mailman/listinfo/python-checkins>, > <mailto:pyt...@py...?subject=3Dunsubscribe> > List-Archive: <http://mail.python.org/pipermail/python-checkins/> > List-Help: <mailto:pyt...@py...?subject=3Dhelp> > List-Id: Check-in messages from the Python maintainers =20 > <python-checkins.python.org> > Original-recipient: rfc822;fdr...@co... > From: rhe...@us... > Sender: pyt...@py... > To: pyt...@py... > Subject: [Python-checkins] python/dist/src/Lib unittest.py,1.20,1.21 > Date: Sun, 29 Dec 2002 09:59:26 -0800 >=20 > Update of /cvsroot/python/python/dist/src/Lib > In directory sc8-pr-cvs1:/tmp/cvs-serv17844/Lib >=20 > Modified Files: > unittest.py=20 > Log Message: > Incorporate Skip's suggestion to use SciPy's validation test=20 > near equality. Note, there is another flavor that compares=20 > to a given number of significant digits rather than decimal=20 > places. If there is a demand, that could be added at a later date. >=20 >=20 > Index: unittest.py=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v > retrieving revision 1.20 > retrieving revision 1.21 > diff -C2 -d -r1.20 -r1.21 > *** unittest.py 30 Sep 2002 19:25:56 -0000 1.20 > --- unittest.py 29 Dec 2002 17:59:23 -0000 1.21 > *************** > *** 301,307 **** > --- 301,335 ---- > (msg or '%s =3D=3D %s' % (`first`, `second`)) > =20 > + def failUnlessAlmostEqual(self, first, second,=20 > places=3D7, msg=3DNone): > + """Fail if the two objects are unequal as=20 > determined by their > + difference rounded to the given number of decimal places > + (default 7) and comparing to zero. > +=20 > + Note that decimal places (from zero) is usually=20 > not the same > + as significant digits (measured from the most=20 > signficant digit). > + """ > + if round(second-first, places) !=3D 0: > + raise self.failureException, \ > + (msg or '%s !=3D %s within %s places' % (`first`,=20 > + `second`, `places` )) > +=20 > + def failIfAlmostEqual(self, first, second, places=3D7, = msg=3DNone): > + """Fail if the two objects are equal as determined by their > + difference rounded to the given number of decimal places > + (default 7) and comparing to zero. > +=20 > + Note that decimal places (from zero) is usually=20 > not the same > + as significant digits (measured from the most=20 > signficant digit). > + """ > + if round(second-first, places) =3D=3D 0: > + raise self.failureException, \ > + (msg or '%s =3D=3D %s within %s places' % = (`first`,=20 > + `second`, `places`)) > +=20 > assertEqual =3D assertEquals =3D failUnlessEqual > =20 > assertNotEqual =3D assertNotEquals =3D failIfEqual > +=20 > + assertAlmostEqual =3D assertAlmostEquals =3D = failUnlessAlmostEqual > +=20 > + assertNotAlmostEqual =3D assertNotAlmostEquals =3D = failIfAlmostEqual > =20 > assertRaises =3D failUnlessRaises >=20 >=20 >=20 > _______________________________________________ > Python-checkins mailing list > Pyt...@py...=20 > http://mail.python.org/mailman/listinfo/python> -checkins >=20 >=20 > --yJq/i8nUPa-- >=20 >=20 >=20 > --__--__-- >=20 >=20 > _______________________________________________ > Pyunit-interest mailing list Pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyunit-interest >=20 >=20 > End of Pyunit-interest Digest >=20 |