Current File : //usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyc
�
E�`Qc@s�ddlZddlZddlmZmZmZmZddlmZm	Z	m
Z
mZmZd�Z
defd��YZedkr�e	�ndS(i����N(tuint16tfloat16tfloat32tfloat64(tTestCasetrun_module_suitetassert_tassert_equaltdeccOsby|||�Wn9tk
rL}tt|�j|�dkd|�nXttd|�dS(Nis%Did not raise floating point %s error(tFloatingPointErrorRtstrtfindtFalse(tstrmatchtcallabletargstkwargstexc((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pytassert_raises_fpe	stTestHalfcBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
jej�dkd�d
��Zd�ZRS(cCstjddt�|_t|j_tj|jdt�|_tj|jdt	�|_
tjtjddddt�tjddddt�f�|_t|j_tj|jdt�|_
tj|jdt	�|_|jdd!|_|j
dd!|_|jdd!|_dS(	Nitdtypei�i�i����ii|i(tnptarangeRtall_f16RRtarrayRtall_f32Rtall_f64tconcatenatet	nonan_f16t	nonan_f32t	nonan_f64t
finite_f16t
finite_f32t
finite_f64(tself((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pytsetUps$cCs(tj|jdt�}t|jjdt�|jdt��tj|jdt�}t|jjdt�|jdt��tj|j	dtj
�}tj|dt�}t|j	jdt�|jdt��tjdd�}tj|dt�}tj|dtj�}t||�dS(s[Checks that all 16-bit values survive conversion
           to/from 32-bit and 64-bit floatRi���iN(
RRRRRRtviewRRRt
longdoubleRtint(R"tbta_ldti_intti_f16tj((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_conversions)scCs#tjdd�}z�ttj|j�tj|j��ttj|j�tj|j��ttj|j�tj|j��ttj|j�tj|j��ttj	t
d��tj�t
tj�}t
|j|kj��t
||jkj��t
|j|kj��t
||jkj��t
|j|kj��t
||jkj��t
|j|kj��t
||jkj��t
|j|kj��t
||jkj��t
|j|kj��t
||jkj��Wdtj|�XdS(Ntalltignorei�(RtseterrRtisnanRRtisinftisfinitetsignbittspacingRtinftnanRtanyR-(R"toldsettingsR6((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_nans_infsGs*%%%%cCs�tjdddddddddd!d"d$ddd
tjtjg�}tjddddddddddddddddgdt�}t|_t||�dS(%s,Confirms a small number of known half valuesg�?g�g@g�g��?gT�?i�i ��i�i��ii����g�i<i�i@i�if.iU5i�{i��ii�ii�i�i|i�RNg?g?g�gp>gp>gp�(RRR5RRRR(R"taR'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_valuesis$
	c	Cs�tjdddddddddddd	d
gdt�}dd
d
dddddtjg}tj|dt�}t||�tj|dt�}tj|dt�}t||�dS(s7Checks that rounding when converting to half is correctg@i��i���i��g�?i����i�i�i�i�Ri��gi����i�Ng`>g�=g`>gP>g@?g�>g@?g0?gp>gP?(RRRR5RRR(R"R:troundedR'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_rounding~s,
		
c
Cso|j}|jdt�}d|d@d?}tj|d@d?dtj�d}|d@d}||d
kcd7<d||d
k<||d|}tj|j|k�d
}t|�d
kr|d
}t	|j|dt
||j|||f�ntj|j|k�d
}	t|	�d
krk|	d
}t	|j|dt
||j|||f�ndS(s_Take every finite float16, and check the casting functions with
           a manual conversion.Rg�i�ii|i
i�g@i����i�ii�is,First non-equal is half value %x -> %g != %gNgP?(RR$RRRtint32tnonzeroR tlenRR:R!(
R"ta_f16ta_bitsta_sgnta_expta_manta_manualta32_failt	bad_indexta64_fail((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_correctness�s0	$



cCs4|jddd�j�}tj|dt�}|j�|j�t||�t|d |dkj��t|d |dkj	��t|d|d kj��t|d|d kj	��ttj
|d |dk�dj|jd�ttj
|d|d k�dj|jd�dS(s'Make sure comparisons are working rightNi����Riii(RtcopyRRRtsortRRR-R7R?tsize(R"R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_ordering�s


2c	Csttjddt�tjddt��tjddt�}|jd�t|tjddt��tjdddddddd
gdt�}t|j	�ddddg�|j
�j�}t|j	�ddddg�tjddd
dt�}tjddt�}ttj||�d�tjdtj
dd
ddddgdt�}t|j�d�tjdtj
dtj
dtjddgdt�}t|j�d�tjddt�}x*td�D]}t|j|�|�q�WdS(sTest the various ArrFuncsi
Riiii����g@��x�Dg@i��g��T����>iig�?ii_i����g�����)@g333333@g������@g������(@iN(i(igp>(i(RRRRRtzerostfilltonesRR?tbyteswaptnewbyteordertdotR5targmaxR6trangetitem(R"R:R'ti((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_funcs�s0
.17cCs�tjddt�}tjtjfdt�}|jdt�}ttj|d �|d|d �ttj	|d |�|d�ttj	|d|�|d�ttj	|d|�|d �|dO}ttj|d�tj|d��ttj|d�|d |d�ttj	|d|�|d�ttj	|d|�|d �ttj	|d |�|d�dS(s Test np.spacing and np.nextafteri|Ri����iii�N(
RRRRR5RR$RR4t	nextafter(R"R:thinfRA((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_spacing_nextafter�s&!#"
'&"!cCs�tjdddddgdt�}tjdddddgdt�}tjdd	tjtjd
gdt�}ttj||�dd
dddg�ttj||�ddddd	g�ttj||�dddd
d
g�ttj	||�dddddg�ttj
||�tttttg�ttj
||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj||�tttttg�ttj|�tttttg�ttj|�tttttg�ttj|�tttttg�ttj|�tttttg�ttj|�tttttg�ttj||�dddddg�ttj||�dddddg�tj||�}ttj|d��d|d<t|ddddd
g�ttj||�dddddg�tj||�}ttj|d��d|d<t|dd	tjddg�ttj||�dddddg�ttj||�ddddd
g�ttj||�dddddg�ttj||�dd	tjddg�ttj ||�dddddg�ttj!||�dddddg�ttj"|�dddd
dg�ttj#|�dddddg�ttj$|�dddddg�ttj%|�|�ttj&|�dddddg�ttj'|�ddd	ddg�ttj(|�d	ddddg�ttj)|�dddddg|f�ttj*|�dddddgdddddgf�ttj+|dddddg�dddddg�dS(sTest the various ufuncsiiiiRi����iii����iii����ig��?gT�?ii	g�g�?gT�?i����i����g�?g�?g�?i
i@iN(,RRRR5R6RtaddtsubtracttmultiplytdividetequalRtTruet	not_equaltlesst
less_equaltgreatert
greater_equaltlogical_andt
logical_ortlogical_xortlogical_notR0R1R2R3tcopysigntmaximumRtminimumtfmaxtfmintfloor_dividet	remaindertsquaret
reciprocalt	ones_liket	conjugatetabsolutetnegativetsigntmodftfrexptldexp(R"R:R'tctx((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_ufuncss`$$+(((((((((((((%%%%%((
(
 (((,((%%%%%%+:cCstjddt�}tjddt�}td�}td�}ttj|d�jt�ttj|d�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj|d�jt�ttj|d�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�ttj||�jt�dS(s9Test that half gets coerced properly with the other typesiRig@N(i(i(RRRRRtpowerRR(R"ta16ta32tb16tb32((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_coercionPs(tarmv5telsSee gh-413.cCs�tjdd�}z�tjd/dt�}tjd0dt�}td�}td�}tdd�||�tdd�||�tdd	�||�tdd
�||�tdd�||�tdd�||�tdd
�||�tdd�||�tdd�td1�td2��tdd�td4�td5��tdd�td6d7�td��tdd�td9d:�td��tdd�td;d<�td��tdd�||�tdd�||�tdd�||�tdd�||�tdd �||�tdd!�||�tdd"�||�tdd#�||�tdd$�td%�td&��tdd'�td(�td&��tdtjtd%�ttj��tdtjtd(�ttj��tdtjtd%��td)tjttj�ttj��td)tjttj��td)tjttj	��td)tjttj�td*��td)tjttj�td*��td)tjtd*�ttj	��td+�td,�td=�td�td>�td?�tjtd(��tjtd%�ttj��tjtd(�ttj��td@�tdA�tdC�tdD�tdEdF�td�tdHdI�td�Wdtj|�XdS(JNR-traiseg-C��6?Rg��@t	underflowcSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyt<lambda>tscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�uscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�vscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�wscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�xscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�yscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�zscSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�{scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�|sg@i�iicSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR�~scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��si��cSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��si��itoverflowcSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��scSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��si�icSs||S(N((R:R'((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��si ��tinvalidii��i i�i
(g-C��6?(g��@g?ig?g�ig?gp>g?g�gp>g?g�>g ?g?ig?ig?g�ig?g�>g?g�g�>(
RR/RRRRZR5R4R`R6(R"R8tsx16tbx16tsy16tby16((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyt
test_half_fpejsp%&(%&% cCspddd��Y}tjddt�}|�}|j|_tj|�}t|jtk�t||�dS(s5Test that half is compatible with __array_interface__tDummycBseZRS((t__name__t
__module__(((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyR��siRN((i(RRQRt__array_interface__RRRR(R"R�R:R'R}((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyttest_half_array_interface�s	(R�R�R#R,R9R;R=RJRNRYR\RR�RtskipiftplatformtmachineR�R�(((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyRs			"			%		'		:	'Dt__main__(R�tnumpyRRRRRt
numpy.testingRRRRRRRR�(((s@/usr/lib64/python2.7/site-packages/numpy/core/tests/test_half.pyt<module>s"(	
��