Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_statistics.cpython-35.opt-2.pyc



���]��@s<ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
Z
dd�Zdd�Zdd	d
d�Z
Gdd
�d
�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#ej�ZGd$d%�d%ej�ZGd&d'�d'ej�ZGd(d)�d)ej�ZGd*d+�d+ej�ZGd,d-�d-ej�ZGd.d/�d/�Z Gd0d1�d1�Z!Gd2d3�d3e e!�Z"Gd4d5�d5e�Z#Gd6d7�d7e�Z$Gd8d9�d9e�Z%Gd:d;�d;e �Z&Gd<d=�d=ee&e!�Z'Gd>d?�d?ee&�Z(Gd@dA�dAee!�Z)GdBdC�dCe(e!�Z*GdDdE�dEe(e!�Z+GdFdG�dGe(�Z,GdHdI�dIee&e!�Z-GdJdK�dKe �Z.GdLdM�dMe.ee!�Z/GdNdO�dOe.ee!�Z0GdPdQ�dQe.e�Z1GdRdS�dSe.e�Z2dTdU�Z3e4dVkr8ej5�dS)W�N)�Decimal)�FractioncCs}t|�t|�k	rdSt|t�rGtj|�oFtj|�S|j�d}|j�d}||ko||dkS)NF��n�N)rr)�type�
isinstance�float�math�isnanZas_tuple)�a�bZaexpZbexp�r�4/opt/alt/python35/lib64/python3.5/test_statistics.py�
_nan_equalsrcCsQtt|�t|��}t||�}|r;||n	td�}||fS)N�inf)�max�absr	)�actual�expected�base�abs_err�rel_errrrr�_calc_errors7s
rg�-���q=gH�����z>cCs�|dks|dkr$td��tj|�sBtj|�rFdS||krVdStj|�sttj|�rxdSt||�}t||tt|�t|���}||kS)Nrz%error tolerances must be non-negativeFT)�
ValueErrorr
r�isinfrr)�x�y�tol�relZactual_errorZ
allowed_errorrrr�approx_equalGs"(r c@seZdZdS)�
_DoNothingN)�__name__�
__module__�__qualname__rrrrr!�s$r!c@s\eZdZdZZddddd�Zdd�Zddd�Zed	d
��Z	dS)�NumericTestCaserNcCs}|dkr|j}|dkr*|j}t|tj�rZt|tj�rZ|j}n	|j}||||||�dS)N)rrr�collections�Sequence�_check_approx_seq�_check_approx_num)�self�first�secondrr�msg�checkrrr�assertApproxEqual�s			z!NumericTestCase.assertApproxEqualc
Cs�t|�t|�krUdt|�t|�f}|j||�}|j|��xEtt||��D].\}\}}	|j||	||||�qkWdS)Nz0sequences differ in length: %d items != %d items)�len�_formatMessage�failureException�	enumerate�zipr))
r*r+r,rrr-�standardMsg�ir�errrr(�s(z!NumericTestCase._check_approx_seqcCsYt||||�rdS|j|||||�}|j||�}|j|��dS)N)r �_make_std_err_msgr1r2)r*r+r,rrr-�idxr5rrrr)�s
z!NumericTestCase._check_approx_numc	CsUd}|dk	r&d|}||}t||�\}}|||||||fS)Nzk  %r != %r
  values differ by more than tol=%r and rel=%r
  -> absolute error = %r
  -> relative error = %rz,numeric sequences first differ at index %d.
)r)	r+r,rrr9�template�headerrrrrrr8�s

z!NumericTestCase._make_std_err_msg)
r"r#r$rrr/r(r)�staticmethodr8rrrrr%�s

+	r%c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ApproxEqualSymmetryTestcCs|dddtd�tdd�g}ddd
td
�tdd�g}x-t||�D]\}}|j||�qXWdS)Ni�	gfffff�B@gfffff�(@z2.54��6i�	g������B@gR����(@z2.59�gfffff�(�gR����(�)rrr4�do_relative_symmetry)r*Zargs1Zargs2rr
rrr�test_relative_symmetrys
$$z.ApproxEqualSymmetryTest.test_relative_symmetrycCs�t||�t||�}}||}t||�t||�}}||d}|jt||ddd|��|jt||ddd|��dS)Nrrrr)�minrr�
assertTruer )r*rr
�deltaZrel_err1Zrel_err2rrrrrA!s
!"z,ApproxEqualSymmetryTest.do_relative_symmetryc
Cs�dddddg}d}x^|D]V}xMttttfD]9}||�d}||}t|t||��}|j||d|d|�|j||d|d	dd|�|j||d|d	d|d�|j||d|d|d�|j||d|d	d|�|j||d|d	dd|�|j||dd
dd
�|j||dd
dd
�q;Wq"WdS)
N�r��ki�m�drr�ri�����)�intr	rrrr�do_symmetry_test)r*�argsrEr�type_rr�rrrr�
test_symmetry-s

$$  $z%ApproxEqualSymmetryTest.test_symmetrycCs\d}t||||�}t||||�}|j|||j||||f��dS)Nz+approx_equal comparisons don't match for %r)r �assertEqual�format)r*rr
rrr:Zflag1Zflag2rrrrMEsz(ApproxEqualSymmetryTest.do_symmetry_testN)r"r#r$rBrArQrMrrrrr=sr=c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�ApproxEqualExactTestcCset||d|d|�}|j|d|�t||d|d|�}|j|d|�dS)Nrrzequality failure for x=%r)r rD)r*rrr�resultrrr�do_exactly_equal_testRsz*ApproxEqualExactTest.do_exactly_equal_testcCs=x6dddddddgD]}|j|dd�qWdS)	N�*iMi~:��iiU�
i�r)rV)r*rrrr�test_exactly_equal_intsXs"z,ApproxEqualExactTest.test_exactly_equal_intscCs=x6dddddddgD]}|j|dd�qWdS)	Ng�z�G��?g/�$���?g�����e�@g7@gpf@g!�rh��Q@gB`��"KB@r)rV)r*rrrr�test_exactly_equal_floats]s"z.ApproxEqualExactTest.test_exactly_equal_floatscCsst}xf|dd�|d�|dd�|dd�|dd	�|dd�gD]}|j|dd�qRWdS)
NrJrrrG��	��#�$)rrV)r*�F�frrr�test_exactly_equal_fractionsbsRz1ApproxEqualExactTest.test_exactly_equal_fractionscCs=t}x0t|dj��D]}|j|dd�qWdS)Nz8.2 31.274 912.04 16.745 1.2047r)r�map�splitrV)r*�D�drrr�test_exactly_equal_decimalshsz0ApproxEqualExactTest.test_exactly_equal_decimalscCssxlddddddgD]R}|j|dd�|j|d	dd�t|d
�}|j|dd�qWdS)N�i�i\i�i��g{�G�z�?r�
i�)rVr)r*rrarrr�test_exactly_equal_absolutens
z0ApproxEqualExactTest.test_exactly_equal_absolutecCsC|jtd�td�d�|jtd�td�d�dS)Nz3.571z0.01rz81.3971)rVr)r*rrr�$test_exactly_equal_absolute_decimalsysz9ApproxEqualExactTest.test_exactly_equal_absolute_decimalscCs\x6ddd
tdd�gD]}|j|dd�qW|jtd�dtd	��dS)Ni� g33333SY@g�z�G�@rG�rg{�G�z�?z11.68z0.01g�z�G�)rrVr)r*rrrr�test_exactly_equal_relative~s"z0ApproxEqualExactTest.test_exactly_equal_relativecCshx6dddtdd�gD]}|j|dd�qWt}|j|d�|d	�|d
��dS)Ni9�gˡE��0@g\��(h�@r[�g�������?g{�G�z�?z7.2z0.1z0.01g\��(h��)rrVr)r*rrerrr�test_exactly_equal_both�s"z,ApproxEqualExactTest.test_exactly_equal_bothN)r"r#r$rVrYrZrbrgrkrlrnrprrrrrTLsrTc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ApproxEqualUnequalTestcCsOxH||fD]9}t||ddddd�}|j|d|�qWdS)NrJrrrzinequality failure for x=%r)r �assertFalse)r*rrrUrrr�do_exactly_unequal_test�sz.ApproxEqualUnequalTest.do_exactly_unequal_testcCs1x*dddddgD]}|j|�qWdS)Ni�i��i�i�iXC)rs)r*rrrr�test_exactly_unequal_ints�sz0ApproxEqualUnequalTest.test_exactly_unequal_intscCs1x*dddddgD]}|j|�qWdS)Ng��Q�#@g����[�@gfffff�G@gףp=
W"@g=
ףp=1@)rs)r*rrrr�test_exactly_unequal_floats�sz2ApproxEqualUnequalTest.test_exactly_unequal_floatscCsXt}xK|dd�|dd�|dd�|dd�gD]}|j|�q=WdS)	NrJrGr]r\���eiς)rrs)r*r`rarrr�test_exactly_unequal_fractions�s=z5ApproxEqualUnequalTest.test_exactly_unequal_fractionscCs1x*ttdj��D]}|j|�qWdS)Nz!3.1415 298.12 3.47 18.996 0.00245)rcrrdrs)r*rfrrr�test_exactly_unequal_decimals�sz4ApproxEqualUnequalTest.test_exactly_unequal_decimalsN)r"r#r$rsrtruryrzrrrrrq�s
rqc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�ApproxEqualInexactTestc	Cs�d}x�||||fD]j}|j||�}|jt||dd|dd�|�|jt||d|ddd�|�qWdS)NzTest failure for x={!r}, y={!r}rrrr)rSrDr rr)r*rrEr:rr-rrr�do_approx_equal_abs_test�s
)z/ApproxEqualInexactTest.do_approx_equal_abs_testcCsVxOd
dddddddd	d
dgD]&}|j|d�|j|d�q(WdS)Ni�)i�r]rrrJr\�%i�i�&i6�jrji��iI���i����rK)r|)r*rrrr�test_approx_equal_absolute_ints�s.z6ApproxEqualInexactTest.test_approx_equal_absolute_intsc	Cs`xYd
dddddddd	g	D]6}|j|d
�|j|d�|j|d�q"WdS)Ng�t��q@gfffffFX@g333333@g333333@g�?g�?g333333@g�Q���@g�����ҭ@g�?g{�G�z�?g-C��6?g�t��q�gfffffFX�g333333�g333333�)r|)r*rrrr�!test_approx_equal_absolute_floats�s(z8ApproxEqualInexactTest.test_approx_equal_absolute_floatscCs~tdd�}ddddddddd	d
dg}xAdd
�|D�D],}|j||�|j|t|��qJWdS)NrJ��Tr@rrrGr>rF�"�Gcss|]}t|d�VqdS)r�N)r)�.0rrrr�	<genexpr>�szNApproxEqualInexactTest.test_approx_equal_absolute_fractions.<locals>.<genexpr>i����i�rK���)rr|r	)r*rE�
numeratorsrarrr�$test_approx_equal_absolute_fractions�s
'z;ApproxEqualInexactTest.test_approx_equal_absolute_fractionscCsQtd�}x>ttdj��D]'}|j||�|j||�q"WdS)Nz0.01z1.0 3.5 36.08 61.79 7912.3648)rrcrdr|)r*rErfrrr�#test_approx_equal_absolute_decimals�sz:ApproxEqualInexactTest.test_approx_equal_absolute_decimalscCs&|jtdddddd��dS)Ng�h㈵��>rg-C��6?rrg�h㈵��)rDr )r*rrr�test_cross_zero�sz&ApproxEqualInexactTest.test_cross_zeroc
Cs�d}x�|d||d|fD]j}|j||�}|jt||dddd|�|�|jt||ddd|d�|�q#WdS)NzTest failure for x={!r}, y={!r}rJrrrr)rSrDr rr)r*rrEr:rr-rrr�do_approx_equal_rel_test�s
#)z/ApproxEqualInexactTest.do_approx_equal_rel_testcCs�|jtdddddd��|jtdddddd��|jtdd	dddd
��|jtdd	dddd
��|jtdd	dddd
��dS)
N�@�/rrrg
ףp=
�?g�G�z��?i�ig�?i�i�)rDr rr)r*rrr�test_approx_equal_relative_ints�s
""""z6ApproxEqualInexactTest.test_approx_equal_relative_intscCsJxCd	d
dddddgD]&}|j|d�|j|d�qWdS)Ng{�G�Jf@g�������?g�?g\��(|B@g��ʡE>�@g��x��@g{�G�z�?g-C��6?g{�G�Jf�g��������)r�)r*rrrr�!test_approx_equal_relative_floats�s"z8ApproxEqualInexactTest.test_approx_equal_relative_floatscCs�t}tdd�}x||dd�|dd�|dd�|dd	�gD]D}x;|t|�fD]'}|j||�|j||�qeWqLWdS)
Nr[ror�r>��1�2�\�U)rr	r�)r*r`rErarfrrr�$test_approx_equal_relative_fractions�s=z;ApproxEqualInexactTest.test_approx_equal_relative_fractionscCsQxJttdj��D]3}|j|td��|j|td��qWdS)Nz$0.02 1.0 5.7 13.67 94.138 91027.9321z0.001z0.05)rcrrdr�)r*rfrrr�#test_approx_equal_relative_decimals�sz:ApproxEqualInexactTest.test_approx_equal_relative_decimalscCs�|r|jn|j}|t||d|dd��|rF|jn|j}|t||ddd|��|sz|r�|jn|j}|t||d|d|��dS)Nrrr)rDrrr )r*rr
rrZtol_flagZrel_flagr.rrr�
do_check_bothsz$ApproxEqualInexactTest.do_check_bothcCs<|jdddddd�|jd
ddd	dd�dS)NgR����@g+���@g����Mbp?g���W�8?Tg?5^�I�@g%��C�@g����Mb`?g-C��6*?g?5^�I��g%��C��)r�)r*rrr�test_approx_equal_both1sz.ApproxEqualInexactTest.test_approx_equal_both1cCs |jdddddd�dS)NgR����@g+���@g����Mbp?gV�F�?8?TF)r�)r*rrr�test_approx_equal_both2sz.ApproxEqualInexactTest.test_approx_equal_both2cCs |jdddddd�dS)NgR����@g+���@g����MbP?g���W�8?FT)r�)r*rrr�test_approx_equal_both3sz.ApproxEqualInexactTest.test_approx_equal_both3cCs<|jdddddd�|jdddd	dd�dS)
Ng=
ףp=@g@g{�G�z�?g����MbP?Fg�Q��[�@g�(\��[�@g{�G�z�?giUMu�>)r�)r*rrr�test_approx_equal_both4sz.ApproxEqualInexactTest.test_approx_equal_both4N)r"r#r$r|r~rr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr{�s 		r{c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ApproxEqualSpecialsTestcCs�x�ttfD]�}|d�}|jt||��|jt||dd��|jt||dd��|jt||��|jt||��|jt|d��q
WdS)NrrrJg{�G�z�?i�)r	rrDr rr)r*rOrrrr�test_inf%sz ApproxEqualSpecialsTest.test_infcCs]xVttfD]H}|d�}x3||d�dfD]}|jt||��q5Wq
WdS)N�nanri�)r	rrrr )r*rOr��otherrrr�test_nan/sz ApproxEqualSpecialsTest.test_nancCs8tjdd�}|jt|ddddd��dS)NgrJrg�������?rr�)r
�copysignrDr )r*�nzerorrr�test_float_zeroes5sz)ApproxEqualSpecialsTest.test_float_zeroescCs8td�}|jt|td�dddd��dS)Nz-0.0rrg�������?r)rrDr )r*r�rrr�test_decimal_zeroes9sz+ApproxEqualSpecialsTest.test_decimal_zeroesN)r"r#r$r�r�r�r�rrrrr�"s
r�c@s(eZdZdd�Zdd�ZdS)�TestApproxEqualErrorscCs |jttdddd�dS)NrIrJg�������?r�)�assertRaisesrr )r*rrr�test_bad_tolAsz"TestApproxEqualErrors.test_bad_tolcCs |jttdddd�dS)NrIrJg�������?g��������)r�rr )r*rrr�test_bad_relEsz"TestApproxEqualErrors.test_bad_relN)r"r#r$r�r�rrrrr�>sr�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestNumericTestCasecCsCtj|�}|j|�}x|D]}|j||�q%WdS)N)r%r8�generate_substringsZassertIn)r*rNZ
actual_msgrZ	substringrrr�do_testUs
zTestNumericTestCase.do_testcCs|jtttj��dS)N)rD�
issubclassr%�unittest�TestCase)r*rrr� test_numerictestcase_is_testcase[sz4TestNumericTestCase.test_numerictestcase_is_testcasecCsd}|j|�dS)N�@�@��?��?)r�r�r�r�N)r�)r*rNrrr�test_error_msg_numeric_sz*TestNumericTestCase.test_error_msg_numericcCsd}|j|�dS)N�@�� @��?��?r])r�r�r�r�r])r�)r*rNrrr�test_error_msg_sequencedsz+TestNumericTestCase.test_error_msg_sequencec	CsXt||�\}}d|d|d|d|g}|dk	rT|jd|�|S)Nztol=%rzrel=%rzabsolute error = %rzrelative error = %rzdiffer at index %d)r�append)	r*r+r,rrr9rrZ
substringsrrrr�is
z'TestNumericTestCase.generate_substringsN)r"r#r$r�r�r�r�r�rrrrr�Os
r�c@s:eZdZeZddgZdd�Zdd�ZdS)�GlobalsTest�__doc__�__all__cCs8x1|jD]&}|jt|j|�d|�q
WdS)Nz%s not present)�expected_metadatarD�hasattr�module)r*�metarrr�	test_meta�szGlobalsTest.test_metacCs[|j}xK|jD]@}|j|jd�d|�|jt||�d|�qWdS)N�_zprivate name "%s" in __all__zmissing name "%s" in __all__)r�r�rr�
startswithrDr�)r*r��namerrr�test_check_all�s	zGlobalsTest.test_check_allN)r"r#r$�
statisticsr�r�r�r�rrrrr�|sr�c@s:eZdZejejjdkd�dd��ZdS)�DocTestsrz)Docstrings are omitted with -OO and abovecCs9tjt�\}}|j|d�|j|d�dS)Nr)�doctest�testmodr��
assertGreaterrR)r*ZfailedZtriedrrr�test_doc_tests�szDocTests.test_doc_testsN)	r"r#r$r�ZskipIf�sys�flags�optimizer�rrrrr��sr�c@seZdZdd�ZdS)�StatisticsErrorTestcCsFd}|jttd��|jttjt�|tjj�dS)NzNExpected StatisticsError to be a ValueError, but got a subclass of %r instead.�StatisticsError)rDr�r�r�r�r�__base__)r*�errmsgrrr�test_has_exception�s
z&StatisticsErrorTest.test_has_exceptionN)r"r#r$r�rrrrr��sr�c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ExactRatioTestcCs4x-dD]%}|jtj|�|df�qWdS)N�r[rrG�crjrJ������� F�x:^V)r�r�rrGr�r�)rRr��_exact_ratio)r*r6rrr�test_int�s
zExactRatioTest.test_intcCsId}x<|D]4}t|d�}|jtj|�|df�q
WdS)NrGrJrv�&r}���)r�rJrvr�)rrRr�r�)r*r�rrarrr�
test_fraction�s
zExactRatioTest.test_fractioncCs�|jtjd�d	�|jtjd�d
�dd�td�D�}x7|D]/}tj|�\}}|j|||�qRWdS)Ng�?rJrog�?r\cSs"g|]}tjdd��qS)rIi����)�random�uniform)r�r�rrr�
<listcomp>�s	z-ExactRatioTest.test_float.<locals>.<listcomp>rI)rJro)r\ro)rRr�r��range)r*�datar�num�denrrr�
test_float�s
zExactRatioTest.test_floatcCsgt}tj}|j||d��d	�|j||d��d
�|j||d��d�dS)
Nz0.125�}��z12.345�90z-1.98��rI)r�r�)r�r��:���)r�rI)rr�r�rR)r*rer�rrr�test_decimal�s
	zExactRatioTest.test_decimalcCs�td�}Gdd�dt�}Gdd�dt�}x�||fD]�}xt|t|fD]k}||�}tj|�}|j||df�|jt|d�|�|jtj|d��q_WqFWdS)N�INFc@seZdZdS)z(ExactRatioTest.test_inf.<locals>.MyFloatN)r"r#r$rrrr�MyFloat�sr�c@seZdZdS)z*ExactRatioTest.test_inf.<locals>.MyDecimalN)r"r#r$rrrr�	MyDecimal�sr�r)	r	rr�r�rRrrDr
r)r*r�r�r�rrOr�ratiorrrr��szExactRatioTest.test_infcCs�td�}Gdd�dt�}xw|||�fD]c}tj|�}|jtj|d��|j|dd�|jt|d�t|��q5WdS)N�NANc@seZdZdS)z.ExactRatioTest.test_float_nan.<locals>.MyFloatN)r"r#r$rrrrr��sr�rrJ)	r	r�r�rDr
r�assertIsrRr)r*r�r�r�r�rrr�test_float_nan�szExactRatioTest.test_float_nancCs�td�}td�}Gdd�dt�}x�|||�|||�fD]c}tj|�}|jt|d|��|j|dd�|jt|d�t|��qMWdS)Nr��sNANc@seZdZdS)z2ExactRatioTest.test_decimal_nan.<locals>.MyDecimalN)r"r#r$rrrrr��sr�rrJ)rr�r�rDrr�rRr)r*r�r�r�r�r�rrr�test_decimal_nan�s%zExactRatioTest.test_decimal_nanN)
r"r#r$r�r�r�r�r�r�r�rrrrr��s
r�c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�DecimalToRatioTestcCsPtd�}|jtj|�|df�|jtj|�|df�dS)Nr�)rrRr��_decimal_to_ratio)r*rrrr�
test_infinity�sz DecimalToRatioTest.test_infinitycCsbx[td�td�fD]A}tj|�\}}|jt||��|j|d�qWdS)Nr�r�)rr�r�rDrr�)r*r�r�r�rrrr��szDecimalToRatioTest.test_nancCs�td�td�g}xy|D]q}tj|�\}}|j|d�|j|d�tj|�\}}|j|d�|j|d�qWdS)Nz	9.8765e12z
9.8765e-12r)rr�r��assertGreaterEqualr�ZassertLessEqual)r*Znumbersrfr�r�rrr�	test_sign�s
zDecimalToRatioTest.test_signcCs)tjtd��}|j|d�dS)Nz0.1234���')r�r�)r�r�rrR)r*�trrr�test_negative_exponent
sz)DecimalToRatioTest.test_negative_exponentcCs)tjtd��}|j|d�dS)Nz1.234e7� K�rJ)rrJ)r�r�rrR)r*r�rrr�test_positive_exponentsz)DecimalToRatioTest.test_positive_exponentcCsNtjtd��}|j|d�tjtd��}|j|d�dS)NZ1e2rIrJz1.47e5�8>)rIrJ)rrJ)r�r�rrR)r*r�rrr�test_regression_20536sz(DecimalToRatioTest.test_regression_20536N)	r"r#r$r�r�r�r�rrrrrrr��s
r�c@s4eZdZdd�Zdd�Zdd�ZdS)�IsFiniteTestcCsFx?dtdd�dtd�fD]}|jtj|��q"WdS)NrGrJr[g@z5.5)rrrDr��	_isfinite)r*rrrr�test_finite s(zIsFiniteTest.test_finitecCs=x6td�td�fD]}|jtj|��qWdS)Nr)r	rrrr�r)r*rrrrr�%szIsFiniteTest.test_infinitycCsFx?td�td�td�fD]}|jtj|��q"WdS)Nr�r�r�)r	rrrr�r)r*rrrrr�*s(zIsFiniteTest.test_nanN)r"r#r$rr�r�rrrrrsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
CoerceTestcCsoxhttttfD]T}|jtj|t�|�Gdd�d|�}|jtj|t�|�qWdS)Nc@seZdZdS)z%CoerceTest.test_bool.<locals>.MyClassN)r"r#r$rrrr�MyClassKsr)rLr	rrr�r��_coerce�bool)r*�Trrrr�	test_boolEszCoerceTest.test_boolcCs<|jtj||�|�|jtj||�|�dS)N)r�r�r	)r*�A�Brrr�assertCoerceToNszCoerceTest.assertCoerceTocCsp|j||�Gdd�d|�}|j||�Gdd�d|�}|j||�|j||�dS)Nc@seZdZdS)z/CoerceTest.check_coerce_to.<locals>.SubclassOfAN)r"r#r$rrrr�SubclassOfAXsrc@seZdZdS)z/CoerceTest.check_coerce_to.<locals>.SubclassOfBN)r"r#r$rrrr�SubclassOfB[sr)r)r*r
rrrrrr�check_coerce_toSszCoerceTest.check_coerce_tocCs<|jttj||f�|jttj||f�dS)N)r��	TypeErrorr�r	)r*r
rrrr�assertCoerceRaises_szCoerceTest.assertCoerceRaisescCs�|jtj||�|�Gdd�d|�}Gdd�d|�}Gdd�d|�}x'|||fD]}|j||�qnW|j||�|j||�|j||�dS)Nc@seZdZdS)z*CoerceTest.check_type_coercions.<locals>.UN)r"r#r$rrrr�Ujsrc@seZdZdS)z*CoerceTest.check_type_coercions.<locals>.VN)r"r#r$rrrr�Vksrc@seZdZdS)z*CoerceTest.check_type_coercions.<locals>.WN)r"r#r$rrrr�Wlsr)r�r�r	rr)r*rrrr�typrrr�check_type_coercionsdszCoerceTest.check_type_coercionscCs;|jt�x'tttfD]}|jt|�qWdS)N)rrLr	rrr)r*rrrrr�ts
zCoerceTest.test_intcCs!|jt�|jtt�dS)N)rrrr	)r*rrrr�zs
zCoerceTest.test_fractioncCs|jt�dS)N)rr)r*rrrr�szCoerceTest.test_decimalcCs|jt�dS)N)rr	)r*rrrr��szCoerceTest.test_floatcCsWxPtttd�ttfD]3}x*ttttfD]}|j	||�q5WqWdS)N)
�str�listr�tuple�dictrLr	rrr)r*Zbad_typeZ	good_typerrr�test_non_numeric_types�s"z!CoerceTest.test_non_numeric_typescCsQxJttfD]<}Gdd�d|�}|j|t�|j|t�q
WdS)Nc@seZdZdS)z6CoerceTest.test_incompatible_types.<locals>.MySubclassN)r"r#r$rrrr�
MySubclass�sr)r	rrr)r*rrrrr�test_incompatible_types�sz"CoerceTest.test_incompatible_typesN)r"r#r$rrrrrr�r�r�r�rr rrrrr0s	rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ConvertTestcCs0|j||�|jt|�t|��dS)N)rRr�r)r*rrrrr�check_exact_equal�szConvertTest.check_exact_equalcCsptjtd�t�}|j|d�Gdd�dt�}tjtd�|�}|j||d��dS)Nr�c@seZdZdS)z#ConvertTest.test_int.<locals>.MyIntN)r"r#r$rrrr�MyInt�sr#r>)r��_convertrrLr")r*rr#rrrr��s
zConvertTest.test_intcCs�tjtdd�t�}|j|tdd��Gdd�dt�}tjtdd�|�}|j||dd��dS)N�_r�cs"eZdZ�fdd�Z�S)z-ConvertTest.test_fraction.<locals>.MyFractioncs|jt�j|��S)N)�	__class__�super�__truediv__)r*r�)r&rrr(�sz9ConvertTest.test_fraction.<locals>.MyFraction.__truediv__)r"r#r$r(rr)r&r�
MyFraction�sr)r��
)r�r$rr")r*rr)rrrr��s
zConvertTest.test_fractioncCsvtjtd	d�t�}|j|d
�Gdd�dt�}tjtdd�|�}|j||d��dS)NrJrg�?cs"eZdZ�fdd�Z�S)z'ConvertTest.test_float.<locals>.MyFloatcs|jt�j|��S)N)r&r'r()r*r�)r&rrr(�sz3ConvertTest.test_float.<locals>.MyFloat.__truediv__)r"r#r$r(rr)r&rr��sr�r\rog�?r�g�)r�r$rr	r")r*rr�rrrr��s
zConvertTest.test_floatcCs|tjtdd�t�}|j|td��Gdd�dt�}tjtd	d�|�}|j||d��dS)
NrJ�(z0.025cs"eZdZ�fdd�Z�S)z+ConvertTest.test_decimal.<locals>.MyDecimalcs|jt�j|��S)N)r&r'r()r*r�)r&rrr(�sz7ConvertTest.test_decimal.<locals>.MyDecimal.__truediv__)r"r#r$r(rr)r&rr��sr�r@rhz-0.9375i�)r�r$rrr")r*rr�rrrr��s
zConvertTest.test_decimalcCsgx`td�td�fD]F}x=||fD].}tj|t|��}|j||�q-WqWdS)Nr)r	rr�r$rr")r*r�rrrrrr��szConvertTest.test_infcCs^xWtd�td�td�fD]4}tj|t|��}|jt||��q"WdS)Nr�r�r�)r	rr�r$rrDr)r*r�rrrrr��s(zConvertTest.test_nanN)
r"r#r$r"r�r�r�r�r�r�rrrrr!�s


r!c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�UnivariateCommonMixincCs|jt|j�dS)N)r�r�func)r*rrr�test_no_args�sz"UnivariateCommonMixin.test_no_argscCs=x6gftg�fD]}|jtj|j|�qWdS)N)�iterr�r�r�r-)r*�emptyrrr�test_empty_data�sz%UnivariateCommonMixin.test_empty_datacCs<ttd��}x#|t|�kr7tj|�qW|S)Nrj)rr��sortedr��shuffle)r*r�rrr�prepare_data�sz"UnivariateCommonMixin.prepare_datacCsB|j�}|dd�}|j|�}|j||d�dS)Nzdata has been modified)r4r-ZassertListEqual)r*r�Zsavedr�rrr�test_no_inplace_modifications�sz3UnivariateCommonMixin.test_no_inplace_modificationscCsaddddddddgd}|j|�}tj|�|j|�}|j||�dS)NrJrr[rirG�rI)r-r�r3rR)r*r�rrrrr�test_order_doesnt_matter�s
"
z.UnivariateCommonMixin.test_order_doesnt_mattercCs�Gdd�dt�}Gdd�dt�}dd�}|j�}|j|�}xEttt|||fD]+}|j||��}|j||�qlWdS)Nc@seZdZdS)zBUnivariateCommonMixin.test_type_of_data_collection.<locals>.MyListN)r"r#r$rrrr�MyList�sr8c@seZdZdS)zCUnivariateCommonMixin.test_type_of_data_collection.<locals>.MyTupleN)r"r#r$rrrr�MyTuple�sr9cSsdd�|D�S)Ncss|]}|VqdS)Nr)r��objrrrr�szXUnivariateCommonMixin.test_type_of_data_collection.<locals>.generator.<locals>.<genexpr>r)r�rrr�	generatorszEUnivariateCommonMixin.test_type_of_data_collection.<locals>.generator)rrr4r-r/rR)r*r8r9r;r�r�kindrUrrr�test_type_of_data_collection�sz2UnivariateCommonMixin.test_type_of_data_collectioncCsDtddd�}|jt|��}|j|j|�|�dS)Nr�r�r[)r�r-rrR)r*r�rrrr�test_range_datasz%UnivariateCommonMixin.test_range_datacCs;|jd�|jd�|jd�|jt��dS)NrFgE@)�check_for_type_error�object)r*rrr�test_bad_arg_typess



z(UnivariateCommonMixin.test_bad_arg_typescGs|jt|j|�dS)N)r�rr-)r*rNrrrr?sz*UnivariateCommonMixin.check_for_type_errorcs�Gdd�dt�}|j�}|j|�}x^t|ttfD]J��fdd�|D�}t|�|j|��}|j||�qDWdS)Ncs:eZdZ�fdd�Z�fdd�ZeZ�S)z@UnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloatcst|�t�j|��S)N)rr'r()r*r�)r&rrr(%szLUnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloat.__truediv__cst|�t�j|��S)N)rr'�__add__)r*r�)r&rrrB'szHUnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloat.__add__)r"r#r$r(rB�__radd__rr)r&rr�$sr�csg|]}�|��qSrr)r�r)r<rrr�.s	zCUnivariateCommonMixin.test_type_of_data_element.<locals>.<listcomp>)r	r4r-rrrrR)r*r��rawrr�rUr)r<r�test_type_of_data_element sz/UnivariateCommonMixin.test_type_of_data_elementN)
r"r#r$r.r1r4r5r7r=r>rAr?rErrrrr,�s

r,c@seZdZdd�ZdS)�UnivariateTypeMixincs�Gdd�dt�}|j�}xXttt|fD]D��fdd�|D�}|j|�}|jt|���q5WdS)NcspeZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�fd	d
�ZeZ�S)z9UnivariateTypeMixin.test_types_conserved.<locals>.MyFloatcst|�t�j|��S)N)rr'r()r*r�)r&rrr(BszEUnivariateTypeMixin.test_types_conserved.<locals>.MyFloat.__truediv__cst|�t�j|��S)N)rr'�__sub__)r*r�)r&rrrGDszAUnivariateTypeMixin.test_types_conserved.<locals>.MyFloat.__sub__cst|�t�j|��S)N)rr'�__rsub__)r*r�)r&rrrHFszBUnivariateTypeMixin.test_types_conserved.<locals>.MyFloat.__rsub__cst|�t�j|��S)N)rr'�__pow__)r*r�)r&rrrIHszAUnivariateTypeMixin.test_types_conserved.<locals>.MyFloat.__pow__cst|�t�j|��S)N)rr'rB)r*r�)r&rrrBJszAUnivariateTypeMixin.test_types_conserved.<locals>.MyFloat.__add__)	r"r#r$r(rGrHrIrBrCrr)r&rr�Asr�csg|]}�|��qSrr)r�r)r<rrr�Ps	z<UnivariateTypeMixin.test_types_conserved.<locals>.<listcomp>)r	r4rrr-r�r)r*r�r�rfrUr)r<r�test_types_conserved=s
z(UnivariateTypeMixin.test_types_conservedN)r"r#r$rJrrrrrF3s
rFc@seZdZdd�ZdS)�
TestSumCommoncCsdd�}||_dS)NcWs(tj|�\}}}tj||�S)N)r��_sumr	)rNr�valuerrrr�simplified_sum[sz+TestSumCommon.setUp.<locals>.simplified_sum)r-)r*rNrrr�setUpZszTestSumCommon.setUpN)r"r#r$rOrrrrrKUsrKc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestSumcCstj|_dS)N)r�rLr-)r*rrrrOfsz
TestSum.setUpcCs�x�gftg�fD]�}|j|j|�ttd�df�|j|j|d�ttd�df�|j|j|d�ttd�df�qWdS)NrrFgffffff@)r/rRr-rLrr	)r*r�rrrr1is(+zTestSum.test_empty_datac
Cs~|j|jdddd
ddddg�ttd�df�|j|jdd	ddd
gd�ttd�df�dS)NrJrGr[riror�rW�<rr]i�i����i����i����)rRr-rLr)r*rrr�	test_intsps*$zTestSum.test_intscCsj|j|jdgd�ttd�df�|j|jddddgd�ttd�d	f�dS)
Ng�?r�g@g�?g�?g�?g�?g	@ri)rRr-r	r)r*rrr�test_floatsvs!zTestSum.test_floatscCs?|j|jtdd�gd�ttdd�df�dS)NrJi�i�r)rRr-r)r*rrr�test_fractions|s"zTestSum.test_fractionsc	Cs�t}|d�|d�|d�|d�|d�|d�|d�|d�g}|j|j|�ttd	�d
f�dS)Nz0.001z5.246z1.702z-0.025z3.974z2.328z4.617z2.843z20.686ro)rrRr-)r*rer�rrr�
test_decimals�s
$*zTestSum.test_decimalscCsOdd�td�D�}|jt|j|�d�tj|�dd�dS)NcSs"g|]}tjdd��qS)rIi�i����)r�r�)r�r�rrrr��s	z7TestSum.test_compare_with_math_fsum.<locals>.<listcomp>i�rJrg��ؗ�Ҭ<)r�r/r	r-r
�fsum)r*r�rrr�test_compare_with_math_fsum�sz#TestSum.test_compare_with_math_fsumcCs�dd�td�D�}|j|�d}|j|d|j|d�d�|j|d|j|d�d�|j|td�|j|d�d�dS)	NcSs"g|]}tjdd��qS)rJi�)r�r�)r�r�rrrr��s	z/TestSum.test_start_argument.<locals>.<listcomp>rIrJrWrFg@��x�Di��)r�r-rRr)r*r�r�rrr�test_start_argument�s
$$zTestSum.test_start_argumentcCsH|jt|jdddgd�|jt|jddddg�dS)NrJrr[Z999)r�rr-)r*rrr�test_strings_fail�s"zTestSum.test_strings_failcCsH|jt|jdddgd�|jt|jddddg�dS)NrJrr[s999)r�rr-)r*rrr�test_bytes_fail�s"zTestSum.test_bytes_failcCsN|jt|jddtd�g�|jt|jddgtd��dS)NrJg@)r�rr-r)r*rrr�test_mixed_sum�s%zTestSum.test_mixed_sumN)r"r#r$rOr1rSrTrUrVrXrYrZr[r\rrrrrPasrPc@seZdZdd�ZdS)�SumTortureTestcCs�|jtjdddd
gd�ttd�df�|jtjddddgd�ttd�df�tjddddgd�\}}}|j|t�|j|d�|jt|�ddd	�dS)
NrJg}Ô%�I�Ti'g��@i@�g0��.�++g���^�,rgV瞯�<g}Ô%�I��g}Ô%�I��r�)rRr�rLr	rr�r/)r*rr��countrrr�test_torture�s""(zSumTortureTest.test_tortureN)r"r#r$r_rrrrr]�sr]c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�SumSpecialValuescCsoxhttfD]Z}|d�}tjd|dg�d}|jt|�|�|jtj|��q
WdS)Nr�rJr)	r	rr�rLr�rrDr
r)r*rOr�rUrrrr��s
zSumSpecialValues.test_nancCsR|jtj|��|jt|�t|��|j|dk|dk�dS)Nr)rDr
rr�rrR)r*rrrrr�check_infinity�szSumSpecialValues.check_infinitycCshtjdd|dg�d}|j||�tjdd|d|dg�d}|j||�dS)NrJrr[ri)r�rLra)r*rrUrrr�do_test_inf�s%zSumSpecialValues.do_test_infcCs2td�}xdD]}|j||�qWdS)NrrJrJr�)rJr�)r	rb)r*r�signrrr�test_float_inf�s
zSumSpecialValues.test_float_infcCs2td�}xdD]}|j||�qWdS)NrrJrJr�)rJr�)rrb)r*rrcrrr�test_decimal_inf�s
z!SumSpecialValues.test_decimal_infcCsLtd�}tjdd|d|dg�d}|jtj|��dS)NrrJrr[ri)r	r�rLrDr
r)r*rrUrrr�test_float_mismatched_infs�s&z+SumSpecialValues.test_float_mismatched_infscCsftd�}dd|d|dg}tjtj��(|jtjtj|�d��WdQRXdS)NrrJrr[ri)	r�decimal�localcontextZExtendedContextrDr
rr�rL)r*rr�rrr�3test_decimal_extendedcontext_mismatched_infs_to_nan�szDSumSpecialValues.test_decimal_extendedcontext_mismatched_infs_to_nancCs\td�}dd|d|dg}tjtj��|jtjtj|�WdQRXdS)NrrJrr[ri)rrgrhZBasicContextr��InvalidOperationr�rL)r*rr�rrr�0test_decimal_basiccontext_mismatched_infs_to_nan�szASumSpecialValues.test_decimal_basiccontext_mismatched_infs_to_nancCs8td�}d|dg}|jtjtj|�dS)Nr�rJr)rr�rgrjr�rL)r*r�r�rrr�test_decimal_snan_raises�sz)SumSpecialValues.test_decimal_snan_raisesN)r"r#r$r�rarbrdrerfrirkrlrrrrr`�sr`c@s(eZdZdd�Zdd�ZdS)�AverageMixincCsOxHdddtdd�td�fD]"}|j|j|g�|�q%WdS)NrFg@E@g�X_yCr@�z0.28)rrrRr-)r*rrrr�test_single_value�s+zAverageMixin.test_single_valuecCsjxcdddtdd�td�fD]=}x4dD],}|g|}|j|j|�|�q2Wq%WdS)Ng@r>g��7y�!C�=�Cz4.9712rrGrjr�)rrGrjr�)rrrRr-)r*rr^r�rrr�test_repeated_single_value�s+

z'AverageMixin.test_repeated_single_valueN)r"r#r$rorrrrrrrm�srmc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�TestMeancCstj|_dS)N)r��meanr-)r*rrrrOszTestMean.setUpcCs)|j|jddddg�d�dS)Ng}Ô%�I�TrJr[g}Ô%�I��)rRr-)r*rrr�test_torture_pep
szTestMean.test_torture_pepcCs`ddddddddddddddd	d
g}tj|�|j|j|�d�dS)NrrJrr[rirGr6r]ror\g@@)r�r3rRr-)r*r�rrrrSs6
zTestMean.test_intscCsHddddddddg}tj|�|j|j|�d	�dS)
Ng@1@g�3@g4@g�5@g�5@g@7@g 9@g�;@g6@)r�r3rRr-)r*r�rrrrTs
zTestMean.test_floatscCsit}|d�|d�|d�|d�|d�g}tj|�|j|j|�|d��dS)Nz1.634z2.517z3.912z4.072z5.813z3.5896)rr�r3rRr-)r*rer�rrrrVs3
zTestMean.test_decimalsc	Cs�t}|dd�|dd�|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�|d	d
��dS)NrJrr[rirGr6r]roi�i�)rr�r3rRr-)r*r`r�rrrrU!sZ
zTestMean.test_fractionscCs�dddddg}xwttfD]i}x`dD]X}|d�|}||g}|j|�}|jtj|��|j||�q/Wq"WdS)	NrJr[rGr]r\rr�)rJr�)r	rr-rDr
rrR)r*rDr<rcrr�rUrrrr�(s

zTestMean.test_infc	CsSdddtd�dddtd�g}|j|�}|jtj|��dS)	Nrrir6rrJr[rGz-inf)r	r-rDr
r)r*r�rUrrr�test_mismatched_infs3s*zTestMean.test_mismatched_infscCsndddddg}xRttfD]D}|d�}||g}|j|�}|jtj|��q"WdS)NrJr[rGr]r\r�)r	rr-rDr
r)r*rDr<rr�rUrrrr�9s
zTestMean.test_nanc	spd�dddddddd	d
g	}|j|��}|j�fdd�|D��}|j||�dS)
Nge��Ag333333@g@g������@g������@g333333@g������@g @g333333 @g������"@csg|]}|��qSrr)r�r)�crrr�Hs	z*TestMean.test_big_data.<locals>.<listcomp>)r-rR)r*r�rrUr)rwr�
test_big_dataBs
!"zTestMean.test_big_datacCsOdd�td�D�}|j|�}|j|d�}|j||�dS)NcSs"g|]}tjdd��qS)r[rGr�)r�r�)r�r�rrrr�Ms	z.TestMean.test_doubled_data.<locals>.<listcomp>i�r)r�r-r/)r*r�rrrrr�test_doubled_dataKszTestMean.test_doubled_datacCs,td�}|jtj|g�|�dS)NZ1e4)rrRr�rt)r*rfrrr�test_regression_20561RszTestMean.test_regression_20561cCs�|jtjddg�d�d}d}xNdD]F}|jtj|g|�|�|jtj|g|�|�q2WdS)	Ng�������g�grr[rG��)rr[rGr{)rRr�rt)r*�bigZtinyrrrr�test_regression_25177Xs
 zTestMean.test_regression_25177N)r"r#r$rOrurSrTrVrUr�rvr�rxryrzr}rrrrrss		rscsveZdZdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�S)�
TestMediancCstj|_dS)N)r��medianr-)r*rrrrOhszTestMedian.setUpcs6t�j�}t|�ddkr2|jd�|S)NrrJ)r'r4r0r�)r*r�)r&rrr4ks
zTestMedian.prepare_datacCs5ddddddg}|j|j|�d�dS)NrJrr[rirGr6g@)rRr-)r*r�rrr�test_even_intsrszTestMedian.test_even_intscCs8dddddddg}|j|j|�d�dS)NrJrr[rirGr6r\)rRr-)r*r�rrr�
test_odd_intsxszTestMedian.test_odd_intscCs{t}|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�|dd��dS)NrJr]rr[rirG)rr�r3rRr-)r*r`r�rrr�test_odd_fractions~sB
zTestMedian.test_odd_fractionscCs�t}|dd�|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�|dd��dS)NrJr]rr[rirGr6)rr�r3rRr-)r*r`r�rrr�test_even_fractions�sN
zTestMedian.test_even_fractionscCsit}|d�|d�|d�|d�|d�g}tj|�|j|j|�|d��dS)Nz2.5z3.1z4.2z5.7z5.8)rr�r3rRr-)r*rer�rrr�test_odd_decimals�s3
zTestMedian.test_odd_decimalscCsrt}|d�|d�|d�|d�|d�|d�g}tj|�|j|j|�|d��dS)Nz1.2z2.5z3.1z4.2z5.7z5.8z3.65)rr�r3rRr-)r*rer�rrr�test_even_decimals�s<
zTestMedian.test_even_decimals)r"r#r$rOr4r�r�r�r�r�r�rr)r&rr~fsr~c@s(eZdZdd�Zdd�ZdS)�TestMedianDataTypecCstj|_dS)N)r�rr-)r*rrrrO�szTestMedianDataType.setUpcCs<ttd��}x#|t|�kr7tj|�qW|S)Nr@)rr�r2r�r3)r*r�rrrr4�szTestMedianDataType.prepare_dataN)r"r#r$rOr4rrrrr��sr�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TestMedianLowcCstj|_dS)N)r�Z
median_lowr-)r*rrrrO�szTestMedianLow.setUpcCs5ddddddg}|j|j|�d�dS)NrJrr[rirGr6)rRr-)r*r�rrrr��szTestMedianLow.test_even_intscCs�t}|dd�|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�|dd��dS)NrJr]rr[rirGr6)rr�r3rRr-)r*r`r�rrrr��sN
z!TestMedianLow.test_even_fractionscCsrt}|d�|d�|d�|d�|d�|d�g}tj|�|j|j|�|d��dS)Nz1.1z2.2z3.3z4.4z5.5z6.6)rr�r3rRr-)r*rer�rrrr��s<
z TestMedianLow.test_even_decimalsN)r"r#r$rOr�r�r�rrrrr��sr�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestMedianHighcCstj|_dS)N)r�Zmedian_highr-)r*rrrrO�szTestMedianHigh.setUpcCs5ddddddg}|j|j|�d�dS)NrJrr[rirGr6)rRr-)r*r�rrrr��szTestMedianHigh.test_even_intscCs�t}|dd�|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�|dd��dS)NrJr]rr[rirGr6)rr�r3rRr-)r*r`r�rrrr��sN
z"TestMedianHigh.test_even_fractionscCsrt}|d�|d�|d�|d�|d�|d�g}tj|�|j|j|�|d��dS)Nz1.1z2.2z3.3z4.4z5.5z6.6)rr�r3rRr-)r*rer�rrrr��s<
z!TestMedianHigh.test_even_decimalsN)r"r#r$rOr�r�r�rrrrr��sr�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestMedianGroupedcCstj|_dS)N)r�Zmedian_groupedr-)r*rrrrO�szTestMedianGrouped.setUpcCsdddddddg}|j|j|�d�dddddddg}|j|j|�d�ddddddddd	d	d
g}|j|j|d�d�dd
d
d
d
ddddddddddg}|j|j|d�ddd�dS)Nrvr*�r@g�+@rGrjr��r�g`3@rh�����rg������4@rg:�0�yE>)rRr-r/)r*r�rrr�test_odd_number_repeated�s'3z*TestMedianGrouped.test_odd_number_repeatedcCsddddddddddg
}|j|j|d�ddd	�d
dddddg}|j|j|�d
dd	�d
dddddddddddg}|j|j|�d�ddddddddddg
}|j|j|�d�dS)NrGrjr@r�r�r�g�����*3@rg:�0�yE>rr[rig["8���@r6g@g@)r/r-rR)r*r�rrr�test_even_number_repeated�s$"*$z+TestMedianGrouped.test_even_number_repeatedcCspxidddtdd�td�fD]C}x:dD]2}|g|}|j|j|�t|��q2Wq%WdS)Ng333333@�Dg��ޗCr�rxz32.9714rrGrjr�)rrGrjr�)rrrRr-r	)r*rr^r�rrrrrs+

z,TestMedianGrouped.test_repeated_single_valuecCsrt}|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�d�dS)NrGrir\r*r>g@)rr�r3rRr-)r*r`r�rrrr�sB
z$TestMedianGrouped.test_odd_fractionscCs~t}|dd�|dd�|dd�|dd�|dd�|dd�g}tj|�|j|j|�d�dS)NrGrir\r*r>g
@)rr�r3rRr-)r*r`r�rrrr�sN
z%TestMedianGrouped.test_even_fractionscCsct}|d�|d�|d�|d�|d�g}tj|�|j|j|�d�dS)Nz5.5z6.5z7.5z8.5g@)rr�r3rRr-)r*rer�rrrr�%s3
z#TestMedianGrouped.test_odd_decimalscCs�t}|d�|d�|d�|d�|d�|d�g}tj|�|j|j|�d�|d�|d�|d�|d�|d�|d�g}tj|�|j|j|�d�dS)Nz5.5z6.5z7.5z8.5g@g@)rr�r3rRr-)r*rer�rrrr�-s<
<
z$TestMedianGrouped.test_even_decimalscCs�ddddddddddg
}|j|j|d�d	�dddddddddddg}|j|j|d�d
dd�d
d
ddddddddddg}|j|j|d�d�dS)Ng@g@g@g@g
@g@g@g�?g@g["8���@rg:�0�yE>����iii,i@iTr�g�p@)rRr-r/)r*r�rrr�
test_interval:s$'"*zTestMedianGrouped.test_intervalN)r"r#r$rOr�r�rrr�r�r�r�r�rrrrr��s	
r�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestModecCstj|_dS)N)r��moder-)r*rrrrOFszTestMode.setUpcCs%dddddddddddgS)	NrJr[rir]r\rrorr)r*rrrr4IszTestMode.prepare_datacCs/tddd�}|jtj|j|�dS)Nr�r�r[)r�r�r�r�r-)r*r�rrrr>NszTestMode.test_range_datacCsHd}|j|j|�d�dj�}|j|j|�d�dS)NZabcbdbr
zfe fi fo fum fi fi�fi)rRr-rd)r*r�rrr�test_nominal_dataSszTestMode.test_nominal_datacCs`ttd��}xGtd�D]9}||g}tj|�|j|j|�|�qWdS)Nrj)rr�r�r3rRr-)r*r�r6rfrrr�test_discrete_dataZs


zTestMode.test_discrete_datacCsVdddddddddddddddd	d	g}|jtj|j|�dS)
NrJrr[rirGr6r]ror\)r�r�r�r-)r*r�rrr�test_bimodal_databs9zTestMode.test_bimodal_datacCs/ttd��}|jtj|j|�dS)Nrj)rr�r�r�r�r-)r*r�rrr�test_unique_data_failureisz!TestMode.test_unique_data_failurecCs|jt|jd�dS)N)r�rr-)r*rrr�test_none_datanszTestMode.test_none_datacCs8tjddddg�}|jtj|j|�dS)NrJr)r&�Counterr�r�r�r-)r*r�rrr�test_counter_datauszTestMode.test_counter_dataN)r"r#r$rOr4r>r�r�r�r�r�r�rrrrr�Dsr�c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�VarianceStdevMixing�-���q=cCsOxHdddtdd�td�fD]"}|j|j|g�d�q%WdS)Nrwg������3@g���%�Brmr�z8.392r)rrrRr-)r*rrrrro�s+z$VarianceStdevMixin.test_single_valuecCsjxcdddtdd�td�fD]=}x4dD],}|g|}|j|j|�d
�q2Wq%WdS)Ng������@r�g@�6��<Cr[r]z62.4802rrGr@r)rr[rGr@)rrrRr-)r*rr^r�rrrrr�s+

z-VarianceStdevMixin.test_repeated_single_valuecCsFdgd}|j|�}|j|ddd�|j|d�dS)Ng.�F7ݚ�?i'grg��ؗ�Ҍ<r)r-r/r�)r*r�rUrrr�test_domain_error_regression�s
z/VarianceStdevMixin.test_domain_error_regressionc
soddddddddd	d
g
}|j|�}d��fdd
�|D�}|j|j|�|�dS)Ng{�G�z�?gR���Q�?g
ףp=
�?gR���Q@g�p=
ף@g��Q�	@g@g�Q���@g�G�z�@g��Q�@gj�@csg|]}|��qSrr)r�r)�shiftrrr��s	z6VarianceStdevMixin.test_shift_data.<locals>.<listcomp>)r-r/)r*rDrr�r)r�r�test_shift_data�s
$z"VarianceStdevMixin.test_shift_datac
sodddddddddd	g
}|j|�}d��fd
d�|D�}|j|j|�|�dS)
NrJr[rirGr]r\rjrwrhcsg|]}|��qSrr)r�r)r�rrr��s	z<VarianceStdevMixin.test_shift_data_exact.<locals>.<listcomp>iʚ;)r-rR)r*rDrr�r)r�r�test_shift_data_exact�s
$z(VarianceStdevMixin.test_shift_data_exactcCsKdd�td�D�}|j|�}|j|jt|��|�dS)NcSs"g|]}tjdd��qS)r[ror�)r�r�)r�r�rrrr��s	z:VarianceStdevMixin.test_iter_list_same.<locals>.<listcomp>i�)r�r-rRr/)r*r�rrrr�test_iter_list_same�sz&VarianceStdevMixin.test_iter_list_sameN)
r"r#r$rrorrr�r�r�r�rrrrr��s
	r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
TestPVariancecCstj|_dS)N)r��	pvariancer-)r*rrrrO�szTestPVariance.setUpcCsBttd��}tj|�d}|j|j|�|�dS)Ni'rrJrvi�i��gP�_A)rr�r�r3rRr-)r*r�rrrr�test_exact_uniform�s
z TestPVariance.test_exact_uniformcCs5ddddg}d}|j|j|�|�dS)Nrir]r*rhg�6@)rRr-)r*r��exactrrrrS�szTestPVariance.test_intscCs~t}|dd�|dd�|dd�|dd�g}|dd�}|j|�}|j||�|j|t�dS)NrJrir[r]ro)rr-rR�assertIsInstance)r*r`r�r�rUrrrrU�s6zTestPVariance.test_fractionscCsot}|d�|d�|d�|d�g}|d�}|j|�}|j||�|j|t�dS)Nz12.1z12.2z12.5z12.9z0.096875)rr-rRr�)r*rer�r�rUrrrrV�s*zTestPVariance.test_decimalsN)r"r#r$rOr�rSrUrVrrrrr��s
	r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestVariancecCstj|_dS)N)r��variancer-)r*rrrrO�szTestVariance.setUpcCsOxHdddtdd�td�fD]"}|jtj|j|g�q%WdS)Nr^g33333�8@g�(G�!=Crnr�z4.2084)rrr�r�r�r-)r*rrrrro�s+zTestVariance.test_single_valuecCs5ddddg}d}|j|j|�|�dS)Nrir]r*rhr�)rRr-)r*r�r�rrrrS�szTestVariance.test_intscCs~t}|dd�|dd�|dd�|dd�g}|dd�}|j|�}|j||�|j|t�dS)NrJrir[r]r)rr-rRr�)r*r`r�r�rUrrrrU�s6zTestVariance.test_fractionscCs}t}|d�|d�|d�|d�g}d|d�|d�}|j|�}|j||�|j|t�dS)Nrr]r\riz9.5r[)rr-rRr�)r*rer�r�rUrrrrVs*zTestVariance.test_decimalsN)r"r#r$rOrorSrUrVrrrrr��s
	r�c@s(eZdZdd�Zdd�ZdS)�
TestPStdevcCstj|_dS)N)r�Zpstdevr-)r*rrrrOszTestPStdev.setUpcCsNdd�td�D�}tjtj|��}|j|j|�|�dS)NcSs"g|]}tjdd��qS)r>r�i��)r�r�)r�r�rrrr�s	z7TestPStdev.test_compare_to_variance.<locals>.<listcomp>i�)r�r
�sqrtr�r�rRr-)r*r�rrrr�test_compare_to_variancesz#TestPStdev.test_compare_to_varianceN)r"r#r$rOr�rrrrr�
sr�c@s4eZdZdd�Zdd�Zdd�ZdS)�	TestStdevcCstj|_dS)N)r�Zstdevr-)r*rrrrOszTestStdev.setUpcCsOxHdddtdd�td�fD]"}|jtj|j|g�q%WdS)N�QgH�z�wi@gf7?+�BrGrmz35.719)rrr�r�r�r-)r*rrrrros+zTestStdev.test_single_valuecCsNdd�td�D�}tjtj|��}|j|j|�|�dS)NcSs"g|]}tjdd��qS)rr\rK)r�r�)r�r�rrrr�"s	z6TestStdev.test_compare_to_variance.<locals>.<listcomp>i�)r�r
r�r�r�rRr-)r*r�rrrrr� sz"TestStdev.test_compare_to_varianceN)r"r#r$rOror�rrrrr�sr�cCs|jtj��|S)N)ZaddTestsr�ZDocTestSuite)�loaderZtests�ignorerrr�
load_tests)sr��__main__)6r&rgr�r
r�r�r�rZ	fractionsrr�rrr r!r�r%r=rTrqr{r�r�r�r�r�r�r�r�rrr!r,rFrKrPr]r`rmrsr~r�r�r�r�r�r�r�r�r�r�r�r"�mainrrrr�<module>sf:+b>@w-@4d<c"H
@`9
b<B%#