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
U
O±daã@stddlZddlmZddlmZddlZdd„Zdd„Zejj    edd    ej 
d
d geƒ¡ej  d ¡d d„ƒƒƒZ dS)éN)Úparam)ÚIS_WASMc
csâtddddVtddddVtddddVtt d¡dd    dVtt d¡dd
dVtt d¡dddVtd d d ddVtdd ddVtt d¡d d    dVtt d¡d d
dVt tj¡j}t t t d¡jd¡¡}||t d¡jkrtt tj¡jdddVtddddVtddddVtddddVtt d¡dddVtj    ddltj
dD]Z}tj tj fD]F}tj
dD]4}t  |¡}| |¡}t|||›d |›dVq–qˆqxW5QRXd!S)"a?
    Generate value+dtype pairs that generate floating point errors during
    casts.  The invalid casts to integers will generate "invalid" value
    warnings, the float casts all generate "overflow".
 
    (The Python int/float paths don't need to get tested in all the same
    situations, but it does not hurt.)
    ipÚfloat16z    int-to-f2)ÚidZ70000z    str-to-f2gñ@z float-to-f2zlongdouble-to-f2z double-to-f2é
édÚfloat32z    int-to-f4g}Ô%­I²Tgœuˆ<ä7~Zf8rÚfloat64zlongdouble-to-f8gœuˆ<äG~Z    complex64z float-to-c8yœuˆ<äG~z complex-to-c8yœuˆ<äG~zlongdouble-to-c8Úignore)ZoverZ
AllIntegerZAllFloatz-to-N)rÚnpZ
longdoubler    rZfinfoÚmaxÚspacingZ    nextafterÚerrstateZ    typecodesÚinfÚnanÚdtypeÚtype)Zmax_ldr Zto_dtÚvalueZfrom_dtZfrom_val©rúid:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/tests/test_casting_floatingpoint_errors.pyÚvalues_and_dtypess6
ÿ
 
rc#sþˆjdkr2‡‡fdd„}|V‡‡fdd„}|V‡‡fdd„}|V‡‡fdd    „}|V‡‡fd
d „}|V‡‡fd d „}|V‡‡fdd„}|V‡‡fdd„}    |    V‡‡fdd„}
|
V‡‡fdd„} | V‡‡fdd„} | V‡‡fdd„} | VdS)zŽ
    There are many dedicated paths in NumPy which cast and should check for
    floating point errors which occurred during those casts.
    Úicstjdˆd}ˆ|d<dS)Né©rr)r Úempty©Úarr©rrrrÚ
assignment=sz$check_operations.<locals>.assignmentcstjdˆd}| ˆ¡dS)Nrr)r rÚfillrrrrrCszcheck_operations.<locals>.fillcs"tjdˆd}tj|ˆdddS©NrrÚunsafe)Úcasting©r rÚcopytorrrrÚ copyto_scalarIsz'check_operations.<locals>.copyto_scalarcs.tjdˆd}tj|t ˆˆˆg¡dddSr ©r rr$Úarrayrrrrr$Osz check_operations.<locals>.copytocs*tjdˆd}tj|ˆddddgddS©Nrrr!TF)r"Úwherer#rrrrÚcopyto_scalar_maskedUs
ÿz.check_operations.<locals>.copyto_scalar_maskedcs6tjdˆd}tj|t ˆˆˆg¡ddddgddSr(r&rrrrÚ copyto_masked\sÿz'check_operations.<locals>.copyto_maskedcst ˆˆˆg¡ ˆ¡dS)N)r r'ÚastyperrrrÚ direct_castcsz%check_operations.<locals>.direct_castcs4tjdˆddd…ddd…dd…f}| ˆ¡dS)N)ér.r.)Z
fill_valueé)r Úfullr,rrrrÚdirect_cast_nd_stridedhs&z0check_operations.<locals>.direct_cast_nd_stridedcs*tjdˆd}t ˆˆg¡|dddg<dS)NrrTF©r rr'rrrrÚboolean_array_assignmentnsz2check_operations.<locals>.boolean_array_assignmentcs,tjdˆd}t ˆˆg¡}||ddg<dS)Nrrrér2©rÚvaluesrrrÚinteger_array_assignmenttsz2check_operations.<locals>.integer_array_assignmentcs.tjdˆd}t ˆˆˆg¡}||ddg<dS)N)r.rrrr/r2r5rrrÚ&integer_array_assignment_with_subspace|sz@check_operations.<locals>.integer_array_assignment_with_subspacecs0tjdˆd}t ˆˆˆg¡}||jdd…<dS)N)rr)r rr'Zflatr5rrrÚflat_assignment„sz)check_operations.<locals>.flat_assignmentN)Úkind)rrrrr%r$r*r+r-r1r3r7r8r9rrrÚcheck_operations6s2
r;zno wasm fp exception support)Úreasonrrzignore::numpy.ComplexWarningc Cs’t |¡}t||ƒD]x}t |¡}|jdkr0dnd}tjt|d |ƒW5QRXtjdd&tjt    |d |ƒW5QRXW5QRXqdS)NÚiuÚinvalidZoverflow)ÚmatchÚraise)Úall)
r rr;r:ÚpytestZwarnsÚRuntimeWarningrZraisesÚFloatingPointError)rrZ    operationr?rrrÚ!test_floatingpoint_errors_casting‹s
 
rE) rBrZ numpy.testingrÚnumpyr rr;ÚmarkZskipifZ parametrizeÚfilterwarningsrErrrrÚ<module>s  /U