zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
U
O±dã@sJddlZddlZddlZddlmZmZddlmZddl    m
Z
ej dej dej diZ ej dejejejg¡d    d
„ƒZej dejejejg¡d d „ƒZej dejejejg¡d d„ƒZej dejejejg¡dd„ƒZddd„Zej dejejejg¡dd„ƒZej dejejejg¡dd„ƒZdd„ZGdd„deƒZdS)éN)Úassert_Ú assert_equal)ÚCommaDecimalPointLocale)ÚStringIOÚinfz-infÚnanÚtpcCs€dD]&}tt||ƒƒtt|ƒƒd|dq|dƒjdkr^tt|dƒƒttdƒƒd|dnd}tt|dƒƒ|d|ddS)    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.
 
    ©rééÿÿÿÿg@Œµx¯Dú!Failed str formatting for type %s©Úerr_msgç€à7yÃACéZ1e16ú1e+16N)rÚstrÚfloatÚitemsize©rÚxÚref©rúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/tests/test_print.pyÚtest_float_typess    ÿÿÿrcCs:tjtj tjfD]"}tt||ƒƒt|d|dqdS)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.
 
    r r N)ÚnprrrrÚ_REF)rrrrrÚtest_nan_inf_float%s    ÿrcCsÜdD]‚}tt||ƒƒtt|ƒƒd|dtt||dƒƒtt|dƒƒd|dtt|||dƒƒtt||dƒƒd|dq|dƒjdkrºtt|dƒƒttdƒƒd|dnd}tt|dƒƒ|d|ddS)    zÜCheck 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    r r yð?réú
(1e+16+0j)N)rrÚcomplexrrrrrÚtest_complex_types3s$    ÿÿ&ÿÿÿr!Údtypec!Csüttjdƒdtdtjƒdttj dƒdtdtj ƒdttjdƒdtdtjƒdttj dƒd    tdtj ƒd
ttjdƒd tdtjƒd ttj dƒd tdtj ƒd ttjdƒd tdtjƒdttj dƒd tdtj ƒdi}| ¡D]\}}tt||ƒƒ|ƒqÜdS)z*Check inf/nan formatting of complex types.rz(inf+0j)Zinfjz    (-inf+0j)z-infjr
ú(inf+1j)z(1+infj)ú    (-inf+1j)z(1-infj)z(nan+0j)Znanjú(nan+1j)z(1+nanj)N)r rrrÚitemsrr)r"ZTESTSÚcÚsrrrÚtest_complex_inf_nanMsF
 
 
 
 
 
 
 
  ðr)cCsltƒ}tƒ}tj}z2|t_t||ƒƒ|t_|r:t|ƒnt|ƒW5|t_Xt| ¡| ¡d|ddS)Nzprint failed for type%sr )rÚsysÚstdoutÚprintrÚgetvalue)rrrÚfileZfile_tpr+rrrÚ_test_redirected_printgs 
 ÿr/cCszdD]}tt|ƒ|ƒqtjtj tjfD]}tt|ƒ|t|ƒq*|dƒjdkrbttdƒ|ƒnd}ttdƒ||ƒdS)ú"Check formatting when using print r    rrrN)r/rrrrrrrrrrÚtest_float_type_printzsr1cCsŽdD]}tt|ƒ|ƒq|dƒjdkr6ttdƒ|ƒnd}ttdƒ||ƒtttjdƒ|dƒtttj dƒ|dƒtttj dƒ|dƒd    S)
r0r    rrrr
r#r$r%N)r/r rrrrrrrrÚtest_complex_type_printŠsr2cCs2ddtjfddtjfddtjfddtjfddtjfddtjfdd    tjfdd
tjfdd tjfdd tj    fd dtj
fd dtj fd dtj fd dtj fd dtjfd dtjfd dtjfg}|D]z\}}}z(t| |¡| ||ƒ¡d||fƒWq²tk
r*}z&tdd|t|ƒt|ƒt|ƒfƒW5d}~XYq²Xq²dS)z2Test the str.format method with NumPy scalar typesz{0}TFz{0:d}é‚iPÃl^ el¸RU iˆÿÿÿiЊÿÿilʈlûÿÿÿx'¦{'    z{0:g}gø?yø?à?zfailed with val %s, type %sz=format raised exception (fmt='%s', val=%s, type=%s, exc='%s')N)rZbool_Zuint8Zuint16Zuint32Zuint64Zint8Úint16Úint32Úint64Úfloat16Úfloat32Úfloat64Ú
longdoubleÚ    complex64Z
complex128Ú clongdoublerÚformatÚ
ValueErrorrÚreprr)ÚtestsZfmatÚvalZvaltypeÚerrrÚtest_scalar_formats:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ð
ÿÿÿrCc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestCommaDecimalPointLocalecCs ttt d¡ƒttdƒƒƒdS©Nç333333ó?)rrrr8r©ÚselfrrrÚtest_locale_singleÁsz.TestCommaDecimalPointLocale.test_locale_singlecCs ttt d¡ƒttdƒƒƒdSrE)rrrÚdoublerrGrrrÚtest_locale_doubleÄsz.TestCommaDecimalPointLocale.test_locale_doublecCs ttt d¡ƒttdƒƒƒdS)Nz1.2rF)rrrr:rrGrrrÚtest_locale_longdoubleÇsz2TestCommaDecimalPointLocale.test_locale_longdoubleN)Ú__name__Ú
__module__Ú __qualname__rIrKrLrrrrrD¿srD)N)r*ZpytestÚnumpyrZ numpy.testingrrZnumpy.core.tests._localesrÚiorrrrÚmarkZ parametrizer8rJr:rrr;Zcdoubler<r!r)r/r1r2rCrDrrrrÚ<module>s*  
 
 
 
 
 
 
"