o 6a [@sdddlZddlZddlZddlZddlmmZddl m Z m Z m Z m Z mZejdd!eeejdjdkpFeeejdjejkZWdn1sQwYejd p^eZejjeddZGdd d ZGd d d ZGd d d ZGdddZ GdddZ!GdddZ"dddZ#dddZ$GdddZ%GdddZ&GdddZ'dS) N) assert_raises assert_equalassert_array_equalassert_almost_equalassert_array_max_ulpignore)alllinuxzInadequate C99 complex supportreasonc@s6eZdZddZeddZejjddddZ d S) TestCexpcCszt}tj}||ddtddd||ddtdtddtdttdtd}||dd|j|jddS)NrF)check_complex_valuenpexpcossincomplexrealimag)selfcheckfrefrE/usr/lib/python3/dist-packages/numpy/core/tests/test_umath_complex.py test_simple!s  zTestCexp.test_simplecst}tj|tjdddd|tjdddd|dtjtjtj|dtjtjtj|dtjtjtj|tjdtjd|tj dtjtj|tj dtjtjtj|tjdtjtj|tjdtjtj tjfdd}|dfdd }|dfd d }|dfd d }|d|tjdtjtj|tjdtjtj|tjtjtjtj|tjtj tjtj|tjtjtjtjdS)Nrr F?csxd}tjdd*tttj tj}|jdks |jdkr*t||j|jfWddS1s5wYdS)Nz0cexp(-inf, inf) is (%f, %f), expected (+-0, +-0)rinvalidr)rerrstatearrayrinfrrAssertionErrordummymsgformzrrr_check_ninf_infH"z5TestCexp.test_special_values.._check_ninf_infcszd}tjdd+tttjtj}t|jr!t|js+t ||j|jfWddS1s6wYdS)Nz1cexp(inf, inf) is (%f, %f), expected (+-inf, nan)rr) rr!r"rr#isinfrisnanrr$r%r)rr_check_inf_infR"z4TestCexp.test_special_values.._check_inf_infcsxd}tjdd*tttj tj}|jdks |jdkr*t||j|jfWddS1s5wYdS)Nz0cexp(-inf, nan) is (%f, %f), expected (+-0, +-0)rrr) rr!r"rr#nanrrr$r%r)rr_check_ninf_nan\r+z5TestCexp.test_special_values.._check_ninf_nancszd}tjdd+tttjtj}t|jr!t|j s+t ||j|j fWddS1s6wYdS)Nz2cexp(-inf, nan) is (%f, %f), expected (+-inf, nan)rr) rr!r"rr#r0r,rr-rr$r%r)rr_check_inf_nanfr/z4TestCexp.test_special_values.._check_inf_nan)rrrPZERONZEROr#r0pi)rrr*r.r1r2rr)rtest_special_values+s2    zTestCexp.test_special_valuesz)cexp(nan + 0I) is wrong on most platformsr cCs"t}tj}||tjdtjddS)Nr)rrrr0)rrrrrrtest_special_values2{szTestCexp.test_special_values2N) __name__ __module__ __qualname__r platform_skipr6pytestmarkskipr7rrrrr s   Or c@s8eZdZddZeejje dkddddZ dS) TestClogcCs^tddg}tt|dt|}t|}tt|D] }t||||q!dS)N??@?)rr"logabsanglerangelenrrxy_ryirrrrs  zTestClog.test_simplearmv5telz See gh-413.r cCsLg}g}tjdd tjtjgtd}ttj tj}tttj |Wdn1s-wYtjddt t ||Wdn1sKwY| || |tjddtjdgtd}ttj d}tttj |Wdn1swYtjddt t ||Wdn1swY| || |tjtdtjgtd}ttjdtj}t t ||| || |tjtdtjgtd}t t ||| || |tjdd tjtd tj gtd}ttj tj }Wdn 1swYtjdd t t ||Wdn 1s7wY| || |tjdd tjtjd tj gtd}Wdn 1sfwYtjdd t t ||Wdn 1swY| || |tjtj d gtd}ttjtj}t t ||| || |tjtjd gtd}ttjd}t t ||| || |tjttj tjgtd}ttjd tj}t t ||| || |tjttjtjgtd}ttjd tj}t t ||| || |tjttjtj gtd}ttjtj }t t ||| || |tjttj tj gtd}t t ||| || |tjttj dgtd}ttj tj }t t ||| || |tjttj tjgtd}ttjtj }t t ||| || |tjttj tj gtd}ttj tj }t t ||| || |tj|td}tj|td}tjdd#t t|D]}t t ||||qWddS1swYdS)Nraise)dividedtyperrr ?rr?rBr?)rr!r"r4rr#r5rFloatingPointErrorrCrappendr0rFrGconj)rxlylrIrKxayarLrrrr6s                               $$zTestClog.test_special_valuesN) r8r9r:rr;r<r=skipifplatformmachiner6rrrrr?s r?c@s(eZdZddZddZeddZdS) TestCsqrtcCsNttjdddddtd}|}ttjdd||dttjdddddS)Nr rrRFr)rrsqrt)rrresiresrrrrs zTestCsqrt.test_simplecCs8tttdd}dd}t|dd|j|jddS)Nr cStt|SN)rrarW)r(rrrr&z*TestCsqrt.test_simple_conjugate..fF)rrWrarrrr)rrrrrrtest_simple_conjugate#szTestCsqrt.test_simple_conjugatecCst}tj}||tjddd||tjddd||dtjtjtj||dtjtjtj||tjtjtjtj||tjtjtjtj||tjtjtjtj||tj tjtjtj||tj tjtjtj||dtjtjtj||dtjtjtj||dtjtjtj||tj dtjtj||tjdtjtjdd}|d||tjtjtjtj||tjdtjtj||tjdtjtj||tjtjtjtjdS)Nrr rcSs~d}ttttj tj}tjddt|jr#t |j s-t ||j|j fWddS1s8wYdS)Nz3csqrt(-inf, nan) is (%f, %f), expected (nan, +-inf)rr) rrar"rr#r0r!r-rr,rr$r%rrrr1Os"z6TestCsqrt.test_special_values.._check_ninf_nan)rrrar3r4r#r0)rrrr1rrrr6.s,zTestCsqrt.test_special_valuesN)r8r9r:rrgr;r6rrrrr_s   r_c@4eZdZddZddZddZddZd d Zd S) TestCpowcCtjdd|_dSNrrrseterrolderrrrrrsetupfzTestCpow.setupcCtjdi|jdSNrrlrorrrteardownizTestCpow.teardowncCsTtdddtjtjg}|d}t|d}tt|D] }t||||qdS)N??@rAr`)rr"r#r0powerrFrGrrHrrrrls  zTestCpow.test_simplecstddddtjtjgtgdttt}dddd ttjtjttjtjg}fd d |D}|D]}t||||d |d q:dS)Nr rBr`@Gz?r rB?r{r`r@gF̛? hx?X‚?SLJ#4?4C?csg|] }||qSrr).0rLrIrKrr sz(TestCpow.test_scalar..Loop %d err_msg rr"r#r0listrFrGrr)rlxp_rn_rrLrrr test_scalarss   zTestCpow.test_scalarcCstddddtjtjg}tgd}ttt|}dddd ttjtjttjtjg}||}|D]}t||||d |d q4dS) Nr rBr`ryrzr@r}r~rrrr)rrIrKrrrrLrrr test_arrays   zTestCpow.test_arrayN)r8r9r:rprtrrrrrrrries  ric@rh) TestCabscCrjrkrlrorrrrprqzTestCabs.setupcCrrrsrlrorrrrtruzTestCabs.teardowncCsntdddtjtjg}ttddtdtjtjg}t|}tt|D] }t||||q)dS)NrvrwrAg@r`) rr"r#r0rarDrFrGrrHrrrrs $ zTestCabs.test_simplecCstjdgtd}tt|t|tjtdtjgtd}tt|t|tjttjtjgtd}tt|t|tjttjtjgtd}tt|t|dS)Nr@rPr ) rr"rrrDrr4r#r0)rrIrrr test_fabsszTestCabs.test_fabscCs&gg}}|tj|tjttjtjtjtj|tj|tj ttjtj tjtj|tj|tjttjtjtjtj|tj |tjttjtj tjtjdd}dd}tj|td}tt |D]}|||||}t||||||qzdS)NcSrdre)rrDrW)arrrrrfz%TestCabs.test_cabs_inf_nan..fcSstt||Sre)rrDr)rbrrrgrfz%TestCabs.test_cabs_inf_nan..grP) rVrr0check_real_valuerDr#r"rrFrG)rrIrKrrrZrLrrrrtest_cabs_inf_nans(       zTestCabs.test_cabs_inf_nanN)r8r9r:rprtrrrrrrrrs  rc@s2eZdZddZejjddddZddZd S) TestCargcCs\ttjddddttjdddtjdttjdddtjdttjtjtjtjdS)Nr rFrRrT)rncu_argrr5r3rorrrrszTestCarg.test_simplez;Complex arithmetic with signed zero fails on most platformsr cCs$ttjtjtjtjdttjtjtjtj dttjtjtjtjttjtjtjtjttjdtjtjdttjdtjtjdttjdtjtjdttjdtjtj dttjtjddtjdttjtjddtjdttjtjddtjdttjtjddtjddS)NFr rrR)rrrrr4r3r5rorrr test_zeroszTestCarg.test_zerocCslttjtj dtjdttjtj dtj dttjtjdtjdttjtjdtjdttjdtjdtjdttjdtj dtjdttjtj tjdtjdttjtj tj dtjdttjtjtjdtjdttjtjtj d tjdttjtjd tjdttjd tjtjdttjtjtjtjdttjtjtjtjddS) Nr FrrRrrgrTgпr) rrrrr#r5r3r4r0rorrrr6s zTestCarg.test_special_valuesN) r8r9r:rr<r=r>rr6rrrrrs  rTcCs:tt||g}|rt|||dSt|||dSre)rr"rrr)rx1y1rIexactz1rrrrsrcCstt||g}t||}tjdd"|rt|||nt|||WddSWddS1s9wYdSrk)rr"rr!rr)rrrx2y2rrz2rrrr%s "rc@s<eZdZejdgdejdejejgddZ dS)TestSpecialComplexAVXstride)rr r`astypec Cstjttjtjttjtjttjtjttjtjtdtjttjdtddtdtjttjdg |d}tjtjtjtjtjtjtjdtjtjg |jjd}tjttjtjttjtjttjtjttjtjttj tjttjtjtddttjtjttjtjg |d}tt|dd||dd|tj ddtt |dd||dd|WddS1swYdS)NrPrr) rr"rr0r#rrQrrDr!square)rrrarrabs_truesq_truerrrr/s:       4       $ &"z TestSpecialComplexAVX.test_arrayN r8r9r:r<r= parametrizer complex64 complex128rrrrrr.src@sNeZdZejdgdejdgdejdejejgddZ dS) TestComplexAbsoluteAVX arraysize)r r`r|rr rrrrr r`r|rrcCsHtj||d}tj||jjd}tt|dd||dd|dS)NrP)ronesrrQrrD)rrrrrrrrrrJs(z!TestComplexAbsoluteAVX.test_arrayNrrrrrrIs rc@sNeZdZejdgdejdejejgejdgdddZ dS) TestComplexAbsoluteMixedDTypesrrrfunc)rDr conjugatec Csddddddddd |fd g }tjgd |d }tt|}|d }||dd|}|d } || dd|} t| j|jd t| j|jd dS)N) template_ids6 dP6> D