python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_math.cpython-312.opt-1.pyc

ΑeddlmZmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZdZedZedZedZej(j*Zej(j.Zd\ZZeezd	k(Zed
k(rej:dZneZe
j@jCexse
jDZ#e
j@jIe#dZ%e
j@jIe#dZ&d
Z'dZ(dZ)dZ*dZ+dZ,dZ-d dZ.GddZ/Gdde0Z1Gdde2Z3GddejhZ5GddejhZ6dZ7ed
k(rejpyy)!)verboserequires_IEEE_754)supportNgh㈵>naninf-inf)7yACg):@g7yAC__main__zmath_testcases.txtzcmath_testcases.txtcvtjdtjd|d}|dkr|dz}|S)aConvert a non-NaN float x to an integer, in such a way that
    adjacent floats are converted to adjacent integers.  Then
    abs(ulps(x) - ulps(y)) gives the difference in ulps between two
    floats.

    The results from this function will only make sense on platforms
    where native doubles are represented in IEEE 754 binary64 format.

    Note: 0.0 and -0.0 are converted to 0 and -1, respectively.
    z<qz<drl)structunpackpack)xns  B/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_math.pyto_ulpsr(s;	

dFKKa01!4A1ugJHc2|rdt||dz
zzSdS)zANumber of '1' bits in binary expansion of a nonnnegative integer.r)count_set_bits)rs rrrNs!,-1~a!a%i((414rch||z
dz	}|sy|dk(r|S||zdz}t||t||zS)zProduct of integers in range(start, stop, 2), computed recursively.
    start and stop should both be odd, with start <= stop.

    r)partial_product)startstop
numfactorsmids    rrrRsL
,1$J	qz!Q&uc*_S$-GGGrcdx}}tt|jD]+}|t||dzz	dzdz||z	dzdzz}||z}-||t	|z
zS)zFactorial of nonnegative integer n, via "Binary Split Factorial Formula"
    described at http://www.luschny.de/math/factorial/binarysplitfact.html

    r)reversedrange
bit_lengthrr)rinnerouteris    rpy_factorialr$`s}
EE
eALLN+
,
!q1u*!1A!5Q!|a7GHH
Q**++rctt|t|z
}t||z
}||ks||kryd}|j||||S)zGiven finite floats `expected` and `got`, check that they're
    approximately equal to within the given number of ulps or the
    given absolute tolerance, whichever is bigger.

    Returns None on success and an error message on failure.
    NzAerror = {:.3g} ({:d} ulps); permitted error = {:.3g} or {:d} ulps)absrformat)expectedgotulp_tolabs_tol	ulp_error	abs_errorfmts       r
ulp_abs_checkr/ksZGH%45IHsN#IGyG37zz)YAArc#lKt|d5}|D]}d|vr|d|jd}|js,|jd\}}|j\}}}|j}|d}	|dd}
||t	|t	|	|
f	dddy#1swYyxYww)zParse a file with test values

    -- starts a comment
    blank lines, or lines containing only a comment, are ignored
    other lines are expected to have the form
      id fn arg -> expected [flag]*

    utf-8encoding--N->rr)openindexstripsplitfloat)fnamefplinelhsrhsidfnarg
rhs_piecesexpflagss           rparse_mtestfilerF}s
eg	&:"
	:Dt|-TZZ-.::<zz$'HC))+KBCJQ-CqrNEr5:uSz599
	::::sB4BB(	B4(B1-B4c
#Kt|d5}|D]}|jds|js%|jd\}}|j\}}}}|j}	|	d|	d}}
|	dd}||t	|t	|t	|
t	||f	dddy#1swYyxYww)	zParse a file with test values

    Empty lines or lines starting with -- are ignored
    yields id, fn, arg_real, arg_imag, exp_real, exp_imag
    r1r2r4r5rrN)r6
startswithr8r9r:)
r;r<r=r>r?r@rAarg_realarg_imagrCexp_realexp_imagrEs
             rparse_testfilerNs
eg	&"	Dt$DJJLzz$'HC),&BHhJ!+A
1
hHqrNEr?E(O?E(O
	sCB!B;2	C;CCc&||k(ryd}t|trt|trt|}n+t|trt|trt|}t|trvt|trftj|rtj|rd}n9tj
|stj
|rnt
||||}|*d}|j||}|dj|z
}|Sy)aCompare arguments expected and got, as floats, if either
    is a float, using a tolerance expressed in multiples of
    ulp(expected) or absolutely (if given and greater).

    As a convenience, when neither argument is a float, and for
    non-finite floats, exact equality is demanded. Also, nan==nan
    as far as this function is concerned.

    Returns None on success and an error message on failure.
    Nz	not equalzexpected {!r}, got {!r}z ({}))
isinstancer:intmathisnanisinfr/r')r(r)r*r+failurefail_fmtfail_msgs       rresult_checkrXshG(E"z#s';Cj	C	Jx$=?(E"z#u'=::hDJJsOG
ZZ
!TZZ_$Hc7GDG,??8S1GNN7++rceZdZdZdZy)	FloatLikec||_yNvalueselfr^s  r__init__zFloatLike.__init__	
rc|jSr\r]r`s r	__float__zFloatLike.__float__zzrN)__name__
__module____qualname__rarerrrZrZrrZceZdZy)IntSubclassNrgrhrirjrrrmrmsrrmceZdZdZdZy)MyIndexablec||_yr\r]r_s  rrazMyIndexable.__init__rbrc|jSr\r]rds r	__index__zMyIndexable.__index__rfrNrgrhrirarsrjrrrprprkrrpcTeZdZdQdZdZdZdZdZdZdZ	d	Z
d
ZdZdZ
ed
ZdZej$ej(dk(xrej*dvddZdZdZdZdZdZdZej<dZdZ dZ!dZ"eej$e#ddZ$dZ%d Z&eej$e#d!d"Z'd#Z(d$Z)d%Z*d&Z+d'Z,d(Z-d)Z.ed*Z/eej`d+dd,Z1d-Z2d.Z3eej$e#d/ej<d0Z4ejjd1d2Z6eej$e#d/ej<ejjd1d3Z7d4Z8d5Z9d6Z:ed7Z;d8Z<d9Z=d:Z>d;Z?d<Z@ed=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGejeIdDdEZJedFZKedGZLdHZMdIZNdJZOedKZPedLZQdMZRdNZSdOZTyP)R	MathTestscht||||}|"|jdj||yy)aaCompare arguments expected and got, as floats, if either
        is a float, using a tolerance expressed in multiples of
        ulp(expected) or absolutely, whichever is greater.

        As a convenience, when neither argument is a float, and for
        non-finite floats, exact equality is demanded. Also, nan==nan
        in this function.
        Nz{}: {})rXfailr')r`namer)r(r*r+rUs       rftestzMathTests.ftests6xgw?IIhoodG45rc|jdtjd|jdtjd|j	tj
dtjzy)Npig-DT!	@egiW
@rH)r{rRr}r~assertEqualtaurds r
testConstantszMathTests.testConstantssH

4"<=

3 :;1TWW9-rc8|jttj|j	dtjdtj
|j	dtjdtj
dz|j	dtjdd|jttjt|jttjt|jttjdtz|jttjdtz
|jtjtjty)Nzacos(-1)zacos(0)rrHzacos(1)r)
assertRaises	TypeErrorrRacosr{r}
ValueErrorINFNINFeps
assertTruerSNANrds rtestAcoszMathTests.testAcoss)TYY/

:tyy}dgg6

9diilDGGAI6

9diilA.*dii5*dii6*diiS9*diic:

499S>23rc|jttj|j	dtjdd|j	dtjdd|jt
tjd|jt
tjd|j
tjtt|jt
tjt|jtjtjty)Nzacosh(1)rrzacosh(2)rHg5qB?r)rrrRacoshr{rrrrrrSrrds r	testAcoshzMathTests.testAcoshs)TZZ0

:tzz!}a0

:tzz!}.@A*djj!4*djj"5C#.*djj$7

4::c?34rc@|jttj|j	dtjdtj
dz|j	dtjdd|j	dtjdtj
dz|jttjt|jttjt|jttjdtz|jttjdtz
|jtjtjty)Nzasin(-1)rrHzasin(0)rzasin(1)r)
rrrRasinr{r}rrrrrrSrrds rtestAsinzMathTests.testAsins)TYY/

:tyy}twwhqj9

9diilA.

9diilDGGAI6*dii5*dii6*diiS9*diic:

499S>23rcZ|jttj|j	dtjdd|j	dtjdd|j	dtjdd|jtjtt|jtjtt|jtjtjty)	Nzasinh(0)rzasinh(1)rg'ya64?z	asinh(-1)rg'ya64)rrrRasinhr{rrrrrSrrds r	testAsinhzMathTests.testAsinh#s)TZZ0

:tzz!}a0

:tzz!}.AB

;

20DEC#.D)40

4::c?34rc|jttj|j	dtjdtj
dz|j	dtjdd|j	dtjdtj
dz|j	dtjttj
d	z|j	d
tjttj
d	z|jtjtjty)Nzatan(-1)rzatan(0)rzatan(1)rz	atan(inf)rHz
atan(-inf))rrrRatanr{r}rrrrSrrds rtestAtanzMathTests.testAtan,s)TYY/

:tyy}twwhqj9

9diilA.

9diilDGGAI6

;		#	:

<4477(1*=

499S>23rc|jttj|j	dtj
dd|j	dtj
dd|j	dtj
dd|jttj
d	|jttj
d
|jttj
t|jttj
t|jtjtj
ty)Nzatanh(0)rz
atanh(0.5)?gz?zatanh(-0.5)gzrr)rrrRrr{atanhrrrrrSrrds r	testAtanhzMathTests.testAtanh5s)TYY/

:tzz!}a0

<C2EF

=$**T"24HI*djj!4*djj"5*djj#6*djj$7

4::c?34rc2|jttj|j	dtjddtj
dz|j	dtjddtj
dz|j	dtjddd|j	d	tjddtj
dz|j	d
tjddtj
dz|j	dtjdttj
|j	d
tjddtj
|j	dtjddtj
|jtjddd|jtjddd|jtjdtd|jtjtjdt|j	dtjdttj
|j	dtjddtj
|j	dtjddtj
|jtjddd|jtjddd|jtjdtd|jtjtjdt|j	dtjtttj
dzdz|j	dtjtdtj
dz|j	dtjtdtj
dz|j	dtjtdtj
dz|j	dtjtdtj
dz|j	dtjtttj
dz|jtjtjtt|j	dtjtttj
dzdz|j	dtjtdtj
dz|j	dtjtdtj
dz|j	dtjtdtj
dz|j	d tjtdtj
dz|j	d!tjtttj
dz|jtjtjtt|j	d"tjdttj
|j	d#tjddtj
dz|j	d$tjddtj
dz|jtjdtd|jtjtjdt|j	d%tjdttj
|j	d&tjddtj
dz|j	d'tjddtj
dz|jtjdtd|jtjtjdt|jtjtjtt|jtjtjtd|jtjtjtd|jtjtjtd|jtjtjtd|jtjtjtt|jtjtjtty)(Nzatan2(-1, 0)rrrHzatan2(-1, 1)rrzatan2(0, 1)zatan2(1, 1)zatan2(1, 0)zatan2(0., -inf)zatan2(0., -2.3)ffffffzatan2(0., -0.)ffffff@zatan2(-0., -inf)zatan2(-0., -2.3)zatan2(-0., -0.)zatan2(inf, -inf)zatan2(inf, -2.3)zatan2(inf, -0.)zatan2(inf, 0.)zatan2(inf, 2.3)zatan2(inf, inf)zatan2(-inf, -inf)zatan2(-inf, -2.3)zatan2(-inf, -0.)zatan2(-inf, 0.)zatan2(-inf, 2.3)zatan2(-inf, inf)zatan2(2.3, -inf)zatan2(2.3, -0.)zatan2(2.3, 0.)zatan2(-2.3, -inf)zatan2(-2.3, -0.)zatan2(-2.3, 0.))rrrRatan2r{r}rrrrrSrrds r	testAtan2zMathTests.testAtan2@s)TZZ0

>4::b!#4twwhqjA

>4::b!#4twwhqjA

=$**Q"2A6

=$**Q"2DGGAI>

=$**Q"2DGGAI>	

$djjT&:DGGD

$djjT&:DGGD

#TZZC%8$''BB+R0B,b1B,b1

4::b##678

%tzz#t'<twwhG

%tzz#t'<twwhG

$djjc&:TWWHEC,c2C-s3C-s3

4::c3#789

%tzz#t'<dggaikJ

%tzz#t'<dggaiH

$djjd&;TWWQYG

#TZZS%947719E

$djjc&:DGGAIF

$djjc&:DGGAIF

4::c3#789

&

4(>
1M

&

4(>
K

%tzz$'=xzJ

$djjs&;dggXaZH

%tzz$'<twwhqjI

%tzz$'<twwhqjI

4::dC#89:

%tzz#t'<dggF

$djjc&:DGGAIF

#TZZR%8$''!)DC-r2

4::c3#789

&

4(>I

%tzz$'<twwhqjI

$djjr&:TWWHQJGD#.4

4::dC#89:

4::c4#89:

4::c4#89:

4::c3#789

4::c2#678

4::c3#789

4::c3#789

4::c3#789rcn|jttj|j	dtjdd|j	dtjdd|j	dtjdd|j	dtjd	d	|j	d
tjdd|j	dtjd
d|j	dtjdd|j	dtjdd|j	dtjdd|j	dtjdd|jtjtt|jtjtt|jtjtjty)Nzcbrt(0)rzcbrt(1)rzcbrt(8)rHz	cbrt(0.0)rz
cbrt(-0.0)rz	cbrt(1.2)g333333?ggAE?z
cbrt(-2.6)ggL]6Hzcbrt(27)rzcbrt(-1)rz	cbrt(-27)i)rrrRcbrtr{rrrrrSrrds rtestCbrtzMathTests.testCbrt}sU)TYY/

9diilA.

9diilA.

9diilA.

;		#4

<4$7

;		#0AB

<42DE

:tyy}a0

:tyy}b1

;		#33-4$/

499S>23rcR|jttj|j	t
t
tjd|j	tjdd|j	tjdd|j	tjdd|j	tjdd|j	tjdd	|j	tjd
d	|j	tjdd|j	tjddGd
d}Gddt}Gdd}|j	tj|d|j	tj|d|j	tjtdd|jttj||}d|_	|jttj||jttj|dy)Nrr??rHrrrrrceZdZdZy)$MathTests.testCeil.<locals>.TestCeilcyN*rjrds r__ceil__z-MathTests.testCeil.<locals>.TestCeil.__ceil__rNrgrhrirrjrrTestCeilr
rrceZdZdZy)%MathTests.testCeil.<locals>.FloatCeilcyrrjrds rrz.MathTests.testCeil.<locals>.FloatCeil.__ceil__rrNrrjrr	FloatCeilrrrrceZdZy)&MathTests.testCeil.<locals>.TestNoCeilNrnrjrr
TestNoCeilrrrrg@E@+c|Sr\rjargss r<lambda>z$MathTests.testCeil.<locals>.<lambda>s4r)
rrrRceilrrQtyper:rZr)r`rrrts     rtestCeilzMathTests.testCeils)TYY/d499S>233+3+3+4!,4"-4"-3+4!,
						8:.39;/49T?3R8)TYY
=L'
)TYY2)TYY15rc|jtjddd|jtjddd|jtjddd|jtjddd|jtjd	d
d|jttj|jtjddd|jtjdd
d|jtjt
dt
|jtjt
d
t|jtjtdt
|jtjtd
t|jtjdt
d|jtjdtd|jtjt
t
t
|jtjt
tt|jtjtt
t
|jtjttt|jtjtjtd|jtjtjtt
|jtjtjtt|jtjtjtt|jtjtjt
t|jttjdtdy)
Nrrrrirr@@r@)rrRcopysignrrrrrrSrrTr&rds rtestCopysignzMathTests.testCopysignsq"-s3r2.4r3/6q"-s3r3/6)T]]3r2.3r3/5sB/5sC0$7tR0#6tS148r3/4r40#6sC0#6sD148tS137tT2D9

4==b#9:;

4==c#:;<

4==d#;<=

4==c#:;<	


4==c#:;<T]]2s34b9rcX|jttj|j	dtjtj
dzdtjd|j	dtjdd|j	dtjtj
dzdtjd|j	dtjtj
d		|jtjtjt|jtjtjt|jtjtjty#t$rU|jttjt|jttjtYwxYw)
Nz
cos(-pi/2)rHrrr+zcos(0)z	cos(pi/2)zcos(pi)r)
rrrRcosr{r}ulprrSrrrrrds rtestCoszMathTests.testCossB)TXX.

<477(1*!5q$((1+
N

8TXXa[!,

; 3Q
L

9dhhtww/4	:OODJJtxx}56OODJJtxx~67	


488C=12	:j$((C8j$((D9	:sA6GAH)(H)win32)ARMARM64zEWindows UCRT is off by 2 ULP this test requires accuracy within 1 ULPcF|jttj|j	dtjdd|j	dtjddtjddzzz
d|jtjtt|jtjtt|jtjtjty)Nzcosh(0)rrzcosh(2)-2*cosh(1)**2rHr)rrrRcoshr{rrrrrSrrds rtestCoshzMathTests.testCoshs	
)TYY/

9diilA.

)499Q<$))A,/8I+I2N3-4#.

499S>23rc|jttj|j	dtjtj
d|j	dtjtj
dzd|j	dtjtj
dzd|j	d	tjd
d
y)Nzdegrees(pi)gf@z
degrees(pi/2)rHgV@zdegrees(-pi/4)rgFz
degrees(0)r)rrrRdegreesr{r}rds rtestDegreeszMathTests.testDegreess)T\\2

=$,,tww"7?

?DLL$;TB

#T\\477(1*%=uE

<a!4rc|jttj|j	dtjddtj
z|j	dtjdd|j	dtjdtj
|j
tjtt|j
tjtd|jtjtjt|jttjdy)	Nzexp(-1)rrzexp(0)rzexp(1)r@B)
rrrRrDr{r~rrrrrSr
OverflowErrorrds rtestExpzMathTests.testExps)TXX.

9dhhrlAdffH5

8TXXa[!,

8TXXa[$&&1#,$,

488C=12-7;rc|jttj|j	dtjdd|j	dtjdd|j	dtjdd|j	d	tjd
d|jtjtt|jtjtd|jtjtjt|jttjd
y)Nzexp2(-1)rrzexp2(0)rrzexp2(1)rHz	exp2(2.3)rg){IJ@rr)rrrRexp2r{rrrrrSrrrds rtestExp2zMathTests.testExp2s)TYY/

:tyy}c2

9diilA.

9diilA.

;		#0AB3-4"-

499S>23-G<rc0|jttj|j	dtjdd|j	dtjdd|j	dtjddy)Nzfabs(-1)rrzfabs(0)rzfabs(1))rrrRfabsr{rds rtestFabszMathTests.testFabss^)TYY/

:tyy}a0

9diilA.

9diilA.rc|jtjddd}tddD]Z}||z}|jtj|||jtj|t	|\|jttjd|jttjddzy)Nrrr
d)rrR	factorialrr$rr)r`totalr#s   r
testFactorialzMathTests.testFactorial
s*A.q$	AAQJET^^A.6T^^A.Q@	A	
*dnnb9*dnnr3wh?rcV|jttjd|jttjd|jttjd|jttjd|jttjt	j
d|jttjt	j
d|jttjdy)N@g@r}Ô%I5z5.2)rrrRrdecimalDecimalrds rtestFactorialNonIntegersz"MathTests.testFactorialNonIntegerss)T^^S9)T^^S9)T^^T:)T^^V<)T^^W__S5IJ)T^^W__U5KL)T^^S9rc|jttjddz|jttjdy)Nrr}Ô%IT)rrrRrrrds rtestFactorialHugeInputsz!MathTests.testFactorialHugeInputss4	
-SA)T^^U;rc|jttj|j	t
t
tjd|j	tjdd|j	tjdd|j	tjdd|j	tjdd|j	tjdd|j	tjd	d
Gdd}Gd
dt}Gdd}|j	tj|d|j	tj|d|j	tjtdd|jttj||}d|_	|jttj||jttj|dy)NrrrrrrrrrceZdZdZy)&MathTests.testFloor.<locals>.TestFloorcyrrjrds r	__floor__z0MathTests.testFloor.<locals>.TestFloor.__floor__3rrNrgrhrirrjrr	TestFloorr2rrrceZdZdZy)'MathTests.testFloor.<locals>.FloatFloorcyrrjrds rrz1MathTests.testFloor.<locals>.FloatFloor.__floor__6rrNrrjrr
FloatFloorr5rrr	ceZdZy)(MathTests.testFloor.<locals>.TestNoFloorNrnrjrrTestNoFloorr8rrrrg33333D@)c|Sr\rjrs rrz%MathTests.testFloor.<locals>.<lambda>@sDr)
rrrRfloorrrQrr:rZr)r`rr	rrs     r	testFloorzMathTests.testFloor%s)TZZ0d4::c?34C!,C!,C!,D)2.D)2.D)2.
						IK0"5JL126IdO4b9)TZZ?M()TZZ3)TZZA6rc|jttj|j	dtjddd|j	dtjddd|j	dtjddd	|j	d
tjddd|j	d
tjddd|j	dtjddd|jtjtjtd	|jtjtjd	t|jtjtjtt|jttjd	d|jttjtd	|jttjtd	|jttjtd|jtjdtd|jtjdtd|jtjdtd|jtjdtd|jtjddd|jtjdtdy)Nzfmod(10, 1)rrrz
fmod(10, 0.5)rz
fmod(10, 1.5)rrzfmod(-10, 1)rzfmod(-10, 0.5)zfmod(-10, 1.5)rr)rrrRfmodr{rrSrrrrrrds rtestFmodzMathTests.testFmodDs)TYY/

=$))B"2C8

?DIIb#$6<

?DIIb#$6<

>499S!#4d;

#TYYsC%8$?

#TYYsC%8$?

499S"#567

499R#567

499S##678*diiR8*diib9*diir:*diib93,c24-t43-s34.53,c23-s3rc|jttjfd}|dtjdd|dtjdd|dtjd	d
|dtjdd
j	tjt
dt
j	tjtdtjtjtjtdy)Nc||c\}}\}}t||z
tkDs||k7rj|d|d|yyNz
 returned z, expected r&rry)rzresultr(mantrDemanteexpr`s       r	testfrexpz&MathTests.testFrexp.<locals>.testfrexp]sJ)/&KT3%4:$t		34)4rz	frexp(-1)r)rrzfrexp(0)rrrzfrexp(1)r)rrzfrexp(2)rH)rrH)
rrrRfrexprrrrrSr)r`rs` r	testFrexpzMathTests.testFrexpZs)TZZ0	4	+tzz"~y9*djjmV4*djjmX6*djjmX6C+S1D)!,d3

4::c?1#567rz2fsum is not exact on machines with double roundingc0ddlm}|j|jz
fd}gdfdgdfgddfgddfgd	d
fgddfgd
dft	ddDcgc]}d|z	c}t
j
dft	ddDcgc]
}d|z|zc}t
j
dfgddfgddft	dddDcgc]}d|zd|dzzz
d|dzzzc}dgzt
j
dfg}t	dDcgc]}d |z	}}|jt	d!Dcgc]}||dz||z
c}|d!gz|dft|D]0\}\}}	tj|}	|j	|2dd$lm}
m}m}t	d!D]}
gd%d&z}d}t	d'D],}|d|
d(z|z
}||z
}|j|.||||}|j||tj|ycc}wcc}wcc}wcc}wcc}w#t$r|jd"|||fzYt$r|jd#|||fzY
wxYw))Nr)
float_infoc	d\}}|D][}tj|\}}ttj|	|	z
}}||kDr|||z
z}|}n|||z
z}||z
}]t	tt
t|dz
	z
|z
}|dkDr1d|dz
z}|d|zzt||zxr|d|zdz
zz}||z
}tj||S)zFull precision summation.  Compute sum(iterable) without any
            intermediate accumulation of error.  Based on the 'lsum' function
            at http://code.activestate.com/recipes/393090/

            rrHrrr)	rRr rQldexpmaxlenbinr&bool)
iterabletmanttexprrrDtailhetinymant_digs
        rmsumz MathTests.testFsum.<locals>.msumsKE4
 JJqM	c

4 :;S8^c#:d3h&EDSX%D

s3s5z?+A-8%$,GDax$q&M!A#eai.IEAaCEM)JJ::eT**rr)rrr0.++gd~QJrgd~Qr2)@Crgg?C)r3r9g@C)g@Crr4g@C)g?Crg<g?Crirz0x1.df11f45f4e61ap+2rz-0x1.62a2af1bd3624p-1)r	r缉ؗҜ<g7yAC)g7yACg?g7yAgirHr24gz0x1.5555555555555p+970g333333?rzDtest %d failed: got OverflowError, expected %r for math.fsum(%.100r)zAtest %d failed: got ValueError, expected %r for math.fsum(%.100r))randomgaussshuffle)rirgh$.5g#B;rr<)sysr#r0min_exprr:fromhexappend	enumeraterRfsumrryrrr9r:r;)r`r#r1rtest_valuesr#termsvalsr(actualr9r:r;jsvr/r0s                @@rtestFsumzMathTests.testFsumls	#&&""X-	+8IUCL
<fE
'5
&4
+\:
);7!!TN
+qbd
+
]]1
2
4"'4.
1QsQhqj
1
]]2
3
5
 34
=sC7<UC7K
L!b!eb1R4j 2":-
L[
]]3
4
6*"'t-Aa--,1$K8qU1Q3Z%(
"8U4[L>I
1XI
	
$-[#9		/Ah
I4
VX.		/	21t
	:A82=DA3Z
!VX&!+a/QA

DMT
AT$Z49
	:?,
1
M.8!
I		256$4GHI
I		256$4GHI
Is6H7	H<II6I5I J2JJc tj}|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd	|j|dd
d	|j|ddd
d}d}dD]}||z}||z}|j|||||j|||||j|||||j|||||j|||||j|||||j|||||j|||||j|d|j|dd|j|d
d|j|dddd|j|dddd|jt|d|jt|dd|jt|dd|jt|ddd|j|tdtdd	y)Nrrrr<xT j9W P)} "o`T"- l8P9cC/
S9bXl	9@{wM275k )	lZ'^%#>;*Q!/61^f^@U@)rRgcdrrrrp)r`r[rycabs       rtestGcdzMathTests.testGcdshhQA&QA&RQ'QA&QQ'QA&QQ'S"q)S"r*R+98:;=	?
O4V	-AAAAASAY*SAY*S!QZ+SQBZ+SQBZ+S!QZ+S!aR[!,S!aR[!,	-	
"S3'TC(S"c*A.S!R!,)S%0)S%4)S#t4)S#q$7[-{2?Drcddlm}ddlm}tj
}tjtjt	jdt	jdt	jdf}tt|dzD]@}|j||d|t	jtd|d|DB|j|d	d
d|j|dd
d|j||d|d
d|j||dd|d
d|dd|j|t!dt!dt!dt!dt	jd|j|ddd|j|dd|j|d|jdt	j"d|d|j|ddd|ddd|j%t&5|dddd|j%t&5|dddddddt(j*j,d
zz}|j%t.t0f5|d|ddd|j|t2t2|j|dt2t2|j|dt2t2|j|dt2t2|j|t4t2t2|j|t2t4t2|j|t6t4t2|j|t4t6t2|j|t2t2t2|j|t2t2t2|j|dt2t2|j9t	j:|t4|j9t	j:|dt4|j9t	j:|t4d|j9t	j:|dt4|j9t	j:|t4t4|j9t	j:|t4t<dz}tdD]D}|j9t	j>||g|z|t	j|zFtdD]=}	t@d|	zz}
|jt	j
d|
zd|
zd
|
z?y#1swYxYw#1swYxYw#1swYmxYw) NrrFractionr@g@rc3&K|]	}|dzyw)rHNrj).0rIs  r	<genexpr>z&MathTests.testHypot.<locals>.<genexpr>s5qad5sg(@r*@rQrw
rUrr%%@rrrrr皙?string皙@rrrr)!rr	fractionsrdrRhypotr~r}sqrtgammasinrr'assertAlmostEqualsumrr)rrrr>r#
max_10_exprrrrrrrS	FLOAT_MAXisclose	FLOAT_MIN)r`rrdrrrr#int_too_big_for_float	fourthmaxrrDscales           r	testHypotzMathTests.testHypots#&

vvtww		#

3#Ns4y{#	A""tBQx 		#5D!H556
		
tS)40r1r*wr{GAJ7<xB/!RA8BPRCSTtAwQa$q'BDIIaLQ	
sC#.ut,#&MM#uT{+	
	
#sC #sC 	


y
)	AJ	


y
)	&#x%	& "s~~'@'@1'D E



M:
;	,!*+	,	
sS)q#,r3-sC#.sC#.sC#.tS)3/sD)3/tS)3/tcT*C0rC4#.	


5:./

5C=12

5b>23

5S>23

5c?34

5:./O	r	DAOODLL)Q)@)2TYYq\)AC
D	D
9	DCs
*ETZZ%591U7C	DI			&	&	,	,s$
X%<X2

X?%X/2X<?Y	z7hypot() loses accuracy on machines with double roundingc	tj}tj}tjd}dD]\}}t
j
|}t
j
|}|j||||5tj|5t||dz||dzzj}ddd|j|||dddy#1swY-xYw#1swYxYw)N)prec))z0x1.10e89518dca48p+29z0x1.1970f7565b7efp+30)z0x1.10106eb4b44a2p+29z0x1.ef0596cdc97f8p+29)z0x1.459c058e20bb7p+30z0x1.993ca009b9178p+29)z0x1.378371ae67c0cp+30z0x1.fbe6619854b4cp+29)z0x1.f4cd0574fb97ap+29z0x1.50fe31669340ep+30)z0x1.494b2cdd3d446p+29z0x1.212a5367b4c7cp+29)z0x1.f84e649f1e46dp+29z0x1.1fa56bef8eec4p+30)z0x1.2e817edd3d6fap+30z0x1.eb0814f1e9602p+29)z0x1.0d3a6e3d04245p+29z0x1.32a62fea52352p+30)z0x1.888e19611bfc5p+29z0x1.52b8e70b24353p+29)z0x1.538816d48a13fp+29z0x1.7967c5ca43e16p+29)z0x1.57b47b7234530p+29z0x1.74e2c7040e772p+29)z0x1.821b685e9b168p+30z0x1.677dc1c1e3dc6p+29)z0x1.9e8247f67097bp+29z0x1.24bd2dc4f4baep+29)z0x1.b73b59e0cb5f9p+29z0x1.da899ab784a97p+28)z0x1.94a8d2842a7cfp+30z0x1.326a51d4d8d8ap+30)z0x1.e930b9cd99035p+29z0x1.5a1030e18dff9p+30)z0x1.1592bbb0e4690p+29z0x1.a9c337b33fb9ap+29)z0x1.1243a50751fd4p+29z0x1.a5a10175622d9p+29)z0x1.57a8596e74722p+30z0x1.42d1af9d04da9p+30)z0x1.ee7dbd9565899p+29z0x1.7ab4d6fc6e4b4p+29)z0x1.5c6bfbec5c4dcp+30z0x1.02511184b4970p+30)z0x1.59dcebba995cap+30z0x1.50ca7e7c38854p+29)z0x1.768cdd94cf5aap+29z0x1.9cfdc5571d38ep+29)z0x1.dcf137d60262ep+29z0x1.1101621990b3ep+30)z0x1.3a2d006e288b0p+30z0x1.e9a240914326cp+29)z0x1.62a32f7f53c61p+29z0x1.47eb6cd72684fp+29)z0x1.d3bcb60748ef2p+29z0x1.3f13c4056312cp+30)z0x1.282bdb82f17f3p+30z0x1.640ba4c4eed3ap+30)z0x1.89d8c423ea0c6p+29z0x1.d35dcfe902bc3p+29)hxhyrr\rH)rRrrrrContextr:r@subTestlocalcontextrsr)	r`rrrhigh_precisionrrrr\zs	         rtestHypotAccuracyzMathTests.testHypotAccuracyBs

// c2$
*	1FBJ

b!A

b!Aa15
1)).9Fwqz1}wqz1}<BBDEAF  q!a0
1
1O*	1PFF
1
1s$>C;/C/!C;/C84C;;D	c>ddlm}ddlm}tj
}tj}|j|ddd|j|dddtd	D]}td
D]q}tdt|D}tdt|D}|j||||td
t||Ds|j|gdgdd|j|tgdtgdd|j|ddd|j|ddd|j||d|df|d|df|d|j||dd|ddf|dd|ddf|dd|j|dd|d|j|ddd|j|ddd|jdt	jd|d d!|jdt	jd|d!d |j|d"d#|d$d#Gd%d&t}	|j||	ddd|jt 5|dd'(ddd|jt 5|dddd|jt 5|dd'd)ddd|jt 5|ddddd|jt 5|d*dddd|jt"5|d+d,ddd|jt"5|dd-ddd|jt 5|d.d/dddd0t$j&j(d
zz}
|jt"t*f5|d|
fd1ddd|jt"t*f5|d1d|
fdddtd2D]Q}t-j,t-j,}}|j||f|ft/||z
St0d3d4dd5t2t4g}t7j8|d67D]}t7j8|d67D]}t||D
cgc]
\}}
||
z
}}}
t;t=tj>|r|j|||t2et;t=tj@|s|jCt	j@|||tDd8z}tdD]}|f|z}d!|z}|jCt	jF||||t	j|z|jCt	jF||||t	j|ztdD]l}tHd|zz}d9|zd6|zf}d:}|jt	j
||d
|z|jt	j
||d
|zny#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swY}xYw#1swYcxYw#1swY!xYw#1swYxYwcc}
}w);Nrrbrc)rrr)rrrrrrHr)rrHr	rwc3HK|]}tjddywrwNr9uniformrgks  rrhz%MathTests.testDist.<locals>.<genexpr>BA&..Q/B "c3HK|]}tjddywrrrs  rrhz%MathTests.testDist.<locals>.<genexpr>rrc32K|]\}}||z
dzyw)rNrj)rgpxqxs   rrhz%MathTests.testDist.<locals>.<genexpr>sF&"bb2g#-Fs)g,@r)rrri)r)rHrjrrrHrrU)TTFTF)TFTTFr)*@g)@
rrjr)r)r)rrr)rrr)rrrceZdZy)MathTests.testDist.<locals>.TNrnrjrrTrrrr)rrwrXpq)r<rr)rnrorp)rrHrr)rwrXr<)rrwrXr<abcxyzr)rHrrkrrlrrepeatrr)rr)%rrrqrdrRdistrsrrtuplervrwzipiterrrrrr>r#rxrr9r&rrr	itertoolsproductanymaprTrSrryrzr{)r`DFrrsr#rHrrrr|valuesrrdiffsr}rrDr~s                   rtestDistzMathTests.testDists(+yyyy	
o/?@#Fi4c:q	A1X
BqBBBqBB&&AJFC1IFFG
		
o/?@#Fd?3T:J5KLcR	
k;7>gw/4quadmadAbE];QrUCqRy!Ar(3a2h"b	5JK2r	$>>@c	$
	
224		
b"s+MM#tGV45	
	
MM#tFG45	
	
),),	
		a	lZ93?

y
)	+9	*	+


y
)	O	


y
)	2Iy1	2


y
)	AJ	


y
)	2%y1	2


z
*	*y)	*


z
*	*L)	*


y
)		 "s~~'@'@1'D E



M:
;	5!*+V4	5



M:
;	5!234	5r	;A==?FMMOqAT1$-s1q5z:	;
tS$S9""6!4	<A&&va8
</21ay9VRb99s4::u-.$$T!QZ5TZZ/0OODJJtAqz$:;
<	<O	r	PAq A
AOODLLaY15MNOOODLLaY15MNO		P9	7Cs
*E5!E'"AATYYq!_ag6TYYq!_ag6	7a	+	+			2	2			2	2	*	*	*	*			5	5	5	5:s~5\	\$\1+
\>
]9
] 
]%
]2]?^^
\!$\.1\;>]]]"%]/2]<?^	^c|jt5tjddggddddy#1swYyxYw)NrrH)rrrw)rrrRrrds rtest_math_dist_leakzMathTests.test_math_dist_leaks7


z
*	)IIq!fi(	)	)	)s	:Ac	ttdttddztddDcgc]}tddD]
}d|z|zc}}zd	d
zddzgz}|D]}|j|
5tj|}|jt
|t|j||z||j||dz|dzzddd|jt5tjddddtjd}|jt
|t|j|dtjd}|jt
|t|j|dGddt}tj|d}|jt
|t|j|d|jt5tj|ddddddtjddddg}|D]P}|j|
5|jt 5tj|ddddddRycc}}w#1swYXxYw#1swYxYw#1swYxYw#1swY@xYw#1swYxYw)NriX>i(F<r=i(rHri'rir]rrTFrceZdZdZdZy)(MathTests.testIsqrt.<locals>.IntegerLikec||_yr\r]r_s  rraz1MathTests.testIsqrt.<locals>.IntegerLike.__init__s	"
rc|jSr\r]rds rrsz2MathTests.testIsqrt.<locals>.IntegerLike.__index__szz!rNrtrjrrIntegerLikers
#
"rrir
rreza stringz3.5y@gY@r)listrrrRisqrtassertIsrrQassertLessEqual
assertLessrrrobjectrrr)r`r~r#rDr^rIr
bad_valuess        r	testIsqrtzMathTests.testIsqrts
t5|45
6!&r3HAsBHAq!taxHxH
I$wD!
"	!	4EE*
4JJu%

d1gs+$$QqS%0!ac{3	
4
4	4

z
*	JJrN	
JJt

d1gs#AJJu

d1gs#A	"&	"
JJ{4()

d1gs#B


z
*	(JJ{2'	(

W__U3T4

 	&EE*
&&&y1&JJu%&
&
&	&WI

4
4		.	(	(&&
&
&sN J4A%J:KK5K,K !K,:K	KK K)%K,,K5	c0tj}|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|dd	d
|j|d	dd
|j|dd
dd}d}dD]}||z}||z}||z|z}|j|||||j|||||j|||||j|||||j|||||j|||||j|||||j|||||j|d|j|dd|j|dd|j|dd	dd|j|ddd	d|jt|d|jt|dd	|jt|dd|jt|ddd|j|tdtd	d
y)Nrrrr<rMrNiYrOrPiHrRrSrTl ,`aUx-xB:Vn
Ldblme%Y%l};T^	)rVl|/Kr2rWi7rYrZ)rRlcmrrrrp)r`rrr\r]r^r_ds        rtest_lcmzMathTests.test_lcm,shhQA&QA&RQ'QA&QQ'QA&QQ'S"s+S"s+R,98:R	T
! (	-AAAAAA	ASAY*SAY*S!QZ+SQBZ+SQBZ+S!QZ+S!aR[!,S!aR[!,	-	
"S3'TC(S"c*E2S!R!,)S%0)S%4)S#t4)S#q$7[-{2?Erc	|jttj|j	dtjddd|j	dtjddd|j	dtjddd|j	d	tjddd
|jt
tjdd|jt
tjd
d|j
tjddd|j
tjd
dd|j
tjtdt|j
tjtdt|jtjtjtddddddzfD]j}|j
tjt|t|j
tjt|t|j
tjd|d|j
tjd
|d|j
tjd|d|j
tjd|d|jtjtjt||jt
tjd||jt
tjd
||j
tjd|d|j
tjd|d|j
tjt|t|j
tjt|t|jtjtjt|my)Nz
ldexp(0,1)rrz
ldexp(1,1)rHzldexp(1,-1)rrzldexp(-1,1)rrrrirri+ild(	 Fx:^Vrr)rrrRr%r{rrrrrrSrr`rs  r	testLdexpzMathTests.testLdexpXs)TZZ0

<Aa!4

<Aa!4

=$**Qr"2C8

=$**R"2B7-RA-S'BB126C2C8C,c2D$/6

4::c1#567R0	<ATZZaR0#6TZZqb148TZZQB/4TZZaR0#6TZZQB/4TZZaR0#6OODJJtzz#r':;<mTZZQ?mTZZa@TZZA.3TZZQ/5TZZQ/5TZZa0$7OODJJtzz#q'9:;	<rct|jttj|j	dtjdtj
zd|j	dtjdd|j	dtjtj
d|j	dtjdd	d
|j	dtjdd
zdd
|j	dtjdd
zdd	|j	dtjddzd|jttjd|jttjddz|jttjt|jtjtt|jtjtjty)Nzlog(1/e)rrzlog(1)rzlog(e)z	log(32,2)rUrHrwzlog(10**40, 10)rrzlog(10**40, 10**20)rz
log(10**1000)rgO+@r)
rrrRlogr{r~rrrrrrSrrds rtestLogzMathTests.testLogxsc)TXX.

:txx$&&126

8TXXa[!,

8TXXdff-q1

;A2

$dhhr2vr&:B?

($((2r66*BAF

?DHHRX$6%	'*dhh5*dhhT	:*dhh5#,

488C=12rc	|jttjdddzddzfD]C}|j	tj|tjt|E|jttjd|jtjtty)NrHZi,r)	rrrRlog1prvr:rrrrs  r	testLog1pzMathTests.testLog1ps)TZZ0QUAsF#	HA""4::a=$**U1X2FG	H*djj"5C#.rc,|jttj|j	tjdd|j	tjdd|j	tjdd|j	tjddzd|j	tjdd	zd
|j	tjddzd|jt
tjd
|jt
tjt|jtjtjty)NrrrHrrrig@g@ig@@r)
rrrRlog2rrrrrSrrds rtestLog2zMathTests.testLog2s)TYY/	
1s+1s+1s+	
1d7+V41d7+V41d7+V4*dii6*dii6

499S>23rrc	tddDcgc]+}tjtjd|-}}tddDcgc]
}t	|}}|j||ycc}wcc}w)Nr6rr)rrRrr%r:r)r`rrGr(s    r
testLog2ExactzMathTests.testLog2Exactsi
:?ud9KLA$))DJJsA./LL&+E4&89E!H99*M9s0A6A;c@|jttj|j	dtjdd|j	dtjdd|j	dtjdd|j	d	tjdd
zd|jt
tjd|jt
tjdd
z|jt
tjt|jtjtt|jtjtjty)
Nz
log10(0.1)皙?rzlog10(1)rrz	log10(10)rzlog10(10**1000)rg@@r)
rrrRlog10r{rrrrrrrSrrds r	testLog10zMathTests.testLog10s)TZZ0

<C"5

:tzz!}a0

;

22

$djjT&:FC*djj$7*djj2t8)<*djj$7#,

4::c?34rctj}tj}tj
}|j
|tgddd|j
|ddgddgd|j
|ggd	dd
|dd|d
df|d|dfdd|ddfd|ddfd|dffD]}||f||dddffD]~\}}|j||5tdt||dD}|||}|j
|||j
t|t|ddd|jt||jt|g|jt|ggg|jt|ddg|jt|dgd|jt|ddgdg|jt|dgddgd}	|jt5|t!d|	dddd|jt5||	dt!ddddGdd}
|jt5|d|
dggdddd|jt5|gdd|
dgddd|jt5|ddgddgddd|jt5|ddgddgddd|j
|dtj"gddgtj"|j
|dtj"gtj"dgtj"|j
|dtj"gtj"tj"gtj"|j
|dtj"gddgtj"|j%tj&|dtj"gtj"tj"g|j%tj&|dtj(gddg|j%tj&|dtj"gtj(dg|j%tj&|dtj"gdtj(gd }|j
||d!y#1swYxYw#1swYdxYw#1swY;xYw#1swY
xYw#1swYxYw#1swYxYw#1swYxYw)"N)rrrrr@reg@g0@r)rgrrwr)rrrrc3,K|]\}}||zywr\rj)rgp_iq_is   rrhz(MathTests.testSumProd.<locals>.<genexpr>s"Tc39"TsTstrictrrrc3>Kt|D]}|twr\)rRuntimeError)rr#s  rraise_afterz*MathTests.testSumProd.<locals>.raise_afters$1X

sceZdZdZdZy)*MathTests.testSumProd.<locals>.BadMultiplyctr\rr`others  r__mul__z2MathTests.testSumProd.<locals>.BadMultiply.__mul__""rctr\rrs  r__rmul__z3MathTests.testSumProd.<locals>.BadMultiply.__rmul__rrN)rgrhrirrrjrrBadMultiplyrs
#
#rrrg333333$@g3333334@gL>@gL4@))rrr)rr)rRsumprodrrrqrdrrrrwrrrrrrrrrrSr)r`rrrdrJrrr(rGrrrs            rtestSumProdzMathTests.testSumProds,,//%%	
l!3Y?E#sc3Z8$?R!,

a^Xa^,
S\73<(
(1a.!
!Q 
	
	CAQ!QttW.
C1\\A\+C""TSAd=S"TTH$Q]F$$Xv6$$T(^T&\B	CC
C	C$	
)W-)Wb1)Wb"b9)WdRD9)WrdD9	
*gBx">*gtb"X>	

|
,	/E"I{1~.	/


|
,	/KNE"I.	/	#	#


|
,	8R+Y7	8


|
,	8IKM267	8

y
)	)UAJB(	)


y
)	)QGeQZ(	)	
$!1D$<@$((K$!1DHHd3CDdhhO$!1DHHdhh3GH$((S$	!2T4LADHH9M

7D$((+;txxi=R#STU

7D$((+;dD\#JKL

7D$((+;dhh=M#NOP

7D$((+;dDHH=M#NOPO$-qCC,	/	/	/	/	8	8	8	8	)	)	)	)sU7AV'V"V/V<W	?W*W#V"V,/V9<W	WW #W-zBsumprod() accuracy not guaranteed on machines with double roundingctj}|j|dgdzdgdzd|j|dgdzddgdzd|j|gddgd	zd
y)NrrrrrTF)rg\nTrg\nrr)rRrr)r`rs  rtest_sumprod_accuracyzMathTests.test_sumprod_accuracyst
,,#aSV4c:#dE]R-?@#F!<seAgFLrcpucPtj}tj}tj
}tj}GfddtGfddt}d}d}ddd	d
ddd
ddzddf
ddddzzdddzzdddzzdddddddzf	dd d!td"td"td#d$d%d&|d'd(fd)d*|d+|d,|d'd-|d.d/d0d1d2df
|d3|d4|d5|d6|d7|d7|d#d8d9f	d:dddzzddd;d<d=d>fd?d@dAdBdCdDdEddFfg	}|D]U}	tdGD]E}
||	|
HD]6}||	|
HD]'}||f}
|j||g|
||g|
|
)8GWy)INc0eZdZfdZfdZeZeZdZy)*MathTests.test_sumprod_stress.<locals>.Intc>t|t|zSr\rQr`rInts  r__add__z2MathTests.test_sumprod_stress.<locals>.Int.__add__3t9s5z122rc>t|t|zSr\rrs  rrz2MathTests.test_sumprod_stress.<locals>.Int.__mul__r	rc dt|dS)NzInt()rrds r__repr__z3MathTests.test_sumprod_stress.<locals>.Int.__repr__c$i[**rNrgrhrirr__radd__rr
rsrrr
3
3HH
+rrc0eZdZfdZfdZeZeZdZy)*MathTests.test_sumprod_stress.<locals>.Fltc>t|t|zSr\rrs  rrz2MathTests.test_sumprod_stress.<locals>.Flt.__add__#r	rc>t|t|zSr\rrs  rrz2MathTests.test_sumprod_stress.<locals>.Flt.__mul__%r	rc dt|dS)NzFlt(rrrds rr
z3MathTests.test_sumprod_stress.<locals>.Flt.__repr__)rrNrrsrFltr"rrrcFd}t||dD]
\}}|||zz
}|S)zThis defines the target behavior including expections and special values.
            However, it is subject to rounding errors, so float inputs should be exactly
            representable with only a few bits.
            rTr)r)rrrrrs     rbaseline_sumprodz7MathTests.test_sumprod_stress.<locals>.baseline_sumprod,s8
E1T2
#Ss"
#Lrc	||}dt|t	|fS#ttf$rt$r}t|ddfcYd}~Sd}~wwxYw)zHMake comparing functions easier. Returns error status, type, and result.NNone)AssertionError	NameError	Exceptionrrepr)funcrrr~s    rrunz*MathTests.test_sumprod_stress.<locals>.run6sZ
-t
ftF|33	#I.

-Awf,,
-sA
A	A	ArrillrrrHPrr<)	@gg@&@gy@g??rg3rrrii:,r$rg8rig@rrrNaNrry@@rjrrgz10.5z-2.25riy@?aiz6.125z12.375z-2.75rInfrQg+@gplgpg`g)g<gr'gr%ggg`7@TFrwrr)rRrrrrrrqrdrQr:rr)r`rrrrdrrr"poolspoolsizeargs1args2rrs              @rtest_sumprod_stresszMathTests.test_sumprod_stresss
,,##//%%	+#	+	+%	+		4VUE5%BSVLM
1c6\2ag:r!T'z8UNQ3
8
3eElU5\M5<4R#
'
E76?GG,<hr1o#r"M2sCF
D
W
wx0''2BGAJ'%.'%."d
L
Bq$wJ1iZ
A
E6643q6B
"		Da
$T$7E!(d!; %u~(( 0848/$/ 
		rc	R	

ddlddlmddlmddlm}ddlmm	m
ddlm
m
mddlm}|dd	fd
fdd
f	d
	fd
	
fdd}dd|fdt#|D}|j%|dy)Nrrc)starmap)
namedtuple)rrr)choicesrr;)median
DotExample)rr\target_sumprod	conditionc
t|}t|}tjt||dS)NTr)rrwmulr)rr\vec1vec2rdoperatorr5s    rDotExactzDMathTests.test_sumprod_extended_precision_accuracy.<locals>.DotExactls:x#Dx#Dwx||StD-IJKKrczdtt|tt|zt||zS)Nr)rr&)rr\rAs  r	ConditionzEMathTests.test_sumprod_extended_precision_accuracy.<locals>.Conditionqs1#c1+s3{;;c(1a.>QQQrc`||z
|dz
z}t|Dcgc]
}|||zzc}Scc}wNr)r)lohirwidthr#s     rlinspacezDMathTests.test_sumprod_extended_precision_accuracy.<locals>.linspacets4"WQ'E,1!H5qBN555s+c	|dz}dg|z}dg|z}|}
tt|dz|}t|dzdz|d<d|d<|Dcgc]}dd|zc}|d	||Dcgc]}dd|zc}|d	|ttt|dzd||z
}t||D]H}dd|||z
z||<dd|||z
z||z
||z||<Jtt||}	|	t|	\}}||||
||Scc}wcc}w)
a Algorithm 6.1 (GenDot) works as follows. The condition number (5.7) of
            the dot product xT y is proportional to the degree of cancellation. In
            order to achieve a prescribed cancellation, we generate the first half of
            the vectors x and y randomly within a large exponent range. This range is
            chosen according to the anticipated condition number. The second half of x
            and y is then constructed choosing xi randomly with decreasing exponent,
            and calculating yi such that some cancellation occurs. Finally, we permute
            the vectors x, y randomly and calculate the achieved condition number.
            rHr)rrrrrrN)rrQrrroundr)rr]n2rr\r_r~rr#pairsrCrAr9r7rrIrr;rs          rGenDotzBMathTests.test_sumprod_extended_precision_accuracy.<locals>.GenDotxsaB	A	AQAc!A#h2.Aq1u:>AaDAbE<=>qgdC(472>AcrF<=>qgdC(472>AcrFS1cAbD 9:;A2q\
VtS)D1r6O;!c*T!AF)_<x1~MQRSTQUU!
V
QOEEN;DAqaHQNIaODD?>sE:Ecp|\}}}}t||gzt|dgz}||zSrE)r)	resexrr\r:r;rrArs	       r
RelativeErrorzIMathTests.test_sumprod_extended_precision_accuracy.<locals>.RelativeErrorsD.0+Aq.)aSD6)47aS=9AN*++rcbd|}||j|j}||S)Nr)rr\)dotfuncr]rrQrPrNrRs     rTrialzAMathTests.test_sumprod_extended_precision_accuracy.<locals>.Trials/AB"$$%C b))rrrgꌠ9Y>)Fc3NK|]}tjywr\)rRr)rgr#rUr]rs  rrhzEMathTests.test_sumprod_extended_precision_accuracy.<locals>.<genexpr>sNAeDLL!Q7Ns"%r5)r@rqrdrr5collectionsr6rRrrrr9r7rr;
statisticsr8rr)r`r6r8timesrelative_errrCrAr9rdrNrRrUr]r7rrrIrrr@r;r5rs     @@@@@@@@@@@@@@@@@@r(test_sumprod_extended_precision_accuracyz2MathTests.test_sumprod_extended_precision_accuracy\s	&%*))44%.WX
	L
	R	6$	E$	EL	,
	*
NuNNe,rcVjttjfd}|dtjdd|dtjddj	tjt
dt
fj	tjtd	tftjt}jtj|d
jtj|dy)Nc||c\}}\}}t||z
tkDst||z
rj|d|d|yyrr)rzrr(v1v2e1e2r`s       rtestmodfz$MathTests.testModf.<locals>.testmodfsN!'HRhr22b5zC3r"u:		34$.rz	modf(1.5)r)rrz
modf(-1.5)r)rrrrrr)
rrrRmodfrrrrrrS)r`rbmodf_nans`  rtestModfzMathTests.testModfs)TYY/	4	diinj9tyy=3#s444,799S>

8A;/0

8A;/0rct%|jttj|j	dtjddd|j	dtjddd|j	dtjddd|j	dtjddd	|jtjtdt|jtjtdt|jtjdtd
|jtjdtd
|jtjtjtd|jtjtjdt|jtjtjdt|jtjdtd|jtjdtd|jtjddd|jtjdd
d|jtjddd|jtjddd
|jtjddd
|jttjdd|jttjdd|jttjdd|jtjdtt|jtjtjdt|jtjttt|jtjtdt|jtjtd
t|jtjtdt|jtjtdd
|jtjtdd
|jtjtdd|jtjtdd|jtjtdd|jtjttd|jtjtjtt|jtjdtd|jtjddd|jtjdd
d|jtjddd|jtjddd
|jtjddd
|jttjdd|jttjdd|jttjdd|jtjdtt|jtjtjdt|jtjttt|jtjtdt|jtjtd
t|jtjtdt|jtjtdd
|jtjtdd
|jtjtdd|jtjtdd|jtjtdd|jtjttd|jtjtjtt|jtjdtd
|jtjddd|jttjdd
|jtjddd
|jtjddd
|jtjddd
|jtjddd
|jttjdd|jtjddd|jtjdtd
|jtjtjdt|jtjd
td
|jtjd
dd
|jtjd
d
d
|jtjd
dd
|jtjd
dd
|jtjd
dd
|jtjd
dd
|jtjd
dd
|jtjd
dd
|jtjd
td
|jtjd
td
|jtjd
dd
|jtjddd
|jtjtdd
|jtjd
dd
|jtjddd
|jtjtdd
|jttjdd
|jttjdd|jtjdtd|jtjdtd|jtjdtt|jtjdtt|jtjdtt|jtjdtt|jtjdtd|jtjdtd|jtjdtt|jtjdtt|jtjdtd|jtjdtd|jtjdtd|jtjdtd|jtjdtt|jtjdtt|j	dtjddd|j	d tjddd!|j	d"tjdd
d|j	d#tjddd
|j	d$tjddd
|j	d%tjddd&|j	d'tjddd(|j	d)tjddd*|jttjdd&|jttjdd	y)+Nzpow(0,1)rrzpow(1,0)zpow(2,1)rHz	pow(2,-1)rrrrrrrrgrrrg.ggffffff?rn?rggggffffffz	(-2.)**3.g z	(-2.)**2.rz	(-2.)**1.z	(-2.)**0.z
(-2.)**-0.z
(-2.)**-1.rz
(-2.)**-2.r&z
(-2.)**-3.g)rrrRpowr{rrrrrSrrrds rtestPowzMathTests.testPows)TXX.

:txx!}a0

:txx!}a0

:txx!}a0

;24#q)3/$*D1$((1c*R0$((1d+b1

488C#345

488As#345

488As#345!S)1-	
"c*B/"b)2."c*B/"b)2."b)2."c*B/*dhhC8*dhhD9*dhhC8"d+S1

488B#456	
#s+S1#r*C0#s+S1#r*C0#r*B/#s+R0#s+R0#t,b1#s+R0#t,b1

488C#567	
#s+R0#r*C0#s+R0#r*B/#r*B/#s+R0*dhhS9*dhhT:*dhhS9#t,c2

488C#567	
$,c2$+T2$,c2$+S1$+R0$,b1$,b1$-r2$,c2$-r2

488D##678	
#s+R0#r*C0*dhhS9#r*B/#r*B/#s+R0#s+R0*dhhT:#s+S1#t,b1

488C#567	
"c*B/"b)2."c*B/"b)2."b)2."c*B/"c*B/"d+R0"c*B/"d+R0"c*B/	
#r*B/$+R0#r*B/#s+R0$,b1#s+R0	
*dhhS9*dhhd;	
#t,b1#t,b1#t,c2#t,c2$-s3$-s3$-r2$-r2	
#s+S1#s+S1#s+R0#s+R0$,b1$,b1$,c2$,c2	

;s 3T:

;s 3S9

;s 3T:

;s 3S9

<$!5s;

<$!5t<

<$!5t<

<$!5v>*dhhd;*dhhc:rc|jttj|j	dtjdtj
|j	dtjdtj
dz|j	dtjdtj
dz|j	d	tjd
d
y)Nzradians(180)zradians(90)rrHzradians(-45)irz
radians(0)r)rrrRradiansr{r}rds rtestRadianszMathTests.testRadians\s)T\\2

>4<<#4dgg>

=$,,r"2DGGAI>

>4<<#4twwhqjA

<a!4rcddlmfd}gd}|D]}j|5|j\}}}tj|}tj|}tj|}	||||	t
j||}
j|
j|	jdddtjd}tddD]d}|dk(r	||z}td	D]I}
|
|z}t
j||}
||||
t
j||}
||||
Kftd
ddd
ttfD]T}jt
jt|jt
j|tVdD]V}jt
j|t|jt
j|t|Xtd
dd
dtfD]}jt 5t
jt|dddjt 5t
jt|dddjt 5t
j|d
dddjt 5t
j|ddddy#1swYxYw#1swYxYw#1swYxYw#1swYexYw#1swYxYw)NrrccB|||}}}jt|t|dz||z
|z}j|t|t|t|dzk(r"j|dzt|dzyy)z
            Check that r matches remainder(x, y) according to the IEEE 754
            specification. Assumes that x, y and r are finite and y is nonzero.
            rHN)rr&rrQ)	rr\rfxfyfrrrdr`s	       r
validate_specz.MathTests.testRemainder.<locals>.validate_specgs
"!hqk8A;BB  R#bd)4bBAQA'2w#bd)#  1c!A#h/$r)0z-4.0 1 -0.0z-3.8 1  0.8z-3.0 1 -0.0z-2.8 1 -0.8z-2.0 1 -0.0z-1.8 1  0.8z-1.0 1 -0.0z-0.8 1 -0.8z-0.0 1 -0.0z 0.0 1  0.0z 0.8 1  0.8z 1.0 1  0.0z 1.8 1 -0.8z 2.0 1  0.0z 2.8 1  0.8z 3.0 1  0.0z 3.8 1 -0.8z 4.0 1  0.0z&0x0.0p+0 0x1.921fb54442d18p+2 0x0.0p+0z?0x1.921fb54442d18p+0 0x1.921fb54442d18p+2  0x1.921fb54442d18p+0z?0x1.921fb54442d17p+1 0x1.921fb54442d18p+2  0x1.921fb54442d17p+1z?0x1.921fb54442d18p+1 0x1.921fb54442d18p+2  0x1.921fb54442d18p+1z?0x1.921fb54442d19p+1 0x1.921fb54442d18p+2 -0x1.921fb54442d17p+1z?0x1.921fb54442d17p+2 0x1.921fb54442d18p+2 -0x0.0000000000001p+2z00x1.921fb54442d18p+2 0x1.921fb54442d18p+2  0x0p0z?0x1.921fb54442d19p+2 0x1.921fb54442d18p+2  0x0.0000000000001p+2z?0x1.2d97c7f3321d1p+3 0x1.921fb54442d18p+2  0x1.921fb54442d14p+1z?0x1.2d97c7f3321d2p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d18p+1z?0x1.2d97c7f3321d3p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1z?0x1.921fb54442d17p+3 0x1.921fb54442d18p+2 -0x0.0000000000001p+3z00x1.921fb54442d18p+3 0x1.921fb54442d18p+2  0x0p0z?0x1.921fb54442d19p+3 0x1.921fb54442d18p+2  0x0.0000000000001p+3z?0x1.f6a7a2955385dp+3 0x1.921fb54442d18p+2  0x1.921fb54442d14p+1z?0x1.f6a7a2955385ep+3 0x1.921fb54442d18p+2  0x1.921fb54442d18p+1z?0x1.f6a7a2955385fp+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1z?0x1.1475cc9eedf00p+5 0x1.921fb54442d18p+2  0x1.921fb54442d10p+1z?0x1.1475cc9eedf01p+5 0x1.921fb54442d18p+2 -0x1.921fb54442d10p+1z 1  0.c  0.4z-1  0.c -0.4z 1 -0.c  0.4z-1 -0.c -0.4z 1.4  0.c -0.4z-1.4  0.c  0.4z 1.4 -0.c -0.4z-1.4 -0.c  0.4z$0x1.dp+1023 0x1.4p+1023  0x0.9p+1023z$0x1.ep+1023 0x1.4p+1023 -0x0.ap+1023z$0x1.fp+1023 0x1.4p+1023 -0x0.9p+1023)casez1p-1074irrrrrr)rrrrr)rqrdrr9r:r@rR	remainderrhexrrrrassertIsNaNrr)r`rt	testcasesrux_hexy_hexexpected_hexrr\r(rGtinyrmr^rds`              @r
testRemainderzMathTests.testRemaindercs&
	0 9
	v
	?D4(	
?-1ZZ\*ulMM%(MM%( ==6aH-1-  x||~>	
?	
?
	?}}Y'sB		-AAvDA3Z
-H1-aF+A.qb!V,
-			-3c4s;	9ET^^C78T^^E378	9
,	AET^^E37?T^^E48%@	AD$S#6	,E"":.
+sE*
+"":.
,tU+
,"":.
+uc*
+"":.
,ud+
,
,	,O	
?	
?P
+
+
,
,
+
+
,
,s<B"L
L L,=L81ML	 L)	,L5	8M	M	c|jttj|j	dtjdd|j	dtjtj
dzd|j	dtjtj
dzd	|j
tjtjt|j
tjtjt|j
tjtjty#t$rU|jttjt|jttjtYwxYw)Nzsin(0)rz	sin(pi/2)rHrz
sin(-pi/2)r)rrrRrur{r}rrSrrrrrds rtestSinzMathTests.testSins
)TXX.

8TXXa[!,

; 3Q7

<477(1*!5r:	:OODJJtxx}56OODJJtxx~67	


488C=12	:j$((C8j$((D9	:s;A6E--AG
Gc|jttj|j	dtjdd|j	dtjddztj
ddzz
d|j	dtjdtjdzd|j
tjtt|j
tjtt|jtjtjty)Nzsinh(0)rzsinh(1)**2-cosh(1)**2rrHrzsinh(1)+sinh(-1))rrrRsinhr{rrrrrrSrrds rtestSinhzMathTests.testSinhs)TYY/

9diilA.

*DIIaL!ODIIaL!O,KRP

%tyy|DIIbM'A1E3-4$/

499S>23rc|jttj|j	dtjdd|j	dtjdd|j	dtjdd|j	dtjdd	|j	d
tjdd|j	d
tjdd|j	dtjdd|jtjtt|jttjd|jttjt|jtjtjty)Nzsqrt(0)rrz	sqrt(2.5)rgS[:XL?z
sqrt(0.25)r&rzsqrt(25.25)g@9@g)#L@zsqrt(1)rzsqrt(4)rrHr)rrrRrsr{rrrrrrSrrds rtestSqrtzMathTests.testSqrts")TYY/

9diilA.

9diinc2

;		#0BC

<4#6

=$))E"24EF

9diilA.

9diilA.3-*dii4*dii6

499S>23rc|jttj|j	dtjdd|j	dtjtj
dzd|j	dtjtj
dzd	|j
tjtjt|j
tjtjt|j
tjtjty#|jttjt|jttjtYxYw)Nztan(0)rz	tan(pi/4)rrz
tan(-pi/4)r)rrrRtanr{r}rrSrrrrrds rtestTanzMathTests.testTans)TXX.

8TXXa[!,

; 3Q7

<477(1*!5r:	:OODJJtxx}56OODJJtxx~67	


488C=12	:j$((C8j$((D9s;A6E--AGcX|jttj|j	dtjdd|j	dtjdtjdzdtj
d|j	dtjtd|j	dtjtd|jtjtjty)	Nztanh(0)rztanh(1)+tanh(-1)rrrz	tanh(inf)z
tanh(-inf))rrrRtanhr{rrrrrSrrds rtestTanhzMathTests.testTanhs)TYY/

9diilA.

%tyy|DIIbM'A188A;		(

;		#2

<4"5

499S>23rc|jtjdd|jtjdtjdtjddy)Nrr)rrRrrrds rtestTanhSignzMathTests.testTanhSignsM	
3-r499S>:r3/	1rcN|jtjdd|jtjdd|jttjdt|jttjdt|jtjdd|jtjdd|jtjdd|jtjdd|jtjdd|jtjd	d
Gdd}Gd
dt
}Gdd}|jtj|d|jtj|d|j
ttj|j
ttjdd|j
ttjtd|j
ttj|y)Nrrrrg?gg!rg-?YiceZdZdZy)'MathTests.test_trunc.<locals>.TestTrunccyNrjrds r	__trunc__z1MathTests.test_trunc.<locals>.TestTrunc.__trunc__2rrNrgrhrirrjrr	TestTruncr1rrrceZdZdZy)(MathTests.test_trunc.<locals>.FloatTrunccyrrjrds rrz2MathTests.test_trunc.<locals>.FloatTrunc.__trunc__5rrNrrjrr
FloatTruncr4rrrceZdZy))MathTests.test_trunc.<locals>.TestNoTruncNrnrjrrTestNoTruncr7rrrrrHg7@)	rrRtruncrrQr:rrrZ)r`rrrs    r
test_trunczMathTests.test_trunc%sA*B,djjm,c2djjo.4C!,D)2.H-q1I.3I.3H-t4							
IK0"5JL126)TZZ0)TZZA6)TZZ4A)TZZ?rc2|jtjd|jtjd|jtjd|jtjd|jtjt	d|jtjt	d|jtjt	dy)Nrrrrrrr)rrRisfiniteassertFalser:rds rtestIsfinitezMathTests.testIsfiniteBs

c*+

d+,

c*+

d+,uU|45uU|45uV}56rc|jtjtd|jtjtd|jtjtddz|j	tjtd|j	tjd|j	tjdy)Nrz-nanrrr)rrRrSr:rrds r	testIsnanzMathTests.testIsnanKs

5<01

5=12

5<"#456E%L12B(B(rc2|jtjtd|jtjtd|jtjd|jtjd|j	tjtd|j	tjd|j	tjdy)Nrrggrrr)rrRrTr:rrds r	testIsinfzMathTests.testIsinfSs

5<01

5=12

5)*

6*+E%L12B(B(rc|jtjtj|j	tj
dtjdy)Nr)rrRrSrrrrds rtest_nan_constantzMathTests.test_nan_constant\s:

488,-r4884b9rcN|jtjtj|j	tjd|jtjt
d|jtjt
dy)Nrrr)rrRrTr
assertGreaterrr:rds rtest_inf_constantzMathTests.test_inf_constantasa

488,-488S)5<0$((E&M2rzrequires verbose modecd	tjd}dk7r|jd	tjd}|jd	tjd}|jdy#|jdYzxYw#t$rYKwxYw#t
$rYywxYw)	Ni6ez6underflowing exp() should not have raised an exceptionrz)underflowing exp() should have returned 0iʚ;z.overflowing exp() didn't trigger OverflowErrorrz sqrt(-1) didn't raise ValueError)rRrDryrrsrr`rs  rtest_exceptionszMathTests.test_exceptionsls	(%A
6IIAB	H$A
IIFG	:		$A
II895	(
II'
(				s.A<BB#<B	B B #	B/.B/cdh}d}tjdk(r@tjd}	tt	t
|j
d}d}g}ttD]\}}}}	}
}}|	dk7s|dk7r|dvr|
|dkr||vr'tt|}
d	|vsd
|vrd}
nd|vrd
}
	|
|}d\}}t|
|||}|g|j||||}|j||r$|j!ddj#|zyy#t$rYwxYw#t$rd}Yt$rd
}YwxYw)Ntan0064darwinr.{}: {}({!r}): {}r)rectpolar)rrwinvaliddivide-by-zeroroverflowrrwrzFailures in test_testfile:
  
  )r>platformmac_verrrrQr9rrN	test_filegetattrrRrrXr'rAryjoin)r`
SKIP_ON_TIGERosx_versionversion_txtrVfailuresr@rAaraiereirEr!rr*r+rUmsgs                   r
test_testfilezMathTests.test_testfiles#
<<8#"**,Q/K
#C[->->s-C$DE&-;I-F"	!)BBBESyB#I&&&;+@&4$DE!%5%>!u$$
)b &GW"2vw@G//"b"g6COOC E"	!HII6kk(+,
-U

6
&% 
)(
)s)(D!5D0!	D-,D-0E
=
E
	E
cd}g}ttD]\}}}}}tt|}d|vsd|vrd}nd|vrd}	||}	d\}
}|dk(rd	}
n$|d
k(rd}n|dk(r|d
k\r|dkrd}
n
|dkrd}
nd}
t
||	|
|}|u|j||||}
|j|
|r$|jddj|zyy#t$rd}	Yt
$rd}	YwxYw)NrrrrrrrrtrlgammagV瞯<erfcrrr$@rrzFailures in test_mtestfile:
  r)rFmath_testcasesrrRrrrXr'rAryr)r`rVrr@rArBr(rEr!r)r*r+rUrs              rtest_mtestfilezMathTests.test_mtestfilesE%,;N,K8	!(BC54$DE!%5%>'u$*
&3i &GWW}x
 v#*9 G4Z!G"G"8S'7CG//"b#w7COOC q8	!tII7kk(+,
-a
#" 
&%
&sCC1$
C10C1ctj}|j|gd|j|gdd|j|tt	ddd|j|ttt	ddd|j|t	dddd|j|gd	d
|j|gdd|j|gd
d|j|gdd|j|gdd|j|gdt
d|jt||jt|d|jt|gd|jt|gdd|jt|ddgdtdtdg}|jt||td|jt|dgdgdgg|jt|ddig|jt|ddigdzddi|jt|dgdgdggg|j|ddgdd|j|ddgddggd|j|gddiddi|jt5|ddgdddd|j|gdd|j|gd d|j|gd!dd2d"}t	dd#}|j||||t	d$d%}|j||||t	d&d'}|j||dt	dd'Dcgc]
}t
|}}|j||||t	d&d%Dcgc]
}t
|}}|j||||t	d&d'Dcgc]
}t
|}}|j|||j|dddt
d(ddg|j|ddt
d(ddg|j|dt
d(ddg|j|dt
d)t
d(dg|j|dt
d*t
d(dg|j|dt
d(t
d)dg|j|dt
d(t
d*dg|j|dddt
d)d+d,gt
d*|j|dddt
d*d+d,gt
d)|j|dddt
d)d+d,g|j|dddt
d*d+d,g|j|dddt
d)d+ddg|j|dddt
d*d+ddg|jt|gd-t|jt|gd.t|jt|t	dd#t|jt|t	dd#d/t|jt|dtjd0dd,dd1gtjy#1swYxYwcc}wcc}wcc}w)3Nrrw)rrHriri_7)rrHrrrwrO)rrrrrrY)rrHrrr)rrrrrw)rrrrr)rrrrrr)r^r_r]acrbrababababababab)rrHrrHrrHrrHrrHrrHr)rrrHrr)rrrHr)rrHrrc|D]}||z}	|Sr\rj)r*relems   r_naive_prodz(MathTests.test_prod.<locals>._naive_prod2s 


Lri'irirrrrrr)rrHrrrwrX)rrrrrwrXrrrX)r)rRprodrrrrr:rr	bytearrayrxrrQrr)r`rrrr*rs      r	test_prodzMathTests.test_prodsyyb1%b*A.d51:./6d4a
#345t<eArl"5w?o.478%@12E:34e<	
12E:56eE)T*)T2.)T?;)T?"E)TD$<sCD/9T?3)T63H)TQC!qc?;)TQqE73)TQqE719QqEB)TQC!qc?"E	
q!fD1>Bq!fQF35YZbA/!A7


y
)	"b1		
l+Q/l+Q/l+Q/	E?hX)>?$hX)>?%h+',Atn5E!H55hX)>?&+E2&67E!H77hX)>?&+E4&89E!H99h(	
q!Qea;<=q!U5\1a89:q%,1567q%,eQ?@Aq%-ua@ABq%,eQ?@Aq%,f
a@ABq!QeR:;U6]Kq!Qf
b;<eElKq1U5\2q9:;q1U6]B:;<q!Qeb!Q?@Aq!Qf
r1a@AB	
d#567=d#7895Ad5E?34c:d5E?#>?GdAws';Q1a#HIJ 	*m		.679s^01^=1_1_0^:c	tj}tj}tdD]`}|dkrt|dzn|dkrtdn
tdD]-}|j	||||||||z
z/btddD]I}td|D]8}|j	|||||dz
|dz
|z||dz
|z:KtddD]S}|j	||dd|j	||d||j	|||||UtdD]?}|j	|||||j	||d||A|jt|dd	|jt|dtjd	|jt|dd
|jt|dd|jt|tjdd|jt|dd|jt||jt|ddd
|jt||jt|dd|jt|ddzd|jt|dd|jt|dddz|j	|ddd|j	|dddzdddz}|j	||dd|j	||d||j	||d||dz
ztjdr|jt|||dD]D\}}|j	|||d|jt|||tF|j	|t!dt!dd|j	|t#dt#ddtd
D]r}|jt|t!dt!|t|jt|t#dt#|tty)Nrrrr=rrrrr1r10rrrHrTcpython)TT)TF)FFrw)rRpermrrrrrrrrrcheck_impl_detailrrrrQrmrp)r`rrrrs     rtestPermzMathTests.testPermds8yyNN	s	CA&'#geAElC59USUY
C  a!*11q51A!AC
C	Cq#	VA1a[
V  aT!a%Q-?!-Cd1q5RSn-TU
V	V
q#	7AT!QZ+T!QZ+T!QZ16	7r	:AT!Wil3T!T]IaL9	:	
)T2s3)T2ws/CD)T2s3)T43)T7??4+@!D)T43)T*)T2q!4)T*	
*dB2*dQWHa8*dAr2*dA4x8	
aQ'aD)1-
tGaQ'aQ'aQ!A#Y/$$T2mT1a8?	1DAqT!QZ+MM$tAqz*C0	1	
k!nk!n=rBk!nk!n=rBq	KAMM$tKNKNCDcJMM$tKNKNCDcJ	Krc
tj}tj}tdD]i}|dkrt|dzn|dkrtdn
tdD]6}|j	||||||||||z
zz8ktddD]F}td|D]5}|j	|||||dz
|dz
||dz
|z7HtdD]4}|j	||dd|j	|||d6tddD]7}|j	||d||j	|||dz
|9tdD]8}t|dzD]%}|j	|||||||z
':|jt|dd	|jt|dtjd	|jt|dd
|jt|dd|jt|tjdd|jt|dd|jt|d|jt|ddd
|jt||jt|dd|jt|ddzd|jt|dd|jt|dddz|j	|ddd|j	|dddzdddz}|j	||dd|j	||d||j	||d||dz
zdz|j	|||d|j	|||dz
||j	|||dz
||dz
zdztjdr|jt|||dzdD]D\}}|j	|||d|jt|||tF|j	|t!dt!dd|j	|t#dt#ddtd
D]r}|jt|t!dt!|t|jt|t#dt#|tty)Nrrrr=rrrrHrrrrrrrTrrrw)rRcombrrrrrrrrrrrrrrQrmrp)r`rrrrs     rtestCombzMathTests.testCombsyyNN	s	:A&'#geAElC59USUY
:  aYq\!!yQ'77.9:
:	:q#	RA1a[
R  aT!a%Q-?$q1ua.-PQ
R	R
s	,AT!QZ+T!QZ+	,q#	0AT!QZ+T!QU^Q/	0
s	=A16]
=  aT!QU^<
=	=	
)T2s3)T2ws/CD)T2s3)T43)T7??4+@!D)T43)T2.)T2q!4)T*	
*dB2*dQWHa8*dAr2*dA4x8	
aQ'aD)1-
tGaQ'aQ'aQ!A#Y!^4aQ'a1q)a1qAaCyA~6$$T2mT1ad;?	1DAqT!QZ+MM$tAqz*C0	1	
k!nk!n=rBk!nk!n=rBq	KAMM$tKNKNCDcJMM$tKNKNCDcJ	Krc|jtjdtd|jtjdtd|jtjddd|jtjddd|jtjd	ttjd
|jtjd	ttjd|jtjd	td
tjd
|jtjd	td
tjd|jtjd	td
tjd|jtjd	td
tjdt
ddD]z}|jtjdd|
d|jtjdd|
d|jtjdd|
d|tjjtjjz}|jtjdt||jtjdt||jtjdt||jtjdt||jtj|dd|jtj|dd|jtj|dd|jtj|ddtjj}|jtjtd||jtjtd||jtj|tt|jtj|tt|jtjtd	|jtjd	t|jtjtt|jd	tjd	td
|jt 5tjd	td
dddy#1swYyxYw)Ng0Cg/Cg0CgCrgCggrz0x1.fffffffffffffp-1z0x1.0000000000001p+0r)stepsrz0x1.ffffffffffffdp-1z0x1.0000000000003p+0rwrrrr)rrR	nextafterrr:r@rassertEqualSignr>r#minepsilonr&rxrrr)r`rsmallest_subnormallargest_normals    rtest_nextafterzMathTests.test_nextafters-	
(:SDA+	-(:C@+	-(=sC.	0(>D/	1	
cT2'=>	@S1'=>	@cT;'=>	@S:'=>	@cT;'=>	@S:'=>	@1a[	PET^^CEBCH  d%!H$O  d%!H$O	P!^^//#..2H2HHc24FGc24FGsd36H5HIsd36H5HIT^^,>EtLT^^-?,?FMT^^,>EtLT^^-?,?FM++S1>Bc2^OD<cB#>E	
S12S12S12dnnS#Q?@


z
*	/NN32.	/	/	/s.WWcD|jtjdtjj
|jtjdd|jtjdd|jtjdd|jtjdtjjtjj
z|jtjtttjttz
|jtjtt|jtjtjddddtfD]V}|j|5|jtj|tj|dddXy#1swYcxYw)	Nrllrlg@rrm)
rrRrr>r#rrryrrrxrrrs  rtest_ulpzMathTests.test_ulp&	sp#(>(>?'*C0'*C0'*F3	
#++cnn.D.DD	F),"T^^It%DD	F	
#,$((+,sGWc2	<A"
<  1"txx{;
<
<	<
<
<s:HH	c,Gdd}tjtjtjfD]L}|}|j	t
5|d|ddd|j
t|ddNy#1swY(xYw)NceZdZdZy)$MathTests.test_issue39871.<locals>.Fcd|_ddzy)NTrr)	convertedrds rrez.MathTests.test_issue39871.<locals>.F.__float__A	s!%!rN)rgrhrirerjrrrr@	s
rrznot a numberrF)rRrrrvrrrr)r`rr!r\s    rtest_issue39871zMathTests.test_issue39871=	s}		JJ

t~~=	=DA""9-
(^Q'
(

WQU;<	=
(
(s
B

B	cptj|s!|jdj|yy)NzExpected a NaN, got {!r}.)rRrSryr'r_s  rrxzMathTests.assertIsNaNO	s+zz% II188?@!rc|j|||jtjd|tjd|y)zSimilar to assertEqual(), but compare also the sign with copysign().

        Function useful to compare signed zeros.
        rN)rrRr)r`rr\s   rrzMathTests.assertEqualSignS	s:
	
AsA.

c10EFrNr)Urgrhrir{rrrrrrrrrrrrrunittestskipIfr>rmachinerrrrrrrrcpython_onlyrrrr!HAVE_DOUBLE_ROUNDINGrKr`rrrrrrrrrrrequires_mac_verrrrrrequires_resourcer3r[rerirmrrrrrrrrrrrrr
skipUnlessrrrrrrrrrrrxrrjrrrvrvs6.	45	454	5;:z4 6B::B3X__S\\W,W1A1A1A1CGW1W[]4]45<	=/@:
<<7>4,8$X__)MO\:O\:|(ETIDVX__)NP:1P:1xo7b)
3&j*FX<@3 /44"Wb!$+%+
5N.bX__)]_M_MWu%H&HTX__)]_Wu%Q-&_
Q-f1&G;j5~,~,@3443411@:7)):
3X"9::;:>6-6-p@-@-DZ*x>K@DKL8/8/v<<,=$AGrrvc~eZdZejZdZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZy)IsCloseTestsc`|j|j||g|i||d|dy)N and z should be close!r)rrzr`r^r_rkwargss     r
assertIsClosezIsCloseTests.assertIsClose_	s5Q;D;F;<=qA		Crc`|j|j||g|i||d|dy)Nr
z should not be close!r)rrzrs     rassertIsNotClosezIsCloseTests.assertIsNotClosec	s7a<T<V<ABAF		HrcF|D]\}}|j||g|i|yr\)rr`examplesrr
r^r_s      rassertAllClosezIsCloseTests.assertAllCloseg	s1	6DAqDq!5d5f5	6rcF|D]\}}|j||g|i|yr\)rrs      rassertAllNotClosezIsCloseTests.assertAllNotClosek	s1	9DAq!D!!!Q888	9rc|jt5|jdddddd|jt5|jdddddddy#1swY=xYw#1swYyxYw)Nrg0.+rel_tolr2g _©rr+)rrrrds rtest_negative_tolerancesz%IsCloseTests.test_negative_toleranceso	s~


z
*	6q!W5	6


z
*	Dq!VUC	D	D	6	6	D	DsA'A3'A03A<c4gd}|j|ddy)N))rr)N@ir);r)i90g@)rr)NFrrrr)r`identical_exampless  rtest_identicalzIsCloseTests.test_identicalv	s"0	
.SIrcXgd}|j|d|j|dy)N))gחAgחA)g:0yEgnyE)g	ѭ?gfNӭ?:0yE>r&.>rr)r`eight_decimal_places_exampless  rtest_eight_decimal_placesz&IsCloseTests.test_eight_decimal_places	s5)C%	
94H<dKrcXgd}|j|d|j|dy)N))r%r)g&.r)gu?j/ʠrrgrr$r)rr)r`near_zero_exampless  rtest_near_zerozIsCloseTests.test_near_zero	s4.	
13?.=rc|jtt|jttd|jtt|jttdy)Nrr)rrrrds rtest_identical_infinitez$IsCloseTests.test_identical_infinite	sL3$3S14&4s3rcttftdfdtfttfttfttftdfdtftdfdtfg
}|j|dy)Nr2rgg?r)rrrr)r`not_close_exampless  rtest_inf_ninf_nanzIsCloseTests.test_inf_ninf_nan	sg"Cj"Fm%sm"Cj"Cj"Dk"Cj"Cj"El$cl	,	
1;LMrc`gd}|j|dgd}|j|dy)N))rr)333333r2)Ynr3rr))rg?)g?r)gZbtigTbtir&)r`zero_tolerance_close_examples!zero_tolerance_not_close_exampless   rtest_zero_tolerancez IsCloseTests.test_zero_tolerance	s?)=%	
93G-N)	
@#Nrc.|jddgdy)N)rr)rrrrr rds rtest_asymmetryzIsCloseTests.test_asymmetry	sWg.<rcXddg}|j|d|j|dy)N))i[i[r$rr%r&)r`integer_exampless  r
test_integerszIsCloseTests.test_integers	s:224	
,d;/>rcddlm}|d|df|d|df|d|df|d	|d
fg}|j|d|j|d
y)Nrrbz
1.00000001z1.0z1.00000001e-20z1.0e-20z1.00000001e-100z1.0e-100z
1.00000001e20z1.0e20r$rr%)rrrr)r`rdecimal_exampless   r
test_decimalszIsCloseTests.test_decimals	s#$\2GENC$%56	8JK$%679LM$_5wx7HIK	
,d;/>rcddlm}|dddz|df|d|df|dd|ddfg}|j|d	|j|d
	y)Nrrcrr;r:l 	(qe	rr$rr%)rqrdrr)r`rdfraction_exampless   rtest_fractionszIsCloseTests.test_fractions	sz&a
#a
'!5
i
 (9"56
i
((1f*=>@	
-t<0$?rN)rgrhrirRrzrrrrrr"r(r+r-r0r6r8r=r@rCrjrrrr\	s^llGCH69DJL>4
N
O=?	?	@rrc@ddlm}|j|d|S)Nr)DocFileSuitezieee754.txt)doctestrEaddTest)loadertestspatternrEs    r
load_testsrK	s$	MM,}-.Lrr)9test.supportrrtestrrrqrrrRosrr9rr>rr:rrrr#r&ryrr{rr\rrgargvfile__file__pathdirnamecurdirtest_dirrrrrrrr$r/rFrNrXrZrQrmrrpTestCaservrrKmainrjrr<module>rXs4	


ElElV}NN	NN	1A)z88A;DD
77??4 -BIIh(<=GGLL#89	
L5H	,B$:40+Z	#	&k!G!!k!G\Cx@8$$x@v
zHMMOr