[Python-Dev] RE: [Python-checkins] CVS: python/dist/src/Lib/test test_math.py,1.10,1.11 test_fork1.py,1.8,1.9 test_fcntl.py,1.16,1.17

Tim Peters tim.one@home.com
Wed, 11 Apr 2001 18:15:01 -0400


> Update of /cvsroot/python/python/dist/src/Lib/test
> In directory usw-pr-cvs1:/tmp/cvs-serv12386
>
> Modified Files:
> 	test_math.py test_fork1.py test_fcntl.py
> Log Message:
> Unixware 7 support by Billy G. Allie (SF patch 413011)
> ...
> ***************
> *** 36,40 ****
>   testit('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2)
>   testit('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4)
> ! testit('atan2(0, 1)', math.atan2(0, 1), 0)
>   testit('atan2(1, 1)', math.atan2(1, 1), math.pi/4)
>   testit('atan2(1, 0)', math.atan2(1, 0), math.pi/2)
> --- 37,44 ----
>   testit('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2)
>   testit('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4)
> ! if sys.platform in ['unixware7']:
> !     testit('atan2(0, 1)', math.atan2(0, 1), math.pi)
> ! else:
> !     testit('atan2(0, 1)', math.atan2(0, 1), 0)
>   testit('atan2(1, 1)', math.atan2(1, 1), math.pi/4)
>   testit('atan2(1, 0)', math.atan2(1, 0), math.pi/2)

atan2(0, 1) should be 0 on *all* platforms.  It's too bad if the original
test fails on unixware7, but if it does it means their libm's atan2() is
buggy.  C99 spells this out in excruciating detail.  C89 isn't as clear, but
is clear enough:

    The atan2(y, x) function computes the principal value of the
    arc tangent of y/x, using the signs of both arguments to
    determine the quadrant of the return value.  A domain
    error may occur if both arguments are 0.

IOW, atan2 returns the angle with x-axis made by a unit vector from the
origin to the point (x, y).  The point (1, 0) lies on the x axis, pointing to
the right, so is at an angle of 0.  The only question is whether it should be
+0 or -0, and while C99 spells that out too, Python's test doesn't
distinguish those cases so we don't have to answer that here.

So, if nobody leaps to defend unixware7, I'm going to revert that part of the
patch.