CDZ,ddlZddlZddlZddlmZmZmZddlm Z ddl m Z ej dej dej diZejdejejejgd Zejdejejejgd Zejdejejejgd Zejd ejejejgd ZddZejdejejejgdZejdejejejgdZdZGdde ZdS)N)assert_ assert_equalIS_MUSL)CommaDecimalPointLocale)StringIOinfz-infnantpc dD]G}tt||tt|d|zH|djdkrGtt|dttdd|zdSd}tt|d|d|zdS) z Check formatting. This is only for the str function, and only for simple types. The precision of np.float32 and np.longdouble aren't the same as the python float precision. rg@xD!Failed str formatting for type %serr_msg7yAC1e161e+16N)rstrfloatitemsizer xrefs o/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/numpy/core/tests/test_print.pytest_float_typesrs GGSAZZU1XX@2E G G G G G r$xx1SD]]Cf $6$6@2E G G G G G GSD]]C@2E G G G G G Gctjtj tjfD]8}tt ||t |d|z9dS)z Check formatting of nan & inf. This is only for the str function, and only for simple types. The precision of np.float32 and np.longdouble aren't the same as the python float precision. rrN)nprr rr_REF)r rs rtest_nan_inf_floatr"%sofrvgrv &GGSAZZa@2E G G G G GGGrc dD]}tt||tt|d|ztt||dztt|dzd|ztt|||dzztt||dzzd|z|djdkrGtt|dttdd|zdSd}tt|d|d|zdS) zCheck formatting of complex types. This is only for the str function, and only for simple types. The precision of np.float32 and np.longdouble aren't the same as the python float precision. r rry?r (1e+16+0j)N)rrcomplexrrs rtest_complex_typesr'3sGGSAZZWQZZ@2E G G G GSAbD]]C" $6$6@2E G G G GSA"H&&GA"H,=,=(>(>@2E G G G G G r$xx1SD]]C $6$6@2E G G G G G GSD]]C@2E G G G G G Grdtypecittjddtdtjdttj ddtdtj dttjddtdtjdttj dd tdtj d ttjdd tdtjd ttj dd tdtj d ttjdd tdtjdttj dd tdtj d}|D]+\}}t t |||,dS)z*Check inf/nan formatting of complex types.rz(inf+0j)infjz (-inf+0j)z-infjr (inf+1j)z(1+infj) (-inf+1j)z(1-infj)z(nan+0j)nanj(nan+1j)z(1+nanj)N)r&r rr itemsrr)r(TESTScss rtest_complex_inf_nanr3Ms J 26F  [  BF7W   J   26J   [  BF7Z  J  26F  Z  BF7V  J  26J  Z  BF7Z! E$ ''1Sq]]A&&&&''rct}t}tj} |t_t|||t_|rt|nt||t_n#|t_wxYwt ||d|zdS)Nzprint failed for type%sr)rsysstdoutprintrgetvalue)rr rfilefile_tpr6s r_test_redirected_printr;gs ::DjjG ZF   bbee    #JJJJ !HHH V '"2"2"4"42R7999999s ABBcdD]}tt|| tjtj tjfD]+}tt||t |,|djdkrttd|dSd}ttd||dS)"Check formatting when using print r rrrN)r;rr rr r!rrs rtest_float_type_printr>zs--uQxx,,,,frvgrv &66uQxxT!W5555 r$xx1uT{{B/////uT{{B44444rcdD]}tt|| |djdkrttd|n d}ttd||tttjd|dtttj d|dtttj d|dd S) r=r rr$r%r r+r,r.N)r;r&rr rr rs rtest_complex_type_printr@s //wqzz2.... r$xx1wt}}b1111wt}}b#6667261--r:>>>7BF7A..K@@@7BF7A..J?????rc<ddtjfddtjfddtjfddtjfddtjfddtjfdd tjfdd tjfdd tjfdd tj fd dtj fd dtj fd dtj fd dtj fd dtjfd dtjfd dtjfg}|D]\}}} t#|||||d|d|N#t&$rN}t)dd|dt+|dt+|dt-|d Yd}~d}~wwxYwdS)z2Test the str.format method with NumPy scalar typesz{0}TFz{0:d}iPl^elRU iiЊilʈlx'{' z{0:g}g?y??zfailed with val z, type zformat raised exception (fmt='z', val=z, type=z, exc='z')N)r bool_uint8uint16uint32uint64int8int16int32int64float16float32float64 longdouble complex64 complex128 clongdoublerformat ValueErrorrreprr)testsfmatvalvaltypees rtest_scalar_formatr[sT28 $ E28 $ c28 $ eRY ' j") , *BI 6 dBG $ fbh ' k28 , *BH 5 c2: & c2: & c2: & c2= ) h - h . h /! 1E$!&FFsG F S))4;;wws||+D+D+D58SS''B D D D D F F F EE!TT49999d7mmmmSVVVVE F F F F F F F F F FFs:AE F AFFcdeZdZdZdZejeddZ dS)TestCommaDecimalPointLocalectttjdtt ddSN333333?)rrr rMrselfs rtest_locale_singlez.TestCommaDecimalPointLocale.test_locale_singles4SC))3uSzz??;;;;;rctttjdtt ddSr_)rrr doublerras rtest_locale_doublez.TestCommaDecimalPointLocale.test_locale_doubles4S3((#eCjj//:::::rztest flaky on musllinux)reasonctttjdtt ddS)Nz1.2r`)rrr rOrras rtest_locale_longdoublez2TestCommaDecimalPointLocale.test_locale_longdoubles8 Su--..E#JJ@@@@@rN) __name__ __module__ __qualname__rcrfpytestmarkskipifrrirrr]r]sq<<<;;; [8::AA::AAArr])N) r5rmnumpyr numpy.testingrrrnumpy.core.tests._localesriorrr r!rn parametrizerMrerOrr"rPcdoublerRr'r3r;r>r@r[r]rprrrws[ 8888888888====== w6 BIr}EFFGGGFG* BIr}EFF G GGF G bj".IJJGGKJG22<R^"LMM''NM'29999& BIr}EFF 5 5GF 5 bj".IJJ@@KJ@$FFFD A A A A A"9 A A A A Ar